<div dir="ltr"><div><div><div>Hi,<br><br></div>I&#39;m not expert at this:  I see where you use filevardef() to define a variable in the output file named SPI,  but I don&#39;t see where you actually copy data into that variable.   I also see that you define an output variable named &quot;time&quot;, but then copy data into an output variable &quot;T&quot;:   e.g.,   fout-&gt;T = .....    Is this what is intended?<br><br></div><div>Rick<br></div><br></div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 1, 2016 at 11:26 PM, misnawati misna <span dir="ltr">&lt;<a href="mailto:misna39@yahoo.com" target="_blank">misna39@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:verdana,helvetica,sans-serif;font-size:16px"><div><span style="font-size:small"><br></span></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">Dear NCL Supoort,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px" dir="ltr">I was run SPI scripts as below and it&#39;s work, but I try to save the output of SPI to netCDF file, and  I got the results but all values of SPI are -9999, <span style="font-size:12.8px">anyone can help me to fix it?</span></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px">Thank you very much,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px" dir="ltr">Misna</div><div><span style="font-size:small"><br></span></div><div><span style="font-size:small">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;</span><br></div><div><font size="2">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;</font></div><div><font size="2">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;</font></div><div><font size="2"><br></font></div><div><font size="2">  diri   = &quot;./&quot;</font></div><div><font size="2">  fili   = &quot;UCSB_CHIRPS_v2p0_mo8114_indo.nc&quot;</font></div><div><font size="2">  f      = addfile(diri+fili, &quot;r&quot;)</font></div><div><font size="2"><br></font></div><div><font size="2">  prc    = f-&gt;precipitation(0:407,:,:)</font></div><div><font size="2">  ;print(prc)</font></div><div><font size="2">  pmsg   = prc@_FillValue      ; convenience</font></div><div><font size="2"><br></font></div><div><font size="2">  printVarSummary(prc)</font></div><div><font size="2">  printMinMax(prc,0)</font></div><div><font size="2"><br></font></div><div><font size="2">  runlen = (/ 12, 24 /)   </font></div><div><font size="2">  nrun   = dimsizes(runlen)</font></div><div><font size="2">;*********************************</font></div><div><font size="2">; plot parameters</font></div><div><font size="2">;*********************************</font></div><div><font size="2">  dimprc = dimsizes(prc)</font></div><div><font size="2">  ntim   = dimprc(0)</font></div><div><font size="2">  nlat   = dimprc(1)</font></div><div><font size="2">  mlon   = dimprc(2)</font></div><div><font size="2"><br></font></div><div><font size="2">  yyyymm = cd_calendar(f-&gt;T(0:407), -1)</font></div><div><font size="2">  ;print(yyyymm)</font></div><div><font size="2">  ;yyyymm = yyyymm/100</font></div><div><font size="2">  </font></div><div><font size="2">  year    = yyyymm/100</font></div><div><font size="2">  ;print(year)</font></div><div><font size="2">  nyear   = dimsizes(year)</font></div><div><font size="2">  ;print(nyear)</font></div><div><font size="2">  yrStrt  = year(0)</font></div><div><font size="2">  ;print(yrStrt)</font></div><div><font size="2">  yrLast  = year(ntim-1)</font></div><div><font size="2">  ;print(yrLast)</font></div><div><font size="2">  nyear   = yrLast-yrStrt+1</font></div><div><font size="2">  yyyymm  = yyyymm_time(yrStrt, yrLast, &quot;integer&quot;) </font></div><div><font size="2">  yrfrac  = (/ yyyymm_to_yyyyfrac(yyyymm, 0.0) /)</font></div><div><font size="2"><br></font></div><div><font size="2">  prc&amp;T = (/ yyyymm /)</font></div><div><font size="2"><br></font></div><div><font size="2">  ;=================================</font></div><div><font size="2"><br></font></div><div><font size="2">  wks          = gsn_open_wks (&quot;png&quot;,&quot;spiprojectindo1&quot;)</font></div><div><font size="2">  </font></div><div><font size="2">  gsn_define_colormap(wks,&quot;BlueWhiteOrangeRed&quot;)</font></div><div><font size="2">  gsn_reverse_colormap(wks)           ; Reverse the color map.</font></div><div><font size="2"><br></font></div><div><font size="2">  res          = True                   </font></div><div><font size="2">  res@gsnDraw          = False              ; don&#39;t draw</font></div><div><font size="2">  res@gsnFrame         = False              ; don&#39;t advance frame</font></div><div><font size="2">  res@gsnSpreadColors  = True              </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>res@mpMinLonF = 90 <span style="white-space:pre-wrap">                                                </span>;koordinat indonesia</font></div><div><font size="2">  res@mpMaxLonF = 145</font></div><div><font size="2">  res@mpMinLatF = -11</font></div><div><font size="2">  res@mpMaxLatF = 6</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>res@gsnAddCyclic = False</font></div><div><font size="2">  res@cnFillOn         = True               ; color Fill </font></div><div><font size="2">  res@cnFillMode       = &quot;RasterFill&quot;       ; Raster Mode</font></div><div><font size="2">  res@cnLinesOn        =  False             ; Turn off contour lines</font></div><div><font size="2">  res@cnLevelSelectionMode = &quot;ManualLevels&quot; ; set manual contour levels</font></div><div><font size="2">  res@cnMinLevelValF   = -3.0               ; set min contour level</font></div><div><font size="2">  res@cnMaxLevelValF   =  3.0               ; set max contour level</font></div><div><font size="2">  res@cnLevelSpacingF  =  0.5               ; set contour spacing</font></div><div><font size="2">  res@lbLabelBarOn     = False              ; turn off individual cb&#39;s</font></div><div><font size="2"><br></font></div><div><font size="2">  resP                 = True               ; panel resources</font></div><div><font size="2">  resP@txString        = &quot;SPI: 1981-2014 (CHIRPS)&quot;  ; add center string</font></div><div><font size="2">  resP@gsnPanelLabelBar= True               ; add common colorbar</font></div><div><font size="2"><br></font></div><div><font size="2">  plot = new ( 2, &quot;graphic&quot;)</font></div><div><font size="2"><br></font></div><div><font size="2">  do nr=0,nrun-1</font></div><div><font size="2">    spi    = dim_spi_n(prc, runlen(nr), False, 0)</font></div><div><font size="2"><br></font></div><div><font size="2">    spi@long_name = &quot;SPI&quot;</font></div><div><font size="2">    spi@units = &quot;run=&quot;+runlen(nr)</font></div><div><font size="2">    copy_VarCoords(prc, spi)</font></div><div><font size="2"><br></font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>res@gsnCenterString  = yyyymm({200007})</font></div><div><font size="2">    plot(0) = gsn_csm_contour_map_ce(wks,spi({200007},:,:), res) </font></div><div><font size="2"><br></font></div><div><font size="2">    res@gsnCenterString  = yyyymm({200612})</font></div><div><font size="2">    plot(1) = gsn_csm_contour_map_ce(wks,spi({200612},:,:), res)  </font></div><div><font size="2"><br></font></div><div><font size="2">    gsn_panel(wks,plot,(/2,1/),resP)         </font></div><div><font size="2">  end do</font></div><div><font size="2"><br></font></div><div><font size="2"><br></font></div><div><font size="2">dimprc = dimsizes(prc)</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>ntim   = dimprc(0)</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>nlat   = dimprc(1)</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>mlon   = dimprc(2)</font></div><div><span style="white-space:pre-wrap"><font size="2">        </font></span></div><div><font size="2"><span style="white-space:pre-wrap">        </span>;ntime=time</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>;nlat=lat</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>;mlon=lon</font></div><div><span style="white-space:pre-wrap"><font size="2">        </font></span></div><div><font size="2"><span style="white-space:pre-wrap">        </span>diro = &quot;./&quot;                     <span style="white-space:pre-wrap">        </span>; Output directory</font></div><div><font size="2">    filo = &quot;IndeksKekeringan.nc&quot;             ; Output file</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>system(&quot;/bin/rm -f &quot; + diro + filo)    ; remove if exists</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fout  = addfile (diro + filo, &quot;c&quot;)  ; open output file</font></div><div><font size="2">;print(fout)</font></div><div><font size="2">   </font></div><div><font size="2">   setfileoption(fout,&quot;DefineMode&quot;,True)</font></div><div><font size="2">   </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fAtt               = True            ; assign file attributes</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fAtt@title         = &quot;NCL Efficient Approach to netCDF Creation&quot;  </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fAtt@source_file   = &quot;UCSB_JawaTengah.nc&quot;</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fAtt@Conventions   = &quot;None&quot;   </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fAtt@creation_date = systemfunc (&quot;date&quot;)        </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fileattdef( fout, fAtt )            ; copy file attributes  </font></div><div><span style="white-space:pre-wrap"><font size="2">        </font></span></div><div><font size="2"><span style="white-space:pre-wrap">        </span>dimNames = (/&quot;T&quot;, &quot;Y&quot;, &quot;X&quot;/)  </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>dimSizes = (/ ntim   ,  nlat,  mlon/) </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>dimUnlim = (/ False , False, False/)   </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>filedimdef(fout,dimNames,dimSizes,dimUnlim)</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>print(dimNames)</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>print(dimSizes)</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>print(dimUnlim)</font></div><div><span style="white-space:pre-wrap"><font size="2">        </font></span></div><div><font size="2"><span style="white-space:pre-wrap">        </span>filevardef(fout, &quot;time&quot; ,typeof(spi&amp;T),getvardims(spi&amp;T))             </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>filevardef(fout, &quot;lat&quot;  ,typeof(spi&amp;Y),getvardims(spi&amp;Y))                          </font></div><div><font size="2">    filevardef(fout, &quot;lon&quot;  ,typeof(spi&amp;X),getvardims(spi&amp;X))                          </font></div><div><font size="2">    filevardef(fout, &quot;SPI&quot;   ,typeof(spi),getvardims(spi))    </font></div><div><font size="2">      </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>filevarattdef(fout,&quot;SPI&quot;,spi)                     ; copy T attributes</font></div><div><font size="2">    filevarattdef(fout,&quot;time&quot; ,spi&amp;T)                    ; copy time attributes</font></div><div><font size="2">    filevarattdef(fout,&quot;lat&quot;  ,spi&amp;Y)                     ; copy lat attributes</font></div><div><font size="2">    filevarattdef(fout,&quot;lon&quot;  ,spi&amp;X)                     ; copy lon attributes</font></div><div><font size="2">       </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>setfileoption(fout,&quot;DefineMode&quot;,False)</font></div><div><span style="white-space:pre-wrap"><font size="2">        </font></span></div><div><font size="2">    fout-&gt;T   <span style="white-space:pre-wrap">        </span>= (/spi&amp;T/)     </font></div><div><font size="2">    fout-&gt;lat    = (/spi&amp;Y/)</font></div><div><font size="2">    fout-&gt;lon    = (/spi&amp;X/)</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span> </font></div><div dir="ltr"><span style="white-space:pre-wrap"><font size="2">        </font></span></div><div><span style="white-space:pre-wrap"><font size="2">        </font></span></div></div></div><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>