如何将两个netcdf文件与3个时间变量

时间:2018-06-15 04:03:47

标签: netcdf netcdf4

我需要连接两个NetCDF文件。两个文件具有完全相同的变量,并且有3个时间变量,time0time1time2time2是记录变量

使用NCO工具,当我尝试命令时:

ncrcat ${input1} ${input2} -o ${output}.

它只连接依赖于记录变量time2的变量。 我需要做什么来连接依赖于其他两个时间变量的变量?

添加标题以澄清:

netcdf tn_2018061706-utc_nzcsm_bap1 {
dimensions:
time2 = UNLIMITED ; // (48 currently)
rlat = 971 ;
rlon = 741 ;
bnds = 2 ;
bnds_4 = 4 ;
time0 = 49 ;
time1 = 48 ;
variables:
float sum_total_precip(time2, rlat, rlon) ;
    sum_total_precip:cell_methods = "time2: sum" ;
    sum_total_precip:coordinates = "latitude longitude" ;
    sum_total_precip:grid_mapping = "rotated_latitude_longitude" ;
    sum_total_precip:long_name = "sum of rain and lwe snowfall amounts" ;
    sum_total_precip:standard_name = "precipitation_amount" ;
    sum_total_precip:units = "kg m-2" ;
int rotated_latitude_longitude ;
    rotated_latitude_longitude:grid_mapping_name = "rotated_latitude_longitude" ;
    rotated_latitude_longitude:grid_north_pole_latitude = 49.5499992370605 ;
    rotated_latitude_longitude:grid_north_pole_longitude = 171.770004272461 ;
    rotated_latitude_longitude:north_pole_grid_longitude = 0. ;
float time2(time2) ;
    time2:axis = "T" ;
    time2:bounds = "time2_bnds" ;
    time2:units = "hours since 2018-06-17 06:00:00" ;
    time2:standard_name = "time" ;
    time2:long_name = "forecast period (end of reporting period)" ;
    time2:calendar = "gregorian" ;
float time2_bnds(time2, bnds) ;
float rlat(rlat) ;
    rlat:axis = "Y" ;
    rlat:units = "degrees" ;
    rlat:standard_name = "grid_latitude" ;
    rlat:long_name = "latitude on rotated pole grid at cell centres" ;
    rlat:valid_max = 90.f ;
    rlat:valid_min = -90.f ;
float rlon(rlon) ;
    rlon:axis = "X" ;
    rlon:units = "degrees" ;
    rlon:standard_name = "grid_longitude" ;
    rlon:long_name = "longitude on rotated pole grid at cell centres" ;
    rlon:valid_max = 360.f ;
    rlon:valid_min = 0.f ;
float latitude(rlat, rlon) ;
    latitude:bounds = "latitude_bnds" ;
    latitude:units = "degrees_north" ;
    latitude:standard_name = "latitude" ;
    latitude:long_name = "geographic latitude at cell centres" ;
    latitude:valid_max = 90.f ;
    latitude:valid_min = -90.f ;
float latitude_bnds(rlat, rlon, bnds_4) ;
float longitude(rlat, rlon) ;
    longitude:bounds = "longitude_bnds" ;
    longitude:units = "degrees_east" ;
    longitude:standard_name = "longitude" ;
    longitude:long_name = "geographic longitude at cell centres" ;
    longitude:valid_max = 360.f ;
    longitude:valid_min = 0.f ;
float longitude_bnds(rlat, rlon, bnds_4) ;
float orog_model(rlat, rlon) ;
    orog_model:standard_name = "surface_altitude" ;
    orog_model:long_name = "altitude of model orography" ;
    orog_model:stash_model = 1 ;
    orog_model:stash_section = 0 ;
    orog_model:stash_item = 33 ;
    orog_model:units = "m" ;
    orog_model:valid_min = -150.f ;
    orog_model:valid_max = 4000.f ;
    orog_model:_FillValue = -1.073742e+09f ;
    orog_model:coordinates = "latitude longitude" ;
    orog_model:grid_mapping = "rotated_pole" ;
    orog_model:actual_range = -58.91967f, 2800.626f ;
    orog_model:cell_methods = "time3: mean" ;
char rotated_pole ;
    rotated_pole:grid_mapping_name = "rotated_latitude_longitude" ;
    rotated_pole:grid_north_pole_latitude = 49.55f ;
    rotated_pole:grid_north_pole_longitude = 171.77f ;
    rotated_pole:north_pole_grid_longitude = 0.f ;
float sfc_air_press(time0, rlat, rlon) ;
    sfc_air_press:standard_name = "air_pressure" ;
    sfc_air_press:long_name = "surface pressure at model surface" ;
    sfc_air_press:stash_model = 1 ;
    sfc_air_press:stash_section = 0 ;
    sfc_air_press:stash_item = 409 ;
    sfc_air_press:units = "Pa" ;
    sfc_air_press:valid_min = 60000.f ;
    sfc_air_press:valid_max = 110000.f ;
    sfc_air_press:_FillValue = -1.073742e+09f ;
    sfc_air_press:coordinates = "latitude longitude" ;
    sfc_air_press:grid_mapping = "rotated_pole" ;
    sfc_air_press:actual_range = 70902.12f, 102833.1f ;
float sfc_dw_lw_flux(time1, rlat, rlon) ;
    sfc_dw_lw_flux:standard_name = "surface_downward_longwave_flux" ;
    sfc_dw_lw_flux:long_name = "downward longwave flux at the surface" ;
    sfc_dw_lw_flux:stash_model = 1 ;
    sfc_dw_lw_flux:stash_section = 2 ;
    sfc_dw_lw_flux:stash_item = 207 ;
    sfc_dw_lw_flux:units = "W m-2" ;
    sfc_dw_lw_flux:valid_min = 0.f ;
    sfc_dw_lw_flux:valid_max = 2000.f ;
    sfc_dw_lw_flux:_FillValue = -1.073742e+09f ;
    sfc_dw_lw_flux:coordinates = "latitude longitude" ;
    sfc_dw_lw_flux:grid_mapping = "rotated_pole" ;
    sfc_dw_lw_flux:actual_range = 144.8594f, 415.6719f ;
float sfc_dw_sw_flux(time1, rlat, rlon) ;
    sfc_dw_sw_flux:standard_name = "surface_downward_shortwave_flux" ;
    sfc_dw_sw_flux:long_name = "downward shortwave flux at the surface" ;
    sfc_dw_sw_flux:stash_model = 1 ;
    sfc_dw_sw_flux:stash_section = 1 ;
    sfc_dw_sw_flux:stash_item = 235 ;
    sfc_dw_sw_flux:units = "W m-2" ;
    sfc_dw_sw_flux:valid_min = 0.f ;
    sfc_dw_sw_flux:valid_max = 2000.f ;
    sfc_dw_sw_flux:_FillValue = -1.073742e+09f ;
    sfc_dw_sw_flux:coordinates = "latitude longitude" ;
    sfc_dw_sw_flux:grid_mapping = "rotated_pole" ;
    sfc_dw_sw_flux:actual_range = 0.f, 771.4844f ;
float sfc_merid_wind(time0, rlat, rlon) ;
    sfc_merid_wind:standard_name = "northward_wind" ;
    sfc_merid_wind:long_name = "true northward (meridional) wind at 10m" ;
    sfc_merid_wind:stash_model = 1 ;
    sfc_merid_wind:stash_section = 3 ;
    sfc_merid_wind:stash_item = 210 ;
    sfc_merid_wind:units = "m s-1" ;
    sfc_merid_wind:valid_min = -100.f ;
    sfc_merid_wind:valid_max = 100.f ;
    sfc_merid_wind:_FillValue = -1.073742e+09f ;
    sfc_merid_wind:coordinates = "latitude longitude" ;
    sfc_merid_wind:grid_mapping = "rotated_pole" ;
    sfc_merid_wind:actual_range = -28.3125f, 25.6875f ;
float sfc_rh(time0, rlat, rlon) ;
    sfc_rh:standard_name = "relative_humidity" ;
    sfc_rh:long_name = "relative humidity at 1.5m" ;
    sfc_rh:stash_model = 1 ;
    sfc_rh:stash_section = 3 ;
    sfc_rh:stash_item = 245 ;
    sfc_rh:units = "1" ;
    sfc_rh:valid_min = 0.f ;
    sfc_rh:valid_max = 1.f ;
    sfc_rh:_FillValue = -1.073742e+09f ;
    sfc_rh:coordinates = "latitude longitude" ;
    sfc_rh:grid_mapping = "rotated_pole" ;
    sfc_rh:actual_range = 0.22875f, 1.15375f ;
float sfc_snow_amount(time0, rlat, rlon) ;
    sfc_snow_amount:standard_name = "surface_snow_amount" ;
    sfc_snow_amount:long_name = "surface snow amount excluding that on vegetation" ;
    sfc_snow_amount:stash_model = 1 ;
    sfc_snow_amount:stash_section = 0 ;
    sfc_snow_amount:stash_item = 23 ;
    sfc_snow_amount:units = "kg m-2" ;
    sfc_snow_amount:valid_min = 0.f ;
    sfc_snow_amount:valid_max = 100000.f ;
    sfc_snow_amount:_FillValue = -1.073742e+09f ;
    sfc_snow_amount:coordinates = "latitude longitude" ;
    sfc_snow_amount:grid_mapping = "rotated_pole" ;
    sfc_snow_amount:actual_range = 0.f, 41577.25f ;
float sfc_snow_melt(time0, rlat, rlon) ;
    sfc_snow_melt:standard_name = "surface_snow_melt_flux" ;
    sfc_snow_melt:long_name = "land snow melt rate" ;
    sfc_snow_melt:stash_model = 1 ;
    sfc_snow_melt:stash_section = 8 ;
    sfc_snow_melt:stash_item = 231 ;
    sfc_snow_melt:units = "kg m-2 s-1" ;
    sfc_snow_melt:valid_min = 0.f ;
    sfc_snow_melt:valid_max = 100.f ;
    sfc_snow_melt:_FillValue = -1.073742e+09f ;
    sfc_snow_melt:coordinates = "latitude longitude" ;
    sfc_snow_melt:grid_mapping = "rotated_pole" ;
    sfc_snow_melt:actual_range = 0.f, 0.002179627f ;
float sfc_temp(time0, rlat, rlon) ;
    sfc_temp:standard_name = "air_temperature" ;
    sfc_temp:long_name = "air temperature at 1.5m" ;
    sfc_temp:stash_model = 1 ;
    sfc_temp:stash_section = 3 ;
    sfc_temp:stash_item = 236 ;
    sfc_temp:units = "K" ;
    sfc_temp:valid_min = 230.f ;
    sfc_temp:valid_max = 333.f ;
    sfc_temp:_FillValue = -1.073742e+09f ;
    sfc_temp:coordinates = "latitude longitude" ;
    sfc_temp:grid_mapping = "rotated_pole" ;
    sfc_temp:actual_range = 251.9062f, 293.9844f ;
float sfc_zonal_wind(time0, rlat, rlon) ;
    sfc_zonal_wind:standard_name = "eastward_wind" ;
    sfc_zonal_wind:long_name = "true eastward (zonal) wind at 10m" ;
    sfc_zonal_wind:stash_model = 1 ;
    sfc_zonal_wind:stash_section = 3 ;
    sfc_zonal_wind:stash_item = 209 ;
    sfc_zonal_wind:units = "m s-1" ;
    sfc_zonal_wind:valid_min = -100.f ;
    sfc_zonal_wind:valid_max = 100.f ;
    sfc_zonal_wind:_FillValue = -1.073742e+09f ;
    sfc_zonal_wind:coordinates = "latitude longitude" ;
    sfc_zonal_wind:grid_mapping = "rotated_pole" ;
    sfc_zonal_wind:actual_range = -20.3125f, 28.9375f ;
float sum_rain_amount(time2, rlat, rlon) ;
    sum_rain_amount:standard_name = "rainfall_amount" ;
    sum_rain_amount:long_name = "rainfall amount from all processes" ;
    sum_rain_amount:stash_model = 1 ;
    sum_rain_amount:stash_section = 4 ;
    sum_rain_amount:stash_item = 201 ;
    sum_rain_amount:units = "kg m-2" ;
    sum_rain_amount:valid_min = 0.f ;
    sum_rain_amount:valid_max = 200.f ;
    sum_rain_amount:_FillValue = -1.073742e+09f ;
    sum_rain_amount:coordinates = "latitude longitude" ;
    sum_rain_amount:grid_mapping = "rotated_pole" ;
    sum_rain_amount:cell_methods = "time2: sum" ;
    sum_rain_amount:actual_range = 0.f, 118.7461f ;
float sum_snowfall_amount(time2, rlat, rlon) ;
    sum_snowfall_amount:standard_name = "lwe_thickness_of_snowfall_amount" ;
    sum_snowfall_amount:long_name = "snowfall amount from all processes" ;
    sum_snowfall_amount:stash_model = 1 ;
    sum_snowfall_amount:stash_section = 4 ;
    sum_snowfall_amount:stash_item = 202 ;
    sum_snowfall_amount:units = "kg m-2" ;
    sum_snowfall_amount:valid_min = 0.f ;
    sum_snowfall_amount:valid_max = 200.f ;
    sum_snowfall_amount:_FillValue = -1.073742e+09f ;
    sum_snowfall_amount:coordinates = "latitude longitude" ;
    sum_snowfall_amount:grid_mapping = "rotated_pole" ;
    sum_snowfall_amount:cell_methods = "time2: sum" ;
    sum_snowfall_amount:actual_range = 0.f, 11.19141f ;
float time0(time0) ;
    time0:standard_name = "time" ;
    time0:long_name = "forecast period" ;
    time0:calendar = "gregorian" ;
    time0:units = "hours since 2018-06-17 06:00:00" ;
    time0:axis = "T" ;
float time1(time1) ;
    time1:standard_name = "time" ;
    time1:long_name = "forecast period" ;
    time1:calendar = "gregorian" ;
    time1:units = "hours since 2018-06-17 06:00:00" ;
    time1:axis = "T" ;
    // global attributes:
    :NCO = "4.6.8" ;
    :actual_range = 0.f, 118.7461f ;
    :comment = "NIWA NZCSM LAM EPS 3 is the UM10.4/PS36/GA6.0 based NZCSM suite." ;
    :data_assimilation_method = "Pseudo Analysis" ;
    :dynamical_core = "end_game" ;
    :forecast_reference_time = "2018-06-17 06:00:00" ;
    :grid_mapping_name = "rotated_latitude_longitude" ;
    :grid_north_pole_latitude = 49.55 ;
    :grid_north_pole_longitude = 171.77 ;
    :history = "Applied NZCSM 2 paramater hourly rainfall correction surface (to VCSN)\n",
        "Sun Jun 17 13:16:26 2018: ncks -O -x -v time3 -o tn_2018061706-utc_nzcsm.nc tmp_notime3_tn_2018061706-utc_nzcsm.nc\n",
        "Sun Jun 17 13:16:10 2018: ncwa -O -a time3 -o tmp_notime3_tn_2018061706-utc_nzcsm.nc raw_tn_2018061706-utc_nzcsm.nc\n",
        "Sun Jun 17 13:15:57 2018: ncks -O -d rlon,250,990 -d rlat,110,1080 -o raw_tn_2018061706-utc_nzcsm.nc raw_tn_2018061706-utc_nzcsm.nc\n",
        "Sun Jun 17 13:15:19 2018: ncap2 -O -s sum_total_precip=sum_rain_amount+sum_snowfall_amount /niwa/oper/ecox_oper/cylc-run/niwa1-aa179/share/cycle/20180617T06/output/tn_2018061706-utc_nzcsm.nc /niwa/oper/ecox_oper/cylc-run/niwa1-aa179/share/cycle/20180617T06/output/tn_2018061706-utc_nzcsm.nc\n",
        "UM fields file converted by um2netcdf-3.2.1 (2017-11-30, x86_64/Linux/gcc)" ;
    :input_uri = "/niwa/oper/ecox_oper/cylc-run/niwa1-aa179/share/cycle/20180617T06/output/tn_2018061706-utc_nzcsm.um" ;
    :institution = "NIWA" ;
    :met_office_ps = "36" ;
    :model_name = "nzcsm" ;
    :nco_openmp_thread_number = 1 ;
    :niwa_eps = "3" ;
    :references = "http://matiu/~ecoconnect_admin/eco-docs/DataSet_Definitions/  (needs updating)" ;
    :rose_id = "niwa1-aa179" ;
    :title = "nzcsm sub-set output for topnet (tn*.nc)" ;
    :um_version_number = 1004 ;
    :valid_max = 200. ;
    :valid_min = 0. ;
    :Conventions = "CF-1.5" ;
}

