[ncl-talk] xy plot error
Adam Phillips
asphilli at ucar.edu
Thu Jan 28 17:03:40 MST 2016
Hi Steven,
That error message generally occurs when one data type is getting passed to
an array of a different data type. Some exceptions are allowed, like when
you pass a float or integer into a double array as behind the scenes NCL
promotes the input float/integer to a double. In this case, you are passing
a double array into a float array. Add the following printVarSummary
statements to your code right before line 51:
printVarSummary(data)
printVarSummary(var1_reorder)
You will see that data is a float array and var1_reorder is a double array,
and thus this line will exit out in error:
data(0,:) = var1_reorder(120,:)
The solution is to set data to a double array. (That way you can pass float
or double arrays into it.)
data = new((/2,dimsizes(var1_reorder(120,:))/),double)
Or, if you know that both of your input files are of the same type you can
use the typeof function to match the data array type to the var1_reorder
data type:
data = new((/2,dimsizes(var1_reorder(120,:))/),typeof(var1_reorder))
Hope that helps. If not, or if you have any further questions please
respond to ncl-talk.
Adam
On Thu, Jan 28, 2016 at 2:03 PM, BLIUJUS, STEVEN D CTR USAF AFMC
AFLCMC/HBAW-OL <steven.bliujus.3.ctr at us.af.mil> wrote:
> I am trying to create a line graph with two lines (one variable from each
> file). I am usng it to compare two variables. So I' am creating the array
> to
> do so, but when the array is created I get an error when trying to assign
> the value:
>
> fatal:Assignment type mismatch, right hand side can't be coerced to type of
> left hand side
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 51 in file
> Scatterplot.ncl
>
> I am not sure exactly why. The variable is an array 180x359. In this case
> I'm trying to plot the line for point 120.
>
> I have attached the script and one of the files. (This file is the file
> being used when the program fails).
>
> Steven Bliujus, Contractor
> SEMS/16WS WXE
> 557th Weather Wing
> DNS: 232-7151
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
--
Adam Phillips
Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160128/cabbfc15/attachment.html
More information about the ncl-talk
mailing list