[ncl-talk] "cd_inv_string" question

Alan Brammer abrammer at albany.edu
Fri Sep 8 11:56:08 MDT 2017


That’s my bad.  The counter is only incremented 2 spaces instead of 3.  So in your example it is decoding “-0” as the hours.   I possibly only tested with day as the last number so never picked up on this.  

For your example you could add an extra hyphen (any character but % will do) in the format after %J to bump the counter back into the correct position.  

e.g.
print(cd_calendar(cd_inv_string("1980-001-05", "%Y-%J--%H"), 0))


or edit  $NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_inv_string.ncl
line 117 should be:
	strm = strm+3



 Apologies all. 



Alan





> On 8 Sep 2017, at 13:26, Sojin Lee <noitul7 at gmail.com> wrote:
> 
> Please see the below results.
> 
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_inv_string.ncl"
> 
> print(cd_calendar(cd_inv_string("1980-001-05", "%Y-%J-%H"), 0))  
> 
> Variable: unnamed (return)
> Type: float
> Total Size: 24 bytes
>             6 values
> Number of Dimensions: 2
> Dimensions and sizes:	[1] x [6]
> Coordinates: 
> Number Of Attributes: 2
>   _FillValue :	9.96921e+36
>   calendar :	standard
> (0,0)	1980
> (0,1)	 1
> (0,2)	 1
> (0,3)	 0 <--- ???
> (0,4)	 0
> (0,5)	 0
> 
> print(cd_calendar(cd_inv_string("1980-01-01-05", "%Y-%N-%D-%H"), 0))  
> 
> Variable: unnamed (return)
> Type: float
> Total Size: 24 bytes
>             6 values
> Number of Dimensions: 2
> Dimensions and sizes:	[1] x [6]
> Coordinates: 
> Number Of Attributes: 2
>   _FillValue :	9.96921e+36
>   calendar :	standard
> (0,0)	1980
> (0,1)	 1
> (0,2)	 1
> (0,3)	 5 <--- It is ok...
> (0,4)	 0
> (0,5)	 0
> 
> It seems that cd_inv_string has some problems with Julian format. 
> 
> Thank you,
> 
> Sojin
> _______________________________________________
> 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/20170908/352e9b7f/attachment.html>


More information about the ncl-talk mailing list