- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsample_view_InsertFileName.py
More file actions
Latest commit
36 lines (28 loc) · 953 Bytes
/
Copy pathsample_view_InsertFileName.py
File metadata and controls
36 lines (28 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
fromnetCDF4importDataset
importmatplotlib.pyplotasplt
#open reference to the file and see overview of it
data=Dataset("File Name/Path Goes Here.nc", "r");
print(data.variables.items())
#pull the data from file into variables
lon=data.variables['longitude'][:];
lat=data.variables['latitude'][:];
anomaly=data.variables['temperature'][:];
reference=data.variables['climatology'][:];
#grab January 31, 2000 data and convert from C to F
data=anomaly[31, :, :] +reference[31, :, :];
data= (1.8*data) +32;
#plot global max temp
plt.figure(1)
plt.contourf(lon, lat, data)
plt.colorbar()
plt.ylabel('latitude')
plt.xlabel('longitude')
plt.title('Max Temp (F) on January 31, 2000')
#plot US max temp
plt.figure(2)
plt.contourf(lon[50:125], lat[115:135], data[115:135, 50:125])
plt.colorbar()
plt.ylabel('latitude')
plt.xlabel('longitude')
plt.title('Max Temp (F) on January 31, 2000')
plt.show()