[ncl-talk] How to pick out the grids in a chosen area from a polar stereographic projection dataset?

林祥 xianglin72 at icloud.com
Tue Aug 23 13:09:22 MDT 2016


Thanks for the reply!

xbox=x(:,inds_lat,inds_lon)

The above  line can not get the appropriate results since inds_lat /inds_lon is 2-d array, the first dimension of inds_lat/inds_lon  is

the numbers of grids meeting the selection condition in the former.

Now we got to know the grids numbers in a chosen area ( dimsizes(inds_lat(:,0)) ) and the corresponding location in the original 

2-d array of x (  the rightmost dimension of inds_lat/inds_lon denote the location ). However, I still find no resolution to

rearrange these data into another 2d array of y(ygrid,xgrid) or plot 1-d array of x1d with lon1d/lat1d directly.


Besides, the original array is x(ygrid=332,xgrid=316), corresponding to 104912 grids in total. 
 
  box_lon = ind(lon1d.ge.min_lon .AND. lon1d.le.max_lon)   ; min_lon = -180 and max_lon =180, and box_lon is a array of 104912*2

>  box_lat = ind(lat1d.ge.min_lat .AND. lat1d.le.max_lat)   ; min_lat = -60. max_lat=-50 and box_lat is in 38444*2


I am puzzled with why 38444 is not divided by 316.


And this is the webpage of projection

http://nsidc.org/data/polar-stereo/ps_grids.html <http://nsidc.org/data/polar-stereo/ps_grids.html>



Lin  


> 在 2016年8月23日,14:48,Guido Cioni <guidocioni at gmail.com> 写道:
> 
> You can use ind_resolve to reshape the indices of the box and then use them to subset. I guess something like this would work (untested)
> 
>  dims_lat = dimsizes(latitude)
>  dims_lon = dimsizes(longitude)
> 
>  lon1d = ndtooned(longitude)
>  lat1d  = ndtooned(latitude) 
> 
>  box_lon = ind(lon1d.ge.min_lon .AND. lon1d.le.max_lon )
>  box_lat = ind(lat1d.ge.min_lat .AND. lat1d.le.max_lat)
> 
>  inds_lon = ind_resolve(box_lon, dims_lon)
>  inds_lat  = ind_resolve(box_lat, dims_lat)
> 
>  xbox=x(:,inds_lat,inds_lon)
> 
> 
> Guido Cioni
> http://guidocioni.altervista.org <http://guidocioni.altervista.org/> 
> 
> 
> 
> 
>> Il giorno 23 ago 2016, alle ore 04:53, 林祥 <xianglin72 at icloud.com <mailto:xianglin72 at icloud.com>> ha scritto:
>> 
>> Hey Cioni,
>> 
>>     Thanks for your reply.   The longitude and latitude array is 2-dimensional, so I rewrite the following scripts
>> 
>>    lon1d = ndtooned(longitude)
>>    lat1d  = ndtooned(latitude)
>>    x1d    = ndtooned(x)
>> 
>>    box_id = ind(lon1d.ge.min_lon .AND. lon1d.le.max_lon .AND. lat1d.ge.min_lat .AND. lat1d.le.max_lat)
>>   ;box_id = ind(lat1d.ge.min_lat .AND. lat1d.le.max_lat)   ; the result is same as the above line
>> 
>>    xlat    = lat1d(box_id)
>>    xlon   = lon1d(box_id)
>>    xbox   =   x1d(box_id)
>> 
>>  No I have picked out the data in the chosen area. But I am puzzled by plotting the contouring map for xbox.
>> Should I have to deal with the array of xbox like the separated station datas?
>> 
>> Thanks
>> 
>> 
>> Lin
>> 
>> 
>> 
>> 
>>> 在 2016年8月23日,00:12,Guido Cioni <guidocioni at gmail.com <mailto:guidocioni at gmail.com>> 写道:
>>> 
>>> Hey Lin,
>>> when dealing with non-monotonic arrays I usually employ the ind function, so I don’t understand why is not working for you…
>>> 
>>> If you have, say, lon and lat arrays (this assume to have them 1-Dimensional, otherwise it gets fishy…).
>>> 
>>> min_lon= -50.
>>> max_lon= -70.
>>> min_lat= -180.
>>> max_lat= -180.
>>> box_lon= ind(lon.ge.min_lon .AND. lon.le.max_lon)
>>> box_lat= ind(lat.ge.min_lat .AND. lat.le.max_lat)
>>> 
>>> should give you exactly all the indices inside the user-prescribed area. Then you can subset using
>>> 
>>> var_box=var(:,box_lat,box_lon)
>>> 
>>> Please be reminded that box_values will have different dimensions, since it is a subset of the original variable.
>>> Cheers,
>>> 
>>> Guido Cioni
>>> http://guidocioni.altervista.org <http://guidocioni.altervista.org/> 
>>> 
>>>> On 22 Aug 2016, at 01:13, 林祥 <xianglin72 at icloud.com <mailto:xianglin72 at icloud.com>> wrote:
>>>> 
>>>> <latitude.csv>
>>> 
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160824/4e8b2965/attachment.html 


More information about the ncl-talk mailing list