[ncl-talk] date format from GFS0.25

Ehsan Taghizadeh ehsantaghizadeh at yahoo.com
Sat Mar 21 07:08:27 MDT 2020


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.
SincerelyEhsan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200321/4355a9ea/attachment.html>


More information about the ncl-talk mailing list