Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions cherab/openadas/parse/adf15.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
11: 'O',
12: 'Q',
13: 'R',
14: 'T',
15: 'U',
16: 'V',
17: 'W',
18: 'X',
19: 'Y',
20: 'Z',
}


Expand Down Expand Up @@ -109,9 +116,8 @@ def _scrape_metadata_hydrogen(file, element, charge):
lines.pop(0)
index_lines = lines

pec_hydrogen_transition_match = r'^C\s*([0-9]*)\.\s*([0-9]*\.[0-9]*)\s*N=\s*([0-9]*) - N=\s*([0-9]*)\s*([A-Z]*)'
for i in range(len(index_lines)):

pec_hydrogen_transition_match = r'^C\s*([0-9]*)\.\s*([0-9]*\.[0-9]*)\s*N=\s*([0-9]*) - N=\s*([0-9]*)\s*([A-Z]*)'
match = re.match(pec_hydrogen_transition_match, index_lines[i], re.IGNORECASE)
if not match:
continue
Expand All @@ -120,7 +126,7 @@ def _scrape_metadata_hydrogen(file, element, charge):
wavelength = float(match.groups()[1]) / 10 # convert Angstroms to nm
upper_level = int(match.groups()[2])
lower_level = int(match.groups()[3])
rate_type_adas = match.groups()[4]
rate_type_adas = match.groups()[4].upper()
if rate_type_adas == 'EXCIT':
rate_type = 'excitation'
elif rate_type_adas == 'RECOM':
Expand All @@ -147,14 +153,13 @@ def _scrape_metadata_hydrogen_like(file, element, charge):
file.seek(0)
lines = file.readlines()

pec_index_header_match = r'^C\s*ISEL\s*WAVELENGTH\s*TRANSITION\s*TYPE'
pec_index_header_match = r'^C\s*ISEL\s*(?:WAVELENGTH|WVLEN\(A\))\s*TRANSITION\s*TYPE'
while not re.match(pec_index_header_match, lines[0], re.IGNORECASE):
lines.pop(0)
index_lines = lines

pec_full_transition_match = r'^[cC]\s*([0-9]*)\.?\s*([0-9]*\.[0-9]*)\s*([0-9]*)[\(\)\.0-9\s]*-\s*([0-9]*)[\(\)\.0-9\s]*([A-Z]*)'
for i in range(len(index_lines)):

pec_full_transition_match = r'^C\s*([0-9]*)\.\s*([0-9]*\.[0-9]*)\s*([0-9]*)[\(\)\.0-9\s]*-\s*([0-9]*)[\(\)\.0-9\s]*([A-Z]*)'
match = re.match(pec_full_transition_match, index_lines[i], re.IGNORECASE)
if not match:
continue
Expand All @@ -163,7 +168,7 @@ def _scrape_metadata_hydrogen_like(file, element, charge):
wavelength = float(match.groups()[1]) / 10 # convert Angstroms to nm
upper_level = int(match.groups()[2])
lower_level = int(match.groups()[3])
rate_type_adas = match.groups()[4]
rate_type_adas = match.groups()[4].upper()
if rate_type_adas == 'EXCIT':
rate_type = 'excitation'
elif rate_type_adas == 'RECOM':
Expand Down Expand Up @@ -193,18 +198,23 @@ def _scrape_metadata_full(file, element, charge):
configuration_lines = []
configuration_dict = {}

configuration_header_match = r'^C\s*Configuration\s*\(2S\+1\)L\(w-1/2\)\s*Energy \(cm\*\*-1\)$'
configuration_header_match = r'^C\s*(?:lv\s+)?Configuration\s*\(2S\+1\)L\(w-1/2\)\s*Energy\s*\(cm(?:\*\*|\^)-1\)\s*$'
while not re.match(configuration_header_match, lines[0], re.IGNORECASE):
lines.pop(0)
pec_index_header_match = r'^C\s*ISEL\s*WAVELENGTH\s*TRANSITION\s*TYPE'
pec_index_header_match = r'^C\s*ISEL\s*(?:WAVELENGTH|WVLEN\(A\))\s*TRANSITION\s*TYPE'
while not re.match(pec_index_header_match, lines[0], re.IGNORECASE):
configuration_lines.append(lines[0])
lines.pop(0)
index_lines = lines

configuration_string_match = (
r'^[cC]\s*([0-9]+)\s*'
r'((?:[0-9][SPDFG][0-9](?:\s+[0-9][SPDFG][0-9])*)|(?:[0-9A-Z]+))\s*'
r'\(([0-9]*\.?[0-9]+)\)'
r'\s*([0-9]+)'
r'\(\s*([0-9]*\.?[0-9]+)\)'
)
for i in range(len(configuration_lines)):

configuration_string_match = r"^C\s*([0-9]*)\s*((?:[0-9][SPDFG][0-9]\s)*)\s*\(([0-9]*\.?[0-9]*)\)([0-9]*)\(\s*([0-9]*\.?[0-9]*)\)"
match = re.match(configuration_string_match, configuration_lines[i], re.IGNORECASE)
if not match:
continue
Expand All @@ -218,9 +228,8 @@ def _scrape_metadata_full(file, element, charge):
configuration_dict[config_id] = (electron_configuration + " " + spin_multiplicity +
total_orbital_quantum_number + total_angular_momentum_quantum_number)

pec_full_transition_match = r'^[cC]\s*([0-9]*)\.?\s*([0-9]*\.[0-9]*)\s*([0-9]*)[\(\)\.0-9\s]*-\s*([0-9]*)[\(\)\.0-9\s]*([A-Z]*)'
for i in range(len(index_lines)):

pec_full_transition_match = r'^C\s*([0-9]*)\.?\s*([0-9]*\.[0-9]*)\s*([0-9]*)[\(\)\.0-9\s]*-\s*([0-9]*)[\(\)\.0-9\s]*([A-Z]*)'
match = re.match(pec_full_transition_match, index_lines[i], re.IGNORECASE)
if not match:
continue
Expand All @@ -231,7 +240,7 @@ def _scrape_metadata_full(file, element, charge):
upper_level = configuration_dict[upper_level_id]
lower_level_id = int(match.groups()[3])
lower_level = configuration_dict[lower_level_id]
rate_type_adas = match.groups()[4]
rate_type_adas = match.groups()[4].upper()
if rate_type_adas == 'EXCIT':
rate_type = 'excitation'
elif rate_type_adas == 'RECOM':
Expand Down
Loading