Re: MJO Phase diagram

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Aug 17 2012 - 11:25:18 MDT

Technically, you shouldn't have to draw the plot inside the loop. You are attaching all the text strings and markers with calls to gsn_add_text and gsn_add_polymarker , so this means every time you draw "plot", you are drawing everything attached to it.

This in turn means you are drawing the same plot elements over and over, which can slow down your loop.

I may be missing some other reason about why you need to draw the plot inside the loop, but I'm trying to point out that you are going to significantly slow this code down if your loop gets big.

Please see the attached script as an example. If you run this with "draw(plot)" inside the do loop, it takes roughly 8x longer to complete.

--Mary

On Aug 16, 2012, at 11:25 PM, Abhik Santra wrote:

> Hello Mary,
>
> My problem is solved. Yes, you are right: "wks" and "plot" should be placed before the do loop and "frame(wks)" after the loop. But draw(plot) must be inside the do loop.
> Thank you very much for your support.
>
> regards,
> Abhik
>
> ----- Original Message -----
> From: "Mary Haley" <haley@ucar.edu>
> To: "Abhik Santra" <abhiksantra@tropmet.res.in>
> Cc: "ncl-talk" <ncl-talk@ucar.edu>
> Sent: Friday, August 17, 2012 1:45:31 AM
> Subject: Re: MJO Phase diagram
>
> Abhik,
>
> I do finally see where the dependency comes in on the "n" do loop. Still, however, you should not be creating "wks" or "plot" inside the do loop, because you will clobber both of these every time.
>
> My suggestion is to move at least these three lines:
>
> wks = gsn_open_wks(pltType, pltPath) ; open workstation
> gsn_define_colormap(wks,"radar_1")
>
> plot = mjo_phase_background(wks, opt) ; generic phase space backgrou
>
> to above the line:
>
> do n=0,9
>
> You will also need to move these two lines:
>
> draw(plot)
> frame(wks)
>
> to after the very last "end do" (the one for "do n").
>
> If you still continue to have problems, then you will need to provide your data and new version of the script.
>
> --Mary
>
> On Aug 16, 2012, at 1:38 PM, Abhik Santra wrote:
>
>> Hello,
>>
>> I want to draw a single plot for all the 10 years data. Mary suggested that I should not use the "do loop". However, I put the call workstation only inside the loop and the plot call outside following earlier suggestion. But it doesn't solve my problem. The pc1 and pc2 variables for each year are required to store separately. I am not an expert in NCL. So please help me to solve the problem.
>>
>> regards,
>> Abhik
>>
>>
>>
>> ----- Original Message -----
>> From: "Mary Haley" <haley@ucar.edu>
>> To: "Abhik Santra" <abhiksantra@tropmet.res.in>
>> Cc: "ncl-talk" <ncl-talk@ucar.edu>
>> Sent: Thursday, August 16, 2012 8:41:12 PM
>> Subject: Re: MJO Phase diagram
>>
>> Abhik,
>>
>> Gibies is correct that you need to move the initial plot call outside the loop, because you are clobbering it for every iteration on "n". Also, you put the call to open the workstation inside the do loop, which means that's going to get clobbered every time too.
>>
>> This code is hard to debug without being able to run it. I can't tell why you have the "do n=0,9" loop. Is there a dependency on "n" somewhere inside the loop? You have a bunch of code inside this loop that I think should be outside of it. For example, you have:
>>
>> do n=0,9
>> ymdStrt = year+"1016" ; start yyyymmdd
>> ymdLast = year+"0415" ; last
>>
>> pltDir = "./" ; plot directory
>> pltType = "eps"
>> pltName = "mjoclivar" ; yrStrt+"_"+yrLast
>>
>> pltMovie= False ; animation
>> pltTitle= "MJO Phase: 15S-15N: "
>>
>> All of these variables don't change inside the loop, so there's no reason for them to be there. Do loops can be expensive time-wise, so you want to keep them as minimal as possible.
>>
>> Do you want a separate plot for each value of "n", or are you trying to draw things on the same plot for each value of "n"?
>>
>> --Mary
>>
>> On Aug 16, 2012, at 3:57 AM, Abhik Santra wrote:
>>
>>>
>>> Hello,
>>>
>>> Earlier I have tried that also and it was giving similar result. However, I have realized that the variable "plot" must be stored inside the loop and should be drawn by overlapping. I need some help to do so.
>>> Thank you for your suggestion.
>>>
>>> Regards,
>>> Abhik
>>>
>>>
>>> ----- Original Message -----
>>> From: "gibies george" <gibies@tropmet.res.in>
>>> To: "Abhik Santra" <abhiksantra@tropmet.res.in>
>>> Cc: "ncl-talk" <ncl-talk@ucar.edu>
>>> Sent: Thursday, August 16, 2012 3:14:52 PM
>>> Subject: Re: MJO Phase diagram
>>>
>>> Abhik,
>>>
>>> You can use year loop to read data, but you have to take the plotting part outside it, because otherwise it will overwrite on the same plot.
>>>
>>> Regads
>>>
>>> Gibies George
>>>
>>>
>>> On 16 August 2012 12:45, Abhik Santra < abhiksantra@tropmet.res.in > wrote:
>>>
>>>
>>> Hi,
>>>
>>> I am trying to plot the MJO Phase Diagram for 10 years (2000-2009) in a single panel following the example mjoclivar_15.ncl. So I have introduced a do loop to read the multiple years data in the original script. However, it is reading all the years successfully but plotting only the last year. I am attaching the modified script. Please suggest me what to do?
>>>
>>> With regards,
>>> --
>>> Abhik Santra
>>> CSIR Research Fellow,
>>> Indian Institute of Tropical Meteorology,
>>> Pune - 411008.
>>> India
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>>
>>>
>>> --
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> --
> Abhik Santra
> CSIR Research Fellow,
> Forecasting Research Division,
> Indian Institute of Tropical Meteorology,
> Pune - 411008.
> India
> mobile: +919766161652
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Fri Aug 17 11:25:28 2012

This archive was generated by hypermail 2.1.8 : Thu Aug 23 2012 - 16:16:15 MDT