Re: mapping/interpolation from one irregular grid to another (different) irregular grid. [message #79007] |
Thu, 26 January 2012 01:30  |
Maarten[1]
Messages: 176 Registered: November 2005
|
Senior Member |
|
|
On Jan 24, 10:04 pm, Paul van Delst <paul.vande...@noaa.gov> wrote:
> I have a colleague who wants to map/interpolate data from one satellite sensor's footprint to another. The data is
> defined in terms of pixel vs scan line which means the lat/lon grid (which is how the sensor FOVs are matched) for each
> is quite irregular. He has performed loops over individual elements to do the interpolation, but as you would expect,
> this is very slow in IDL. We need to speed it up (a lot).
Which instruments are we talking about? I mapped MODIS on Aqua to OMI
on Aura within the A-train. Although both grids are irregular, at
least you know that they will pass over the same coordinate within a
fixed time-difference. Both use TAI93 for time-stamping, once you know
that, you can reduce the amount to data to a time-slice of about 10
seconds.
The key thing is to reduce the number of pixels as quickly as
possible. For MODIS -> OMI I used the time difference, then searching
in the 5x5 km pixels, and finally using that to search the 1x1 km
pixels. That took the time down to about 45 minutes per orbit (from
the brute force three weeks). That was good enough for me.
I used the pixels centers for MODIS, and constructed pixel boundaries
for OMI. The IDLanROI class is useful, I created a subclass to deal
with the dateline.
> My first thought would be to put both on a common regular grid, do the matchup/interpolation, and then somehow use
> histogram with the reverse_indices trick to get the matched data back to the irregular grid (as detailed in JD's
> histogram tutorial on idlcoyote.com).
>
> Does any of this make sense? I wanted to poll the IDL users out there that may have done this before recommending my
> colleague embark on a a potential fruitless endeavour.
Going to a regular grid first will introduce all kinds of
interpolation artifacts. So, no it doesn't make sense to me. But it
strongly depends on what you need to do, what instruments we're
talking about (relative pixel sizes in particular). Is there any
relation between the instruments?
Maarten
|
|
|
Re: mapping/interpolation from one irregular grid to another (different) irregular grid. [message #79019 is a reply to message #79007] |
Tue, 24 January 2012 23:38   |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
Hi Paul,
If I understand you right, I'd say GridData is at least worth a try. Online help has several examples, but none doing quite what you want. Using the variables from there (scattered points f as a function of x and y):
; Create a dataset of N points.
n = 100 ;# of scattered points
seed = -121147L ;For consistency
x = RANDOMU(seed, n)
y = RANDOMU(seed, n)
; Create a dependent variable in the form a function of (x,y)
; with peaks & valleys.
f = 3 * EXP(-((9*x-2)^2 + (7-9*y)^2)/4) + $
3 * EXP(-((9*x+1)^2)/49 - (1-0.9*y)) + $
2 * EXP(-((9*x-7)^2 + (6-9*y)^2)/4) - $
EXP(-(9*x-4)^2 - (2-9*y)^2)
; -----
; Then, create another set of irregular (x, y)
; points to sample, and sample them:
xOut = RandomU(seed, n)
yOut = RandomU(seed, n)
fOut = GRIDDATA(x, y, f, XOut=xOut, YOut=yOut)
; -----
; To confirm that the gridding of this small set of points is
; doing what we intend, these two contour plots bear some similarity:
!P.Multi=[0,1,2]
Contour, f, x, y, /IRREGULAR, LEVEL=FIndGen(11)/10*5, /FOLLOW
Contour, fOut, xOut, yOut, /IRREGULAR, LEVEL=FIndGen(11)/10*5, /FOLLOW
There are loads of options in GridData for interpolation methods, etc.
Hope this is helpful in some way.
Cheers,
-Dick
Dick Jackson Software Consulting
Victoria, BC, Canada
www.d-jackson.com
|
|
|
Re: mapping/interpolation from one irregular grid to another (different) irregular grid. [message #79022 is a reply to message #79019] |
Tue, 24 January 2012 15:54   |
Klemen
Messages: 80 Registered: July 2009
|
Member |
|
|
If you want to map high resolution data (e.g, MODIS) with the
footprint of the lower resolution data (e.g. SEVIRI), try something
like:
1. Run through all low resolution (LR) pixels (1 or 2 for loops)
- find the closest pixel of datasets having high resolution (HR)
within the dataset having LR: MATCH_2D
- assume that not more than e.g. 10 HR pixels left, right, up, down
from this centre HR pixel can be witin the LR pixel
- once you constrain the possible HR pixels to check, construct (from
the centre points of LR pixels) the LR pixel you are currently
processing and check, which of the high resolution pixels fall in:
ROIobj->IDLanROI::ContainsPoints
- assign an index to these pixels so you can later recognize, which
high res pixels correspond to one
2. This points depend on what you really want to do, if you want to
interpolate than you shoud in preivous step estimate also the distance
between LR centre and each corresponding HR pixel. Here is an example
for aggregation - average all HR pixel to LR pixel.
h=histogram(HR_index, REVERSE_INDICES=ri,omin=om)
gmax = max(h) ;Highest number of duplicate indicies
for j=1,gmax do begin
g = where(h GE j, Ng)
if Ng GT 0 then begin
LR[om+g] = (LR[om+g]*(j-1.) + HR[ri[ri[g]+j-1]]) / j
endif
endfor
If the resolutions of both datasets are significantly different (10 HR
pixels covers 1 LR), then this might be quite fast - the point 2 is
rapid, it takes me about a minute to compute point 1 (LR: 350×150
pixels, HR: 900×600 pixels)
Cheers, Klemen
|
|
|
|
Re: mapping/interpolation from one irregular grid to another (different) irregular grid. [message #79097 is a reply to message #79007] |
Thu, 26 January 2012 08:53  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Maarten wrote:
> On Jan 24, 10:04 pm, Paul van Delst <paul.vande...@noaa.gov> wrote:
>> I have a colleague who wants to map/interpolate data from one satellite sensor's footprint to another. The data is
>> defined in terms of pixel vs scan line which means the lat/lon grid (which is how the sensor FOVs are matched) for each
>> is quite irregular. He has performed loops over individual elements to do the interpolation, but as you would expect,
>> this is very slow in IDL. We need to speed it up (a lot).
>
> Which instruments are we talking about? I mapped MODIS on Aqua to OMI
> on Aura within the A-train. Although both grids are irregular, at
> least you know that they will pass over the same coordinate within a
> fixed time-difference. Both use TAI93 for time-stamping, once you know
> that, you can reduce the amount to data to a time-slice of about 10
> seconds.
MODIS (Terra/Aqua) and VIIRS (on Suomi-NPP)
> The key thing is to reduce the number of pixels as quickly as
> possible. For MODIS -> OMI I used the time difference, then searching
> in the 5x5 km pixels, and finally using that to search the 1x1 km
> pixels. That took the time down to about 45 minutes per orbit (from
> the brute force three weeks). That was good enough for me.
>
> I used the pixels centers for MODIS, and constructed pixel boundaries
> for OMI. The IDLanROI class is useful, I created a subclass to deal
> with the dateline.
>
>> My first thought would be to put both on a common regular grid, do the matchup/interpolation, and then somehow use
>> histogram with the reverse_indices trick to get the matched data back to the irregular grid (as detailed in JD's
>> histogram tutorial on idlcoyote.com).
>>
>> Does any of this make sense? I wanted to poll the IDL users out there that may have done this before recommending my
>> colleague embark on a a potential fruitless endeavour.
>
> Going to a regular grid first will introduce all kinds of
> interpolation artifacts. So, no it doesn't make sense to me. But it
> strongly depends on what you need to do, what instruments we're
> talking about (relative pixel sizes in particular). Is there any
> relation between the instruments?
They are both in sun-synchronous orbits but otherwise, no. Different platforms.
thanks to all for the tips and advice.
cheers,
paulv
|
|
|