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

Home » Public Forums » archive » Relative distances between vector elements and search for matches in other vector.
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
Relative distances between vector elements and search for matches in other vector. [message #80022] Wed, 25 April 2012 07:03 Go to next message
Tito is currently offline  Tito
Messages: 16
Registered: March 2012
Junior Member
Hallo all
I am new in IDL but I am increasing my level everyday and I am so happy that I discover IDL!!!
I stuck very badly in one algorithm that I am developing for my Pipeline.
I am searching for a routine or method to:

1st. define the relative distances between vector elements ( e.g. distances between peaks in the spectrum(allready identified))

2nd. to identify the lines from another vector (bigger or smaller in array size)
based on the criteria of the above (1st.)

E.g.

I have:
RATIO_STLINES FLOAT = Array[21]
0.00000 -0.171038 -0.594733 -1.21922 -1.40923 -1.52994 -1.56168 -1.92495 -2.28294 -2.34803 -2.38444
-3.15909 -3.46812 -3.61399 -3.97221 -4.09896 -4.27114 -4.43637 -5.69552 -6.05595 -6.23174

RATIO_CAT FLOAT = Array[44]
0.00000 -0.209757 -0.249368 -0.930353 -1.05059 -1.21623 -1.21693 -1.74758 -1.75778 -1.77888 -1.78749
-2.03075 -2.22571 -2.99081 -3.29190 -3.31060 -3.42393 -3.43413 -3.43844 -3.44364 -3.59758 -3.61648
-3.76892 -3.80183 -3.92147 -4.26676 -4.53263 -5.02637 -5.31455 -5.35194 -5.52650 -5.59132 -5.75987
-5.81128 -6.60440 -6.68362 -6.71653 -6.73373 -6.81295 -6.95529 -7.23017 -7.48834 -7.66608 -7.90535

And the RATIO_CAT consist the lines from RATIO_STLINES (it is possible not all of them to be in the RATIO_CAT)

So RATIO_STLINES is lets say shifted respect to RATIO_CAT and I want to identify lines based on their line ratios.

I want to mention that I already made a working algorithm but I am 1000 % sure that the more experienced people here can help me to make it much more elegant and efficient. Later on I have a other problem on that I stuck but lets see can you help me on that and it is possible to solve it my self... if not I will post again :(


Here is the code:

;Finding the peak of each line on the spectrum:

peak = peaks(1-chip,0.9) ; finding the peaks from JJohnson IDL.
ddd = xaxis[peak] ;wavelengths of the finded lines.
lines = chip[peak] ;depts of the finded lines.
;xx - HITRAN lines
;z1- VALD catalog wavelengths
;z2 - VALD catalog line depths

;Finding the relative distance between the HITRAN lines (nm):
ratio=fltarr(n_elements(xx))

for j=0L, n_elements(xx)-1 do begin
ratio[j] = xx[0] - xx[j]
endfor

;Finding the relative distance between each line on the spectrum:
ratio2=fltarr(n_elements(ddd))

for jj=0L, n_elements(ddd)-1 do begin
ratio2[jj] = ddd[0] - ddd[jj]
endfor

;Finding the relative distance between the lines from the VALD catalog:
ratio_vald=fltarr(n_elements(z1))

for jjj=0L, n_elements(z1)-1 do begin
ratio_vald[jjj] = z1[0] - z1[jjj]
endfor


; Identify the telluric lines on the spectra. Only stellar lines will be left.
telluric_depts = fltarr(n_elements(xx))
telluric_waves = fltarr(n_elements(xx))
stel_dep = []
stel_wave = []
stel_ra = []
for jjj = 0L, n_elements(ratio2)-1 do begin
a = where((ratio GT (ratio2[jjj] - 0.05)) and (ratio LT (ratio2[jjj] + 0.05)),count)

if count gt 0d0 then begin
telluric_depts[a] = lines[jjj]
telluric_waves[a] = ddd[jjj]
endif

if count le 0d0 then begin
stel_dep =[stel_dep, lines[jjj]]
stel_wave =[stel_wave, ddd[jjj]]
;stel_ra = [stel_ra,ratio2[jjj]]
endif

endfor

;Finding the relative distance between the lines that left from the science spectrum:

ratio_stlines = fltarr(n_elements(stel_wave))
for k = 0L, n_elements(stel_wave) - 1 do begin
ratio_stlines[k] = stel_wave[0] - stel_wave[k]
endfor


And I will stop here because I have more problems below...

Thank you very much in advance!
Re: Relative distances between vector elements and search for matches in other vector. [message #80141 is a reply to message #80022] Sat, 28 April 2012 22:02 Go to previous message
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
I am sorry to say I still don't understand. Overall, I think your example could be simpler, with shorter vectors and fewer significant figures. What's wrong with integers, or 1 sigfig :-) ?

The main thing I don't get is why you have to calculate the shift with respect to each element, and not just the first... and potentially you would want to calculate after shifting each vector differently too? that seems like a big pain. are you sure it's necessary?

Anyway, have you looked into measure_distance() and value_locate()?

Gianguido
Re: Relative distances between vector elements and search for matches in other vector. [message #80143 is a reply to message #80022] Fri, 27 April 2012 07:26 Go to previous message
Tito is currently offline  Tito
Messages: 16
Registered: March 2012
Junior Member
Dear Gianguido,

> In general, I am still confused about what you are trying to do. Could you give a simple example of input and output? Something like
> ;inputs:
> r1=[1,3,3,4,5]
> r2=[2,-1,4,3]

I will try to explain :)

I have this vectors:
Wavelength: (lets call it 'spec = Double[40]')
1572.6780 1573.0127 1573.3506 1573.6405 1573.6990
1573.8116 1574.0538 1574.2353 1574.4169 1574.7384
1574.7856 1574.8598 1575.0498 1575.1705 1575.2022
1575.5655 1575.7488 1575.9235 1575.9886 1576.0250
1576.1455 1576.5514 1576.7996 1576.9631 1577.1086
1577.2545 1577.3844 1577.6127 1577.7395 1577.8119
1577.9117 1578.0769 1578.2476 1578.6911 1579.1422
1579.3361 1579.5977 1579.6965 1579.8723 1580.0659


and :
Depths (lets call it 'dep = Double[40]' which I am going to need later on)
0.37406952 0.24975741 0.36841672 0.72394320 0.39689800
0.85735723 0.45238194 0.88476935 0.47967704 0.57341885
0.69364480 0.71783461 0.90553347 0.85711051 0.82898679
0.45230935 0.79680740 0.81328328 0.86826340 0.89866642
0.63804183 0.50215458 0.70966639 0.44995926 0.77566860
0.46117208 0.44478282 0.56285968 0.69161155 0.44447514
0.89239487 0.63570633 0.40267729 0.39813661 0.36184048
0.88953285 0.36669691 0.88203417 0.86033273 0.45937277


So this is All the peaks (actually minimums) of a spectrum. I have Depths on Y axis and Wavelengths on X axis.

Now there is two types of lines that I want to distinguish from 2 catalogs.

Firs one is:
HITRAN = Double[18] wavelengths:
1572.6598 1572.9920 1573.3317 1573.6790 1574.0339
1574.3965 1574.7667 1575.7256 1576.1226 1576.5273
1576.9396 1577.3596 1577.7872 1578.2224 1578.6653
1579.1158 1579.5739 1580.0395

and the second:
VALD = Double[44] wavelengths:
1573.5713 1573.7811 1573.8207 1574.5017 1574.6219
1574.7876 1574.7883 1575.3189 1575.3291 1575.3502
1575.3588 1575.6021 1575.7971 1576.5622 1576.8632
1576.8819 1576.9953 1577.0055 1577.0098 1577.0150
1577.1689 1577.1878 1577.3403 1577.3732 1577.4928
1577.8381 1578.1040 1578.5977 1578.8859 1578.9233
1579.0978 1579.1627 1579.3312 1579.3826 1580.1757
1580.2550 1580.2879 1580.3051 1580.3843 1580.5266
1580.8015 1581.0597 1581.2374 1581.4767
Now My idea is to find the distances between the lines in the spectrum and in the catalogs and then identify both populations based on their relative distances.

Thanks to David I did this:

;Finding the relative distance bettwen the HITRAN lines (nm):

ratio_hitran = HITRAN[0] - HITRAN

;Finding the relative distance bettwen each line on the spectrum:

ratio_spec = spec[0] - spec

;Finding the relative distance bettwen the lines from the VALD catalog:

ratio_vald = VALD[0] - VALD

And I get this after substracting:

ratio_hitran = 0.0000000 -0.33218057 -0.67191942 -1.0192411 -1.3741670
-1.7367149 -2.1069002 -3.0658462 -3.4628346 -3.8674891
-4.2798071 -4.6997833 -5.1274089 -5.5626720 -6.0055574
-6.4560465 -6.9141175 -7.3797447

ratio_spec = 0.0000000 -0.33465711 -0.67260343 -0.96251210 -1.0209528
-1.1335506 -1.3758041 -1.5572456 -1.7388401 -2.0604169
-2.1075366 -2.1817349 -2.3717436 -2.4924497 -2.5241943
-2.8874598 -3.0707372 -3.2454473 -3.3105429 -3.3469536
-3.4675066 -3.8733788 -4.1215987 -4.2850644 -4.4306307
-4.5765029 -4.7063881 -4.9347199 -5.0614689 -5.1339078
-5.2336548 -5.3988798 -5.5696123 -6.0131190 -6.4641985
-6.6580319 -6.9196382 -7.0184672 -7.1942482 -7.3878522

ratio_vald = 0.0000000 -0.20975704 -0.24936781 -0.93035298 -1.0505857
-1.2162307 -1.2169309 -1.7475752 -1.7577780 -1.7788837
-1.7874861 -2.0307522 -2.2257052 -2.9908133 -3.2918951
-3.3106002 -3.4239310 -3.4341338 -3.4384350 -3.4436364
-3.5975783 -3.6164834 -3.7689249 -3.8018338 -3.9214663
-4.2667602 -4.5326325 -5.0263668 -5.3145451 -5.3519353
-5.5265028 -5.5913204 -5.7598662 -5.8112802 -6.6043959
-6.6836174 -6.7165264 -6.7337311 -6.8129526 -6.9552913
-7.2301661 -7.4883363 -7.6660846 -7.9053497
Now in 'ratio_spec' Some of the relative distances belong to ratio_HITRAN and the rest that are left belong to ratio_VALD(some of them).


Example:
ratio_hitran = 0.0000000 -0.33218057 -0.67191942 -1.0192411 -1.3741670
ratio_spec = 0.0000000 -0.33465711 -0.67260343 -0.9625121 -1.3758041

Are exactly the same lines from the spectra and from catalog( they differ slightly in the +/- 0.05 criteria) but I can identify them based on their distance from the first line.

I Want to do it not only respect to the first line, I want to find lines based on their distances one respect to another ( example: ratio_spec[i] - ratio_spec[i+1] is the same like ratio_vald[k] - ratio_vald[k+4])


Then also tricky is after I identify the catalog lines in to the spectra, to pass them the depths from the spectra. e.g. where I have match on
spec[0:3]:
1572.6780 1573.0127 1573.3506 1573.6405
HITRAN[0:3]:
1572.6598 1572.9920 1573.3317 1573.6790

to give both:
dep[0:3]
0.37406952 0.24975741 0.36841672 0.72394320

and I am able to perform the first step, I am identifying the HITRAN lines and pass them the depts. But this is due to the fact that the first line in 'hitran' and on 'spec' is the same and it is easy. but if this is not the case as it is with the VALD catalog I have no idea how to do it and to pass the depths...


I hope I explain it good.

All the best,
Trifon
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to make an input parameters file??
Next Topic: Time series.

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

Current Time: Thu Oct 09 07:00:45 PDT 2025

Total time taken to generate the page: 0.48024 seconds