Re: object reference for strings using gsn_scm_contour_xxx

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu, 11 Dec 2008 13:29:39 -0700

Hi Sarah,
You are correct, it would be more efficient to do it via setvalues as
example 9 illustrates.

For those who are interested, Sarah is referring to GSUN example 9:
http://www.ncl.ucar.edu/Document/Manuals/Getting_Started/Examples/gsun09n.shtml

The GSUN examples were created as an early tutorial to NCL, and thus
were written many years ago when machines were slower and had limited
memory and the ncl language itself was newer. Obviously, machines are
faster and have more memory now, and ncl coding has advanced. The
examples are still a great place for beginners to start at, as they are
described line by line. But, in this specific case, the time saved by
going with setvalues will be minimal due to machine improvements over
the years, along with the relatively small number of plots you are making.

It is of course recommended that you be efficient with your ncl coding,
deleting arrays when you are done with them, avoiding triple+ do loops
whenever possible (single and to a lesser extent double do loops are
usually OK), etc... But, usually, you don't have to be super-efficient
assuming you are on a semi-modern machine.

You likely already know about the applications example page here, but
just in case: http://www.ncl.ucar.edu/Applications/index.shtml

My apologies for the long email, but I wanted you to understand why I
recommended what I did over the GSUN setvalues way..
Adam

SR Nelson, School Geographical Sciences wrote:
> Hi Adam,
>
> My understanding, from Example 9, was that this method should be avoided
> where possible due to resources being reloaded and slowing things down.
> HOwever, I don't have too many resources set so it shouldn't an issue.
>
> I just assumed that there would be a way to change the gsnRightString
> resource in the same way the title is changed in Example 9.
>
> Sorry for the confusion and thanks for all the help, much appreciated.
>
> Regards,
> Sarah
>
>
>
> --On 11 December 2008 12:16 -0700 Adam Phillips <asphilli_at_cgd.ucar.edu>
> wrote:
>
>> Hi Sarah,
>>
>> Perhaps I am not seeing why you are doing this, but couldn't you just do
>> this:
>>
>> res1_at_gsnDraw = True
>> res1_at_gsnFrame = True
>>
>> month = (/"Jan","Feb","Mar","Apr","May","Jun",\
>> "Jul","Aug","Sep","Oct","Nov","Dec"/)
>> nmonth = 12
>> do imonth = 0,nmonth-1
>> res1_at_gsnRightString = month(imonth)
>> plot1 = gsn_csm_contour_map(xwks,tmp(imonth,:,:),res1)
>> end do
>> Adam
>>
>> SR Nelson, School Geographical Sciences wrote:
>>> Hi Adam, yes I'm trying to change it after the plot has been drawn for
>>> subsequent images. Here's the relevant bits of code:
>>>
>>>
>>> month = (/"Jan","Feb","Mar","Apr","May","Jun",\
>>> "Jul","Aug","Sep","Oct","Nov","Dec"/)
>>>
>>> imonth = 0
>>> res1_at_gsnRightString = month(imonth) ; Month
>>> plot1 = gsn_csm_contour_map(xwks,tmp(imonth,:,:),res1) ; Draw plot.
>>>
>>>
>>> nmonth = 12
>>> do imonth = 1,nmonth-1
>>>
>>> delete(res1_at_gsnRightString)
>>> res1_at_gsnRightString = month(imonth)
>>>
>>> setvalues plot1_at_data
>>> "sfDataArray" : tmp(imonth,:,:) ; Updata data to be plotted
>>> end setvalues
>>>
>>> draw(plot1) ; Draw the contour plot
>>> frame(xwks) ; Advance the frame
>>>
>>> end do
>>>
>>>
>>> Hope that makes sense.
>>> Thanks,
>>> Sarah
>>>
>>>
>>> --On 11 December 2008 11:56 -0700 Adam Phillips <asphilli_at_cgd.ucar.edu>
>>> wrote:
>>>
>>>> Hi Sarah,
>>>> Can you send the group a code snippet of your plotting section? I am
>>>> not
>>>> quite clear what you are trying to do.. Are you trying to alter the
>>>> value of gsnRightString after the plot is drawn?
>>>> Thanks,
>>>> Adam
>>>>
>>>> SR Nelson, School Geographical Sciences wrote:
>>>>> Hi all,
>>>>>
>>>>>
>>>>> I'd like to use the gsn_csm_contour_xxx routines to generate an
>>>>> animation of monthly data. I'm currently using the gsnRightString
>>>>> resource to set the first month, and want to change using 'setvalues',
>>>>> but I can't work out what object reference needed is. Please could
>>>>> someone tell me where I can find this information (I've tried the
>>>>> webpages, but not found anything).
>>>>>
>>>>>
>>>>> Thanks in advance,
>>>>> Sarah
>>>>>
>>>>>
>>>>> ----------------------
>>>>> Sarah Nelson
>>>>> School Geographical Sciences
>>>>> University of Bristol
>>>>> University Road
>>>>> Bristol BS8 1SS
>>>>> Tel: 0117 3317316
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>> --
>>>> --------------------------------------------------------------
>>>> Adam Phillips asphilli_at_ucar.edu
>>>> National Center for Atmospheric Research tel: (303) 497-1726
>>>> ESSL/CGD/CAS fax: (303) 497-1333
>>>> P.O. Box 3000
>>>> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
>>>
>>>
>>>
>>> ----------------------
>>> Sarah Nelson
>>> School Geographical Sciences
>>> University of Bristol
>>> University Road
>>> Bristol BS8 1SS
>>> Tel: 0117 3317316
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> --
>> --------------------------------------------------------------
>> Adam Phillips asphilli_at_ucar.edu
>> National Center for Atmospheric Research tel: (303) 497-1726
>> ESSL/CGD/CAS fax: (303) 497-1333
>> P.O. Box 3000
>> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
>
>
>
> ----------------------
> Sarah Nelson
> School Geographical Sciences
> University of Bristol
> University Road
> Bristol BS8 1SS
> Tel: 0117 3317316
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Dec 11 2008 - 13:29:39 MST

This archive was generated by hypermail 2.2.0 : Wed Dec 24 2008 - 09:38:50 MST