# [ncl-talk] getind_latlon2d_query

Guido Cioni guidocioni at gmail.com
Tue Dec 5 23:38:40 MST 2017

```You can try to use these functions to create 2d coordinate arrays from 1d
arrays. They were provided by Karin Meier Flascher.

;------------------------------------------------------------
;-- Function:      create_lon2d(y,x)
;-- Description:   create 2d lon array from 1D rotlon, rotlat
;------------------------------------------------------------
undef("create_lon2d")
function create_lon2d(rotlat[*]:numeric, rotlon[*]:numeric)
local x, i
begin
x = new((/dimsizes(rotlat),dimsizes(rotlon)/),typeof(rotlat))
;  print("Function create_lon2d: dimsizes of x: "+dimsizes(x))
do i=0,dimsizes(rotlat)-1
x(i,:) = rotlon
end do
return(x)
end

;------------------------------------------------------------
;-- Function:      create_lat2d(y,x)
;-- Description:   create 2d lat array from 1D rotlon,rotlat
;------------------------------------------------------------
undef("create_lat2d")
function create_lat2d(rotlat[*]:numeric, rotlon[*]:numeric)
local y, i
begin
y = new((/dimsizes(rotlat),dimsizes(rotlon)/),typeof(rotlat))
;  print("Function create_lat2d: dimsizes of y: "+dimsizes(y))
do i=0,dimsizes(rotlon)-1
y(:,i) = rotlat
end do
return(y)
end

Kunal Please try to figure it out things on your own by searching in the
mailing list or in the NCL website. You have some really basic question
which shouldn't be posted here.
I'm not going to reply next time if you don't show any intention of solving
the problem on your own.

Good luck

Il 6 dic 2017 7:32 AM, "Guido Cioni" <guidocioni at gmail.com> ha scritto:

> Kunal,
>  lat and lon have to be 2 dimensional. Just renaming them to lat2d and
> lon2d doesn't make them 2 dimensional....
>
> Il 6 dic 2017 6:36 AM, "Kunal Bali" <kunal.bali9 at gmail.com> ha scritto:
>
>> Okay, thanks for the suggestion.
>>
>>
>> If I modify the script using
>>
>> *lat2d = a->lat*
>> *lon2d = a->lon*
>>
>>
>> *and then *
>>
>> *nm   = getind_latlon2d (lat2d, lon2d, latv, lonv)*
>>
>> *I mean I tried this but still got the same error. *
>>
>> Variable: totc
>> Type: float
>> Total Size: 9478656 bytes
>>             2369664 values
>> Number of Dimensions: 3
>> Dimensions and sizes:    [2] x [1088] x [1089]
>> Coordinates:
>> Number Of Attributes: 1
>>   _FillValue :    -28672
>>
>> Variable: lat2d
>> Type: double
>> Total Size: 8704 bytes
>>             1088 values
>> Number of Dimensions: 1
>> Dimensions and sizes:    [lat | 1088]
>> Coordinates:
>>             lat: [21.00781..37.992185]
>> Number Of Attributes: 3
>>   long_name :    "latitude"
>>   units :    "degrees_north"
>>   axis :    Y
>> fatal:Number of dimensions in parameter (0) of (getind_latlon2d) is (1),
>> (2) dimensions were expected
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> regards
>> Kunal Bali
>>
>>
>>
>>
>>
>> On Tue, Dec 5, 2017 at 10:41 PM, Guido Cioni <guidocioni at gmail.com>
>> wrote:
>>
>>> Did you even try to understand the error?
>>>
>>> fatal:Number of dimensions in parameter (0) of (getind_latlon2d) is (1),
>>> (2) dimensions were expected
>>>
>>>
>>>   nm   = getind_latlon2d (lat(:), lon(:), latv, lonv)
>>>
>>> lat and lon are 1-dimensional while the function needs 2-dimensional
>>> latitude and longitudes (getind_latlon*2d*)
>>>
>>>
>>> On 5. Dec 2017, at 10:59, Kunal Bali <kunal.bali9 at gmail.com> wrote:
>>>
>>> Dear NCL user,
>>>
>>>
>>> I am trying to plot the coff. of divergence of the attached file (as a
>>> sample file with 2-time steps). the original file has 365 time steps. The
>>> script related to this query is also attached.
>>>
>>> The error is given below
>>>
>>>
>>> Variable: totc
>>> Type: float
>>> Total Size: 9478656 bytes
>>>             2369664 values
>>> Number of Dimensions: 3
>>> Dimensions and sizes:    [2] x [1088] x [1089]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>   _FillValue :    -28672
>>> fatal:Number of dimensions in parameter (0) of (getind_latlon2d) is (1),
>>> (2) dimensions were expected
>>> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 106 in
>>> file iitd_PM2.5_plot_new.ncl
>>>
>>>
>>>
>>> regards
>>> Kunal Bali
>>>
>>>
>>>
>>>
>>> <data.tar.bz2><iitd_PM2.5_plot_new.ncl>_____________________
>>> __________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>>
>>> Guido Cioni
>>> http://guidocioni.altervista.org
>>>
>>>
>>
>> _______________________________________________
>> 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/20171206/22acecf0/attachment.html>
```