Created
September 1, 2019 00:40
-
-
Save prl900/60e3d57560fdce828b3ca76b06c83bff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xarray as xr | |
import numpy as np | |
import matplotlib.pyplot as plt | |
print("Jan") | |
ds = xr.open_dataset("era5_prec_2018H1.nc") | |
prec = ds.tp.sel(dict(time=slice('2018-01-01', '2018-01-31'))).data * 1000 | |
ds.close() | |
print(prec.shape) | |
mean = np.mean(prec[:,:,:], axis=(1,2))[:-1] | |
plt.plot(mean) | |
plt.savefig("prec_mean.png") | |
plt.clf() | |
plt.plot(mean[:24]) | |
plt.savefig("prec_mean_24.png") | |
plt.clf() | |
plt.plot(mean[:48]) | |
plt.savefig("prec_mean_48.png") | |
plt.clf() | |
plt.plot(mean[:96]) | |
plt.savefig("prec_mean_96.png") | |
plt.clf() | |
diff = np.mean(np.abs(prec[:-1,:,:] - prec[1:,:,:]), axis=(1,2)) | |
prec = None | |
plt.plot(diff) | |
plt.savefig("prec_diff.png") | |
plt.clf() | |
plt.plot(diff[:24]) | |
plt.savefig("prec_diff_24.png") | |
plt.clf() | |
plt.plot(diff[:48]) | |
plt.savefig("prec_diff_48.png") | |
plt.clf() | |
plt.plot(diff[:96]) | |
plt.savefig("prec_diff_96.png") | |
plt.clf() | |
ds = xr.open_dataset("era5_geop_201801.nc") | |
z500 = ds.z[:,0,:,:].data | |
ds.close() | |
mean = np.mean(z500[:,:,:], axis=(1,2))[:-1] | |
plt.plot(mean) | |
plt.savefig("geop_mean.png") | |
plt.clf() | |
plt.plot(mean[:24]) | |
plt.savefig("geop_mean_24.png") | |
plt.clf() | |
plt.plot(mean[:48]) | |
plt.savefig("geop_mean_48.png") | |
plt.clf() | |
plt.plot(mean[:96]) | |
plt.savefig("geop_mean_96.png") | |
plt.clf() | |
diff = np.mean(np.abs(z500[:-1,:,:] - z500[1:,:,:]), axis=(1,2)) | |
z500 = None | |
plt.plot(diff) | |
plt.savefig("geop_diff.png") | |
plt.clf() | |
plt.plot(diff[:24]) | |
plt.savefig("geop_diff_24.png") | |
plt.clf() | |
plt.plot(diff[:48]) | |
plt.savefig("geop_diff_48.png") | |
plt.clf() | |
plt.plot(diff[:96]) | |
plt.savefig("geop_diff_96.png") | |
plt.clf() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment