|
Re: re-binning with linear interpolation [message #76364 is a reply to message #76362] |
Wed, 01 June 2011 09:58  |
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  |
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  |
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  |
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  |
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)
|
|
|