<div dir="ltr"><div><div><div>Hi,<br><br></div>I'm not expert at this: I see where you use filevardef() to define a variable in the output file named SPI, but I don't see where you actually copy data into that variable. I also see that you define an output variable named "time", but then copy data into an output variable "T": e.g., fout->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"><<a href="mailto:misna39@yahoo.com" target="_blank">misna39@yahoo.com</a>></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'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 "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</span><br></div><div><font size="2">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</font></div><div><font size="2">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</font></div><div><font size="2"><br></font></div><div><font size="2"> diri = "./"</font></div><div><font size="2"> fili = "UCSB_CHIRPS_v2p0_mo8114_indo.nc"</font></div><div><font size="2"> f = addfile(diri+fili, "r")</font></div><div><font size="2"><br></font></div><div><font size="2"> prc = f->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->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, "integer") </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&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 ("png","spiprojectindo1")</font></div><div><font size="2"> </font></div><div><font size="2"> gsn_define_colormap(wks,"BlueWhiteOrangeRed")</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't draw</font></div><div><font size="2"> res@gsnFrame = False ; don'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 = "RasterFill" ; Raster Mode</font></div><div><font size="2"> res@cnLinesOn = False ; Turn off contour lines</font></div><div><font size="2"> res@cnLevelSelectionMode = "ManualLevels" ; 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'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 = "SPI: 1981-2014 (CHIRPS)" ; 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, "graphic")</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 = "SPI"</font></div><div><font size="2"> spi@units = "run="+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 = "./" <span style="white-space:pre-wrap">        </span>; Output directory</font></div><div><font size="2"> filo = "IndeksKekeringan.nc" ; Output file</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>system("/bin/rm -f " + diro + filo) ; remove if exists</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fout = addfile (diro + filo, "c") ; 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,"DefineMode",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 = "NCL Efficient Approach to netCDF Creation" </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fAtt@source_file = "UCSB_JawaTengah.nc"</font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fAtt@Conventions = "None" </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>fAtt@creation_date = systemfunc ("date") </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 = (/"T", "Y", "X"/) </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, "time" ,typeof(spi&T),getvardims(spi&T)) </font></div><div><font size="2"><span style="white-space:pre-wrap">        </span>filevardef(fout, "lat" ,typeof(spi&Y),getvardims(spi&Y)) </font></div><div><font size="2"> filevardef(fout, "lon" ,typeof(spi&X),getvardims(spi&X)) </font></div><div><font size="2"> filevardef(fout, "SPI" ,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,"SPI",spi) ; copy T attributes</font></div><div><font size="2"> filevarattdef(fout,"time" ,spi&T) ; copy time attributes</font></div><div><font size="2"> filevarattdef(fout,"lat" ,spi&Y) ; copy lat attributes</font></div><div><font size="2"> filevarattdef(fout,"lon" ,spi&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,"DefineMode",False)</font></div><div><span style="white-space:pre-wrap"><font size="2">        </font></span></div><div><font size="2"> fout->T <span style="white-space:pre-wrap">        </span>= (/spi&T/) </font></div><div><font size="2"> fout->lat = (/spi&Y/)</font></div><div><font size="2"> fout->lon = (/spi&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>