[ncl-talk] To split nc file based on timestamp

Dennis Shea shea at ucar.edu
Tue Jul 2 15:29:03 MDT 2019


One approach: direct use of netCDF operators [ NCO ]:

*%>* ncks -d time,0  z.nc  z_0.nc
*%>* ncks -d time,1  z.nc  z_1.nc
etc
===
I speculate the Climate Data Operators [CDO] could be used also
====

Use (say) an NCL script to invoke the 'ncks' operator
====
  diri = "./"         ; source input directory
  fili = "z.nc"       ; source input file
  pthi = diri+fili

  diro = "./"         ; output directory

  do nt=0,4
     nts  = sprinti("%0.1i", nt)    ; or ... sprinti("%0.2i", nt)
     filo = "z_"+nts+".nc"
     ptho = diro+filo
     nco  = "ncks -O -d time,"+nt+" "+pthi+" "+ptho
     print("nt="+nt+": "+nco)                                      ; echo
NCO command
     system(nco)
  end do


On Tue, Jul 2, 2019 at 2:13 PM Tripura Yerrapothu via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Hello Team,
>
> I am currently looking the command that helps me to split the .nc file
> based on time stamp. Below is the file opened using ncdump
>
> netcdf rtma_20190501_T_interp_test {
> dimensions:
>     time = UNLIMITED ; // (5 currently)
>     lon = 309 ;
>     lat = 195 ;
> variables:
>     double time(time) ;
>         time:standard_name = "time" ;
>         time:long_name = "verification time generated by wgrib2 function
> verftime()" ;
>         time:units = "seconds since 1970-01-01 00:00:00.0 0:00" ;
>         time:calendar = "standard" ;
>         time:axis = "T" ;
>     float lon(lon) ;
>         lon:standard_name = "longitude" ;
>         lon:long_name = "longitude" ;
>         lon:units = "degrees_east" ;
>         lon:axis = "X" ;
>     float lat(lat) ;
>         lat:standard_name = "latitude" ;
>         lat:long_name = "latitude" ;
>         lat:units = "degrees_north" ;
>         lat:axis = "Y" ;
>     float TMP_2maboveground(time, lat, lon) ;
>         TMP_2maboveground:long_name = "Temperature" ;
>         TMP_2maboveground:units = "K" ;
>         TMP_2maboveground:_FillValue = 9.999e+20f ;
>         TMP_2maboveground:missing_value = 9.999e+20f ;
>         TMP_2maboveground:short_name = "TMP_2maboveground" ;
>         TMP_2maboveground:level = "2 m above ground" ;
>
> // global attributes:
>         :CDI = "Climate Data Interface version 1.9.3 (
> http://mpimet.mpg.de/cdi)" ;
>         :Conventions = "CF-1.0" ;
>         :history = "Thu Jun 20 15:36:01 2019: cdo intntime,4
> rtma_20190501_T_test.nc rtma_20190501_T_interp_test.nc\n",
>             "Thu Jun 20 15:31:22 2019: ncrcat
> ../20190501/rtma_2019050123_T_MS.nc rtma_2019050202_T_MS.nc
> rtma_20190501_T_test.nc\n",
>             "Mon Jun 10 16:53:02 2019: cdo
> remapbil,/home/tripura/2019CMA/Concorde-final/data/MS_Sound_Grid_90.13W-87.05W_29N-30.94N
> tmp.nc
> /home/tripura/2019CMA/Concorde-final/download/201905/20190501/rtma_2019050123_T_MS.nc"
> ;
>         :History = "created by wgrib2" ;
>         :GRIB2_grid_template = 30 ;
>         :NCO = "4.7.2" ;
>         :nco_openmp_thread_number = 1 ;
>         :CDO = "Climate Data Operators version 1.9.3 (
> http://mpimet.mpg.de/cdo)" ;
> }
>
>
> Now i want this file to split into 5 files i.e.. i am looking for the
> command to split the files based on the timestamps.
>
> Please kindly help me on this.
>
> Thank you in advance.
>
> Tripura
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190702/34f38582/attachment.html>


More information about the ncl-talk mailing list