Re: Re-gridding Problem [message #58489] |
Wed, 30 January 2008 14:57 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Kenneth P. Bowman writes:
> (I think you mean you want to undersample, correct? That is, you want a
> lower resolution grid than the original data.)
>
> This is pretty easy with INTERPOLATE.
Thanks, Ken. I came up with a solution involving INTERPOL,
mostly because I couldn't figure out the algorithm for
INTERPOLATE. I am *really* grateful to have this example.
I'm going to put it on my web page so I can find it again. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: Re-gridding Problem [message #58498 is a reply to message #58489] |
Wed, 30 January 2008 08:03  |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article <MPG.22093dcc1a580def9896aa@news.frii.com>,
David Fanning <news@dfanning.com> wrote:
> Folks,
>
> I've heard the astro guys talk about this from time to time, so I
> thought I would ask.
>
> I have some output from the climate modeling folks. I need this
> data on a regular grid. Unfortunately, the data is *slightly*
> regular. Here is one of my cases (I have several all like this,
> but different).
>
> The data is on a regular 1-deg grid in the longitudinal direction.
> It is on a regular 1 deg grid in the latitudinal direction,
> EXCEPT between -30 and + 30 degrees, where it is on a gradually
> decreasing grid to 1/3 of a degree at the equator.
>
> I would like a grid that is everywhere sampled on a 1 degree grid.
> So, my idea is to superimpose a 1-deg grid over my data and resample.
> It is going to get messy. :-(
>
> My question is this. Does anyone have any code to share that can
> oversample like this?
(I think you mean you want to undersample, correct? That is, you want a
lower resolution grid than the original data.)
This is pretty easy with INTERPOLATE.
Assuming that your data is 2-D (x = longitude and y = latitude), create
the grids that you want to interpolate to
nx = 360
ny = 181
x = FINDGEN(nx)
y = -90.0 + FINDGEN(ny)
Compute the "interpolation coordinates" from the original grid
j = VALUE_LOCATE(y_original, y)
yj = j + (y - y_original[j])/(y_original[j+1] - y_original[j])
Since the input and output grids are the same in the x-direction, you
don't need to do anything with x. Expand x and yi into 2-D arrays
xx = REBIN(x, nx, ny, /SAMPLE)
yy = REBIN(REFORM(yi, 1, ny), nx, ny, /SAMPLE)
Then interpolate
new = INTERPOLATE(original, xx, yy)
Ken
|
|
|
Re: Re-gridding Problem [message #58518 is a reply to message #58498] |
Tue, 29 January 2008 13:50  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Brian Larsen writes:
> while not exactly the same, I have done things like this and just used
> interpolate() (or interpol()) on the places where you want the
> points. You certainly know how to do this, is this not what you want
> to do?
Like most people who post to this group, I'm not sure what
I want to do. That's my biggest problem. :-)
I guess I'm trying not to change the data too early in the
process. This is just the first step. Mucking too much with
the data here might have consequences at the end of the
process. Humm. Have to think...
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: Re-gridding Problem [message #58519 is a reply to message #58518] |
Tue, 29 January 2008 12:50  |
Brian Larsen
Messages: 270 Registered: June 2006
|
Senior Member |
|
|
> The data is on a regular 1-deg grid in the longitudinal direction.
> It is on a regular 1 deg grid in the latitudinal direction,
> EXCEPT between -30 and + 30 degrees, where it is on a gradually
> decreasing grid to 1/3 of a degree at the equator.
>
> I would like a grid that is everywhere sampled on a 1 degree grid.
> So, my idea is to superimpose a 1-deg grid over my data and resample.
> It is going to get messy. :-(
David,
while not exactly the same, I have done things like this and just used
interpolate() (or interpol()) on the places where you want the
points. You certainly know how to do this, is this not what you want
to do?
Cheers,
Brian
------------------------------------------------------------ -------------
Brian Larsen
Boston University
Center for Space Physics
|
|
|