我想知道是否有人从网格化气候数据中提取信息并以更容易合作生成时间序列的方式组织信息。我不确定如何使用索引(分别为i
和j
或lat
和lon
),我只想选择纬度超过60度的数据。当我尝试提取数据以排列它时,我不断收到以下错误:
ValueError:切片表达式超出变量“
的维数
我试图将数据放在下表格式中:
Date, lat, lon, snc
标题信息是:
netcdf snc_day_MPI-ESM-LR_amip_r1i1p1_19790101-20081231 {
dimensions:
time = UNLIMITED ; // (10958 currently)
lat = 96 ;
lon = 192 ;
bnds = 2 ;
variables:
double time(time) ;
time:bounds = "time_bnds" ;
time:units = "days since 1979-1-1 00:00:00" ;
time:calendar = "proleptic_gregorian" ;
time:axis = "T" ;
time:long_name = "time" ;
time:standard_name = "time" ;
double time_bnds(time, bnds) ;
double lat(lat) ;
lat:bounds = "lat_bnds" ;
lat:units = "degrees_north" ;
lat:axis = "Y" ;
lat:long_name = "latitude" ;
lat:standard_name = "latitude" ;
double lat_bnds(lat, bnds) ;
double lon(lon) ;
lon:bounds = "lon_bnds" ;
lon:units = "degrees_east" ;
lon:axis = "X" ;
lon:long_name = "longitude" ;
lon:standard_name = "longitude" ;
double lon_bnds(lon, bnds) ;
float snc(time, lat, lon) ;
snc:standard_name = "surface_snow_area_fraction" ;
snc:long_name = "Snow Area Fraction" ;
snc:units = "%" ;
snc:cell_methods = "time: mean" ;
snc:cell_measures = "area: areacella" ;
snc:history = "2011-05-26T14:06:06Z altered by CMOR: replaced missing value flag (1e+22) with standard missing value (1e+20)." ;
snc:missing_value = 1.e+20f ;
snc:_FillValue = 1.e+20f ;
snc:associated_files = "baseURL: http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile: gridspec_landIce_fx_MPI-ESM-LR_amip_r0i0p0.nc areacella: areacella_fx_MPI-ESM-LR_amip_r0i0p0.nc" ;
// global attributes:
:institution = "Max Planck Institute for Meteorology" ;
:institute_id = "MPI-M" ;
:experiment_id = "amip" ;
:source = "MPI-ESM-LR 2011; URL: http://svn.zmaw.de/svn/cosmos/branches/releases/mpi-esm-cmip5/src/mod; atmosphere: ECHAM6 (REV: 4418), T63L47; land: JSBACH (REV: 4418);" ;
:model_id = "MPI-ESM-LR" ;
:forcing = "GHG Oz SD Sl Vl LU" ;
:parent_experiment_id = "N/A" ;
:parent_experiment_rip = "N/A" ;
:branch_time = 0. ;
:contact = "cmip5-mpi-esm@dkrz.de" ;
:history = "Model raw output postprocessing with modelling environment (IMDI) at DKRZ: URL: http://svn-mad.zmaw.de/svn/mad/Model/IMDI/trunk, REV: 3135 2011-05-26T14:06:06Z CMOR rewrote data to comply with CF standards and CMIP5 requirements." ;
:references = "ECHAM6: n/a; JSBACH: Raddatz et al., 2007. Will the tropical land biosphere dominate the climate-carbon cycle feedback during the twenty first century? Climate Dynamics, 29, 565-574, doi 10.1007/s00382-007-0247-8;" ;
:initialization_method = 1 ;
:physics_version = 1 ;
:tracking_id = "7c36f2e9-7f1a-4bcc-94f5-bf2ab21dd16d" ;
:product = "output" ;
:experiment = "AMIP" ;
:frequency = "day" ;
:creation_date = "2011-05-26T14:06:06Z" ;
:Conventions = "CF-1.4" ;
:project_id = "CMIP5" ;
:table_id = "Table day (27 April 2011) 86d1558d99b6ed1e7a886ab3fd717b58" ;
:title = "MPI-ESM-LR model output prepared for CMIP5 AMIP" ;
:parent_experiment = "N/A" ;
:modeling_realm = "landIce land" ;
:realization = 1 ;
:cmor_version = "2.5.9" ;
答案 0 :(得分:2)
在使用ncks时同意N1B4。另请注意,ncks接受坐标值(由小数点表示),而不仅仅是索引(由索引表示)。因此,例如,可以通过
获得大于60度的纬度值ncks -d lat,60., in.nc
完全不知道底层坐标网格。
答案 1 :(得分:1)
ncks
非常适合此类程序。您可以轻松地提取纬度大于60度的snc时间序列。您需要首先确定维度lat
中包含大于60的值的索引。
ncks -v lat infile.nc | more
这将打印lat
的值(变量,而不是维度)。没有文件,让我们说大于60的值是80-96。请记住,在Python(和NCO)中,第一个索引是0,因此零索引世界中80-96的范围是79-95。
现在,我们可以使用ncks
在79-95的lat
范围内提取snc的值。
ncks -v snc -d lat,79,95 infile.nc -O outfile.nc
您可以使用ncks添加任意数量的维片。如果您想要特定的time
和lon
范围,只需将其添加即可!例如,
ncks -v snc -d lat,79,95 -d lon,0,25 -d time,0,5 infile.nc -O outfile.nc