[ncl-talk] plotting monthly climatology form hourly data

Dennis Shea shea at ucar.edu
Thu Feb 20 17:21:14 MST 2020


The error message is tellng you the issue. It says that variable *plot1 is
undefined.*
*plot1 *and *plot2 *are arrays and must be explicitly declared as such
before use.

Add the following::

* plot1 = new( nmos, "graphic")*
* plot2= new( nmos, "graphic")*

  do nmo=0,nmos-1                               ; loop over the months
     res at gsnCenterString   = months(nmo)
     plot1(nmo) = gsn_csm_contour_map(wks,xClm(nmo,:,:),res)  ; create plot
     plot2(nmo) = gsn_csm_vector(wks,uClm(nmo,:,:),vClm(nmo,:,:),resv)
     overlay(plot1(nmo),plot2(nmo))
  end do

==================

Also, you should be aware of the
*gsn_csm_vector_scalar_map function*
<http://ww.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_csm_vector_scalar_map.shtml>


On Thu, Feb 20, 2020 at 5:17 AM Setareh Rahimi <setareh.rahimi at gmail.com>
wrote:

> Dear all,
> I would like to plot a variable (dust) from model output [like the
> previous discussion] and also overlay wind vectors on the plot. I did some
> changes in the script but got some errors. Please have a look at the
> attached script and image showing the errors. I do not know why (plot1)
> is undefined! May I ask you please to guide me on how to address this issue?
> Many thanks in advance,
> Best wishes,
>
> On Fri, Nov 8, 2019 at 4:35 PM Setareh Rahimi <setareh.rahimi at gmail.com>
> wrote:
>
>> Dear Dennis,
>> Thank you so much for your explanations and guidance. However, I noticed
>> that the results for every year are similar to each other. Please have look
>> at the attached files. This is not reasonable.  I see no problems in the
>> script, so why this happened?
>> Best wishes,
>>
>> On Fri, Nov 8, 2019 at 4:36 AM Dennis Shea <shea at ucar.edu> wrote:
>>
>>> The issue is the variable "time". This a subtle issue.
>>>
>>>   f        = *addfile*("khuzetan_DUST04.2000010100.nc", "r")
>>>   time  = f->time
>>>   timeb = f->time_bnds
>>>
>>>   ymdh_tag = *cd_calendar*
>>> <http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml>(time
>>>      ,-3)
>>>   ymdh_Strt= *cd_calendar*
>>> <http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml>(timeb(:,0),-3)
>>> ; beginning time 'bound'
>>>   ymdh_Last= *cd_calendar*
>>> <http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml>(timeb(:,1),-3)
>>> ; ending time 'bound'
>>>
>>>   print(timeb(:,0)+"  "+timeb(:,1)+"  "+time+"  " \
>>>        +ymdh_Strt +"  "+ymdh_Last +"  "+ymdh_tag)
>>> =============
>>> One month of time values. Here 124 (31*4) January hours.
>>>
>>> (0)     timeb_0  timeb_1   time       ymdh_Strt    ymdh_Last
>>> ymdh_tag
>>>           439032  439038  439038  2000*010100*  2000*010106*  2000
>>> *010106*
>>> *                :            :             :
>>> :                     :                    :*
>>> (123) 439770  439776  439776  2000*013118*  2000*020100*  2000
>>> *020100*
>>> ===============
>>>
>>> *The last tag value [timeb(:,1)] for the month of JANUARY is FEBRUARY
>>> !!!  *
>>>
>>> *My personal view is that this is not the appropriate time tag. *
>>>
>>> *Rather, the timeb(:,0)]  should be used. *
>>> ================
>>>
>>> In a nutshell, the work-around is to reassign the time coordinate
>>> associated with each variable.
>>>
>>>   timebnd = a[:]->time_bnds
>>>   time0   = timebnd(:,0)                        ; extract the start bound
>>>   [SNIP]
>>>   x  = a[:]->emflx                     ; read emission flux from all
>>> files
>>>   x&time = time0                     ; reassign original 'tag' time
>>> [SNIP]
>>>   u = b[:]->uas(:,0,:,:)              ; read U from all files
>>>   u&time = time0                     ; reassign original 'tag' time
>>>
>>>   v = b[:]->vas(:,0,:,:)              ; read V from all files
>>>   v&time = time0                     ; reassign original 'tag' time
>>>
>>> =========
>>> Comments:
>>> [0] You MUST examine the time variable more carefully.
>>>       Using yyyymmdd start/stop dates is not appropriate for yyyymmddhh.
>>> [1] You do *not *have to compute the daily mean values
>>> [2] *calculate_monthly_values*
>>> <http://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_monthly_values.shtml>
>>> will accept 6-hrly data
>>> [3] *http://www.ncl.ucar.edu/Applications/rcm.shtml*
>>> <http://www.ncl.ucar.edu/Applications/rcm.shtml>
>>> Examples 5,6,7: illustrate how to plot variables for the Regional
>>> Climate Model (RCM).
>>> =========
>>> See Attached
>>>
>>>
>>> On Thu, Nov 7, 2019 at 6:10 AM Setareh Rahimi via ncl-talk <
>>> ncl-talk at ucar.edu> wrote:
>>>
>>>> Dear all,
>>>>
>>>> I need to plot the monthly average from a model output, which gives me
>>>> 4times data per day( at 00, 06,12,18). So I first need to convert hourly
>>>> data tp daily data and then convert to monthly. And finally calculates the
>>>> climatology average of those monthly data from 2000-2014.
>>>> However, once I ran my script I faced some error:
>>>> 1. I did not have data for 2015, but when using print (yyyymmdd)   year
>>>> 2015 printed. ( please have a look at the attachment number 1)
>>>> 2. After reading variable x this warning comes up: Aggregated
>>>> dimension coordinate values are non-monotonic; check aggregated file
>>>> ordering (warning attached)
>>>> 3. Once using clmMonTLL function ( available on :
>>>> https://www.ncl.ucar.edu/Applications/Scripts/climo_3.ncl), NCL tells
>>>> that :  clmMonTLL: dimension must be a multiple of 12 . I just wonder
>>>> why this happened. I used 15 years with 12 months for each year!! (
>>>> attached)
>>>> I attached the script and data for the year 2000. Could you please
>>>> kindly guide me what are my mistakes?
>>>> Best wishes,
>>>>  str.zip
>>>> <https://drive.google.com/file/d/12-n6pQ4JF6nwIRBVW4iaTKaznfP1FGet/view?usp=drive_web>
>>>>
>>>> --
>>>> S.Rahimi
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>> --
>> S.Rahimi
>>
>>
>
> --
> S.Rahimi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200220/2534ec1b/attachment.html>


More information about the ncl-talk mailing list