Python - Use List Of Points To Extract Data From Gridded Netcdf Without For Loops
The following example uses the 'Unidata' sample netCDF dataset of eastward wind which can be downloaded from here (2.8 MB) I have two lists of integers that correspond to the x and
Solution 1:
Do normal indexing with 0
and 16
first, followed by advanced indexing with lat
and lon
:
ua_array = fh.variables['ua'][0,16][lat,lon]
print(ua_array)
Output:
[ 59.2917099 17.41391563 -4.40069008 -11.15423965 -5.26847887
2.12359285 -6.13457298]
BTW, ua_array
is a NumPy array. Therefore, calling its ua_list
is bit misleading.
Post a Comment for "Python - Use List Of Points To Extract Data From Gridded Netcdf Without For Loops"