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 = '01.ches_IOP3.14592/VM_OUTPUT_N03/' file = 'site0001_N03' ds = xr.open_dataset(source + '/' + folder + '/' + file) ds.close() #ds = ds['w']#.sel(zw_3d = height_level) #ds = ds.sel(time="13:30:00") #ds = ds.where(ds.time.notnull(),drop=True) #subsetting for time #ds = ds.where(ds.time.dt.seconds==48600,drop=True) #print(ds.time.sel(station=1).values) fig = plt.figure(figsize=(8,8)) ds.ta.sel(station=1).plot() fig.savefig("Plot.png") #ds.to_netcdf('ensemble_3_1300_w.nc') elapsed = timeit.default_timer() - start_time print('Time elapsed ',elapsed, 'seconds')