Гиперслаб 4D-переменной netcdf с использованием ncks - PullRequest
0 голосов
/ 25 января 2019

У меня большой большой файл netcdf, из которого мне нужны только определенные данные. Поэтому я хочу создать подразделение этого файла netcdf, используя ncks. Файл netcdf выглядит следующим образом:

Source:
           F:\LECOB\Model\20091208_195356.nc
Format:
           64bit
Global Attributes:
           Model = 's26.bobshelf.20141113'
           Title = 'S-NWM_BiP'
Dimensions:
           ni_t = 682
           nj_t = 712
           nk_t = 29
           time = 1     (UNLIMITED)
           ni_w = 682
           nj_w = 712
           nk_w = 30
           ni_u = 681
           nj_u = 712
           nk_u = 29
           ni_v = 682
           nj_v = 711
           nk_v = 29
           ni_f = 681
           nj_f = 711
           nk_f = 29
Variables:
    time 
           Size:       1x1
           Dimensions: time
           Datatype:   double
           Attributes:
                       units         = 'seconds from 2009-dec-08 17:00:14'
                       long_name     = 'time'
                       standard_name = 'time'
                       time_origin   = '2009-dec-08 17:00:14'
                       calendar      = 'gregorian'
                       content       = 'T'
                       axis          = 'T'
                       associate     = 'undefined'
    ni_t 
           Size:       682x1
           Dimensions: ni_t
           Datatype:   single
           Attributes:
                       long_name     = 'x_grid_index'
                       standard_name = 'x_grid_index'
                       content       = 'X'
                       axis          = 'X'
    nj_t 
           Size:       712x1
           Dimensions: nj_t
           Datatype:   single
           Attributes:
                       long_name     = 'y_grid_index'
                       standard_name = 'y_grid_index'
                       content       = 'Y'
                       axis          = 'Y'
    nk_t 
           Size:       29x1
           Dimensions: nk_t
           Datatype:   single
           Attributes:
                       long_name     = 'z_grid_index'
                       standard_name = 'z_grid_index'
                       content       = 'Z'
                       axis          = 'Z'
                       positive      = 'up'
    ni_w 
           Size:       682x1
           Dimensions: ni_w
           Datatype:   single
           Attributes:
                       long_name     = 'x_grid_index_at_w_location'
                       standard_name = 'x_grid_index_at_w_location'
                       content       = 'X'
                       axis          = 'X'
    nj_w 
           Size:       712x1
           Dimensions: nj_w
           Datatype:   single
           Attributes:
                       long_name     = 'y_grid_index_at_w_location'
                       standard_name = 'y_grid_index_at_w_location'
                       content       = 'Y'
                       axis          = 'Y'
    nk_w 
           Size:       30x1
           Dimensions: nk_w
           Datatype:   single
           Attributes:
                       long_name     = 'z_grid_index_at_w_location'
                       standard_name = 'z_grid_index_at_w_location'
                       content       = 'Z'
                       axis          = 'Z'
                       positive      = 'up'
    ni_u 
           Size:       681x1
           Dimensions: ni_u
           Datatype:   single
           Attributes:
                       long_name     = 'x_grid_index_at_u_location'
                       standard_name = 'x_grid_index_at_u_location'
                       content       = 'X'
                       axis          = 'X'
    nj_u 
           Size:       712x1
           Dimensions: nj_u
           Datatype:   single
           Attributes:
                       long_name     = 'y_grid_index_at_u_location'
                       standard_name = 'y_grid_index_at_u_location'
                       content       = 'Y'
                       axis          = 'Y'
    nk_u 
           Size:       29x1
           Dimensions: nk_u
           Datatype:   single
           Attributes:
                       long_name     = 'z_grid_index_at_u_location'
                       standard_name = 'z_grid_index_at_u_location'
                       content       = 'Z'
                       axis          = 'Z'
                       positive      = 'up'
    ni_v 
           Size:       682x1
           Dimensions: ni_v
           Datatype:   single
           Attributes:
                       long_name     = 'x_grid_index_at_v_location'
                       standard_name = 'x_grid_index_at_v_location'
                       content       = 'X'
                       axis          = 'X'
    nj_v 
           Size:       711x1
           Dimensions: nj_v
           Datatype:   single
           Attributes:
                       long_name     = 'y_grid_index_at_v_location'
                       standard_name = 'y_grid_index_at_v_location'
                       content       = 'Y'
                       axis          = 'Y'
    nk_v 
           Size:       29x1
           Dimensions: nk_v
           Datatype:   single
           Attributes:
                       long_name     = 'z_grid_index_at_v_location'
                       standard_name = 'z_grid_index_at_v_location'
                       content       = 'Z'
                       axis          = 'Z'
                       positive      = 'up'
    ssh  
           Size:       682x712x1
           Dimensions: ni_t,nj_t,time
           Datatype:   single
           Attributes:
                       units         = 'm'
                       long_name     = 'sea surface height above geoid'
                       standard_name = 'sea_surface_height_above_geoid'
                       content       = 'TYX'
                       associate     = 'time latitude_t longitude_t'
                       coordinates   = 'time latitude_t longitude_t'
                       _FillValue    = -9999
    CFL2D
           Size:       682x712x1
           Dimensions: ni_t,nj_t,time
           Datatype:   single
           Attributes:
                       units         = 's'
                       long_name     = 'CFL2D'
                       standard_name = 'CFL2D'
                       content       = 'TYX'
                       associate     = 'time latitude_t longitude_t'
                       coordinates   = 'time latitude_t longitude_t'
                       _FillValue    = -9999
    tem  
           Size:       682x712x29x1
           Dimensions: ni_t,nj_t,nk_t,time
           Datatype:   single
           Attributes:
                       units         = 'degrees_Celsius'
                       long_name     = 'sea_water_potential_temperature'
                       standard_name = 'sea_water_potential_temperature'
                       content       = 'TZYX'
                       associate     = 'time depth_t latitude_t longitude_t'
                       coordinates   = 'time depth_t latitude_t longitude_t'
                       _FillValue    = -9999
                       positive      = 'up'
    sal  
           Size:       682x712x29x1
           Dimensions: ni_t,nj_t,nk_t,time
           Datatype:   single
           Attributes:
                       units         = '1e-3'
                       long_name     = 'sea water salinity'
                       standard_name = 'sea_water_salinity'
                       content       = 'TZYX'
                       associate     = 'time depth_t latitude_t longitude_t'
                       coordinates   = 'time depth_t latitude_t longitude_t'
                       _FillValue    = -9999
                       positive      = 'up'
    vel_u
           Size:       681x712x29x1
           Dimensions: ni_u,nj_u,nk_u,time
           Datatype:   single
           Attributes:
                       units         = 'm s-1'
                       long_name     = 'sea_water_x_velocity_at_u_location'
                       standard_name = 'sea_water_x_velocity_at_u_location'
                       content       = 'TZYX'
                       associate     = 'time depth_u latitude_u longitude_u'
                       coordinates   = 'time depth_u latitude_u longitude_u'
                       _FillValue    = -9999
                       positive      = 'up'
    vel_v
           Size:       682x711x29x1
           Dimensions: ni_v,nj_v,nk_v,time
           Datatype:   single
           Attributes:
                       units         = 'm s-1'
                       long_name     = 'sea_water_y_velocity_at_v_location'
                       standard_name = 'sea_water_y_velocity_at_v_location'
                       content       = 'TZYX'
                       associate     = 'time depth_v latitude_v longitude_v'
                       coordinates   = 'time depth_v latitude_v longitude_v'
                       _FillValue    = -9999
                       positive      = 'up'
    kh   
           Size:       682x712x30x1
           Dimensions: ni_w,nj_w,nk_w,time
           Datatype:   single
           Attributes:
                       units         = 'm2/s'
                       long_name     = 'kh'
                       standard_name = 'kh'
                       content       = 'TZYX'
                       associate     = 'time depth_w latitude_t longitude_t'
                       coordinates   = 'time depth_w latitude_t longitude_t'
                       _FillValue    = -9999
                       positive      = 'up'
    tken 
           Size:       682x712x30x1
           Dimensions: ni_w,nj_w,nk_w,time
           Datatype:   single
           Attributes:
                       units         = '(m/s)2'
                       long_name     = 'tken'
                       standard_name = 'tken'
                       content       = 'TZYX'
                       associate     = 'time depth_w latitude_t longitude_t'
                       coordinates   = 'time depth_w latitude_t longitude_t'
                       _FillValue    = -9999
                       positive      = 'up'
    w    
           Size:       682x712x30x1
           Dimensions: ni_w,nj_w,nk_w,time
           Datatype:   single
           Attributes:
                       units         = 'm s-1'
                       long_name     = 'vertical_sea_water_velocity_at_w_location'
                       standard_name = 'vertical_sea_water_velocity_at_w_location'
                       content       = 'TZYX'
                       associate     = 'time depth_w latitude_t longitude_t'
                       coordinates   = 'time depth_w latitude_t longitude_t'
                       _FillValue    = -9999
                       positive      = 'up'

