|
- # 数据合并
- import xarray as xr
- import matplotlib.pyplot as plt
- import numpy as np
- import os
- import pandas as pd
- import glob
- from netCDF4 import Dataset, num2date
- import netCDF4 as nc
- import time
- import datetime
-
- path = r'F:\data\paperdate_93_17\19_12\avhrr-only-v2.20191201.nc'
- nc0 = Dataset(path)
- # print(nc0.variables) #time(1), zlev(1), lat(720), lon(1440)
- time0 = nc0.variables['time'][:] # 815232
- print(time0) #5479.
- time0 = time0.data
- time0 = time0 - 5478
- print(time0)
- lon = nc0.variables['lon'] # current shape = (1440,)
- lat = nc0.variables['lat'] # current shape = (720,)
- lon0 = lon[759:961] # 189.875 --- 240.125
- lat0 = lat[339:381] #-5.125 --- 5.125
- print(lon0.shape)
- print(lat0.shape)
- # print(lon0)
- # print(lat0)
- # # lat lon
- # sst = nc0.variables['sst'][:,:,339:381,759:960]
- # print(sst.shape)
- #
- # sst0 = sst.data
- #
- # time0 = time0
- # # # # # #
- # todo1 = r'F:\data\paperdate_93_17\19_12\*.nc'
- # # # # # # todo1 = todo1[1:]
- # list_nc = glob.glob(todo1)
- # list_nc = sorted(list_nc[1:])
- # # print(list_nc)
- # l = len(list_nc)
- # print(l) # 36520
- # list_nc0 = list_nc.copy()
- # # # print(list_nc0)
- # for i in list_nc0:
- # nc_file = i
- # nc1 = Dataset(nc_file)
- # time1 = nc1.variables['time'][:]
- # # print(time1)
- # time1 = time1.data
- # time1 = time1 - 5478
- # print(time1)
- # #
- # sst1 = nc1.variables['sst'][:,:,339:381,759:960]
- #
- #
- # time0 = np.concatenate((time0, time1), axis=0)
- # # print(time0.shape)
- # sst0 = np.concatenate((sst0, sst1), axis=0) # (13271, 1, 1)
- # # /#
- # print(time0.shape)
- # print('sst0.shape:{}'.format(sst0.shape))
- #
- # sst1 = sst0.mean(axis=0)
- # print('sst1.shape:{}'.format(sst1.shape))
- #
- #
- # time = list(time0)
- #
- # # print(time)
- # for i in range(len(time) - 1):
- # if time[i + 1] - time[i] != 1:
- # print('错误')
- # break
- #
- # np.savez(r'D:\PINN_kuokan\OISST_month\sst_obser_2019_12_month.npz', time=time0, lat=lat0, lon=lon0, sst = sst1,
- # )
|