Re: Reading a vector of points all at once

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 21 2011 - 12:51:26 MDT

Yes this is correct. That is how vector subscripting works in NCL. It is conceptually the same as a colon-style subscript except that the indexes may be irregularly spaced (or repeated or non-monotonic). It would be nice to support a coordinated style of indexing where each index matches with the index used along another dimension, but we would need to add a new type of subscripting syntax, or (probably easier) add a function for this purpose.
 -dave

On Oct 21, 2011, at 11:43 AM, Dennis Shea wrote:

> Ummm,
>
> Yes, I guess to get a the value of 'u' at the 4 locations
> then a do loop is necessary.
>
> I think the NCL is essentially giving you a 2D array
> consisting of ....
>
> 5,10 5,44 5,73 5,20
> 87,10 87,44 87,83 87,20
> 20,10 20,44 20,83 20,20
> 15,10 15,44 15,83 15,20
>
> I think that one of the core developers will have to address this.
>
> D
>
>
> On 10/21/2011 09:51 AM, Hahmann, Andrea N. wrote:
>> Hi Dennis
>>
>> To my surprise the example I gave does work without a loop but the results
>> are not what I expected... Here is the simple example and the results.
>>
>> begin
>> inear = (/5,87,20,15/)
>> jnear = (/10,44,73,20/)
>>
>> ff = addfile("/mnt/mimer/ahah/SBaltic/wrfout_d02_2010-10-30_00.nc","r")
>> u = new(dimsizes(inear),"float")
>> do k=0,dimsizes(inear)-1
>> u(k) = ff->U(0,0,inear(k),jnear(k))
>> end do
>> printVarSummary(u)
>>
>> delete(u)
>> u = ff->U(0,0,inear,jnear)
>> printVarSummary(u)
>> end
>>
>>
>> The result for the first is a 1-D array, but a 2D array (4 x 4) from the
>> second!
>>
>> Variable: u
>> Type: float
>> Total Size: 16 bytes
>> 4 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [4]
>> Coordinates:
>> Number Of Attributes: 7
>> coordinates : XLONG_U XLAT_U
>> stagger : X
>> units : m s-1
>> description : x-wind component
>> MemoryOrder : XYZ
>> FieldType : 104
>> _FillValue : 9.96921e+36
>>
>> Variable: u
>> Type: float
>> Total Size: 64 bytes
>> 16 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [south_north | 4] x [west_east_stag | 4]
>> Coordinates:
>> Number Of Attributes: 6
>> FieldType : 104
>> MemoryOrder : XYZ
>> description : x-wind component
>> units : m s-1
>> stagger : X
>> coordinates : XLONG_U XLAT_U
>>
>>
>>
>>
>>
>>
>> ----
>> Andrea N. Hahmann
>> Senior Scientist
>> Wind Energy Division
>> Risų DTU
>>
>> Technical University of Denmark
>> Risų National Laboratory for Sustainable Energy
>> Frederikborgvej 399, P.O. Box 49
>> 4000 Roskilde, Denmark
>>
>> Direct +45 4677 5471
>> Mobil: +45 2133 0550
>> ahah@risoe.dtu.dk
>> http://www.risoe.dtu.dk
>>
>>
>>
>>
>> On 10/20/11 7:31 PM, "Dennis Shea"<shea@ucar.edu> wrote:
>>
>>> I think the following will work:
>>>
>>> inear = (/5,87,20,15/)
>>> jnear = (/10,44,73,20/)
>>> u = ff->U(inear,jnear)
>>> printVarSummary(u)
>>>
>>> On 10/20/11 7:19 AM, Hahmann, Andrea N. wrote:
>>>> Good morning
>>>>
>>>> I have a not so small list of grid points I would like to read from a
>>>> NetCDF file. Here is an example (ff is an open file):
>>>>
>>>> begin
>>>> inear = (/5,87,20,15/)
>>>> jnear = (/10,44,73,20/)
>>>>
>>>> u = new(dimsizes(inear),"float")
>>>> do k=0,dimsizes(inear)-1
>>>> u(k) = ff->U(inear(k),jnear(k))
>>>> end do
>>>> end
>>>>
>>>> Can this be rewritten without using the loop over the grid point? A
>>>> similar loop seems to be slowing my script down and I have a lot of
>>>> files to readŠ
>>>>
>>>> Thanks,
>>>> Andrea
>>>>
>>>> ----
>>>> Andrea N. Hahmann
>>>> Senior Scientist
>>>> Wind Energy Division
>>>> Risų DTU
>>>>
>>>> Technical University of Denmark
>>>> Risų National Laboratory for Sustainable Energy
>>>> Frederikborgvej 399, P.O. Box 49
>>>> 4000 Roskilde, Denmark
>>>>
>>>> Direct +45 4677 5471
>>>> Mobil: +45 2133 0550
>>>> ahah@risoe.dtu.dk
>>>> http://www.risoe.dtu.dk
>>>> _______________________________________________
>>>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 21 12:51:33 2011

This archive was generated by hypermail 2.1.8 : Mon Oct 24 2011 - 09:29:35 MDT