# Re: Literal Arrays

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Jul 14 2011 - 15:04:15 MDT

There are several differnt ways of doing this.
This morning a response was sent sent to ncl-tal that was

The response was:
===============================
A minor variation of

Example 2 at http://www.ncl.ucar.edu/Applications/xy.shtml

nv = 2 ; number of variables to be plotted
nx1 = dimsizes(X1)
nx2 = dimsizes(X2)
N = max( (/nx1,nx2/) )
x = new( (/nv,N/), typeof(X1) )
y = new( (/nv,N/), typeof(Y1) )

x(0,0:nx1-1) = X1
x(1,0:nx2-1) = X2
y(0,0:nx1-1) = Y1
y(1,0:nx2-1) = Y2

plot = gsn_csm_xy (wks,x,y,res)
===============================

So, by analogy:

nv = 4 ; number of variables to be plotted
nx1 = dimsizes(mvdc1)
nx2 = dimsizes(mvdc2)
nx3 = dimsizes(mvdc3)
nx4 = dimsizes(mvdc4)

N = max( (/nx1,nx2,nx3,nx4/) )
x = new( (/nv,N/), typeof(X1) )
y = new( (/nv,N/), typeof(Y1) )

x(0,0:nx1-1) = mvdc1
x(1,0:nx2-1) = mvdc2
x(2,0:nx1-1) = mvdc3
x(3,0:nx2-1) = mvdc4

y(0,0:nx1-1) = qc1
y(1,0:nx2-1) = qc2
y(2,0:nx1-1) = qc3
y(3,0:nx2-1) = qc4

plot = gsn_csm_xy (wks,x,y,res)

On 07/14/2011 01:06 PM, Nicolas Ledru wrote:
> Hello,
> I'm using the 6.0.0 version of NCL on my Mac. I was trying to plot
> different sets of data together on the same graph, but I get an error
> that says "fatal:_NclBuildArray: each element of a literal array must
> have the same dimension sizes, at least one item doesn't"
> The code looks like this:
>> x= (/mvdc1,mvdc2,mvdc3,mvdc4/)
>> y= (/qc1,qc2,qc3,qc4/)
>> plot= gsn_csm_xy (wks,x,y,res)
> Each variable was defined before, and each pair of mvdc and qc have the
> same amount of elements (mvdc1 and qc1, etc.) Is there a way to plot all
> four pairs together, even though they won't all have the same amount of
> elements?
>
> Thanks,
> Nick
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

```--
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
```
Received on Thu Jul 14 15:04:20 2011

This archive was generated by hypermail 2.1.8 : Mon Jul 18 2011 - 15:57:58 MDT