<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Saran,<div class=""><br class=""></div><div class="">I think the errors all occurred because of the first one. Change </div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">9 do time_step = 0,dimsizes(time)</blockquote>and </div><div class=""><blockquote type="cite" class="">10 do lon_step = 0,dimsizes(lon)</blockquote><div class=""><br class=""></div>to</div><div class=""><br class=""></div><div class="">do time_step = 0,dimsizes(time)<b class=""><u class="">-1</u></b></div><div class="">and<br class=""><div class=""><div class="">
<div dir="auto" style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;">do lon_step = 0,dimsizes(lon)<b class=""><u class="">-1</u></b></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;"><font face="Calibri" class=""><br class=""></font></div><div style="text-align: start; text-indent: 0px;"><font face="Calibri" class="">This should let you run the do-loops without crashing. </font></div><div style="text-align: start; text-indent: 0px;"><font face="Calibri" class=""><br class=""></font></div><div style="text-align: start; text-indent: 0px;"><font face="Calibri" class="">To explain the “-1”, the position of the first item in a list in NCL is <i class="">zero</i>, not one. So the position of the last item in a list is not the length of the list (“</font>dimsizes()”), but “dimsizes()-1”. Without “-1” you were trying to call on a list item that wasn’t there, which is what “subscript <i class="">out of range</i>” means.</div><div style="text-align: start; text-indent: 0px;"><font face="Calibri" class=""><br class=""></font></div><div style="text-align: start; text-indent: 0px;"><font face="Calibri" class="">Best,</font></div><div style="text-align: start; text-indent: 0px;"><font face="Calibri" class="">Toni</font></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;"><font face="Calibri" class=""><br class="Apple-interchange-newline"><br class=""></font></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;"><font face="Calibri" class=""><b class="">Toni Klemm, Ph.D.<br class=""></b>Postdoctoral Research Associate</font></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;">Department of Ecosystem Science and Management</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;">College of Agriculture and Life Sciences</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;">Texas A&M University, College Station, TX</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;"><font face="Calibri" class="">Contributor to the <a href="http://www.eccforum.org" class="">Early Career Climate Forum</a><br class=""><a href="http://www.toni-klemm.de" class="">www.toni-klemm.de</a> | <a href="http://twitter.com/toniklemm" class="">@toniklemm</a></font></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;"><font face="Calibri" class=""><br class=""></font></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-variant-caps: normal; text-align: start; text-indent: 0px;"><font face="Calibri" class=""><br class=""></font></div></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On Jan 29, 2019, at 2:09 PM, Saran Rajendran <<a href="mailto:happysaran.raj@gmail.com" class="">happysaran.raj@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi Toni<br class=""><br class="">           Thank You for that valuable information. I thoroughly read<br class="">your code and I understood my mistake. I modified my code as per your<br class="">correction, but I'm getting some errors again.<br class=""><br class="">These are the errors:<br class=""><br class="">fatal:Subscript out of range, error in subscript #2<br class=""><br class="">fatal:An error occurred reading u<br class=""><br class="">fatal:["Execute.c":8637]:Execute: Error occurred at or near line 11 in<br class="">file hov_sv2cv_2015_test.ncl<br class=""><br class=""><br class="">fatal:Dimension (1) of (vort_timeseries) is not named and therefore<br class="">doesn't have an associated coordinate variable<br class=""><br class="">fatal:["Execute.c":8637]:Execute: Error occurred at or near line 18 in<br class="">file hov_sv2cv_2015_test.ncl<br class=""><br class=""><br class=""><br class="">And the modified code is<br class=""><br class="">1 f    = addfile("curv_vort_lat_lon_925hPa_20150101_20151231.nc","r")<br class=""><br class="">2  time=f->time<br class=""><br class="">3  lon=f->longitude<br class=""><br class="">4   lat=f->latitude<br class=""><br class="">5   u  = f->cur_vort(:,:,:)<br class=""><br class="">6   printVarSummary(u)<br class=""><br class="">7   vort_hov = new((/dimsizes(time),dimsizes(lon)/),float)  ; this is<br class="">the 2-dimensional variable you use for the Hovmoeller diagram<br class=""><br class="">8  printVarSummary(vot_hov)<br class=""><br class="">9  do time_step = 0,dimsizes(time)<br class=""><br class="">10  do lon_step = 0,dimsizes(lon)<br class=""><br class="">11  vort_timeseries = avg(u(time_step,:,lon_step))   ; a loop to<br class="">average the data by latitude for each time step and longitudinal step<br class="">12    end do<br class="">13    end do<br class=""><br class="">14      res=True<br class=""><br class="">15          res@cnFillOn             = True               ; turn on color fill<br class=""><br class="">16  res@cnFillPalette        = "BlWhRe"<br class=""><br class="">17    res@gsnLeftString="cv"<br class=""><br class="">18      plot = gsn_csm_hov(wks, vort_timeseries(:,{60:120}), res )<br class=""><br class="">On Tue, Jan 29, 2019 at 7:55 PM Toni Klemm <<a href="mailto:toni-klemm@tamu.edu" class="">toni-klemm@tamu.edu</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="">Hi Saran,<br class=""><br class="">That’s for two reasons:<br class=""><br class="">(1) You are only using the first time dimension of your data, but all latitude and all longitude dimensions, so by your own setting you're plotting latitude/longitude, not time/longitude:<br class=""><br class="">u = f->cur_vort(0,:,:)<br class=""><br class=""><br class="">(2) You need to prepare the data in the correct way first, so that you can plot it. Your code below only does the plotting, but not the data manipulation so that you can actually plot what you need. Average the latitude dimension (y axis) for each longitudinal grid cell “column” and each time step, and then plot the data.<br class="">This might work (though, it might not. I didn’t test it. Please read through it and try to understand it. Don’t just plug it into your script. Also, there might be an easier way to do this):<br class=""><br class="">u = f->cur_vort(:,:,:)         ; u contains all your (3-dimensional) curvature vorticity data<br class=""><br class="">vort_timeseries = new((/dimsizes(time),dimsizes(lon)/),float)  ; this is the 2-dimensional variable you use for the Hovmoeller diagram<br class=""><br class="">do time_step = 0,dimsizes(time)<br class=""><br class="">  do lon_step = 0,dimsizes(lon)<br class=""><br class="">    vort_timeseries(time_step,lon_step) = avg(u(time_step,:,lon_step))   ; a loop to average the data by latitude for each time step and longitudinal step<br class=""><br class="">  end do  ; lon_step loop<br class=""><br class="">end do  ; time_step loop<br class=""><br class=""><br class="">vort_timeseries should be the data you need for your Hovmoeller diagram.<br class=""><br class=""><br class="">Good luck,<br class="">Toni<br class=""><br class=""><br class="">Toni Klemm, Ph.D.<br class="">Postdoctoral Research Associate<br class="">Department of Ecosystem Science and Management<br class="">College of Agriculture and Life Sciences<br class="">Texas A&M University, College Station, TX<br class="">Contributor to the Early Career Climate Forum<br class=""><a href="http://www.toni-klemm.de" class="">www.toni-klemm.de</a> | @toniklemm<br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class="">On Jan 29, 2019, at 5:16 AM, Saran Rajendran <<a href="mailto:happysaran.raj@gmail.com" class="">happysaran.raj@gmail.com</a>> wrote:<br class=""><br class="">Dear NCL users,<br class=""><br class="">             When I tried this script to plot hovmueller diagram<br class="">(time vs longitude) of curvature vorticity, the code runs. But instead<br class="">of time in y-axis, it shows latitude. I want time in the y-axis.<br class=""><br class=""><br class="">f    = addfile("curv_vort_lat_lon_925hPa_20150101_20151231.nc","r")<br class=""><br class="">u  = f->cur_vort(0,:,:)<br class=""><br class=""> wks  = gsn_open_wks("png","hovmueller_cv_2015")<br class=""><br class=""> res=True<br class=""><br class=""> res@cnFillOn             = True               ; turn on color fill<br class=""><br class="">res@cnFillPalette        = "BlWhRe"<br class=""><br class="">res@gsnLeftString="cv"<br class=""><br class="">plot = gsn_csm_hov(wks, u(:,{60:120}), res )<br class="">_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""><br class=""><br class=""></blockquote><br class=""><br class="">-- <br class="">Saran Rajendran<br class="">Junior Research Fellow<br class="">Centre for Atmospheric Science<br class="">Indian Institute of Technology Delhi<br class=""></div></div></blockquote></div><br class=""></div></div></body></html>