Closed houssank closed 6 years ago
Thanks Sankare: What is the error message?
Cheers
Here is the alternative and more efficient way of doing what you want:
# This example reads precipitation variable metadata without actually reading of the precipitation data
# into memory. In order to get data in memory you have to slice the variable.
from rpn.rpn import RPN
with RPN("pm1979010100_03506400p") as r:
pr_var = r.variables["PR"]
# you can also get the list of fields in the file as below
print(r.variables)
# get the shape of the data (still no field values are read)
print(pr_var.shape)
# get the dates correponding to the time dimension
print([str(d) for d in pr_var.sorted_dates])
# get the level values corresponing to the vertical dimension
print([lev for lev in pr_var.sorted_levels])
data_4d = pr_var[:] # the first dimension corresponds to pr_var.sorted_dates and the second to pr_var.sorted_levels
Sankare:
Could you please update? I've updated the method and it should now work for you. although it is not the most efficient way to do what you want to do, but this way you've discovered a problem and I think I've fixed it, so thanks for that.
Cheers
Please let me know if you still have problems with it, the version with the fix should be 0.0.39.
I have see that, But How can I get a specific level and date? When I do that I obtened for example data_4d (date.size, level.size, lon.size, lat.size) But I need for example data_4d( 2007-01-02 0000, 900hPa, lonsize, lat.size)
In the previous version we can do it like this. r.get_record_for_date_and_level(var_name=vname,date=dv,date_o=do,level=lvl[i],level_kind=level_kinds.PRESSURE)
Ok, Thanks Huziy, I will tell you if it ok for me. Thanks
Thanks Huziy, It works, all is ok now. Thanks very much.