Re: Plot producing same contour rather than looping to produce different contour for each step

From: Cannavina, Dominique <d.cannavina11_at_nyahnyahspammersnyahnyah>
Date: Fri Jul 06 2012 - 04:12:02 MDT

Thanks Rick, I think it was me being a bit vague to be honest. I am a little slow as I have tried the iplot and changed script to the following, (and then a few other combinations) but I get the same error reading the variable sum where it sayes subscript #0 is out of range

iplot = 0

istart = nr + 1

iend = istart + 7

do inr = istart, iend

res1@tiMainString = ("DEMETER_ENSEMBLES -run length =" + (nr+1)+"days"); add a title

res1@tiMainFontHeightF = .018 ; font height

plot(iplot) = gsn_csm_contour_map(wks,spell_tot(0,{spell(inr)},:,:),res1)

iplot =iplot + 1

end do

So can I ask another NCL-TALK question?

I thought I may have been trying to plot the wrong thing and so started the plot function again.

I would like to produce a plot of the variable 'spell_tot' and the varible spell_tot has the following dimensions the first 2 relates to reading two files.

Variable: spell_tot

Type: float

Total Size: 12960 bytes

3240 values

Number of Dimensions: 4

Dimensions and sizes: [2] x [spell | 3] x [latitude | 18] x [longitude | 30]

Coordinates:

spell: [1..10]

latitude: [75..32.5]

longitude: [-27.5..45]

Number Of Attributes: 2

spell : 1

_FillValue : 9.96921e+36

now the variable spell is manually inputted (in the script) and for this run I have used;

spell = (/1, 1, 10/) ; manually specify

and spell and spell_tot are related by;

do nr=0,nspell-1

spell_tot(0,nr,:,:) = dim_sum_n(cold_uk1(0,{spell(nr)},:,:,:),0)

end do

where the r is the number of days in the 'run' of consecutive cold days

So I think I may have been fixated on the spell variable rather then the nr part, I have changed the plot part of the script to the following

plot = new(8, graphic)

do nr =0, 7

res1@tiMainString<mailto:res1@tiMainString> = ("DEMETER_ENSEMBLES -run length =" + (nr+1)+"days"); add a title

res1@tiMainFontHeightF = .018 ; font height

plot(nr) = gsn_csm_contour_map(wks,spell_tot(0,nr,:,:),res1) (this is line 222 in script)

end do

but although it does seem to be doing 'some looping' now;

1. The output gives run lengths 1..3 only not the expected 1...8

2. The output for run length 1 and 2 are the same and 3 is blank (which from other data I have looked out is unlikely)

3. The output from the run gives the following error;

fatal:Subscript out of range, error in subscript #1

fatal:An error occurred reading spell_tot

fatal:["Execute.c":7556]:Execute: Error occurred at or near line 222 in file /work/dc2011/WRF/ECMWF_DEMETER/demeter_v1.ncl

Any advice would be greatly appreciated. I have added attachments of the whole script and the output file.

Kind regards

Dominique

________________________________
From: Rick Brownrigg [brownrig@ucar.edu]
Sent: 05 July 2012 20:52
To: Cannavina, Dominique
Cc: ncl-talk@ucar.edu
Subject: Re: Plot producing same contour rather than looping to produce different contour for each step

Dominique

Its because "i" is likely uninitialized (sorry if I mislead you). Is that what you had intended the variable "iplot" to do -- be in index into the plot() array? If so, then of course want:

iplot = 0
do …..
  …
  plot(iplot) = …
  iplot = iplot+1
  …
end do

Also, inside the loop do spell(nr), or spell(inr)? If the former, I would think all 8 plots would be the same.

Hope that helps!
Rick

On Jul 5, 2012, at 12:48 PM, Cannavina, Dominique wrote:

Thanks Rick, I didn't actually mean to have an inner and outer loop-and your explanation explains the messages and outputs I had when I was playing about with the two loops. I have tried the plot(i) and the inr but I still only get one plots but it has cleared up in my mind what I am trying to now, I have readjusted the end of the script to the following;

So can I ask anothe ncl-talk question?

My aim being to produce a plot to output a contour plot of each duration length (spell_tot) i.e 1 day, 2 days ...30 days which relates to consecutive days of cold spells. So I need 1 loop to give me a plot for each value of 'nr' that relates to each spell length.

I have taken the 'outer loop' away and tidied up the inner part.

plot = new(8, graphic)
istart = nr + 1
iend = istart +7
iplot = 0
do inr = istart,iend

 

res1@tiMainString = ("DEMETER_ENSEMBLES -run length =" + (nr+1)+"days"); add a title
res1@tiMainFontHeightF = .018 ; font height
plot(i) = gsn_csm_contour_map(wks,spell_tot(0,{spell(nr)},:,:),res1)
end do

But get the following error message related to the plot(i) line.

fatal:Subscript out of range, error in subscript #0
fatal:An error occurred reading spell

Any advice would be greatly appreciated

Kind regards

Dominique

________________________________
From: Rick Brownrigg [brownrig@ucar.edu<mailto:brownrig@ucar.edu>]
Sent: 05 July 2012 18:27
To: Cannavina, Dominique
Cc: ncl-talk@ucar.edu<mailto:ncl-talk@ucar.edu>
Subject: Re: Plot producing same contour rather than looping to produce different contour for each step

Hi Dominique,

I'm not sure what you are trying to do here. It looks like there's an inner loop that iterates 8 times: on the line

plot = gsn_csm_contour_map(wks,spell_tot(0,{spell(nr)},:,:),res1)

should that perhaps be:

plot(i) = gsn_csm_contour_map(wks,spell_tot(0,{spell(nr)},:,:),res1)

And the index "inr" vs. "nr"?

If this is what you are trying to do, I suspect you'll also have a problem with the size of the plot array, as the inner loop of 8 iterations is encompassed by the outer loop of indeterminable iterations (i.e, the "do nr =0,(spell(0)-1), 5")

Hope that helps…

Rick

On Jul 5, 2012, at 11:16 AM, Cannavina, Dominique wrote:

Hi NCL-Talk

First of thank to for all the help so far with my script particularly Dennis and Adam.

I would like to ask another NCL-Talk question please plotting the output for the number of consecutive days below the critical temp zero degC.

The following loop, gives 8 plots but of the same contour and the res1@tiMainString<mailto:res1@tiMainString>=.... shows that that I am outputting the same data rather then going to the next value of 'spell_tot'

I have also attached the whole script (this also contains some of my attempts) and a file with the main variables.

Any advice would be greatly appreciated.

Kind regards

Dominique

plot = new(8, graphic)
do nr =0,(spell(0)-1), 5
istart = nr + 1
iend = istart +7
iplot = 0
do inr = istart,iend

 

res1@tiMainString = ("DEMETER_ENSEMBLES -run length =" + (nr+1)+"days"); add a title
res1@tiMainFontHeightF = .018 ; font height

plot = gsn_csm_contour_map(wks,spell_tot(0,{spell(nr)},:,:),res1)
end do
end do
<demeter_v1_plots.ncl><Variables.o1827871>_______________________________________________
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

Received on Fri Jul 6 04:12:28 2012

This archive was generated by hypermail 2.1.8 : Mon Jul 09 2012 - 10:45:32 MDT