[ncl-talk] modifing "Times" in netcdf file

Dennis Shea shea at ucar.edu
Tue Dec 15 13:04:48 MST 2015


Perhaps two approaches....


[1] Add 6 to current values
[2] Use a function

Initially,
  f = addfile("...","r")   ;  Use "r" for test and "w" to actually
overwrite the values
  time0 = f->time

  time   = time0    ; copy for print
  printVarSummary(time0)             ; before

; method  1

  time = (/ time+6 /)   ; replace values
  time at units = "hours since 1987-04-13 18:00:00"  ; new units
  printVarSummary(time)                ; after

or

; method 2
; http://www.ncl.ucar.edu/Document/Functions/Contributed/cd_convert.shtml

  time = cd_convert( time0, "hours since 1987-04-13 18:00:00" )

; print to make sure they are as you expect

  print("-----")
  print(time0+"   "+time)  ; examine before and after values

====
 If all is ok the use the "w" on the addfile and then overwrite

   f->time = time

=================================

I'd make a copy of the file before doing anything ... just in case
tehre are errors.

Good Luck

On Fri, Dec 11, 2015 at 4:35 AM, Mark Chan <cym263 at yahoo.com> wrote:
> Dear NCL group,
>
> I am wondering whether there is any easy method with NCL to modify "internal
> Times" of the netcdf file: (the file name would be changed later)
>
> from: met_em_d01_1987-04-13_12:00:00
>
> To:    met_em_d01_1987-04-13_18:00:00
>
> So the time could be shown as (with "ncdump -v Times")
>  Times =   "1978-04-13_18:00:00" ;
>
> Thanks very much in advance!!!
> Mark
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


More information about the ncl-talk mailing list