简体   繁体   中英

How to get a specific information from the header of a netcdf file using python?

I have several necdf files and I need to read the value of "aod550:scale_factor" and "aod550:add_offset" because they are different for different files. They are located in the header of my netcdf files and are additional information of "short aod550" (the variable which I'm interested). The part of the netcdf header looks like this:

variables:

short aod550(time, latitude, longitude) ;
    aod550:scale_factor = 1.44701502281421e-05 ;
    aod550:add_offset = 0.474128942375304 ;
    aod550:_FillValue = -32767s ;

Is there any command to read this information in python? I'm thinking in something similar to read variables. I can read the values of variable aod550 using aod = 'my_netcdf_file'.variables['aod550'] but it doesn't work with 'aod550:scale_factor' or 'aod550:add_offset' because they aren't variables.

Anyone have any ideas???

Thank you N1B4 for your suggestion, however I'm using Scientific.IO.NetCDF. Finally I solved my problem:

Read variable "aod":

aod = 'my_netcdf_file'.variables['aod550']

Read "scale_factor" and "add_offset" values:

scale_factor = aod.scale_factor[0] add_offset = aod.add_offset[0]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM