[ncl-talk] copy a vector (1D) to one of the dimensions of 2D array

Alessandra Giannini alesall at iri.columbia.edu
Thu Jan 31 02:04:01 MST 2019


onedtond!!!

http://www.ncl.ucar.edu/Document/Functions/Built-in/onedtond.shtml <http://www.ncl.ucar.edu/Document/Functions/Built-in/onedtond.shtml>



— 
Alessandra Giannini
IRI for Climate and Society - The Earth Institute at Columbia University
P.O. Box 1000, Palisades NY 10964-8000, U.S.A.

currently at:
LMD - École Normale Supérieure 
24, Rue Lhomond 75231 PARIS CEDEX 05, France

> On Jan 30, 2019, at 5:28 PM, Greg Thompson <gthompsn at ucar.edu> wrote:
> 
> 
> I am struggling (feeling dumb) that I cannot figure out how to write a one-line efficient solution to copy a 1D vector of latitude to all the columns of a 2D grid since the values (of latitude) are constant across my grid in the X-direction.
> 
> So what I have is this
> ny = 8
> nx = 10
> a = new( (/ny,nx/), float)
> a = 0.
> a(:, 0) = fspan(40., 42., ny)
> do n = 1, nx-1
>   a(:, n) = a(:,0)
> end do
> 
> but that DO-n loop is slow as nx grows large and I thought there was an elegant solution in NCL to treat this array manipulation.
> 
> Any thoughts?
> Thanks!!!
> 
> Greg
> 
> _______________________________________________
> 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/20190131/5e64cec1/attachment.html>


More information about the ncl-talk mailing list