Теперь меня интересует 4D переменная vel_u (ni_u,nj_u,nk_u,time). Я хочу извлечь ni_u 151 до 152, nj_u 234 до 235, nk_u все и time все. Этот вопрос помог мне вместе с NCO: Извлечь переменную из файла NetCDF с помощью NCO ncks , как и следующая ссылка http://nco.sourceforge.net/nco.html#crd Используя их, я попробовал следующий код на моем компьютере с Linux:

ncks -C -F -d vel_u,151,152,1 20091208_195356.nc test.nc

Это дает мне две проблемы:

  1. Копирует все переменные, а не только vel_u, хотя я использовал -C, как предложено в вопросе NCO: Извлечение переменной из файла NetCDF с использованием NCO ncks
  2. Понятия не имею, как указать, чтобы использовать только измерения от 234 до 235 nj_u

Итак, как мне поместить эти части (ni_u 151 до 152, nj_u 234 до 235) переменной vel_u в мой файл test.nc?

Любой ответ высоко ценится!

1 Ответ

0 голосов
/ 25 января 2019

Я думаю, что нашел ответ: -d для измерений и -v для переменных, поэтому ответ на мой вопрос следующий:

ncks -C -F -d nj_u,234,235,1 -d ni_u,151,152,1 -v vel_u 20091208_195356.nc test.nc

-C, чтобы убедиться, что вы копируете только переменную vel_u

-F потому что предупреждение должно начинаться с 1, а не с 0

-d NameDimension, Min, Max, Step

-v NameVariable

input.nc

output.nc

Кажется, это дает мне именно то, что я хочу.

...