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

Home » Public Forums » archive » Re: re-binning with linear interpolation
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: re-binning with linear interpolation [message #76362] Wed, 01 June 2011 12:01
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
In the poster's case, though, they're upsampling, so that should be okay.

-Jeremy.
Re: re-binning with linear interpolation [message #76364 is a reply to message #76362] Wed, 01 June 2011 09:58 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
Just keep in mind that spectra are one of the cases where typically
what would be of interest when downsampling is not to have points that
"fall on the original line", as show in David's plot. It may be points
that preserve the same area under the curve. Like the difference
between a downsampled curve and one convolved with a kernel (which
brings the additional question of which kernel to use).
Re: re-binning with linear interpolation [message #76366 is a reply to message #76364] Wed, 01 June 2011 07:42 Go to previous message
abc is currently offline  abc
Messages: 46
Registered: March 2011
Member
On Jun 1, 4:02 pm, David Fanning <n...@idlcoyote.com> wrote:
> abc writes:
>>             Thanks a lot for your help. I tried to run the program as
>> u mention and it works fine. But the problem is that as you took
>> e=ceil(a[0,1]) it stops at 5206A. and it is not proceeding further. I
>> have total 30000 data point. and I want to run the code for all of
>> them.
>> I tried with
>>  b=floor(a[0,*])
>>  e=ceil(a[0,*])
>> but then I am getting an error
>> "LINDGEN: Expression must be a scalar or 1 element array in this
>> context: <LONG      Array[1, 18]".
>
>> hope you understand the my problem.
>
> I've just written an article that may explain this more
> clearly:
>
>   http://www.idlcoyote.com/code_tips/interpflux.php
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Dear all,
Thanks a lot. It works fantastic. again thanks.
Re: re-binning with linear interpolation [message #76367 is a reply to message #76366] Wed, 01 June 2011 07:02 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
abc writes:

> Thanks a lot for your help. I tried to run the program as
> u mention and it works fine. But the problem is that as you took
> e=ceil(a[0,1]) it stops at 5206A. and it is not proceeding further. I
> have total 30000 data point. and I want to run the code for all of
> them.
> I tried with
> b=floor(a[0,*])
> e=ceil(a[0,*])
> but then I am getting an error
> "LINDGEN: Expression must be a scalar or 1 element array in this
> context: <LONG Array[1, 18]".
>
> hope you understand the my problem.

I've just written an article that may explain this more
clearly:

http://www.idlcoyote.com/code_tips/interpflux.php

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: re-binning with linear interpolation [message #76368 is a reply to message #76367] Wed, 01 June 2011 06:35 Go to previous message
abc is currently offline  abc
Messages: 46
Registered: March 2011
Member
On Jun 1, 11:55 am, Wox <s...@nomail.com> wrote:
> On Wed, 1 Jun 2011 01:17:10 -0700 (PDT), abc <deearvin...@gmail.com>
> wrote:
>
>> I want to re-bin the wavelength at a step of 1 A and also the flux at
>> the same step but with linear interpolation.
>
> a=[[5201.720215,0.0097],$
>    [5205.345215,0.0088],$
>    [5208.970703,0.0080],$
>    [5212.596191,0.0094],$
>    [5216.221680,0.0133],$
>    [5219.846680,0.0167],$
>    [5223.472168,0.0169],$
>    [5227.097656,0.0156],$
>    [5230.722656,0.0145],$
>    [5234.348145,0.0138],$
>    [5237.973633,0.0130],$
>    [5241.599121,0.0118],$
>    [5245.224121,0.0110],$
>    [5248.849609,0.0116],$
>    [5252.475098,0.0134],$
>    [5256.100586,0.0147],$
>    [5259.725586,0.0139],$
>    [5263.351074,0.0126]]
>
> ; New wavelengths
> b=floor(a[0,0])
> e=ceil(a[0,-1])
> inc=1.
> x=b+inc*lindgen(1,(e-b)/inc+1)
>
> ; Linear interpolate flux
> y=interpol(a[1,*],a[0,*],x)
>
> ; Plot
> pa=plot(a,'+r-')
> pb=plot(x,y,'+-',/overplot)

Dear Wox,
Thanks a lot for your help. I tried to run the program as
u mention and it works fine. But the problem is that as you took
e=ceil(a[0,1]) it stops at 5206A. and it is not proceeding further. I
have total 30000 data point. and I want to run the code for all of
them.
I tried with
b=floor(a[0,*])
e=ceil(a[0,*])
but then I am getting an error
"LINDGEN: Expression must be a scalar or 1 element array in this
context: <LONG Array[1, 18]".

hope you understand the my problem.

Again thanks for the prompt response.
Re: re-binning with linear interpolation [message #76369 is a reply to message #76368] Wed, 01 June 2011 02:55 Go to previous message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Wed, 1 Jun 2011 01:17:10 -0700 (PDT), abc <deearvind12@gmail.com>
wrote:

> I want to re-bin the wavelength at a step of 1 A and also the flux at
> the same step but with linear interpolation.


a=[[5201.720215,0.0097],$
[5205.345215,0.0088],$
[5208.970703,0.0080],$
[5212.596191,0.0094],$
[5216.221680,0.0133],$
[5219.846680,0.0167],$
[5223.472168,0.0169],$
[5227.097656,0.0156],$
[5230.722656,0.0145],$
[5234.348145,0.0138],$
[5237.973633,0.0130],$
[5241.599121,0.0118],$
[5245.224121,0.0110],$
[5248.849609,0.0116],$
[5252.475098,0.0134],$
[5256.100586,0.0147],$
[5259.725586,0.0139],$
[5263.351074,0.0126]]

; New wavelengths
b=floor(a[0,0])
e=ceil(a[0,-1])
inc=1.
x=b+inc*lindgen(1,(e-b)/inc+1)

; Linear interpolate flux
y=interpol(a[1,*],a[0,*],x)

; Plot
pa=plot(a,'+r-')
pb=plot(x,y,'+-',/overplot)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: International Help Needed
Next Topic: Re: colorbar inside the plot

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

Current Time: Wed Oct 08 15:16:17 PDT 2025

Total time taken to generate the page: 0.00649 seconds