<div dir="ltr"><div><div><div><div><div>Possibly .....<br><br></div>After<br> lat = f->latitude<br> lon = f->longitude<br></div>Add<br></div> lat!0 = "lat"<br></div> lon!0 = "lon"<br><br></div>Good Luck<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 10, 2017 at 7:39 PM, Elaine Silva <span dir="ltr"><<a href="mailto:laine.usp@gmail.com" target="_blank">laine.usp@gmail.com</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><span id="m_6233283058916815993gmail-m_5600268266641284251gmail-result_box" class="m_6233283058916815993gmail-m_5600268266641284251gmail-" lang="en"><span class="m_6233283058916815993gmail-m_5600268266641284251gmail-">Dear ncl users</span><br><br><span class="m_6233283058916815993gmail-m_5600268266641284251gmail-">I'm
trying to use the mjoclivar_2.ncl script with daily total precipitation data
from Era Interim, </span></span><span id="m_6233283058916815993gmail-m_5600268266641284251gmail-result_box" class="m_6233283058916815993gmail-m_5600268266641284251gmail-" lang="en"><span class="m_6233283058916815993gmail-m_5600268266641284251gmail-"><span class="m_6233283058916815993gmail-m_5600268266641284251gmail-" id="m_6233283058916815993gmail-m_5600268266641284251gmail-result_box" lang="en"><span class="m_6233283058916815993gmail-m_5600268266641284251gmail-">however an error is occurring</span></span></span><br><br><span>Could someone help me?</span> <span>Thank you very much in advance!</span></span><br><br>Variable: xAnom_sm<br>Type: float<br>Total Size: 951857280 bytes<br> 237964320 values<br>Number of Dimensions: 3<br>Dimensions and sizes: [time | 1826] x [latitude | 181] x [longitude | 720]<br>Coordinates: <br> time: [920436..964236]<br> latitude: [-45..45]<br> longitude: [-180..179.5]<br>Number Of Attributes: 3<br> _FillValue : -32767<br> long_name : Anomalies from Smooth Daily Climatology<br> units : m<br>(0) <br>(0) Anomalies from Smooth Daily Climatology: min=-0.0362034 max=0.329606<br>FileAddVar, in file: NclFile.c, line: 412<br>fatal:FileAddVar: Dimension (latitude) is not currently defined, can't add variable<br>fatal:["Execute.c":8578]:Execu<wbr>te: Error occurred at or near line 130 in file 01mjoelaine_2_pr.ncl<br><br></div>And the script<br><br>; ncl 01mjoelaine_2_pr.ncl<br><br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_code.ncl" <br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_csm.ncl" <br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/contributed.<wbr>ncl" <br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/diagnostics_<wbr>cam.ncl"<br><br>begin<br>;-----------------------------<wbr>------------------------------<wbr>--<br>; User specifications<br>;-----------------------------<wbr>------------------------------<wbr>--<br> NC = True <wbr> ; Deseja criar o arquivo netCDF? True = sim e False = não <br> PLOT = False <wbr> ; sample plots? Não cria figura<br><br> ymdStrt = 20050101 <wbr> ; start yyyymmdd<br> ymdLast = 20091231 <wbr> ; last <br> yrStrt = ymdStrt/10000<br> yrLast = ymdLast/10000<br> <br> nhar = 4 <wbr> ; number of fourier comp <br><br> var = "tp" <wbr> ; name of file. Nome da variável do seu arquivo de entrada<br> vName = "TP" <wbr> ; name for plots. Nome da variável do arquivo netCDF que será gerado<br><br> ;diri = "/project/cas/shea/CDC/" <wbr> ; input directory <br> diri = "../../dados/diario/" <wbr> ; input directory. Diretório de entrada dos dados<br> fili = var+".<a href="http://era.interim.2005.2009.invert.nc" target="_blank">era.interim.2005.2009.<wbr>invert.nc</a>" ; input file. Nome do arquivo a ser lido. <br><br> if (NC) then<br> diro= "./" <wbr> ; output dir. Onde será gerado o arquivo netCDF. "./" quer dizer no mesmo diretório do script<br> ;filo= var+".<a href="http://day.anomalies.nc" target="_blank">day.anomalies.nc</a>" <wbr> ; output file <br> filo= var+".day.anomalies."+yrStrt+"<wbr>-"+yrLast+".nc" ; output file. Nome do arquivo netCDF a ser criado.<br> end if<br><br> if (PLOT) then<br> wksType = "pdf" ; extensão da figura. eps, pdf, ps, png<br> wksName = "mjoclivar" ; "mjo."+yrStrt+"_"+yrLast. Nome da figura a ser gerada.<br> end if<br><br>;*****************************<wbr>******************************<br>; Read user specified time and create required yyyyddd <br>;*****************************<wbr>******************************<br> f = addfile (diri+fili , "r") <br><br> time = f->time <wbr> ; all times on file<br> ymd = cd_calendar(time, -2) ; yyyymmdd<br> iStrt = ind(ymd.eq.ymdStrt) <wbr> ; index start<br> iLast = ind(ymd.eq.ymdLast) <wbr> ; index last <br> delete(time)<br> delete(ymd)<br><br>;*****************************<wbr>******************************<br>; Read user specified time and create required yyyyddd <br>;*****************************<wbr>******************************<br> time = f->time(iStrt:iLast) <wbr> ; time:units = "hours since"<br> TIME = cd_calendar(time, 0) ; type float <br> year = floattointeger( TIME(:,0) )<br> month = floattointeger( TIME(:,1) )<br> day = floattointeger( TIME(:,2) ) <br> ddd = day_of_year(year, month, day) <br> yyyyddd = year*1000 + ddd ; needed for input<br><br>;*****************************<wbr>******************************<br>; Read data: short2flt <wbr> <br>;*****************************<wbr>****************************** <br> x = short2flt( f->$var$(iStrt:iLast,:,:) ) ; convert to float <br> printVarSummary( x ) <br><br> <br>;*****************************<wbr>******************************<br>; Compute daily climatology: raw and then 'smoothed' <br>;*****************************<wbr>******************************<br> xClmDay = clmDayTLL(x, yyyyddd) ; daily climatology at each grid point<br> printVarSummary(xClmDay) <wbr> <br><br>;*****************************<wbr>******************************<br>; Compute smoothed daily climatology using 'nhar' harmonics<br>;*****************************<wbr>******************************<br> xClmDay_sm = smthClmDayTLL(xClmDay, nhar)<br> printVarSummary(xClmDay_sm)<br><br>;*****************************<wbr>******************************<br>; Compute daily anomalies using raw and smoothed climatologies<br>;*****************************<wbr>******************************<br> xAnom = calcDayAnomTLL (x, yyyyddd, xClmDay) <br> printVarSummary(xAnom)<br> printMinMax(xAnom, True)<br><br> xAnom_sm = calcDayAnomTLL (x, yyyyddd, xClmDay_sm) <br> xAnom_sm@long_name = "Anomalies from Smooth Daily Climatology"<br> printVarSummary(xAnom_sm)<br> printMinMax(xAnom_sm, True)<br><br> delete( x ) ; no longer needed<br><br><br>;*****************************<wbr>******************************<br>; Create netCDF: convenience use 'simple' method<br>;*****************************<wbr>******************************<br><br> dimx = dimsizes(xAnom)<br> ntim = dimx(0)<br> nlat = dimx(1)<br> mlon = dimx(2)<br><br> if (NC) then<br><br> lat = f->latitude<br> lon = f->longitude<br><br> system("/bin/rm -f "+diro+filo) ; rm any pre-exist file, if any<br> fnc = addfile (diro+filo, "c")<br><br> filAtt = 0<br> filAtt@title = vName+": Daily Anomalies: "+yrStrt+"-"+yrLast <br> filAtt@source_file = fili<br> filAtt@creation_date = systemfunc("date")<br> fileattdef( fnc, filAtt ) ; copy file attributes <br><br> setfileoption(fnc,"DefineMode"<wbr>,True)<br> <br> varNC = vName+"_anom"<br> varNC_sm = vName+"_anom_sm"<br><br> dimNames = (/"time", "lat", "lon"/) <br> dimSizes = (/ -1 , nlat, mlon/) <br> dimUnlim = (/ True , False, False/) <br> filedimdef(fnc,dimNames,<wbr>dimSizes,dimUnlim)<br><br> filevardef(fnc, "time" ,typeof(time),getvardims(time)<wbr>) <br> filevardef(fnc, "lat" ,typeof(lat) ,getvardims(lat)) <br> filevardef(fnc, "lon" ,typeof(lon) ,getvardims(lon))<br> filevardef(fnc, varNC ,typeof(xAnom) ,getvardims(xAnom)) <br> filevardef(fnc, varNC_sm,typeof(xAnom) ,getvardims(xAnom)) <br><br> filevarattdef(fnc,"time" ,time) ; copy time attributes<br> filevarattdef(fnc,"lat" ,lat) ; copy lat attributes<br> filevarattdef(fnc,"lon" ,lon) ; copy lon attributes<br> filevarattdef(fnc,varNC ,xAnom) <br> filevarattdef(fnc,varNC_sm,<wbr>xAnom_sm) <br><br> fnc->time = (/time/) <br> fnc->lat = (/lat/)<br> fnc->lon = (/lon/)<br> fnc->$varNC$ = (/xAnom /)<br> fnc->$varNC_sm$ = (/xAnom_sm/)<br> end if<br><br>;*****************************<wbr>*******************<br>; plotting parameters<br>;*****************************<wbr>*******************<br> if (PLOT) then<br> LAT = (/ 60, 45, 5, -5, -45, 60 /)<br> LON = (/270, 30, 90, 90, 180, 0 /)<br> nPts = dimsizes( LAT )<br><br> plot = new ( nPts, graphic)<br> data = new ( (/2,366/), typeof(xClmDay), getFillValue(xClmDay))<br><br> wks = gsn_open_wks (wksType,wksName) <br><br> res = True ; plot mods desired<br> res@gsnDraw = False<br> res@gsnFrame = False<br> res@trXMinF = 1<br> res@trXMaxF = 366<br> ;res@tiMainString = ""<br> <br> res@xyLineThicknesses = (/1.0, 2.0/) ; make 2nd lines thicker<br> res@xyLineColors = (/"blue","red"/) ; change line color<br> res@xyMonoDashPattern = True ; all solid<br><br> do np=0,nPts-1 <br> data(0,:) = xClmDay(:,{LAT(np)},{LON(np)})<br> data(1,:) = xClmDay_sm(:,{LAT(np)},{LON(<wbr>np)})<br> res@gsnCenterString = "lat="+LAT(np)+" lon="+LON(np)<br> plot(np) = gsn_csm_y (wks,data,res) ; create plot<br> end do<br> <br> resP = True ; modify the panel plot<br> resP@txString = vName+": Raw/Smooth Daily Climatology: "+yrStrt+"-"+yrLast<br> resP@gsnMaximize = True<br> resP@gsnPaperOrientation = "portrait"<br> gsn_panel(wks,plot,(/(nPts/2),<wbr>2/),resP) ; now draw as one plot<br><br> ;==========<br> ; Plot anomalies for an arbitrarily selected near equatorial location<br> ; Time: Oct 1, 1996 to April 1,1997 [arbitrary selection]<br> ;==========<br> LATX = 0<br> LONX = 90<br><br> yyyymmdd = cd_calendar(time, -2)<br> ;;yrfrac = yyyymmdd_to_yyyyfrac (yyyymmdd, 0)<br> ;;delete(yrfrac@long_name)<br><br> xAnom@long_name = "Anomalies from Raw" ; short labels for plot<br> xAnom_sm@long_name = "Anomalies from Smooth"<br><br> ntBegin = ind(yyyymmdd.eq.20051001)<br> ntEnd = ind(yyyymmdd.eq.20060401)<br> <br> monthLabels = (/1,4,7,10/)<br> monNam = (/"Jan","Feb","Mar","Apr","<wbr>May","Jun" \<br> ,"Jul","Aug","Sep","Oct","Nov"<wbr>,"Dec" /)<br> xVal = new(ntim, typeof(xAnom&time) , "No_FillValue") ; bigger than<br> xLab = new(ntim, "string", "No_FillValue") ; needed<br> xValm = new(ntim, typeof(xAnom&time) , "No_FillValue") ; bigger than<br><br> ntm = -1<br> cr = inttochar(10) <wbr> ; carriage return<br> do nt=ntBegin,ntEnd<br> if (day(nt).eq.1) then<br> ntm = ntm + 1<br> xVal(ntm) = xAnom&time(nt)<br> xLab(ntm) = monNam(month(nt)-1)<br> if (month(nt).eq.1) then<br> xLab(ntm) = xLab(ntm) + cr +sprinti("%0.4i", year(nt))<br> end if<br> end if<br> end do<br><br> rxy = True <br> rxy@gsnDraw = False<br> rxy@gsnFrame = False<br> rxy@gsnYRefLine = 0.0 ; create a reference line <br> rxy@gsnAboveYRefLineColor = "red" ; above ref line fill red<br> rxy@gsnBelowYRefLineColor = "blue" ; below ref line fill blue<br> rxy@xyLineThicknessF = 2.0 <wbr> <br> rxy@vpHeightF = 0.4 ; resize <br> rxy@vpWidthF = 0.8 <br> rxy@tmXBMode = "Explicit"<br> rxy@tmXBValues = xVal(0:ntm)<br> rxy@tmXBLabels = xLab(0:ntm)<br><br> plot(0) = gsn_csm_xy (wks,time(ntBegin:ntEnd) \<br> ,xAnom(ntBegin:ntEnd,{0},{90})<wbr>,rxy) <br> plot(1) = gsn_csm_xy (wks,time(ntBegin:ntEnd) \<br> ,xAnom_sm(ntBegin:ntEnd,{0},{<wbr>90}),rxy) <br> resP@txString = vName+": Anomalies: (0,90E)"<br> gsn_panel(wks,plot(0:1),(/2,1/<wbr>),resP) <br><br> end if<br>end<br><div><br><br></div></div>
<br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>