Re: Set of columns from 3D dataset using 'getind_latlon2d'

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Sun Jun 13 2010 - 07:16:43 MDT

I should have added that if memory is an issue, you can "cleanup" at
the end; that is, delete any variables you don't need.

   delete(idx)
   delete(idx1d)
   delete(data2d)
   delete(data) ; If you don't need this any more

You can intersperse these delete statements right after the last time
that you need to use that particular array, so it is freed right away.

--Mary

On Jun 13, 2010, at 7:11 AM, Mary Haley wrote:

> Hi Jakob,
>
> What you need to do is convert these index values into values that
> index into a 1D array.
>
> Assume that:
>
> nlayer = 40
> nlat = 400
> nlon = 550
>
> ;---Convert to indexes into a 1D array dimensioned nlat*nlon.
> idx1d = (idx(:,0)*nlon) + idx(:,1)
>
> ;---Convert model data to 2D array (nlayer x nlat*nlon)
> data2d = onedtond(ndtooned(data),(/nlayer,nlat*nlon/))
>
> ;---Get new values at idx1d locations
> new_data2d = data2d(:,idx1d)
>
>
> --Mary
>
> On Jun 11, 2010, at 3:13 PM, Jakob Tendel wrote:
>
>> Hi,
>>
>> SITUATION:
>> I have model data on a (40layer x 400lat x 550lon) grid, converted
>> out of a rotated lat/lon grid. I have lat2D and lon2D fields for
>> this data.
>>
>> I want to extract whole vertical columns of this data at a set of
>> specific coordinates (lat/lon). I use the function 'getind_latlon2d'
>> to give me the indices into lat2D/lon2D for the nearest grid points
>> to these locations, which is acceptable.
>>
>> PROBLEM:
>> The output of 'getind_latlon2d' has the form (n_points x 2), a set
>> of indices into the rightmost two dimensions of my data. I want to
>> use these indices to subscript into the data to give me a set of
>> columnar data for each of the locations, i.e. a 2D array. However,
>> when I subscript the data in the form 'data( : , idx(:,0) , idx(:,
>> 1) ), I get a 3D array in return. What I actually want is the
>> horizontal diagonal of this array (:,0,0), (:,1,1,),(:,2,2) etc.
>>
>> QUESTION:
>> Is there a sensible way of extracting a set of vertical columns out
>> of 3D data and writing them into a 2D array using proper array
>> indexing notation? Yes of course this can be done with loops but
>> that is horribly slow and not really the point, is it?
>>
>> Thanks for any tips,
>>
>> Jakob
>>
>>
>>
>> --
>> Jakob Tendel Phone 303 497 2713
>> Research Applications Laboratory Office 3106b
>> National Center for Atmospheric Research Building FL2
>> 3450 Mitchell Lane
>> Boulder CO 80301
>> <tendel.vcf>_______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Jun 13 07:16:51 2010

This archive was generated by hypermail 2.1.8 : Wed Jun 16 2010 - 15:28:33 MDT