Re: Relative distances between vector elements and search for matches in other vector. [message #80010] |
Thu, 26 April 2012 06:48  |
Tito
Messages: 16 Registered: March 2012
|
Junior Member |
|
|
First of all I want to thank you for you input!
@ David: ratio = xx[0] - xx ... How it is possible to be sooo easy?!?
I corrected this and now looks much better and understandable.
@ Gianguido: a = where( abs(ratio-ratio2[jjj]) LT 0.05 ,count) - this works the same as mine but it is much shorter! thanks for that!
I tested: good=abs(diff) LT 0.05 and count=total(good,2),
And this gives me, indexes of 1 and 0, and I want the indexes of ratio2, like:
0,1,2,4,5,8,9 and i get :
print,good
0,19,38,....719
The loop is working however thats maybe because the first line of the catalog and the first line of the spectrum "this time" are the same. e.g.
ratio = xx[0] - xx
0,-0,17,-0,34.....
and
ratio2 = ddd[0] - ddd
0,-0,1703,-0,22,-0,3403.... so it is easy to identify those differences which pass the (a = where( abs(ratio-ratio2[jjj]) LT 0.05 ,count)) criteria.
in other hand if they are shifted e.g. the first line from catalog is not the first identified line in the spectrum I am having a problem...
My goal is to identify lines from different catalogs with those from my spectrum based on their relative differences(distances) this is necessary because usually the lines from the spectrum are shifted but they have the same ratios between each other ( they might differ slightly) with those from the catalog.
So first I am finding the atmosphere lines on the spectra and what is left is the stellar lines which I will search again in catalog.
This is important for me because
1st. it will be automatic! ,
2nd. the method will be more accurate then if I have to select the lines manually. Sometimes there is 2 or more lines very close to each other and selecting is pain.
Now i probably need something that will find the same space between the two vectors.
I read about histogram from David's website but my head is about to explode.
I am still investigating, how to use 'histogram'...
Lets assume that I identify the telluric lines and now I have only the stellar which I will search from catalog and this time I know that the first line of the spectrum and the catalog are not the same. So I did this:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
selected_dep = [] ; create empty arrays because I want to append (I dont know the result number of array elements)
selected_lines = []
ratio_sel_vald = []
for z = 0L,n_elements(ratio_stlines)-1 do begin
for zz = 0L,n_elements(ratio_stlines)-1 do begin
aa = where( abs((ratio_stlines[zz] - ratio_stlines[z]) - ratio_vald) LT 0.0025, count)
if count gt 0d0 then begin
selected_dep = [selected_dep,z2[aa]]
selected_lines = [selected_lines, z1[aa]]
ratio_sel_vald = [ratio_sel_vald,ratio_vald[aa]]
endif
endfor
endfor
;;;I have to use 'Uniq' because froim this 2 loops I have many Duplicates.
selected_lines = selected_lines[uniq(selected_lines,sort(selected_lines))]
ratio_sel_vald = ratio_sel_vald[uniq(ratio_sel_vald,sort(abs(ratio_sel_vald)) )]
And this is working! if I want to find which lines from the catalog are in my spectra. BUT i want to give to "selected_lines" not the "selected_dep"(depths) which are from the catalog, I want to associate the fonded lines with the depths from the spectra. (- And this is my biggest problem actually I dont know how to do this!)
Later I have to construct synthetic template(spectrum) based on that data, that will have the same depths and profile like those from the spectra BUT different wavelength. Then I will cross-correlate both synthetic mask + spectra in order to find the shift.
Thank you again for your time reading this and trying to help me!
Trifon
|
|
|