netCDF4 库中 python 中 MATLAB 的 ncdisp() 的替代函数
Alternative function for ncdisp() of MATLAB in python in netCDF4 library
我对netCDF文件的所有格式和维度都使用了这个函数。这就是我在 Matlab 中使用它的方式:
filename = 'C:\Users\my_name\Desktop\metopa_AM.nc'
ncdisp(filename)
Source:
C:\Users\my_name\Desktop\metopa_nh3nn_20100101_AM.nc
Format:
netcdf4
Global Attributes:
Title = 'Ammonia total columns retrieved from IASI measurements from the NH3-ULBNN retrieval algorithm'
Institution = 'Universite Libre de Bruxelles (ULB)/Laboratoire atmosph�res, milieux et observations spatiales (LATMOS)'
Product_Version = '1.0'
keywords = 'satellite, observation, atmosphere, ammonia'
date_created = '2016-04-26 12:44:52'
contact_emails = 'Simon Whitburn (simon.whitburn@ulb.ac.be) and Lieven Clarisse (lclariss@ulb.ac.be)'
platform = 'Metop-A'
spatial_resolution = '12 km diameter pixel at nadir'
Dimensions:
time = 649874
Variables:
time
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'UTC time of acquisition'
standard_name = 'time'
units = 'HHMMSS.ms'
example = '252.9025=000252.9025 >> HH=00, MM=02, SS=52, ms=902'
latitude
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'latitude'
standard_name = 'latitude'
units = 'degrees_north'
valid_range = [-90 90]
longitude
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'longitude'
standard_name = 'longitude'
units = 'degrees_east'
valid_range = [-180 180]
column
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'Ammonia total column'
standard_name = 'NH3_total_column'
units = 'molec.cm^{-2}'
missing_value = 'NaN'
error
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'Error on the ammonia total column'
standard_name = 'NH3_total_column_error'
units = '%'
missing_value = 'NaN'
CLcov
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'Cloud coverage in the on ground pixel'
standard_name = 'cloud_cover'
units = '%'
VertProf
Size: 649874x1
Dimensions: time
Datatype: int32
Attributes:
long_name = 'Vertical profile used in the retrieval procedure. 0= Sea profile, 1= Land profile, 2= PBL height'
standard_name = 'profile_type'
angle
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'viewing angle of the satellite'
standard_name = 'angle'
units = 'degree'
在python中是否有替代函数从netcdf文件中取出所有属性?
NetCDF4
好像没有这样的"pretty print"选项,充其量你可以打开一个NetCDF文件,然后简单地打印对象;提供有关变量、维度等的一些信息:
import netCDF4 as nc4
test = nc4.Dataset('rico.default.0000000.nc')
print(test)
作为替代方案,xarray
确实可以选择 "pretty printing" 有关变量、维度、属性的信息:
import xarray as xr
test = xr.open_dataset('rico.default.0000000.nc')
print(test.info())
这个 returns 与 ncdump -h
几乎相同的输出,例如(完整输出的一小部分):
xarray.Dataset {
dimensions:
t = 7 ;
z = 100 ;
zh = 101 ;
variables:
int32 iter(t) ;
iter:units = - ;
iter:long_name = Iteration number ;
float64 t(t) ;
t:units = s ;
t:long_name = Time ;
float32 z(z) ;
z:units = m ;
z:long_name = Full level height ;
float32 zh(zh) ;
zh:units = m ;
zh:long_name = Half level height ;
............
最后它还打印全局属性(这个特定的 NetCDF 文件没有)。
我对netCDF文件的所有格式和维度都使用了这个函数。这就是我在 Matlab 中使用它的方式:
filename = 'C:\Users\my_name\Desktop\metopa_AM.nc'
ncdisp(filename)
Source:
C:\Users\my_name\Desktop\metopa_nh3nn_20100101_AM.nc
Format:
netcdf4
Global Attributes:
Title = 'Ammonia total columns retrieved from IASI measurements from the NH3-ULBNN retrieval algorithm'
Institution = 'Universite Libre de Bruxelles (ULB)/Laboratoire atmosph�res, milieux et observations spatiales (LATMOS)'
Product_Version = '1.0'
keywords = 'satellite, observation, atmosphere, ammonia'
date_created = '2016-04-26 12:44:52'
contact_emails = 'Simon Whitburn (simon.whitburn@ulb.ac.be) and Lieven Clarisse (lclariss@ulb.ac.be)'
platform = 'Metop-A'
spatial_resolution = '12 km diameter pixel at nadir'
Dimensions:
time = 649874
Variables:
time
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'UTC time of acquisition'
standard_name = 'time'
units = 'HHMMSS.ms'
example = '252.9025=000252.9025 >> HH=00, MM=02, SS=52, ms=902'
latitude
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'latitude'
standard_name = 'latitude'
units = 'degrees_north'
valid_range = [-90 90]
longitude
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'longitude'
standard_name = 'longitude'
units = 'degrees_east'
valid_range = [-180 180]
column
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'Ammonia total column'
standard_name = 'NH3_total_column'
units = 'molec.cm^{-2}'
missing_value = 'NaN'
error
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'Error on the ammonia total column'
standard_name = 'NH3_total_column_error'
units = '%'
missing_value = 'NaN'
CLcov
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'Cloud coverage in the on ground pixel'
standard_name = 'cloud_cover'
units = '%'
VertProf
Size: 649874x1
Dimensions: time
Datatype: int32
Attributes:
long_name = 'Vertical profile used in the retrieval procedure. 0= Sea profile, 1= Land profile, 2= PBL height'
standard_name = 'profile_type'
angle
Size: 649874x1
Dimensions: time
Datatype: single
Attributes:
long_name = 'viewing angle of the satellite'
standard_name = 'angle'
units = 'degree'
在python中是否有替代函数从netcdf文件中取出所有属性?
NetCDF4
好像没有这样的"pretty print"选项,充其量你可以打开一个NetCDF文件,然后简单地打印对象;提供有关变量、维度等的一些信息:
import netCDF4 as nc4
test = nc4.Dataset('rico.default.0000000.nc')
print(test)
作为替代方案,xarray
确实可以选择 "pretty printing" 有关变量、维度、属性的信息:
import xarray as xr
test = xr.open_dataset('rico.default.0000000.nc')
print(test.info())
这个 returns 与 ncdump -h
几乎相同的输出,例如(完整输出的一小部分):
xarray.Dataset {
dimensions:
t = 7 ;
z = 100 ;
zh = 101 ;
variables:
int32 iter(t) ;
iter:units = - ;
iter:long_name = Iteration number ;
float64 t(t) ;
t:units = s ;
t:long_name = Time ;
float32 z(z) ;
z:units = m ;
z:long_name = Full level height ;
float32 zh(zh) ;
zh:units = m ;
zh:long_name = Half level height ;
............
最后它还打印全局属性(这个特定的 NetCDF 文件没有)。