[ncl-talk] Ref line problem
Mary Haley
haley at ucar.edu
Wed Jan 10 08:10:50 MST 2018
Dear Guigma,
I started looking into this, because I'm the person who has modified the
reference line code over the last few years.
Even with the ASCII file, I was still unable to run your script. For
starters, you are missing an "end if" at the very end of the script.
When I fixed this, I was able to get three plots, but didn't get any
errors, I then realized it's because the code that does the x reference
lines is not being reached at all. This is because year=1996, and the code
only executes the reference line if year > 1996.
I tried to fudge around this by forcing the XRefLine code to be executed
anyway, but then this failed because now both SJ_10 and SJ_15 are strings,
which doesn't work for setting an x reference line.
Please, in the future, you must provide a clean script that clearly shows
the problem, because it is time-consuming for us to fix your code to try to
get it to break in the first place.
I finally got it to break by substituting dummy values for gsnXRefLine.
You are correct that the error is confusing. This was a bug in NCL V6.4.0
that has since been fixed in NCL V6.5.0, which hasn't been released yet.
There are a couple of work-arounds.
The first one is to force gsnXRefLine to have the same number of values as
you have curves, by duplicating one of your values:
res1 at gsnXRefLine=(/SJ_10,SJ_15
,SJ_15
/) ;vertical line for the onset dates
res1 at gsnXRefLineColor=(/"Black","grey"
,"grey"
/)
The second is to add the two lines yourself with gsn_add_polyline. I think
the above work-around is easier!
The reason this error message is showing up is because originally, the
reference lines were meant to be created one-per-curve. In NCL 6.4.0 the
reference line code was overhauled for other reasons, and the restriction
got added back in inadvertently.
My apologies for the inconvenience. Let ncl-talk know if the work-around
doesn't fix your issue.
--Mary
On Wed, Jan 10, 2018 at 3:13 AM, Kiswendsida Hyacinthe GUIGMA via ncl-talk <
ncl-talk at ucar.edu> wrote:
> Dear Rick,
> as I said the reference lines I would like to plot are vertical: I set
> some values of x.
> But as you noted, it is quit confusing because I used gsnXRefLine but in
> the error description NCL is using gsnYRefLine!!!
> Concerning the dimensions, it is true that the leftmost dimension length
> is 3 but this is to have 3 different lines (actually each line represents
> one single latitude). The x-axis being the time, what I would like is to
> set 2 specific time values. And this is something which was possible in my
> previous scripts by affecting these values to gsnXRefLine. When I set
> res1 at gsnXRefLine=(/SJ_10,SJ_15/) I have a 1D array of length 2 that was
> allowing me to have these 2 vertical lines.
> So what I think it is that NCL is interpreting my gsnXRefLine as gsnYRefLine.
> If it is so, could you suggest me any solution.
>
> Kindest regards
>
> PS: I am attaching the data, the txt file(which was missing) and the code
> itself. To that I add a plot that I did by the past(and which was working
> perfectly) to explain you what is the expected result.
>
> -----------------------------
> GUIGMA
>
>
> On Tuesday, 9 January 2018, 14:58, Rick Brownrigg <brownrig at ucar.edu>
> wrote:
>
>
> Hi,
>
> I was unable to run your script because it depends upon an ascii file that
> was not included. I'm also a bit confused about whether its gsnYRefLine
> or gsnXRefLine at issue, as only the later is referenced in your script.
> Assuming its the later, it is not actually a scalar, but a 1D array of
> length 2. It needs to be of the same size as the left-most dimensions of
> your data arrays: x_regrid_SJ_xy&time, x_regrid_SJ_xy.
>
> Given these lines below, I would surmise the data's leftmost dimension is
> of length 3 -- try using printVarSummary on those variables to verify:
>
> ; xy plot
> x_regrid_SJ_xy=x_regrid_SJ({5:15:5},:)
>
> res1 = True ; plot mods desired
> res1 at tiMainString = "lat-plot "+tostring(year)
> res1 at xyLineThicknesses = (/1.0,1.0,1.0/)
> res1 at xyLineColors = (/"blue","green","red"/) ; change line
> color
>
> Hope that helps...
> Rick
>
> On Tue, Jan 9, 2018 at 4:16 AM, Kiswendsida Hyacinthe GUIGMA via ncl-talk
> <ncl-talk at ucar.edu> wrote:
>
> Hello dear NCL users,
> I am running a NCL script and I am facing a error that I don't understand
> at all. Actually the script was working perfectly and then it stopped for a
> reason I ignore.
> Actually I am doing a simple xy-plot (with the gsn_csm_xy) and I want to
> add two reference lines (vertically). But I got the following error:
> " ref_line_interp: error: gsnYRefLine must be a scalar or an array of
> length ncurves". However when I print res at gsnXRefLine it gives me this:
> (0) 42179
> (1) 42197
> which proves that they are scalars.
> Can anyone please help me?
> Please have a look at my code.
>
> I'd just like to mention that I have upgraded my NCL from version 6.0.0
> to 6.4.0. Could that be the problem?
>
> Thank you in advance.
>
> -----------------------------
> GUIGMA
>
> ______________________________ _________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/ mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
>
>
>
> _______________________________________________
> 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/20180110/eff16a9c/attachment.html>
More information about the ncl-talk
mailing list