Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import cross sections from csv #41

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0a0270c
add test for process_pdos
Jun 23, 2021
d5c8552
fix the imports
Yaxuan-Lii Jun 29, 2021
553738f
removeed irrelevant files
Yaxuan-Lii Jul 1, 2021
5300d62
import is fixed
Yaxuan-Lii Jul 1, 2021
dab091b
try to remove irrelevant fils second time
Yaxuan-Lii Jul 1, 2021
d69d61b
remove irrelevant files second time
Yaxuan-Lii Jul 1, 2021
7984c15
delet irrelevant files
Yaxuan-Lii Jul 1, 2021
66b1c6f
remove irrelevant files
Yaxuan-Lii Jul 1, 2021
4fdafa7
delete .DS_Store
Yaxuan-Lii Jul 1, 2021
dca2d49
Modified test_process_pdos.py
Yaxuan-Lii Jul 2, 2021
eb079f6
add test.py
Yaxuan-Lii Jul 2, 2021
8190183
Restore some files that were accidentally deleted
ajjackson Jul 2, 2021
946efaa
use flake8 to optimise format
Yaxuan-Lii Jul 5, 2021
cd0f3c0
import cross-sections from CSV archives
Yaxuan-Lii Jul 15, 2021
8f48e5e
form modify
Yaxuan-Lii Jul 17, 2021
a959150
modify follow the comments
Yaxuan-Lii Jul 21, 2021
067c289
make corrections
Yaxuan-Lii Jul 21, 2021
a621ab0
make correction
Yaxuan-Lii Jul 21, 2021
13911d0
Revert changes to galore/__init__.py
ajjackson Jul 21, 2021
4fb993d
modified as comments
Yaxuan-Lii Aug 2, 2021
cd4dc0e
merge the change of galore/__init__.py
Yaxuan-Lii Aug 2, 2021
5c9c31c
add cli to install data and get cross sections
Yaxuan-Lii Aug 9, 2021
b138c4b
merge get_cross_sections_from_csv into get_cross_sections
Yaxuan-Lii Aug 10, 2021
bb8a526
modify and add new test
Yaxuan-Lii Aug 24, 2021
5cdb67b
add a IF statement
Yaxuan-Lii Aug 31, 2021
39651d5
modify as comments
Yaxuan-Lii Sep 9, 2021
a2441b5
modify as comments
Yaxuan-Lii Sep 9, 2021
f59b50a
mistakes fix
Yaxuan-Lii Sep 12, 2021
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
42 changes: 38 additions & 4 deletions galore/cli/galore_get_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,64 @@
from argparse import ArgumentParser
import galore.cross_sections


def main():
parser = get_parser()
args = parser.parse_args()
args = vars(args)
run(**args)


def get_parser():
parser = ArgumentParser()
# parser.add_argument('energy', type=str,
# help="""
# Photon energy, expressed as source type: "he2" for He (II), "alka" for
# Al k-alpha, (values from Yeh/Lindau (1985)) or as energy in keV (values
# from polynomial fit to Scofield (1973)).""")
# parser.add_argument('elements', type=str, nargs='+', help="""
# Space-separated symbols for elements in material.""")

parser.add_argument('energy', type=str,
help="""
If you don't input dataset:
Photon energy, expressed as source type: "he2" for He (II), "alka" for
Al k-alpha, (values from Yeh/Lindau (1985)) or as energy in keV (values
from polynomial fit to Scofield (1973)).""")
parser.add_argument('elements', type=str, nargs='+', help="""
from polynomial fit to Scofield (1973)).
if you input dataset:
Photon energy, 1 to 1500keV for Scofield dataset, 10.2 to 8047.8 eV for Yeh dataset""")

parser.add_argument('elements', nargs='+',
help="""
Space-separated symbols for elements in material.""")

parser.add_argument('--dataset', type=str.lower, choices=['scofield', 'yeh'],
help="""Accepted values are 'Scofield' and 'Yeh """)

return parser

def run(energy, elements):
cross_sections = galore.get_cross_sections(energy, elements)

def run(energy, elements, dataset=None):
cross_sections = galore.get_cross_sections(energy, elements, dataset)
logging = galore.cross_sections.cross_sections_info(cross_sections)

# some input will lead to None cross sections result
if cross_sections is None:
logging.warning("The cross section is None, please check the input")

# inform user the closest energy of input
if dataset != None:
logging.warning('The closest energy of input is {energy}'.format(
energy=cross_sections['energy']))

# inform user if energy input is out of range
if dataset.lower() == 'scofield' and float(energy) > 1500:
logging.warning('The maximum energy of Scofield is 1500 keV')

logging.info("Photoionisation cross sections per electron:")

for element in elements:

if 'warning' in cross_sections[element]:
logging.warning(" {0}: {1}".format(
element, cross_sections[element]['warning']))
Expand Down
31 changes: 31 additions & 0 deletions galore/cli/galore_install_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import logging
from argparse import ArgumentParser
import galore.cross_sections


def main():
parser = get_parser()
args = parser.parse_args()
args = vars(args)
run(**args)


def get_parser():
parser = ArgumentParser()
parser.add_argument('dataset', type=str.lower, choices= ['scofield','yeh'],
help=""" Accepted values are 'Scofield' and 'Yeh'""")

return parser


def run(dataset):
if dataset.lower() == 'scofield' or dataset.lower() == 'yeh':

url, data_file_dir, data_file_path = galore.cross_sections.get_csv_file_path(
dataset)
galore.cross_sections.galore_install_data(
url, data_file_dir, data_file_path)

else:
print("Dataset '{dataset}' was not recognised. Accepted values are 'Scofield' and 'Yeh'.".format(dataset = dataset))

Loading