<div dir="ltr"><div><div>Hi ,<br><br></div>Thank you very much!<br><br></div>DZ<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 8, 2017 at 7:23 PM, Dennis Shea <span dir="ltr"><<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>See attached<br><br></div><div>%> ncl rd_tmp2m.ncl<br></div><div><br>===<br></div>For GRIB & HDF files, NCL does <b>*not* </b>create an array dimension of size one. A dimension of size one is sometime called a "degenerate dimension." NCL does this to make the dimension structure simpler. <br><br></div>Originally, I did not like this behavior. Now, more often than not, I consider it a feature of NCL. :-)<br><br>===<br></div>Please look at the file via:<br><br></div>%> ncl_filedump tmp2m.1995053100.time.grb2 | less<br><br></div>What do you see?<br><br>------------------------------<wbr>------------------------------<wbr>--------------<br></div>[snip]<br><div> dimensions:<br><b> forecast_time0 = 1224 <=== 2400 forecast times<br></b> lat_0 = 190<br> lon_0 = 384<br> variables:<br> float <b>TMP_P0_L103_GGA0 ( forecast_time0, lat_0, lon_0 )</b><br> center : US National Weather Service - NCEP (WMC)<br> production_status : Operational products<br> long_name : Temperature<br> units : K<br> _FillValue : 1e+20<br></div><div>[snip]<br></div><div> i<b>nitial_time : 05/31/1995 (00:00) <=== no time info 'lost'<br></b></div><div><b> <wbr> <wbr> just returned differently<br></b></div><div>[snip]<br> <b><span style="color:rgb(255,0,0)">integer</span></b> forecast_time0 ( forecast_time0 )<br> long_name : Forecast offset from initial time<br> <span style="color:rgb(255,0,0)"><b>units : hours <wbr> <=====</b></span><br>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>----<br></div><div>Now look at:<br><br>%> ncl_filedump tmp2m.1995053100.time.grb2 <b>-itime</b> | less</div><div><br><div><div><div><div>[snip]<br> dimensions:<br><b> initial_time0_hours = 1 <=== <br> forecast_time0 = 1224</b><br> lat_0 = 190<br> lon_0 = 384<br><br> float <b>TMP_P0_L103_GGA0 ( initial_time0_hours, forecast_time0, lat_0, lon_0 )<br><br></b></div><div>[snip]<b><br> <span style="color:rgb(255,0,0)">double<span style="background-color:rgb(255,0,0)"></span></span> initial_time0_hours ( initial_time0_hours )<br> </b>long_name : initial time<b><br> units : <span style="color:rgb(255,0,0)">hours since 1800-01-01 00:00</span> </b><--- cd_calendar style<b><br><br>------------------------------<wbr>------------------------------<wbr>-----------<br></b></div><div><br></div><div>This gives both the initial-time of the forecast & the 2400 forecast times. For this application, I prefer that NCL include the degenerate dimension. How to do this programmatically? Our 'friend' ... <b><span style="color:rgb(0,0,255)">setfileoption<br><br><a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Document/Functions/Built-in/<wbr>setfileoption.shtml</a><br></span></b></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">See Example 6</span><br><span style="color:rgb(0,0,0)"><br>------------------------------<wbr>------------------------------<wbr>-------</span><br></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">NOTE:</span> <br></span></div><div><span style="color:rgb(0,0,255)"><br> <span style="color:rgb(0,0,0)">(a)</span> <span style="color:rgb(0,0,0)">initial_time0_hours is type 'double'<br></span></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"> (b) forecast_time0 is type 'integer'<br></span></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"> (c) cd_calendar <b>requires</b> units such as: "hours/days/minutes/seconds since..."<br><br></span></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">What to do? The attached script contains:<br><br> itime = tmp&initial_time0_hours ; hours since 1800-01-01 00:00 <br> printVarSummary(itime) <wbr> ; typeof(itime) ="double"<br><br> ftime = f->forecast_time0 ; Forecast **offset** from (hours) initial time<br> <wbr> ; typeof(ftime) =<b>"integer</b>"<br> printVarSummary(ftime) <wbr> ; (2400)<br><br></span></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">If I tried to 'rebase' the forecast times via:<br></span></span><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><br> ftime <b>= </b>itime + ftime ; (double + integer) <br><br></span></span></span></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">NCL will not allow because (</span></span></span></span><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">double + integer) returns a 'double'. However, since ftime is type integer</span></span>, <b>NCL which is a strongly typed language</b> default will not allow the type double right-hand-side to overwrite an existing variable of type integer.<br><br></span></span></span></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">How to 'solve'? Use our other 'best friend', the reassignment operatoe <b>:=</b><br></span></span></span></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><br> ftime <b>:= </b>itime + ftime ; double <b>:=</b> (double + integer) <br> ftime@units = itime@units ; same units as itime but rebased<br><br></span></span></div><div><br><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">I really like the <b>:= </b>operator. I like the fact that upon seeing the syntax, a user is aware that 'something' might change: size, shape, type, etc. In some other interpreted languages, this is the default behavior. IMHO, this can lead to unexpected errors.<br><br>------------------------------<wbr>------- <br></span></span></span></span></span></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">Cheers<span class="HOEnZb"><font color="#888888"><br></font></span></span></span></div><span class="HOEnZb"><font color="#888888"><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">D<br></span></span></div><div><span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)"><br></span></span></div><div><b><span style="color:rgb(0,0,255)"></span></b></div></font></span></div></div></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 8, 2017 at 7:09 PM, Alan Brammer <span dir="ltr"><<a href="mailto:abrammer@albany.edu" target="_blank">abrammer@albany.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Forecast time in your file will be hours since simulation started. e.g. 0,6,12,18. Without any guidance the cd_ routines will think this is hours since 1979-01-01. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">I don't want to download a 300MB file just to see if there is another time variable inside, so working with what I can see in the email, you can grab the initialisation date from the file name using cd_inv_string() incldued in 6.4.0 <a href="http://www.ncl.ucar.edu/Document/Functions/User_contributed/cd_inv_string.shtml" target="_blank">http://www.ncl.ucar.edu/<wbr>Document/Functions/User_contri<wbr>buted/cd_inv_string.shtml</a></div><div class="gmail_default" style="font-family:verdana,sans-serif"><span style="font-family:monospace,monospace"><br></span></div><div class="gmail_default" style="font-family:verdana,sans-serif"><span style="font-family:monospace,monospace"><br></span></div><div class="gmail_default" style="font-family:verdana,sans-serif"><span style="font-family:monospace,monospace">load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/contrib/cd_inv_string.ncl"</span><br></div><div class="gmail_default"><font face="monospace, monospace"><div class="gmail_default">load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/contrib/cd_string.ncl"</div><div><br></div></font></div><div class="gmail_default"><font face="monospace, monospace">fname="<a href="http://tmp2m.2002050100.time.nc" target="_blank">tmp2m.2002050100.time.n<wbr>c</a>"<br></font></div><div class="gmail_default"><font face="monospace, monospace">a = addfile(fname, "r")</font></div><div class="gmail_default"><font face="monospace, monospace">init_time = cd_inv_string(fname, "tmp2m.%Y%N%D%<a href="http://H.time.nc" target="_blank">H.time.nc</a>" )<br></font></div><div class="gmail_default"><font face="verdana, sans-serif"><br></font></div><div class="gmail_default"><span style="font-family:verdana,sans-serif">; Then either add the forecast times to the initial_time, or set the calendar for the forecast times so that it is appropriate. </span><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">forecast_hours = a->forecast_time0</font></div><div class="gmail_default"><font face="monospace, monospace">forecast_hours@units = cd_string(init_time, "hours since %Y-%N-%D %H:%M")</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">total_time = init_time + forecast_hours</font></div><div class="gmail_default"><font face="monospace, monospace">total_time@units = init_time@units</font></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_default" style="font-family:verdana,sans-serif">Good luck<br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Alan</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-8994552893064114271h5">On Sun, Oct 8, 2017 at 3:48 PM, dale zuri <span dir="ltr"><<a href="mailto:dalezuri@gmail.com" target="_blank">dalezuri@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div class="m_-8994552893064114271h5"><div dir="ltr"><div><div><div><div><div><div>Hi ,<br></div>This result is almost similar to cd_calendar result.<br>(0) Forecast for 1 Jan. 1979 at 06:00 <br>(1) Forecast for 1 Jan. 1979 at 12:00 <br>(2) Forecast for 1 Jan. 1979 at 18:00 <br>(3) Forecast for 2 Jan. 1979 at 00:00 <br>(4) Forecast for 2 Jan. 1979 at 06:00 <br></div>I am confused with 1979 year . <br></div>But the initial_time : 05/31/1995 (00:00)<br></div><br></div>Thanks<span class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516HOEnZb"><font color="#888888"><br><br></font></span></div><span class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516HOEnZb"><font color="#888888">DZ<br></font></span></div><div class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516HOEnZb"><div class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 8, 2017 at 11:24 AM, Guido Cioni <span dir="ltr"><<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">You need this in your preamble:<div><span class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516m_8909718647525004197m_938275100325876335pl-k" style="box-sizing:border-box;color:rgb(215,58,73);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-variant-ligatures:normal;white-space:pre-wrap;background-color:rgb(255,255,255)">load</span><span style="color:rgb(36,41,46);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-variant-ligatures:normal;white-space:pre-wrap;background-color:rgb(255,255,255)"> </span><span class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516m_8909718647525004197m_938275100325876335pl-s" style="box-sizing:border-box;color:rgb(3,47,98);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-variant-ligatures:normal;white-space:pre-wrap;background-color:rgb(255,255,255)">"<span class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516m_8909718647525004197m_938275100325876335pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">$NCARG_ROOT</span>/lib/ncarg/nclscri<wbr>pts/contrib/cd_string<span class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516m_8909718647525004197m_938275100325876335pl-cce" style="box-sizing:border-box">.</span>ncl”</span></div><div><div class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516m_8909718647525004197h5"><div><span class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516m_8909718647525004197m_938275100325876335pl-s" style="box-sizing:border-box;color:rgb(3,47,98);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-variant-ligatures:normal;white-space:pre-wrap;background-color:rgb(255,255,255)"><br></span></div><div><br></div><div><br><div><blockquote type="cite"><div>Il giorno 08 ott 2017, alle ore 21:23, dale zuri <<a href="mailto:dalezuri@gmail.com" target="_blank">dalezuri@gmail.com</a>> ha scritto:</div><br class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516m_8909718647525004197m_938275100325876335Apple-interchange-newline"><div><div dir="ltr"><div>Hi ,<br></div><div>Thanks for your reply. I need to create a time array with the actual date associated with each forecast time. <br></div><div>fatal:Undefined identifier: (cd_string) is undefined, can't continue error<br>t=cd_string(time, "%H:%M")<br><br></div><div>DZ<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 8, 2017 at 9:32 AM, Guido Cioni <span dir="ltr"><<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">You should really take a look at the starting guide of NCL and to the documentation of the individual functions before posting questions here.<div><br></div><div>I’ve just checked your file and it seems that the time variable has the right attributes. <br><div><br></div><div>Something like this should work (NOT TESTED)<br><div><br></div><div><font face="Menlo" size="1">a=addfile("tmp2m.1995053100.ti<wbr>me.grb2","r”)</font></div><div><font face="Menlo" size="1">time=a->forecast_time0</font></div><div><span style="font-family:Menlo;font-size:x-small"><br></span></div><div><span style="font-family:Menlo;font-size:x-small">date_title= </span><span style="font-family:Menlo;font-size:x-small">"Forecast for "</span><span style="font-family:Menlo;font-size:x-small">+</span><span style="font-family:Menlo;font-size:x-small">cd_string</span><span style="font-family:Menlo;font-size:x-small">(time, </span><span style="font-family:Menlo;font-size:x-small">"%d %c</span><span style="font-family:Menlo;font-size:x-small">.</span><span style="font-family:Menlo;font-size:x-small"> %Y"</span><span style="font-family:Menlo;font-size:x-small">)+</span><span style="font-family:Menlo;font-size:x-small">" at "</span><span style="font-family:Menlo;font-size:x-small">+</span><span style="font-family:Menlo;font-size:x-small">cd_string</span><span style="font-family:Menlo;font-size:x-small">(time, </span><span style="font-family:Menlo;font-size:x-small">"%H:%M"</span><span style="font-family:Menlo;font-size:x-small">)+" UTC</span><font face="Menlo" size="1">”</font></div><div><span style="font-family:Menlo;font-size:x-small"><br></span></div><div><span style="font-family:Menlo;font-size:x-small">Cheers </span></div><div><div><br><div><blockquote type="cite"><div>Il giorno 08 ott 2017, alle ore 11:40, dale zuri <<a href="mailto:dalezuri@gmail.com" target="_blank">dalezuri@gmail.com</a>> ha scritto:</div><br class="m_-8994552893064114271m_1103080053013883208gmail-m_-6668886234285004292m_-5990196081112008516m_8909718647525004197m_938275100325876335m_5624277842751735818Apple-interchange-newline"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline">date = cd_calendar(r, -3)</span></div></blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>
</div></div><br></div></div>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>