This commit is contained in:
Marcel Christian Frommelt 2021-06-18 23:32:46 +09:00
parent a7ee25fba7
commit 0f83bc3345

View File

@ -1,100 +0,0 @@
import numpy as np
import math
import xarray as xr
import matplotlib.pyplot as plt
from scipy.spatial import cKDTree
from scipy import interpolate
import cartopy.crs as ccrs
from datetime import datetime
from netCDF4 import Dataset
begin_time = datetime.now()
import pandas as pd
name = ["testneu1.nc", "testneu2.nc", "testneu3.nc", "testneu4.nc"]
ds = xr.open_mfdataset(name, combine='by_coords', concat_dim="time")
#res = Dataset(name)
res1 = Dataset('testneu1.nc')
# res2 = Dataset('testneu2.nc')
# res3 = Dataset('testneu3.nc')
res4 = Dataset('testneu4.nc')
#print(res1.variables['time'][0])
#print(res1.variables['time'][-1])
start = int(res1.variables['time'][0])
end = int(res4.variables['time'][-1])
a = np.linspace(start, end, (end - start) + 1)
ds = ds.assign_coords(time=a)
res_comp = Dataset("testfull.nc")
#ERAtime1 = res1.variables['time'][:]
#ERAtime2 = res2.variables['time'][:]
#ERAtime3 = res3.variables['time'][:]
#ERAtime4 = res4.variables['time'][:]
#ERAtemp1 = res1.variables['t'][:]
#ERAtemp2 = res2.variables['t'][:]
#ERAtemp3 = res3.variables['t'][:]
#ERAtemp4 = res4.variables['t'][:]
ERAtemp = ds.variables['z'][:].values
ERAtime_sel = ds.variables['time'][:]
ERAtemp_sel = ERAtemp[:, 6, 82, 21]
ERAtime0 = res_comp.variables['time'][:]
ERAtemp0 = res_comp.variables['z'][:]
#ERAtemp1_sel = ERAtemp1[:, 6, 82, 21]
#ERAtemp2_sel = ERAtemp2[:, 6, 82, 21]
#ERAtemp3_sel = ERAtemp3[:, 6, 82, 21]
#ERAtemp4_sel = ERAtemp4[:, 6, 82, 21]
ERAtemp_sel = ERAtemp[:, 6, 82, 21]
ERAtemp0_sel = ERAtemp0[:, 6, 82, 21]
#print(ERAtime2[0])
#ERAtime_sel = ds.variables['time'][:]
ERAtimecomp_sel = res_comp.variables['time'][:]
plt.plot(ERAtime_sel, ERAtemp_sel, 'rx')
plt.plot(ERAtimecomp_sel, ERAtemp0_sel, 'k-')
plt.show()
#print("hier")
#print(int(ds['time'][0]))
#print(int(ds['time'][1]))
#print(type(ds['time'][0]))
#print(type(datetime(1900, 1, 1)))
#print(ds['time'])
# print(ds['time'])
ds.to_netcdf('single_new2.nc')
df = Dataset('single_new2.nc')
#print(df.variables['z'][:])
#print(df.variables['time'][:])