1 个答案:

答案 0 :(得分:1)

@Gabriella,您是正确的。 ncrcat将仅连接记录变量。将您的输入文件从netCDF3转换为netCDF4,并使所有时间维度记录维度,然后它应该可以工作,例如

netcdf mlt_rcd {

 dimensions:
  time1=unlimited; 
  time2=unlimited; 
  time3=unlimited; 

 variables:
  int var1(time1);
  int var2(time2);
  int var3(time3);

 data:
  var1=1;
  var2=2,2;
  var3=3,3,3;

} // end root group


zender@aerosol:~/nco$ ncgen -k netCDF-4 -b -o ~/nco/data/mlt_rcd.nc ~/nco/data/mlt_rcd.cdl
zender@aerosol:~/nco$ ncrcat -O -p ~/nco/data mlt_rcd.nc mlt_rcd.nc ~/foo.nc
zender@aerosol:~/nco$ ncks ~/foo.nc
netcdf foo {
  dimensions:
    time1 = UNLIMITED ; // (2 currently)
    time2 = UNLIMITED ; // (4 currently)
    time3 = UNLIMITED ; // (6 currently)

  variables:
    int var1(time1) ;

    int var2(time2) ;

    int var3(time3) ;

  // global attributes:
    :history = "Sun Jul  8 09:55:16 2018: ncrcat -O -p /Users/zender/nco/data mlt_rcd.nc mlt_rcd.nc /Users/zender/foo.nc" ;
    :NCO = "netCDF Operators version 4.7.6-alpha03 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)" ;


  data:
    var1 = 1, 1 ;

    var2 = 2, 2, 2, 2 ;

    var3 = 3, 3, 3, 3, 3, 3 ;

} // group /
zender@aerosol:~/nco$