Skip to content

Commit 6641fae

Browse files
committed
added 3 new routines; updated 2 routines
1 parent dd40de5 commit 6641fae

5 files changed

Lines changed: 344 additions & 2 deletions

File tree

continuum/two_photon.pro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@
272272
; Ver.26, 07-Dec-2023, Peter Young
273273
; For conversion to keV, I changed indgen to lindgen due to
274274
; errors if there are too many wavelength bins.
275+
;
276+
; Ver.27, 07-Feb-2025, Peter Young
277+
; Now catches error in the case the two photon transition
278+
; doesn't exist.
275279
;-
276280

277281
pro two_photon,temperature,wvl,rad, no_setup=no_setup, $
@@ -582,6 +586,12 @@ for ilist=0,nlist-1 do begin
582586
two_photon=input.two_photon
583587
ENDIF
584588

589+
;
590+
; In case the two_photon transition doesn't exist (this shouldn't
591+
; happen).
592+
;
593+
IF n_tags(two_photon) EQ 0 THEN continue
594+
585595
pop_idx=two_photon.lvl-1
586596

587597
wvl0=1.d+8/(ecm(pop_idx)-ecm(0))

level_population/ch_load_ion_rates.pro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ function ch_load_ion_rates, input, temp, n_lev=n_lev, $
124124
; v.11, 12-May-2023, Peter Young
125125
; Added /quiet for call to proton_dens; message about flipping
126126
; transitions only printed if /verbose set.
127+
; v.12, 12-Feb-2025, Peter Young
128+
; Added a comment about the "mult" paramter. No change to code.
127129
;
128-
; VERSION : 11
130+
; VERSION : 12
129131
;
130132
;-
131133

@@ -272,7 +274,9 @@ endif
272274

273275
IF keyword_set(verbose) THEN print,'% CH_LOAD_ION_RATES: the '+gname+' energy file has '+trim(n_elvl)+' levels'
274276

