[Numpy-discussion] subdivide array

2010-11-30 Thread Gerrit Holl
On 30 November 2010 17:58, Pierre GM  wrote:
> On Nov 30, 2010, at 5:40 PM, John wrote:
>> I have an array of data for a global grid at 1 degree resolution. It's
>> filled with 1s and 0s, and it is just a land sea mask (not only, but
>> as an example). I want to be able to regrid the data to higher or
>> lower resolutions (i.e. 0.5 or 2 degrees). But if I try to use any
>> standard interp functions, such as mpl_toolkits.basemap.interp it
>> fails -- I assume due to the data being binary.
>>
>> I guess there may be a fairly easy routine to do this?? Does someone
>> have an example?
>
> Just a random idea: have you tried to convert your input data to float? 
> Hopefully you could get some values between 0 and 1 for your interpolated 
> values, that you'll have to transform back to integers following a scheme of 
> your choosing...

I would argue that some float between 0 and 1 is an excellent
representation when regridding a binary land-sea-mask onto a higher
resolution. After all, this information is not there. Why should a
land-sea mask be binary anyway? As if a grid-cell can only be fully
ocean or fully land...

BTW, I just realised Pythons convention that negative indices count
from the end of the array is perfect when using a 180x360
land-sea-mask, as lon[-30] and lon[330] mean and should mean the same
:)

Gerrit.

--
Gerrit Holl
PhD student at Department of Space Science, LuleƄ University of
Technology, Kiruna, Sweden
http://www.sat.ltu.se/members/gerrit/
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] subdivide array

2010-11-30 Thread Pierre GM

On Nov 30, 2010, at 5:40 PM, John wrote:

> Hello,
> 
> I have an array of data for a global grid at 1 degree resolution. It's
> filled with 1s and 0s, and it is just a land sea mask (not only, but
> as an example). I want to be able to regrid the data to higher or
> lower resolutions (i.e. 0.5 or 2 degrees). But if I try to use any
> standard interp functions, such as mpl_toolkits.basemap.interp it
> fails -- I assume due to the data being binary.
> 
> I guess there may be a fairly easy routine to do this?? Does someone
> have an example?

Just a random idea: have you tried to convert your input data to float? 
Hopefully you could get some values between 0 and 1 for your interpolated 
values, that you'll have to transform back to integers following a scheme of 
your choosing...
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] subdivide array

2010-11-30 Thread Whitcomb, Mr. Tim
> I have an array of data for a global grid at 1 degree resolution. It's
> filled with 1s and 0s, and it is just a land sea mask (not only, but
> as an example). I want to be able to regrid the data to higher or
> lower resolutions (i.e. 0.5 or 2 degrees). But if I try to use any
> standard interp functions, such as mpl_toolkits.basemap.interp it
> fails -- I assume due to the data being binary.
> 
> I guess there may be a fairly easy routine to do this?? Does someone
> have an example?
> 

When I've had to do this, I typically set Basemap's interp to do
nearest-neighbor interpolation (by setting order=0).  It defaults to
order=1, which is bilinear interpolation, which will destroy the binary
nature of your data (as you perhaps noticed).

Tim
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] subdivide array

2010-11-30 Thread John
Hello,

I have an array of data for a global grid at 1 degree resolution. It's
filled with 1s and 0s, and it is just a land sea mask (not only, but
as an example). I want to be able to regrid the data to higher or
lower resolutions (i.e. 0.5 or 2 degrees). But if I try to use any
standard interp functions, such as mpl_toolkits.basemap.interp it
fails -- I assume due to the data being binary.

I guess there may be a fairly easy routine to do this?? Does someone
have an example?

Thanks!
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion