-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnowread.py
More file actions
37 lines (26 loc) · 869 Bytes
/
Copy pathsnowread.py
File metadata and controls
37 lines (26 loc) · 869 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
37
#!/usr/bin/env python
import os
import numpy as np
from netCDF4 import Dataset
file = '/media/robert/HDD/WRF/NCEditing/test.nc'
def run():
nc = Dataset(file, mode='r')
i = nc.dimensions['west_east']
j = nc.dimensions['south_north']
SNOW = nc.variables['SNOW']
lowest_lon = getattr(nc, 'corner_lons')[0]
lowest_lat = getattr(nc, 'corner_lats')[0]
highest_lat = getattr(nc, 'corner_lats')[2]
highest_lon = getattr(nc, 'corner_lons')[2]
print lowest_lon , ' => ', highest_lon
print lowest_lat , ' => ', highest_lat
lats = np.linspace(lowest_lat, highest_lat, j.size).tolist();
lons = np.linspace(lowest_lon, highest_lon, i.size).tolist();
print(lats)
print(lons)
print SNOW
#for x in range(0, j.size):
# for y in range(0, i.size):
# ST = SNOW[:,x,y];
# print 'SNOW at ', x, ', ', y, ' (', lats[x], ',', lons[y],'): ', ST
run();