Skip to content

Instantly share code, notes, and snippets.

@duartecosta1
Created May 14, 2018 00:35
Show Gist options
  • Save duartecosta1/8a03f16a5ce0faf88209c821669a9d16 to your computer and use it in GitHub Desktop.
Save duartecosta1/8a03f16a5ce0faf88209c821669a9d16 to your computer and use it in GitHub Desktop.
PDF plot of daily temperatures
from netCDF4 import Dataset
from scipy.stats import norm
import numpy as np
import matplotlib.pyplot as plt
list_indices = ['tasmax']
indices = list_indices[0]
#test
files='/g/data3/w97/dc8106/AMZ_def_EXPs/121GPsc_E0/AMZDEF.daily_tasmin.tasmax.pr.1978_2011_121GPsc_E0.nc'
#files = sorted(glob.glob('/g/data3/w97/dc8106/AMZ_def_EXPs/analysis/ensmean/'+indices+'*''*ensmean_1978-2011.nc')) \
#remove CTL diff to CTL file from analysis
#del(files[11]) \
var = np.zeros((len(files),12418,145,192),dtype=np.float32)
t = []
lat = Dataset(files).variables['lat'][:]
lon = Dataset(files).variables['lon'][:]
lons,lats = np.meshgrid(lon,lat)
#)ii) Populate with data from different experiments \
#for n,f in enumerate(files):
var[:,:,:,:] = Dataset(files).variables[indices][:,:,:] # model indicators
print var.shape
t.append(str(files[-32:-3:]))
#x= np.arange(-4,4,0.001)
pdf = plt.plot(var[0,:,:,:], norm.pdf(var[:,:,:,:]))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment