[ncl-talk] climo_3.ncl + loop + conventional subscripts

zoe jacobs zoejacobs1990 at gmail.com
Sat Oct 26 05:41:06 MDT 2019


Many thanks for your help.  As you know the nc file I am using shows
temperature in kelvin, and  I  converted Kelvin to degree Celsius but on
the plot, K is being shown. I want it to be degree celsius. Please, how can
I do so?
best wishes,

On Fri, Oct 25, 2019 at 11:07 PM Dennis Shea <shea at ucar.edu> wrote:

> I forgot to mention that plots can be done in 'portrait' [default] or
> 'landscape' mode.
>
> You should experiment to see which is appropriate for your needs.
>
> resP at gsnPaperOrientation = "landscape"        ; "portrait" is default
>
>   do nmo=0,11                                   ; loop over the months
>      res at gsnLeftString     = months(nmo)
>      plot(nmo) = gsn_csm_contour_map(wks,tmpClm(nmo,:,:), res)  ; create
> plot
>   end do
>
>   if (resP at gsnPaperOrientation .eq."landscape") then
>       gsn_panel(wks,plot,(/3,4/),resP)                                  ;
> 3 rows x 4 columns
>   else
>       gsn_panel(wks,plot,(/4,3/),resP)            ; portrait         ; 4
> rows x 3 columns
>   end if
>
> On Fri, Oct 25, 2019 at 12:15 PM Dennis Shea <shea at ucar.edu> wrote:
>
>> Hello,
>>
>> We do not usually do this but this is offline from ncl-talk.
>>
>> [1]
>> Conventional subscripts start at 1 for Fortran and Matlab.  Hence, for 12
>> months [nmos=12]
>>      Fortran: do nmo=1,nmos
>>      Matlab: for 1:nmos   or 1:1:nmos  [I am not a Matlab user so this is
>> a guess.]
>> NCL 'conventional' subscripts start at 0 [like C/C++/IDL/Python]
>>      NCL: do nmo=0,ntim-1
>>
>> [2] Dave illustrated 'coordinate subscripting' which uses the *{*...*}*
>> syntax.
>>
>> The script I am attaching uses conventional subscripting. Just like
>> Matlab/Fortran except it uses a range fro 0 to 11 [12 elements].
>>
>> [3] Please carefully read the documentation for *clmMonTLL*
>> <http://www.ncl.ucar.edu/Document/Functions/Contributed/clmMonTLL.shtml>,
>> *cd_calendar*
>> <http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml>,*
>> ind* <http://www.ncl.ucar.edu/Document/Functions/Built-in/ind.shtml>
>>
>> [4] Look at the output from '*printVarSummary*
>> <http://www.ncl.ucar.edu/Document/Functions/Built-in/printVarSummary.shtml>'.
>> USE *printVarSummary *frequently.
>>      Note the dimensions and added attributes:
>>      time_op_ncl : Climatology: 29 years
>>      info : function clmMonTLL: contributed.ncl
>>
>> [5] NCL offer a large number of color tables [palettes]:
>>
>> *http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml*
>> <http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml>
>>      Using a color map that emphasizes features can be very useful.
>>
>> [6] You must invest the time to learn any new language.
>> Karin Meier-Fliesher and Michael Bottinger [DKRZ] wrote a wonderful
>> tutorial.
>>
>> *http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/*
>> <http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/>
>>
>> I suggest you read it.
>>
>> Good luck
>> ==============
>> *%>* ncl  zoe_jacobs.hgcn_cams.ncl
>>
>> will produce a png file.
>>
>>
>>
>> On Fri, Oct 25, 2019 at 11:16 AM Dave Allured - NOAA Affiliate via
>> ncl-talk <ncl-talk at ucar.edu> wrote:
>>
>>> 1.  In your example, please notice that the month loop has a stride of
>>> 3.  Therefore it is making plots for only four months:  January, April,
>>> July, and October.
>>>
>>> If you want all 12 months, remove the stride.  Then make sure the array
>>> "plot" is dimensioned 12.  I think you can interchangeably use either a 1-D
>>> or 2-D plot array (i.e. 3*4), your choice.
>>>
>>> The secondary index "i" is used to write the four plots into positions
>>> 0, 1, 2, 3 in the "plot" graphics array.  If you are making 12 plots, you
>>> do not really need to use a secondary index.
>>>
>>> Panel plotting uses a graphics array containing multiple plots.  Please
>>> study basic examples and documentation for making panel plots.
>>>
>>> 2.  That data file has full coordinates.  Therefore you can use either
>>> conventional or coordinate subscripting, or mixed, your choice.
>>>
>>> I suggest using one of the date functions with coordinate subscripting,
>>> to index the time subset that you want.  Something like this:
>>>
>>>     time_units = f->air&time at units
>>>     time1 = cd_inv_calendar (year1, 1, 1, 0, 0, 0, time_units, 0)
>>>     time2 = cd_inv_calendar (year2, 12, 31, 23, 0, 0, time_units, 0)
>>>     air_subset = f->air({time1:time2},:,:)
>>>
>>> Use printVarSummary to ensure that the subset has the dimension sizes
>>> that you expect.  Then you can proceed to compute the climatology.
>>>
>>>
>>> On Fri, Oct 25, 2019 at 10:14 AM zoe jacobs via ncl-talk <
>>> ncl-talk at ucar.edu> wrote:
>>>
>>>> Hi all,
>>>> regarding climo_3.ncl (
>>>> https://www.ncl.ucar.edu/Applications/Scripts/climo_3.ncl) ,
>>>> I have 2 questions:
>>>> 1. I need to plot all months on one panel (say 3*4), and cannot
>>>> understand the logic behind the below loop, which used in the climo_3.ncl
>>>> script :
>>>>
>>>> i = -1                                        ; Climatologies
>>>>   do nmo=0,11,3                                 ; loop over the months
>>>>      i = i+1
>>>>      res at gsnCenterString   = months(nmo)+":"+time(0)/100 +"-"+ time(ntim-1)/100
>>>>      plot(i) = gsn_csm_contour_map(wks,prcClm(nmo,:,:), res)  ; create plot
>>>>   end do
>>>>
>>>> How  does it  work??/
>>>>
>>>> 2. I would like to show climotology temperature from 1987- 2015. Data which I am using is air.mon.mean.nc  ( https://www.esrl.noaa.gov/psd/data/gridded/data.ghcncams.html)  and it is using conventional subscripts. I am not familiar with conventional subscripts. So how can I convert coordinate subscripting to conventional subscripts?!!
>>>>
>>>> Please kindly advice me .
>>>>
>>>> Many thanks in advance,
>>>>
>>>> Best regards,
>>>>
>>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191026/322b9b88/attachment.html>


More information about the ncl-talk mailing list