<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#000000"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#000000">Thank you Dannis and Dave for your suggestion/corrections, which really helped me understand the issue.</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#000000"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#000000"><br></div><div class="gmail_extra"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><i>Dr. MUHAMMAD AFZAAL KARORI</i><br>Pakistan Meteorological Department<br>Sector H-8/2, Pitras Bukhari Road,<br>Islamabad - 44000<br>Pakistan <br><br><br></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Nov 30, 2017 at 5:38 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>I don't know GrADS and how it handles 'time'<br><br>===<br></div>My speculation is that <br><span class=""> <font color="#ff0000">prc&time = (/ yyyymm /)<br></font></span></div><font color="#ff0000"><font color="#000000">is the source of the problem.<br> Likely, GrADS expects 'time' to have units like 'seconds/minutes/hours/days since ...."<br><br></font></font></div><font color="#ff0000"><font color="#000000">I would eliminate the above line .....ALso, not sure why you are 'promoting' the float variable to a double.<br><br></font></font></div><font color="#ff0000"><font color="#000000">GrADS questions should be sent to the GrADS support group.<br></font></font><div><div><div><font color="#ff0000"><font color="#000000">=======================<br></font></font><span class=""><br><font color="#ff0000"><font color="#000000"><font color="#ff0000"> diri = "./"</font></font></font><div><font color="#ff0000"> fili = "<a href="http://precip.mon.total.v7.nc" target="_blank">precip.mon.total.v7.nc</a>"</font></div><div><font color="#ff0000"> f = addfile(diri+fili, "r")</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000"> prc = flt2dble(f->precip(:,{<span class="m_-2414969511064377484gmail-aBn"><span class="m_-2414969511064377484gmail-aQJ">12:33</span></span>},{<wbr>30:60}))</font></div><div><font color="#ff0000"> pmsg = prc@_FillValue ; convenience</font></div><div><font color="#ff0000"><br></font></div></span><span class=""><div><font color="#ff0000">;=============================<wbr>==============================<wbr>====</font></div><div><font color="#ff0000">;write to nc file</font></div><div><font color="#ff0000">;=============================<wbr>==============================<wbr>=====</font></div><div><font color="#ff0000"><br></font></div><font color="#ff0000"><font color="#000000"><br></font></font></span><font color="#ff0000">prc = flt2dble(f->precip(:,{<span class="m_-2414969511064377484gmail-aBn"><span class="m_-2414969511064377484gmail-aQJ">12:33</span></span>},{<wbr>30:60})) ; <<< ??why are you promoting to double?<br><br><span style="color:rgb(0,0,0)">====</span><br><br></font></div><div><font color="#ff0000">Actually, the netCDF Operators could be used<br><br></font></div><div><font color="#ff0000">%> ncks -</font><font color="#ff0000">-d lat,12.0,33.0 -d lon,30.0,60.0 -O</font><font color="#ff0000"><font color="#ff0000"><a href="http://precip.mon.total.v7.nc" target="_blank"><font color="#ff0000"> </font>precip.mon.total.v7.nc </a></font></font><font color="#ff0000"><font color="#ff0000"><font color="#ff0000"><a href="http://prc_3mon.nc" target="_blank"><font color="#ff0000"></font>prc_3mon.nc</a></font></font></font></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Nov 30, 2017 at 2:17 AM, Dr. Muhammad Afzaal <span dir="ltr"><<a href="mailto:afzaalkarori@gmail.com" target="_blank">afzaalkarori@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div style="font-family:georgia,serif;font-size:small;color:rgb(0,0,0)">in continuation to my previous email, following is the defined variable summary</div><div style="font-family:georgia,serif;font-size:small;color:rgb(0,0,0)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(0,0,0)"><div>Variable: prcp</div><div>Type: double</div><div>Total Size: 27336960 bytes</div><div> 3417120 values</div><div>Number of Dimensions: 3</div><div>Dimensions and sizes: [time | 1356] x [lat | 42] x [lon | 60]</div><div>Coordinates:</div><div> time: [190101..201312]</div><div> lat: [12.25..32.75]</div><div> lon: [30.25..59.75]</div><div>Number Of Attributes: 3</div><div> units : (mm)</div><div> long_name : </div><div> _FillValue : -9.969209968386869e+36</div><div><br></div><div>Please read the second last line of my code as ncdf->prcp = prcp</div><div><br></div><div>Thanks </div><div><br></div></div><div class="gmail_extra"><span><div><div class="m_-2414969511064377484m_3512487935546376823gmail_signature"><div dir="ltr"><div><div dir="ltr"><i>Dr. MUHAMMAD AFZAAL KARORI</i><br>Pakistan Meteorological Department<br>Sector H-8/2, Pitras Bukhari Road,<br>Islamabad - 44000<br>Pakistan <br><br><br></div></div></div></div></div>
<br></span><div><div class="m_-2414969511064377484h5"><div class="gmail_quote">On Thu, Nov 30, 2017 at 12:06 PM, Dr. Muhammad Afzaal <span dir="ltr"><<a href="mailto:afzaalkarori@gmail.com" target="_blank">afzaalkarori@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:georgia,serif;font-size:small;color:rgb(0,0,0)">Dear NCL users</div><div style="font-family:georgia,serif;font-size:small;color:rgb(0,0,0)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(0,0,0)">I am using NCL 6.4.0 on ubuntu. I need to write a variable to netcdf file. I did it successfully using Method 1 given on ncl homepage. I have little problem that when I open nc file in grads, the time is not realistic. I mean its like;</div><div style="font-family:georgia,serif;font-size:small;color:rgb(0,0,0)"><br></div><div><div style="color:rgb(0,0,0);font-family:georgia,serif;font-size:small">Time values set: 2320:6:25:0 2320:6:25:0</div><div style="color:rgb(0,0,0);font-family:georgia,serif;font-size:small"> </div><div style="color:rgb(0,0,0);font-family:georgia,serif;font-size:small">while the variable has the time from 190101 to 201312</div><div style="color:rgb(0,0,0);font-family:georgia,serif;font-size:small"><br></div><div style="color:rgb(0,0,0);font-family:georgia,serif;font-size:small">Can someone please help me how can add time dim as that attached with the define variable? My code is given below</div><div style="color:rgb(0,0,0);font-family:georgia,serif;font-size:small"><br></div><div><div><font color="#ff0000">;=============================<wbr>=======================</font></div><div><font color="#ff0000">begin</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000"> diri = "./"</font></div><div><font color="#ff0000"> fili = "<a href="http://precip.mon.total.v7.nc" target="_blank">precip.mon.total.v7.nc</a>"</font></div><div><font color="#ff0000"> f = addfile(diri+fili, "r")</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000"> prc = flt2dble(f->precip(:,{12:33},{<wbr>30:60}))</font></div><div><font color="#ff0000"> pmsg = prc@_FillValue ; convenience</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">;*****************************<wbr>****</font></div><div><font color="#ff0000">; plot parameters</font></div><div><font color="#ff0000">;*****************************<wbr>****</font></div><div><font color="#ff0000"> dimprc = dimsizes(prc)</font></div><div><font color="#ff0000"> ntim = dimprc(0)</font></div><div><font color="#ff0000"> nlat = dimprc(1)</font></div><div><font color="#ff0000"> mlon = dimprc(2)</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000"> tim = f->time</font></div><div><font color="#ff0000"> utc_date = cd_calendar(tim, 0) </font></div><div><font color="#ff0000"> year = tointeger(utc_date(:,0))</font></div><div><font color="#ff0000"> yrStrt = year(0)</font></div><div><font color="#ff0000"> yrLast = year(ntim-1)</font></div><div><font color="#ff0000"> nyear = yrLast-yrStrt+1</font></div><div><font color="#ff0000">;print(year + " " + yrStrt + " "+ yrLast +" "+ nyear)</font></div><div><font color="#ff0000"> yyyymm = yyyymm_time(yrStrt, yrLast, "integer") </font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000"> yrfrac = (/ yyyymm_to_yyyyfrac(yyyymm, 0.0) /)</font></div><div><span style="white-space:pre-wrap"><font color="#ff0000"> </font></span></div><div><font color="#ff0000"> prc&time = (/ yyyymm /)</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">;=============================<wbr>==============================<wbr>====</font></div><div><font color="#ff0000">;write to nc file</font></div><div><font color="#ff0000">;=============================<wbr>==============================<wbr>=====</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000"> system("/bin/rm -f <a href="http://prc_3mon.nc" target="_blank">prc_3mon.nc</a>") ;remove any pre-existing file</font></div><div><font color="#ff0000"> ncdf = addfile("<a href="http://prc_3mon.nc" target="_blank">prc_3mon.nc</a>" ,"c") ; open output netCDF file</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">;=============================<wbr>==============================<wbr>====</font></div><div><font color="#ff0000">; create global attributes of the file (optional)</font></div><div><font color="#ff0000">;=============================<wbr>==============================<wbr>=====</font></div><div><font color="#ff0000"> fAtt = True ; assign file attributes</font></div><div><font color="#ff0000"> fAtt@title = "GPCC Rainfall"</font></div><div><font color="#ff0000"> fAtt@source_file = "<a href="http://precip.mon.total.v7.nc" target="_blank">precip.mon.total.v7.nc</a>"</font></div><div><font color="#ff0000"> fAtt@Conventions = "None"</font></div><div><font color="#ff0000"> fAtt@creation_date = systemfunc ("date")</font></div><div><font color="#ff0000"> fileattdef( ncdf, fAtt ) ; copy file attributes</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">;=============================<wbr>==============================<wbr>====</font></div><div><font color="#ff0000">; make time an UNLIMITED dimension;recommended for most applications</font></div><div><font color="#ff0000">;=============================<wbr>==============================<wbr>====</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000"> filedimdef(ncdf,"time",-1,Tru<wbr>e) </font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">;=============================<wbr>==============================<wbr>====</font></div><div><font color="#ff0000">; output variables directly; NCL will call appropriate functions</font></div><div><font color="#ff0000">; to write the meta data associated with each variable</font></div><div><font color="#ff0000">;=============================<wbr>==============================<wbr>====</font></div><div><font color="#ff0000"> ncdf->spi = spi ; 3D </font></div><div><font color="#ff0000">end</font></div></div><div><br></div><div><br></div><div>Regards</div></div><div><div class="m_-2414969511064377484m_3512487935546376823gmail-m_-3285677477193680377gmail_signature"><div dir="ltr"><div><div dir="ltr"><i>Dr. MUHAMMAD AFZAAL KARORI</i><br>Pakistan Meteorological Department<br>Sector H-8/2, Pitras Bukhari Road,<br>Islamabad - 44000<br>Pakistan <br><br><br></div></div></div></div></div>
</div>
</blockquote></div><br></div></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>
</blockquote></div><br></div></div>