comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: interpolation for resizing
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: interpolation for resizing [message #64136] Wed, 03 December 2008 13:19 Go to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
I really love this ;-)

IDL> a=float('nanny')
IDL> help,a
A FLOAT = NaN


Chris wrote:
> On Dec 3, 6:36�am, Paolo <pgri...@gmail.com> wrote:
>> David Fanning wrote:
>>> bryan.s.h...@gmail.com writes:
>>
>>>> Only works in a real array not in a integer array.
>
> It also only seems to work for strings which correspond to actual
> floating point values, like 'nan' and 'inf':
>
> IDL> a = fltarr(3)
> IDL> a[0] = 'nan'
> IDL> a[1] = 'hi'
> % Type conversion error: Unable to convert given STRING to Float.
Re: interpolation for resizing [message #64138 is a reply to message #64136] Wed, 03 December 2008 13:02 Go to previous messageGo to next message
Chris[6] is currently offline  Chris[6]
Messages: 84
Registered: July 2008
Member
On Dec 3, 6:36 am, Paolo <pgri...@gmail.com> wrote:
> David Fanning wrote:
>> bryan.s.h...@gmail.com writes:
>
>>> Only works in a real array not in a integer array.

It also only seems to work for strings which correspond to actual
floating point values, like 'nan' and 'inf':

IDL> a = fltarr(3)
IDL> a[0] = 'nan'
IDL> a[1] = 'hi'
% Type conversion error: Unable to convert given STRING to Float.
Re: interpolation for resizing [message #64144 is a reply to message #64138] Wed, 03 December 2008 08:36 Go to previous messageGo to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
David Fanning wrote:
> bryan.s.hong@gmail.com writes:
>
>> Only works in a real array not in a integer array.
>
> Well, there you go. I've learned something already today. :-)

Maybe we should have one of those december xmas
calendars for IDL: every day we open a little window
and discover a new IDL feature never dreamed
of before!

Ciao,
Paolo

>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: interpolation for resizing [message #64145 is a reply to message #64144] Wed, 03 December 2008 08:25 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
bryan.s.hong@gmail.com writes:

> Only works in a real array not in a integer array.

Well, there you go. I've learned something already today. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: interpolation for resizing [message #64146 is a reply to message #64145] Wed, 03 December 2008 08:17 Go to previous messageGo to next message
bryan.s.hong is currently offline  bryan.s.hong
Messages: 12
Registered: November 2008
Junior Member
On 12월3일, 오전9시54분, David Fanning <n...@dfanning.com> wrote:
> bryan.s.h...@gmail.com writes:
>> Replacing the fill value to a string, for example 'NaN', will exclude
>> the pixels when using 'congrid' or 'rebin'.
>
> To a string!? How would that work?
>
> IDL> a = lindgen(5)
> IDL> a[2] = 999
> IDL> I = where(a eq 999)
> IDL> a[I] = 'nan'
> % Type conversion error: Unable to convert given STRING to Long.
> % Detected at: $MAIN$
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Only works in a real array not in a integer array.
Re: interpolation for resizing [message #64147 is a reply to message #64146] Wed, 03 December 2008 07:54 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
bryan.s.hong@gmail.com writes:

> Replacing the fill value to a string, for example 'NaN', will exclude
> the pixels when using 'congrid' or 'rebin'.

To a string!? How would that work?

IDL> a = lindgen(5)
IDL> a[2] = 999
IDL> I = where(a eq 999)
IDL> a[I] = 'nan'
% Type conversion error: Unable to convert given STRING to Long.
% Detected at: $MAIN$

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: interpolation for resizing [message #64148 is a reply to message #64147] Wed, 03 December 2008 07:49 Go to previous messageGo to next message
bryan.s.hong is currently offline  bryan.s.hong
Messages: 12
Registered: November 2008
Junior Member
On 12월3일, 오전7시52분, loebasboy <stijn....@gmail.com> wrote:
> On 3 dec, 14:43, David Fanning <n...@dfanning.com> wrote:
>
>
>
>
>
>> Craig Markwardt writes:
>>> That's true, but nearest-neighbor sampling also adds high-frequency
>>> aliases, so what one uses to interpolate does depend on what one
>>> needs.
>
>> I have a feeling it will be some weeks before the person
>> asking the question feels compelled to ask about this
>> complication. ;-)
>
>> Cheers,
>
>> David
>
>> P.S. Isn't a 100 by 100 image, uh, pretty small to be
>> doing *any* high-resolution analysis? Certainly too
>> small to be worried about high-frequency aliasing.
>> You should be thinking about other problems, my friend!
>
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
> About interpolate and other related functions... is it possible to use
> these function to interpolate data where there is no data in a grid.
> For instance I have the following code:
>
> a= findgen(5,5)
> a[3,3] = -999
> a[1,2] = -999
> indices = where(a EQ -999)
> b = interpolate(a, indices)
>
> and the interpolated numbers in b are interpolated with available
> numbers in 2 dimensions...
>
> Is there a function in IDL that can do this, because interpolate and
> other related functions work differently I guess (making extra rows or
> columns between rows or columns). I'm sorry that this is a very 'open'
> question but I'm rather busy and this something I could use later on.- 따온 텍스트 숨기기 -
>
> - 따온 텍스트 보기 -

Replacing the fill value to a string, for example 'NaN', will exclude
the pixels when using 'congrid' or 'rebin'.
Re: interpolation for resizing [message #64156 is a reply to message #64148] Wed, 03 December 2008 05:52 Go to previous messageGo to next message
loebasboy is currently offline  loebasboy
Messages: 26
Registered: August 2008
Junior Member
On 3 dec, 14:43, David Fanning <n...@dfanning.com> wrote:
> Craig Markwardt writes:
>> That's true, but nearest-neighbor sampling also adds high-frequency
>> aliases, so what one uses to interpolate does depend on what one
>> needs.
>
> I have a feeling it will be some weeks before the person
> asking the question feels compelled to ask about this
> complication. ;-)
>
> Cheers,
>
> David
>
> P.S. Isn't a 100 by 100 image, uh, pretty small to be
> doing *any* high-resolution analysis? Certainly too
> small to be worried about high-frequency aliasing.
> You should be thinking about other problems, my friend!
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

About interpolate and other related functions... is it possible to use
these function to interpolate data where there is no data in a grid.
For instance I have the following code:

a= findgen(5,5)
a[3,3] = -999
a[1,2] = -999
indices = where(a EQ -999)
b = interpolate(a, indices)

and the interpolated numbers in b are interpolated with available
numbers in 2 dimensions...

Is there a function in IDL that can do this, because interpolate and
other related functions work differently I guess (making extra rows or
columns between rows or columns). I'm sorry that this is a very 'open'
question but I'm rather busy and this something I could use later on.
Re: interpolation for resizing [message #64159 is a reply to message #64156] Wed, 03 December 2008 05:43 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Craig Markwardt writes:

> That's true, but nearest-neighbor sampling also adds high-frequency
> aliases, so what one uses to interpolate does depend on what one
> needs.

I have a feeling it will be some weeks before the person
asking the question feels compelled to ask about this
complication. ;-)

Cheers,

David

P.S. Isn't a 100 by 100 image, uh, pretty small to be
doing *any* high-resolution analysis? Certainly too
small to be worried about high-frequency aliasing.
You should be thinking about other problems, my friend!

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: interpolation for resizing [message #64161 is a reply to message #64159] Wed, 03 December 2008 02:13 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Dec 2, 11:07 pm, David Fanning <n...@dfanning.com> wrote:
> Chris writes:
>> One potential issue with this approach is that IDL may interpolate
>> between your 9999 values and your real data values when you expand the
>> array. If you set the 9999s to !values.f_nan beforehand, then the
>> interpolation will behave more sensibly.
>
> I deliberately used CONGRID without the INTERP keyword
> to avoid this problem. Nearest neighbor interpolation
> does not create any data that is not present in the
> original image.

That's true, but nearest-neighbor sampling also adds high-frequency
aliases, so what one uses to interpolate does depend on what one
needs.

Craig
Re: interpolation for resizing [message #64162 is a reply to message #64161] Tue, 02 December 2008 20:07 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Chris writes:

> One potential issue with this approach is that IDL may interpolate
> between your 9999 values and your real data values when you expand the
> array. If you set the 9999s to !values.f_nan beforehand, then the
> interpolation will behave more sensibly.

I deliberately used CONGRID without the INTERP keyword
to avoid this problem. Nearest neighbor interpolation
does not create any data that is not present in the
original image.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: interpolation for resizing [message #64163 is a reply to message #64162] Tue, 02 December 2008 20:04 Go to previous messageGo to next message
Chris[6] is currently offline  Chris[6]
Messages: 84
Registered: July 2008
Member
On Dec 2, 1:28 pm, David Fanning <n...@dfanning.com> wrote:
> bryan.s.h...@gmail.com writes:
>> I have a 100 X 100 spatial image to be resized to 1000*1000.
>> The data of this image is surface temperature and includes some part
>> of ocean.
>> Because I want to exclude data of ocean area during interpolation, I'm
>> trying to resize it using "interpolate".
>> But I cannot understand the IDL help pages for the 'interpolate'.
>> Could anyone help me with a simple command line for this job?
>
> I don't think this is what you want to do.
> Just use CONGRID (or REBIN) to resize your
> image. (CONGRID uses INTERPOLATE to do the
> interpolation, so you can see how it is done,
> if you read the code.) Then mask out your ocean
> pixels in the usual way, with the WHERE function.
>
>   bigImage = Congrid(image, 1000, 1000)
>   oceanPixels = Where(bigimage EQ 9999, count)
>   IF count GT 0 THEN image[oceanPixels] = 0
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

One potential issue with this approach is that IDL may interpolate
between your 9999 values and your real data values when you expand the
array. If you set the 9999s to !values.f_nan beforehand, then the
interpolation will behave more sensibly.

chris
Re: interpolation for resizing [message #64166 is a reply to message #64163] Tue, 02 December 2008 15:28 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
bryan.s.hong@gmail.com writes:

> I have a 100 X 100 spatial image to be resized to 1000*1000.
> The data of this image is surface temperature and includes some part
> of ocean.
> Because I want to exclude data of ocean area during interpolation, I'm
> trying to resize it using "interpolate".
> But I cannot understand the IDL help pages for the 'interpolate'.
> Could anyone help me with a simple command line for this job?

I don't think this is what you want to do.
Just use CONGRID (or REBIN) to resize your
image. (CONGRID uses INTERPOLATE to do the
interpolation, so you can see how it is done,
if you read the code.) Then mask out your ocean
pixels in the usual way, with the WHERE function.

bigImage = Congrid(image, 1000, 1000)
oceanPixels = Where(bigimage EQ 9999, count)
IF count GT 0 THEN image[oceanPixels] = 0

Cheers,

David
--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: interpolation for resizing [message #64211 is a reply to message #64148] Fri, 05 December 2008 00:36 Go to previous message
loebasboy is currently offline  loebasboy
Messages: 26
Registered: August 2008
Junior Member
On 3 dec, 16:49, bryan.s.h...@gmail.com wrote:
> On 12월3일, 오전7시52분, loebasboy <stijn....@gmail.com> wrote:
>
>
>
>
>
>> On 3 dec, 14:43, David Fanning <n...@dfanning.com> wrote:
>
>>> Craig Markwardt writes:
>>>> That's true, but nearest-neighbor sampling also adds high-frequency
>>>> aliases, so what one uses to interpolate does depend on what one
>>>> needs.
>
>>> I have a feeling it will be some weeks before the person
>>> asking the question feels compelled to ask about this
>>> complication. ;-)
>
>>> Cheers,
>
>>> David
>
>>> P.S. Isn't a 100 by 100 image, uh, pretty small to be
>>> doing *any* high-resolution analysis? Certainly too
>>> small to be worried about high-frequency aliasing.
>>> You should be thinking about other problems, my friend!
>
>>> --
>>> David Fanning, Ph.D.
>>> Fanning Software Consulting, Inc.
>>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
>> About interpolate and other related functions... is it possible to use
>> these function to interpolate data where there is no data in a grid.
>> For instance I have the following code:
>
>> a= findgen(5,5)
>> a[3,3] = -999
>> a[1,2] = -999
>> indices = where(a EQ -999)
>> b = interpolate(a, indices)
>
>> and the interpolated numbers in b are interpolated with available
>> numbers in 2 dimensions...
>
>> Is there a function in IDL that can do this, because interpolate and
>> other related functions work differently I guess (making extra rows or
>> columns between rows or columns). I'm sorry that this is a very 'open'
>> question but I'm rather busy and this something I could use later on.- 따온 텍스트 숨기기 -
>
>> - 따온 텍스트 보기 -
>
> Replacing the fill value to a string, for example 'NaN', will exclude
> the pixels when using 'congrid' or 'rebin'.- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

I guess you didn't read my question properly (although I maybe didn't
have to ask it in this thread to avoid this, but I didn't want to make
a new thread because of David's post several days ago). I'm not trying
to resize anything. I just want the -999 or NaN (I make them with !
Values.F_NAN option btw.) values to have a value in the b array that
is calculated by interpolation (for instance: the IDW of the
surroundig pixels in a 3x3 window).

So sorry for the mixup and thanks if you guys still feel like finding
a solution for this.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Irregular Satellite data plotting
Next Topic: Assigning Coordinates in NetCDF

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 15:21:43 PDT 2025

Total time taken to generate the page: 2.08137 seconds