275-
; Multiplicity:
277+
; Multiplicity:
278+
; PRY, 12-Feb-2025: the variable "mult" has been wrongly named as it
279+
; is not the multiplicity, but the weight.
276280
mult=2.*jj+1.
277281
;
278282
hck=1.98648d-16/1.38062d-16
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
2+
3+
PRO ch_check_all_duplicates, outfile=outfile, quiet=quiet
4+
5+
;+
6+
; NAME:
7+
; CH_CHECK_ALL_DUPLICATES
8+
;
9+
; PURPOSE:
10+
; Goes through the complete set of CHIANTI ions and checks for
11+
; duplicated transitions in the wgfa, scups and rrlvl files.
12+
;
13+
; CATEGORY:
14+
; CHIANTI; validity.
15+
;
16+
; CALLING SEQUENCE:
17+
; CH_CHECK_ALL_DUPLICATES
18+
;
19+
; INPUTS:
20+
; None.
21+
;
22+
; OPTIONAL INPUTS:
23+
; Outfile: The name of a file to send the list of duplicated
24+
; transitions. If not set, they are send to
25+
; ch_duplicates.txt in the working directory.
26+
;
27+
; KEYWORD PARAMETERS:
28+
; QUIET: If set, then no information is written to the IDL window.
29+
;
30+
; OUTPUTS:
31+
; The list of problem files is printed to the IDL window (unless /quiet
32+
; set), and the list of problem transitions is written to
33+
; ch_duplicates.txt (or OUTFILE).
34+
;
35+
; CALLS:
36+
; CH_READ_LIST_IONS, CH_DUPLICATE_TRANSITIONS, CONVERTNAME,
37+
; ZION2FILENAME, Z2ELEMENT
38+
;
39+
; EXAMPLE:
40+
; IDL> ch_check_all_duplicates
41+
;
42+
; MODIFICATION HISTORY:
43+
; Ver.1, 07-Feb-2025, Peter Young
44+
;-
45+
46+
47+
mlist=ch_read_list_ions(count=n)
48+
ions=mlist.list_ions
49+
50+
IF n_elements(outfile) EQ 0 THEN outfile='ch_duplicates.txt'
51+
52+
openw,lout,outfile,/get_lun
53+
54+
problem_files=''
55+
problem_ions=''
56+
57+
file_ext=['.wgfa','.scups','.rrlvl']
58+
n_ext=n_elements(file_ext)
59+
60+
progress,0.0,/reset,label='Progress (%)'
61+
FOR i=0,n-1 DO BEGIN
62+
convertname,ions[i],iz,ion,diel=diel
63+
zion2filename,iz,ion,fname,diel=diel
64+
FOR j=0,n_ext-1 DO BEGIN
65+
d=ch_duplicate_transitions(fname+file_ext[j],status=status,/quiet)
66+
IF status EQ 1 THEN BEGIN
67+
problem_files=[problem_files,file_basename(fname+file_ext[j])]
68+
problem_ions=[problem_ions,ions[i]]
69+
nt=n_elements(d)
70+
printf,lout,fname+file_ext[j]
71+
FOR k=0,nt-1 DO BEGIN
72+
trans=trim(d[k].lvl1)+'-'+trim(d[k].lvl2)
73+
trans=strpad(trans,10,/after,fill=' ')
74+
printf,lout,format='(3x,a10," n_trans: ",i2)',trans,d[k].n_trans
75+
ENDFOR
76+
ENDIF
77+
ENDFOR
78+
progress,100.*float(i+1)/n
79+
ENDFOR
80+
progress,100.,/last
81+
82+
free_lun,lout
83+
84+
IF n_elements(problem_files) GT 1 AND NOT keyword_set(quiet) THEN BEGIN
85+
problem_files=problem_files[1:*]
86+
problem_ions=problem_ions[1:*]
87+
n=n_elements(problem_files)
88+
message,/info,/cont,'There are '+trim(n)+' files with duplicate transitions. They are listed below.'
89+
FOR i=0,n-1 DO BEGIN
90+
convertname,problem_ions[i],iz,ion
91+
z2element,iz-ion+1,seq,/symb
92+
print,' ',problem_files[i]+' ['+seq+' sequence]'
93+
ENDFOR
94+
message,/info,/cont,'Problem transitions are listed in '+outfile+'.'
95+
ENDIF ELSE BEGIN
96+
message,/info,/cont,'There are no files with duplicate transitions!'
97+
ENDELSE
98+
99+
END
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
2+
PRO ch_check_two_photon
3+
4+
;+
5+
; NAME:
6+
; CH_CHECK_TWO_PHOTON
7+
;
8+
; PURPOSE:
9+
; This checks the two photon transitions in the H-like and He-like wgfa
10+
; files to make sure they are present.
11+
;
12+
; CATEGORY:
13+
; CHIANTI; validity.
14+
;
15+
; CALLING SEQUENCE:
16+
; CH_CHECK_TWO_PHOTON
17+
;
18+
; INPUTS:
19+
; None.
20+
;
21+
; OUTPUTS:
22+
; Text messages are printed to the IDL window. If no problems are found,
23+
; then a message stating this will be printed.
24+
;
25+
; EXAMPLE:
26+
; CH_CHECK_TWO_PHOTON
27+
;
28+
; MODIFICATION HISTORY:
29+
; Ver.1, 07-Feb-2025, Peter Young
30+
;-
31+
32+
33+
mlist=ch_read_list_ions(count=n)
34+
mlist=mlist.list_ions
35+
36+
problems=0b
37+
38+
FOR i=0,n-1 DO BEGIN
39+
convertname,mlist[i],iz,ion,diel=diel
40+
;
41+
; H-like ions
42+
;
43+
IF iz-ion EQ 0 AND diel EQ 0 THEN BEGIN
44+
zion2filename,iz,ion,fname
45+
read_elvlc,fname+'.elvlc',elvlc=elvlc
46+
read_wgfa_str,fname+'.wgfa',wgfa,two_photon=two_photon
47+
;
48+
; If the two_photon structure exists then we're OK. Otherwise check if
49+
; the transition exists, but has a non-zero wavelength.
50+
; In case the level index of the 2S1/2 levels changes with ion, then I
51+
; check the elvlc file to get the index.
52+
;
53+
IF n_tags(two_photon) EQ 0 THEN BEGIN
54+
problems=1b
55+
message,/info,/cont,'H-like: no two photon transition for '+mlist[i]+'.'
56+
d=elvlc.data
57+
k=where(d.level EQ '2S1/2' AND d.conf EQ '2s',nk)
58+
IF nk EQ 1 THEN BEGIN
59+
upp_lev=d[k].index
60+
k=where(wgfa.lvl1 EQ 1 AND wgfa.lvl2 EQ upp_lev,nk)
61+
CASE nk OF
62+
0: message,/info,/cont,'H-like: no transitions from 2s 2S1/2 level for '+mlist[i]+'.'
63+
1: BEGIN
64+
IF wgfa[k[0]].wvl NE 0. THEN message,/info,/cont,'H-like: wavelength for 2s 2S1/2 transition for '+mlist[i]+' is not zero!'
65+
END
66+
ELSE: message,/info,/cont,'H-like: more than one transition from 2s 2S1/2 level for '+mlist[i]+'.'
67+
ENDCASE
68+
ENDIF ELSE BEGIN
69+
message,/info,/cont,'H-like: the 2s 2S1/2 level is missing for '+mlist[i]+'.'
70+
ENDELSE
71+
ENDIF
72+
ENDIF
73+
;
74+
; H-like ions
75+
;
76+
IF iz-ion EQ 1 AND diel EQ 0 THEN BEGIN
77+
zion2filename,iz,ion,fname
78+
read_elvlc,fname+'.elvlc',elvlc=elvlc
79+
read_wgfa_str,fname+'.wgfa',wgfa,two_photon=two_photon
80+
;
81+
; If the two_photon structure exists then we're OK. Otherwise check if
82+
; the transition exists, but has a non-zero wavelength.
83+
;
84+
IF n_tags(two_photon) EQ 0 THEN BEGIN
85+
problems=1b
86+
message,/info,/cont,'He-like: no two photon transition for '+mlist[i]+'.'
87+
d=elvlc.data
88+
k=where(d.level EQ '1S0' AND d.index LE 7,nk)
89+
IF nk EQ 1 THEN BEGIN
90+
upp_lev=d[k].index
91+
k=where(wgfa.lvl1 EQ 1 AND wgfa.lvl2 EQ upp_lev,nk)
92+
CASE nk OF
93+
0: message,/info,/cont,'He-like: no transitions from 2s 1S0 level for '+mlist[i]+'.'
94+
1: BEGIN
95+
IF wgfa[k[0]].wvl NE 0. THEN message,/info,/cont,'He-like: wavelength for 2s 1S0 transition for '+mlist[i]+' is not zero!'
96+
END
97+
ELSE: message,/info,/cont,'He-like: more than one transition from 2s 1S0 level for '+mlist[i]+'.'
98+
ENDCASE
99+
ENDIF ELSE BEGIN
100+
message,/info,/cont,'He-like: the 2s 1S0 level is missing for '+mlist[i]+'.'
101+
ENDELSE
102+
ENDIF
103+
ENDIF
104+
105+
ENDFOR
106+
107+
108+
IF ~ problems THEN message,/info,/cont,'The two photon transitions are all present and correct!'
109+
110+
END
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
2+
FUNCTION ch_duplicate_transitions, filename, status=status, quiet=quiet
3+
4+
;+
5+
; NAME:
6+
; CH_DUPLICATE_TRANSITIONS
7+
;
8+
; PURPOSE:
9+
; Checks the specified CHIANTI file to see if there are any transitions
10+
; that are duplicated in the file.
11+
;
12+
; CATEGORY:
13+
; CHIANTI; validity check.
14+
;
15+
; CALLING SEQUENCE:
16+
; Result = CH_DUPLICATE_TRANSITIONS( Filename )
17+
;
18+
; INPUTS:
19+
; Filename: The name of a CHIANTI file to check.
20+
;
21+
; KEYWORD PARAMETERS:
22+
; QUIET: If set, then no information messages are printed to IDL window.
23+
;
24+
; OUTPUTS:
25+
; If status=1, then the output is a structure array with the following
26+
; tags:
27+
; .lvl1 Lower level of duplicate transition.
28+
; .lvl2 Upper level of duplicate transition.
29+
; .n_trans No. of transitions in the file.
30+
;
31+
; For other values of status, the output is the number -1.
32+
;
33+
; OPTIONAL OUTPUTS:
34+
; Status: A byte scalar with the value
35+
; 0 - file exists, and there are no duplicates.
36+
; 1 - file exists, and there are duplicates.
37+
; 2 - file does not exist
38+
; 3 - file exists, but the file is not processed by this routine.
39+
;
40+
; EXAMPLE:
41+
; IDL> output=ch_duplicate_transitions('c_5.wgfa')
42+
;
43+
; MODIFICATION HISTORY:
44+
; Ver.1, 06-Feb-2025, Peter Young
45+
;-
46+
47+
48+
status=0b
49+
50+
chck=file_info(filename)
51+
IF chck.exists EQ 0 THEN BEGIN
52+
IF NOT keyword_set(quiet) THEN message,/info,/cont,'The specified file does not exist. Returning...'
53+
status=2b
54+
return,-1
55+
ENDIF
56+
57+
CASE 1 OF
58+
filename.endswith('wgfa'): BEGIN
59+
read_wgfa_str,filename,wgfa
60+
lvl1=wgfa.lvl1
61+
lvl2=wgfa.lvl2
62+
END
63+
filename.endswith('scups'): BEGIN
64+
read_scups,filename,scups
65+
lvl1=scups.data.lvl1
66+
lvl2=scups.data.lvl2
67+
END
68+
filename.endswith('rrlvl'): BEGIN
69+
rrdata=read_rrlvl(filename.remove(-6),status_rr)
70+
lvl1=rrdata.initial_level
71+
lvl2=rrdata.final_level
72+
END
73+
ELSE: BEGIN
74+
message,/info,/cont,'No matches to the CHIANTI file types. Returning...'
75+
status=3b
76+
return,-1
77+
END
78+
ENDCASE
79+
80+
81+
lvl1_str=trim(lvl1)
82+
lvl1_str=lvl1_str.reverse()
83+
lvl1_str=lvl1_str.insert('0',6,fill='0')
84+
lvl1_str=lvl1_str.substring(0,3)
85+
lvl1_str=lvl1_str.reverse()
86+
87+
lvl2_str=trim(lvl2)
88+
lvl2_str=lvl2_str.reverse()
89+
lvl2_str=lvl2_str.insert('0',6,fill='0')
90+
lvl2_str=lvl2_str.substring(0,3)
91+
lvl2_str=lvl2_str.reverse()
92+
93+
lvl_str=lvl1_str+lvl2_str
94+
n=n_elements(lvl_str)
95+
IF NOT keyword_set(quiet) THEN message,/info,/cont,'There are '+trim(n)+' transitions in the file.'
96+
97+
a=lvl_str[uniq(lvl_str,sort(lvl_str))]
98+
n2=n_elements(a)
99+
IF NOT keyword_set(quiet) THEN message,/info,/cont,'There are '+trim(n2)+' unique transitions in the file.'
100+
101+
IF n NE n2 THEN BEGIN
102+
status=1b
103+
str={ lvl1: 0, lvl2: 0, n_trans: 0}
104+
FOR j=0,n2-1 DO BEGIN
105+
k=where(lvl_str EQ a[j],nk)
106+
IF nk GT 1 THEN BEGIN
107+
str.lvl1=fix(a[j].substring(0,3))
108+
str.lvl2=fix(a[j].substring(4,7))
109+
str.n_trans=nk
110+
IF n_tags(output) EQ 0 THEN output=str ELSE output=[output,str]
111+
ENDIF
112+
ENDFOR
113+
ENDIF ELSE BEGIN
114+
output=-1
115+
ENDELSE
116+
117+
return,output
118+
119+
END

0 commit comments

Comments
 (0)