Re: how to extend a vector from size A to size B, (A<B) without "damage" the data in A [message #79503] |
Thu, 08 March 2012 15:59  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Tito writes:
> Dear David,
> Dear Craig,
>
> First of all I want to thank you both for your answers!
>
> David, the "congrid" function did exactly what I wanted! Thank you very much for the tip!
>
> However, another problem just rise and this lead to my answer to Craig....
Yeah, I'm bowing out. Craig is the one who knows what
he is talking about here. I'm just blowing smoke. ;-)
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: how to extend a vector from size A to size B, (A<B) without "damage" the data in A [message #79505 is a reply to message #79503] |
Thu, 08 March 2012 15:42   |
Tito
Messages: 16 Registered: March 2012
|
Junior Member |
|
|
Dear David,
Dear Craig,
First of all I want to thank you both for your answers!
David, the "congrid" function did exactly what I wanted! Thank you very much for the tip!
However, another problem just rise and this lead to my answer to Craig....
First let me explain my set up and then I will discus my constrains about the "congrid" function.
I have "A" vector which I use for synthetic mask spectrum, witch I will cross-correlate with my science spectra in order to determine the RV signal.
This "A" vector is actually extracted from the HITRAN catalog (atmosphere absorption line database) for the C02 molecule in the IR. Actually this is teluric lines witch in other hand also present on my science spectra.
So I just extracted all the C02 line in range from 6222 to 6248 cm^-1 for example. I convert them to wavelengths and it turn out that in this range I have around 970 C02 lines, BUT only 20 of them are the sharp and deep lines that I need (the telluric). So this "A" 970 array vector is indeed made on a different grid then the "B" vector. from this 970 element vector I am interested only in about 20 of the lines. The others are noise or very faint lines in that I don't care but I take them in order to represent my experiment more accurate.
The "B" vector is the spectra from the 1024 pixel IR detector so it has 1024 elements.
I want to cross-correlate A and B. that means I have to "extend" the A vector to 1024 elements with out harm the relative distances between those 20 lines. in other words I need to increase the resolution of this vector without damage the intensity of the lines... interpol(A) just make the plot look very different from the original.
Craig, now I can see that you are right...
Vector B extracted from the spectrograph is probably irregular in the sense that the wavelength solution from pixel 1 to pixel 1024 is not linear witch is not the case for the intensity and wavelength base extracted from HITRAN. There the teluric lines are equidistant all over the array for A and for the B vector the may vary a bit over the array on the wave length solution from the pipeline .
In order to cross-correlate correctly two of the vectors B and the expanded A must be on the same grid is that right?
I have to do the same for the stellar lines synthetic template mask, but ones I am done with this I will do it much more easy!
As I can see in "interpol" program is written "....Linearly interpolate vectors with a regular or IRREGULAR grid."
Witch I am not sure "congrid" does.
However I have to experiment....
At last I need a function that will keep the nice shape the intensity lines like "congrid" and to be capable to "interpolate" in irregular grids so I can put in the end the two vectors in the same wavelength or pixel grid and to cross-correlate them.
I really hope I was clear.... I will experiment with "congrid" and also with you suggestions Craig...
I hope I will find the answer of my problems alone, but more help is always welcome and appreciate.
All the best,
Tito
|
|
|
Re: how to extend a vector from size A to size B, (A<B) without "damage" the data in A [message #79514 is a reply to message #79505] |
Wed, 07 March 2012 21:37   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Wednesday, March 7, 2012 4:51:20 PM UTC-5, Tito wrote:
> Hi all!
>
> I have the fowling problem:
> I have a array vector A with size [970] elements lets say, and another that is 'B' with [1024] elements. now... both contain spectra and I want to do cross-correlation between the two vectors. This will be possible if A is 1024 element vector.
>
> I am new in IDL and shoot and try several thing here like:
> A = interpol(A,1024)
> and I saw also someone suggested:
> A = [A, intarr(n_elements(B)-n_elements(A))] , but doesn't give me what I want.
>
> A is synthetic spectra (mask) and I just want to increase the resolution without losing the quality of the data(the relative distances between the lines)
>
> A = interpol(A,1024), actually works, but I see very obvious differences in the 970 and the result spectra.
I think you need to define your problem a little more clearly.
Either your A spectrum is sampled on a different grid than B, or it is simply truncated. Either way you have to make an assumption about the quality of your data.
Sampled on a different grid means that the spacing between measurement points in A was different by about 5.3%, or it could also mean uneven sampling of A. Your best bet in this case is to do some form of interpolation, to put them on the same grid. The assumption you would need to make here is that the values vary smoothly from point to point, so that the missing data can be represented by its interpolant. Yes, there could be aliasing artifacts, but I think those would be minimized by doing sinc-interpolation, maybe cubic spline is OK. Both spl_init/spl_interp and interpolate() offer smoothly varying interpolation functions.
If instead A is *truncated* then things are easier. You need to pad your A to the full length. The assumption you make here is that the missing data do not contain useful information, so there is no harm in padding the series. It's probably best to pad with the mean value of your series instead of zero like you indicated above.
Best wishes,
Craig
|
|
|
Re: how to extend a vector from size A to size B, (A<B) without "damage" the data in A [message #79515 is a reply to message #79514] |
Wed, 07 March 2012 17:48   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
tito_trifonov@abv.bg writes:
> I have the fowling problem:
> I have a array vector A with size [970] elements lets say, and another that is 'B' with [1024] elements. now... both contain spectra and I want to do cross-correlation between the two vectors. This will be possible if A is 1024 element vector.
>
> I am new in IDL and shoot and try several thing here like:
> A = interpol(A,1024)
> and I saw also someone suggested:
> A = [A, intarr(n_elements(B)-n_elements(A))] , but doesn't give me what I want.
>
> A is synthetic spectra (mask) and I just want to increase the resolution without losing the quality of the data(the relative distances between the lines)
>
> A = interpol(A,1024), actually works, but I see very obvious differences in the 970 and the result spectra.
>
> Anybody know how to do it?
Have you tried A = Congrid(a, 1024)?
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: how to extend a vector from size A to size B, (A<B) without "damage" the data in A [message #79601 is a reply to message #79505] |
Thu, 08 March 2012 21:09  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Thursday, March 8, 2012 6:42:10 PM UTC-5, Tito wrote:
> Dear David,
> Dear Craig,
>
> First of all I want to thank you both for your answers!
>
> David, the "congrid" function did exactly what I wanted! Thank you very much for the tip!
>
> However, another problem just rise and this lead to my answer to Craig....
>
> First let me explain my set up and then I will discus my constrains about the "congrid" function.
>
> I have "A" vector which I use for synthetic mask spectrum, witch I will cross-correlate with my science spectra in order to determine the RV signal.
> This "A" vector is actually extracted from the HITRAN catalog (atmosphere absorption line database) for the C02 molecule in the IR. Actually this is teluric lines witch in other hand also present on my science spectra.
>
> So I just extracted all the C02 line in range from 6222 to 6248 cm^-1 for example. I convert them to wavelengths and it turn out that in this range I have around 970 C02 lines, BUT only 20 of them are the sharp and deep lines that I need (the telluric). So this "A" 970 array vector is indeed made on a different grid then the "B" vector. from this 970 element vector I am interested only in about 20 of the lines. The others are noise or very faint lines in that I don't care but I take them in order to represent my experiment more accurate.
>
> The "B" vector is the spectra from the 1024 pixel IR detector so it has 1024 elements.
>
> I want to cross-correlate A and B. that means I have to "extend" the A vector to 1024 elements with out harm the relative distances between those 20 lines. in other words I need to increase the resolution of this vector without damage the intensity of the lines... interpol(A) just make the plot look very different from the original.
>
> Craig, now I can see that you are right...
> Vector B extracted from the spectrograph is probably irregular in the sense that the wavelength solution from pixel 1 to pixel 1024 is not linear witch is not the case for the intensity and wavelength base extracted from HITRAN. There the teluric lines are equidistant all over the array for A and for the B vector the may vary a bit over the array on the wave length solution from the pipeline .
> In order to cross-correlate correctly two of the vectors B and the expanded A must be on the same grid is that right?
>
> I have to do the same for the stellar lines synthetic template mask, but ones I am done with this I will do it much more easy!
>
> As I can see in "interpol" program is written "....Linearly interpolate vectors with a regular or IRREGULAR grid."
>
> Witch I am not sure "congrid" does.
> However I have to experiment....
>
> At last I need a function that will keep the nice shape the intensity lines like "congrid" and to be capable to "interpolate" in irregular grids so I can put in the end the two vectors in the same wavelength or pixel grid and to cross-correlate them.
>
> I really hope I was clear.... I will experiment with "congrid" and also with you suggestions Craig...
>
> I hope I will find the answer of my problems alone, but more help is always welcome and appreciate.
You must have wavelength labels, i.e. sample positions, for each spectrum. That is vital information that shows how regularly (or irregularly) the spectrum is sampled. If you are not using this information when you interpolate, no wonder you are getting suspicious results.
INTERPOL is capable of interpolating with an irregular grid. You just need to pass it the sample positions.
Craig
|
|
|