import numpy as np import xarray as xr import matplotlib as mpl #mpl.use('Agg') # Must be before importing matplotlib.pyplot or pylab! import matplotlib.pyplot as plt import pandas as pd import os import datetime #import seaborn as sns import timeit #variable of interest var = 'shf*_xy' height_level = 48 #list to combine the data ds_list = [] start_time = timeit.default_timer() #data folder source = '/bog/incoming/CHEESEHEAD/palm/realistic_runs/ches_IOP03/OUTPUT/ensemble.member.1' os.chdir(source) #folder = '02.ches_IOP3.660/VM_OUTPUT_N03/' #file = 'site0001_N03' folder = '02.ches_IOP3.660' file = 'DATA_3D_AV_NETCDF_N03' ds = xr.open_dataset(source + '/' + folder + '/' + file) ds.close() #ds = ds[['w','theta','wtheta']]#.sel(zw_3d = height_level) #ds = ds.sel(x=2217,y=9147) ds = ds['s'] #ds = ds.sel(time="13:30:00") ds = ds.where(ds.time.notnull(),drop=True) #select variables of interest print(ds) ''' w = ds.w print(w) theta = ds.theta.rename({'zu_3d': 'zw_3d'}) print(theta) theta_interpolated = theta.interp_like(w) print(theta_interpolated.sel(zw_3d=32)) #subsetting for time #ds = ds.where(ds.time.dt.seconds==48600,drop=True) #print(ds) #print(ds.time.sel(station=1).values) ''' ds.to_netcdf('co2_3D_sample.nc') elapsed = timeit.default_timer() - start_time print('Time elapsed ',elapsed, 'seconds')