[ncl-talk] date format from GFS0.25

Dennis Shea shea at ucar.edu
Sat Mar 21 08:24:05 MDT 2020


Please read the setfileoption documentation and understand "Initial_time"
anf "Forecast_time"

;;monName = (/"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep" \
;;           ,"Oct","Nov","Dec"/)
  dayName = (/"Sat","Mon","Tue","Wed","Thu","Fri","Sat"/)

  *setfileoption*(
<https://www.ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml>"grb","SingleElementDimensions","Initial_time")
; force an initial time dimension
  fgrb = *addfile*("gfs.t00z.pgrb2.0p25.f024","r")
  time = fgrb->initial_time0_hours
  printVarSummary(time)

  TIME = *toint*( cd_calendar(time, 0) )         ; (:,6)
  yyyy   = TIME(0,0)                                    ; 1st time
  mm     = TIME(0,1)
  dd       = TIME(0,2)
  hh      = TIME(0,3)
  mn     = TIME(0,4)
  sc     = TIME(0,5)
 ;
  nd     = *day_of_week*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/day_of_week.shtml>(yyyy,mm,dd)
            ; 0 to 6
  dateLabel = "Init: "+dayName(nd)+" "+yyyy +"-" \
                      +*sprinti*(
<https://www.ncl.ucar.edu/Document/Functions/Built-in/sprinti.shtml>"%0.2i",mm)
 +"-" \
                      +*sprinti*("%0.2i",nd)  +" " \
                      +*sprinti*("%0.2i",hh)  +"z"
  print(dateLabel)

On Sat, Mar 21, 2020 at 7:08 AM Ehsan Taghizadeh via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Dears,
> First of all, happy Nowruz. I hope best wishes for all people and safe
> from COVID-19.
>
> I want to handle a header for plot GFS 0.25 data. I've used following
> lines:
>
>   ; To read precipitation variable from file
>   gfs_f = addfile("gfs.t00z.pgrb2.0p25.f024", "r")
>   gfs_prc = gfs_f->APCP_P8_L1_GLL0_acc24h
>   print(gfs_prcn at initial_time)
>   print(gfs_prcn at forecast_time)
>   ; initial_time :        03/21/2020 (00:00)
>   ; forecast_time :       24
>   ; forecast_time_units : hours
>
>  ; For Initial time in header I've used following lines:
>   moni = str_get_cols(gfs_prcn at initial_time, 0, 1) ; 03
>   dayi = str_get_cols(gfs_prcn at initial_time, 3, 4) ; 21
>   yeari=str_get_cols(gfs_prcn at initial_time, 6, 9)  ; 2020
>   houri=str_get_cols(gfs_prcn at initial_time, 12, 13); 00
>   dow =
> day_of_week(stringtointeger(yeari),stringtointeger(moni),stringtointeger(dayi))
>
>   ; Convert day_of_week output from integer to corresponding day.
>   if (dow .eq. 0) then
> dowc = "Sun"
>   else if (dow .eq. 1) then
> dowc = "Mon"
>   else if (dow .eq. 2) then
> dowc = "Tue"
>  else if (dow .eq. 3) then
> dowc = "Wed"
>   else if (dow .eq. 4) then
> dowc = "Thu"
>   else if (dow .eq. 5) then
> dowc = "Fri"
>   else
> dowc = "Sat"
>   end if
>   end if
>   end if
>   end if
>   end if
>   end if
>   res at gsnRightString = "Init: "+dowc+" "+yeari+"-"+moni+"-"+dayi+" "+houri
> +"z"
>  ; output will be something like: Init: Sat 2020-03-21 00z
>
> May I ask some help?
> 1- Is there any straightforward to get desired output for initial time
> header, same as above? I mean is there any function to use instead of "
> str_get_cols" and also instead of many "if" for above lines?
> 2- forecast_time gives me just an integer number, 24. How could I created
> a valid time header for plots, like: "Valid: Sun 2020-03-22 00z"?
> I've seen following link:
> https://www.ncl.ucar.edu/Support/talk_archives/2012/3759.html
> It seems like my problem, however is it final way?
> I hope hearing from you, as always.
>
> *Sincerely*
> *Ehsan*
>
> _______________________________________________
> 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/20200321/d6d12e10/attachment.html>


More information about the ncl-talk mailing list