From 7c2f6b50641b81319cd6b8f475bcfaf20f57cfd7 Mon Sep 17 00:00:00 2001 From: shimwell Date: Fri, 9 Aug 2019 17:16:49 +0100 Subject: [PATCH 01/15] changed destination so that it matches other libraries format --- convert_jeff32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index 57a6b22..aebde71 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -33,7 +33,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, description=description, formatter_class=CustomFormatter ) -parser.add_argument('-d', '--destination', default='jeff32_hdf5', +parser.add_argument('-d', '--destination', default='jeff-3.2-hdf5', help='Directory to create new library in') parser.add_argument('--download', action='store_true', help='Download files from OECD-NEA') From 877ffc2fa76ef326463e6d3f4bd2c0b945f60edc Mon Sep 17 00:00:00 2001 From: shimwell Date: Fri, 9 Aug 2019 17:21:02 +0100 Subject: [PATCH 02/15] added ace_files_dir which is influence by release version --- convert_jeff32.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index aebde71..cb48154 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -47,9 +47,15 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, default='latest', help="Output HDF5 versioning. Use " "'earliest' for backwards compatibility or 'latest' for " "performance") +parser.add_argument('-r', '--release', choices=['3.2'], + default='3.2', help="The nuclear data library release version. " + "The currently supported options are 3.2") parser.set_defaults(download=True, extract=True) args = parser.parse_args() +library_name = 'jeff' +ace_files_dir = '-'.join([library_name, args.release, 'ace']) + print(download_warning) base_url = 'https://www.oecd-nea.org/dbforms/data/eva/evatapes/jeff_32/Processed/' @@ -82,13 +88,13 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, if f.endswith('.zip'): with zipfile.ZipFile(f, 'r') as zipf: print('Extracting {}...'.format(f)) - zipf.extractall('jeff-3.2') + zipf.extractall(ace_files_dir) else: suffix = 'ACEs_293K' if '293' in f else '' with tarfile.open(f, 'r') as tgz: print('Extracting {}...'.format(f)) - tgz.extractall(os.path.join('jeff-3.2', suffix)) + tgz.extractall(os.path.join(ace_files_dir, suffix)) # Remove thermal scattering tables from 293K data since they are # redundant From 423f817938c25a1702b9499efaf5b068906394f8 Mon Sep 17 00:00:00 2001 From: shimwell Date: Fri, 9 Aug 2019 17:48:03 +0100 Subject: [PATCH 03/15] added release details dict and download warning restrucutred --- convert_jeff32.py | 48 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index cb48154..958e433 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -33,7 +33,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, description=description, formatter_class=CustomFormatter ) -parser.add_argument('-d', '--destination', default='jeff-3.2-hdf5', +parser.add_argument('-d', '--destination', default=None, help='Directory to create new library in') parser.add_argument('--download', action='store_true', help='Download files from OECD-NEA') @@ -50,27 +50,47 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, parser.add_argument('-r', '--release', choices=['3.2'], default='3.2', help="The nuclear data library release version. " "The currently supported options are 3.2") +parser.add_argument('-t', '--temperatures', + choices=['293', '400', '500', '600', '700', '800', '900', + '1000', '1200', '1500', '1800'], + default=['293', '400', '500', '600', '700', '800', '900', + '1000', '1200', '1500', '1800'], + help="Temperatures to download in Kelvin", nargs='+',) parser.set_defaults(download=True, extract=True) args = parser.parse_args() library_name = 'jeff' ace_files_dir = '-'.join([library_name, args.release, 'ace']) +# the destination is decided after the release is know to avoid putting the release in a folder with a misleading name +if args.destination is None: + args.destination = '-'.join([library_name, args.release, 'hdf5']) + +# This dictionary contains all the unique information about each release. This can be exstened to accommodated new releases +release_details = { + '3.2':{ + 'base_url': 'https://www.oecd-nea.org/dbforms/data/eva/evatapes/jeff_32/Processed/', + 'files':['JEFF32-ACE-'+temperature+'K.tar.gz' for temperature in args.temperatures]+['TSLs.tar.gz'], + 'neutron_files': os.path.join(ace_files_dir, '*', '*.ACE'), + 'metastables': os.path.join(ace_files_dir, '**', '*M.ACE'), + 'sab_files': os.path.join(ace_files_dir, 'ANNEX_6_3_STLs', '*', '*.ace'), + 'redundant': os.path.join(ace_files_dir, 'ACEs_293K', '*-293.ACE'), + 'compressed_file_size': '9 GB', + 'uncompressed_file_size': '40 GB' + } +} +download_warning = """ +WARNING: This script will download approximately {} of data. Extracting and +processing the data may require as much as {} of additional free disk +space. + +Are you sure you want to continue? ([y]/n) +""".format(release_details[args.release]['compressed_file_size'], + release_details[args.release]['uncompressed_file_size']) + print(download_warning) -base_url = 'https://www.oecd-nea.org/dbforms/data/eva/evatapes/jeff_32/Processed/' -files = ['JEFF32-ACE-293K.tar.gz', - 'JEFF32-ACE-400K.tar.gz', - 'JEFF32-ACE-500K.tar.gz', - 'JEFF32-ACE-600K.tar.gz', - 'JEFF32-ACE-700K.tar.gz', - 'JEFF32-ACE-800K.zip', - 'JEFF32-ACE-900K.tar.gz', - 'JEFF32-ACE-1000K.tar.gz', - 'JEFF32-ACE-1200K.tar.gz', - 'JEFF32-ACE-1500K.tar.gz', - 'JEFF32-ACE-1800K.tar.gz', - 'TSLs.tar.gz'] + # ============================================================================== # DOWNLOAD FILES FROM OECD SITE From be780c2afd6976bb131f02b8d0321a4bc7da2908 Mon Sep 17 00:00:00 2001 From: shimwell Date: Fri, 9 Aug 2019 18:14:40 +0100 Subject: [PATCH 04/15] changed mkdir statement to be the same as example from convert_jeff33.py --- convert_jeff32.py | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index 958e433..d571b1e 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -18,12 +18,6 @@ """ -download_warning = """ -WARNING: This script will download approximately 9 GB of data. Extracting and -processing the data may require as much as 40 GB of additional free disk -space. Note that if you don't need all 11 temperatures, you can modify the -'files' list in the script to download only the data you want. -""" class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter): @@ -80,30 +74,27 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, } download_warning = """ -WARNING: This script will download approximately {} of data. Extracting and -processing the data may require as much as {} of additional free disk -space. - -Are you sure you want to continue? ([y]/n) +WARNING: This script will download approximately {} GB of data. Extracting and +processing the data may require as much as {} GB of additional free disk +space. Note that if you don't need all 11 temperatures, you can modify the +'files' list in the script to download only the data you want. """.format(release_details[args.release]['compressed_file_size'], release_details[args.release]['uncompressed_file_size']) - -print(download_warning) - +print(download_warning) # ============================================================================== # DOWNLOAD FILES FROM OECD SITE if args.download: - for f in files: - download(urljoin(base_url, f)) + for f in release_details[args.release]['files']: + download(urljoin(release_details[args.release]['base_url'], f)) # ============================================================================== # EXTRACT FILES FROM TGZ if args.extract: - for f in files: + for f in release_details[args.release]['files']: # Extract files if f.endswith('.zip'): with zipfile.ZipFile(f, 'r') as zipf: @@ -119,13 +110,13 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, # Remove thermal scattering tables from 293K data since they are # redundant if '293' in f: - for path in glob.glob(os.path.join('jeff-3.2', 'ACEs_293K', '*-293.ACE')): + for path in glob.glob(release_details[args.release]['redundant']): os.remove(path) # ============================================================================== # CHANGE ZAID FOR METASTABLES -metastables = glob.glob(os.path.join('jeff-3.2', '**', '*M.ACE')) +metastables = glob.glob(release_details[args.release]['metastables']) for path in metastables: print(' Fixing {} (ensure metastable)...'.format(path)) text = open(path, 'r').read() @@ -138,7 +129,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, # GENERATE HDF5 LIBRARY -- NEUTRON FILES # Get a list of all ACE files -neutron_files = glob.glob(os.path.join('jeff-3.2', '*', '*.ACE')) +neutron_files = glob.glob(release_details[args.release]['neutron_files']) # Group together tables for same nuclide tables = defaultdict(list) @@ -153,8 +144,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, x.split(os.path.sep)[1].split('_')[1][:-1])) # Create output directory if it doesn't exist -if not os.path.isdir(args.destination): - os.mkdir(args.destination) +args.destination.mkdir(parents=True, exist_ok=True) library = openmc.data.DataLibrary() @@ -179,7 +169,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, # ============================================================================== # GENERATE HDF5 LIBRARY -- S(A,B) FILES -sab_files = glob.glob(os.path.join('jeff-3.2', 'ANNEX_6_3_STLs', '*', '*.ace')) +sab_files = glob.glob(release_details[args.release]['sab_files']) # Group together tables for same nuclide tables = defaultdict(list) From 48f0ca61b1c081651cee033b1c4d21d55e18a045 Mon Sep 17 00:00:00 2001 From: shimwell Date: Fri, 9 Aug 2019 23:22:10 +0100 Subject: [PATCH 05/15] moved to pathlib from os.path --- convert_jeff32.py | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index d571b1e..f86ca23 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -6,6 +6,7 @@ import tarfile import zipfile from collections import defaultdict +from pathlib import Path from string import digits from urllib.parse import urljoin @@ -27,7 +28,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, description=description, formatter_class=CustomFormatter ) -parser.add_argument('-d', '--destination', default=None, +parser.add_argument('-d', '--destination', type=Path, default=None, help='Directory to create new library in') parser.add_argument('--download', action='store_true', help='Download files from OECD-NEA') @@ -54,27 +55,28 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, args = parser.parse_args() library_name = 'jeff' -ace_files_dir = '-'.join([library_name, args.release, 'ace']) +ace_files_dir = Path('-'.join([library_name, args.release, 'ace'])) # the destination is decided after the release is know to avoid putting the release in a folder with a misleading name if args.destination is None: - args.destination = '-'.join([library_name, args.release, 'hdf5']) + args.destination = Path('-'.join([library_name, args.release, 'hdf5'])) # This dictionary contains all the unique information about each release. This can be exstened to accommodated new releases release_details = { '3.2':{ 'base_url': 'https://www.oecd-nea.org/dbforms/data/eva/evatapes/jeff_32/Processed/', - 'files':['JEFF32-ACE-'+temperature+'K.tar.gz' for temperature in args.temperatures]+['TSLs.tar.gz'], - 'neutron_files': os.path.join(ace_files_dir, '*', '*.ACE'), - 'metastables': os.path.join(ace_files_dir, '**', '*M.ACE'), - 'sab_files': os.path.join(ace_files_dir, 'ANNEX_6_3_STLs', '*', '*.ace'), - 'redundant': os.path.join(ace_files_dir, 'ACEs_293K', '*-293.ACE'), + 'files':['JEFF32-ACE-'+temperature+'K.tar.gz' for temperature in args.temperatures] + +['TSLs.tar.gz'], + 'neutron_files':ace_files_dir.rglob('*.ACE'), + 'metastables': ace_files_dir.rglob('*M.ACE'), + 'sab_files': ace_files_dir.glob('ANNEX_6_3_STLs/*/*.ace'), + 'redundant': ace_files_dir.glob('ACEs_293K/*-293.ACE'), 'compressed_file_size': '9 GB', 'uncompressed_file_size': '40 GB' } } download_warning = """ -WARNING: This script will download approximately {} GB of data. Extracting and +WARNING: This script will download up to {} GB of data. Extracting and processing the data may require as much as {} GB of additional free disk space. Note that if you don't need all 11 temperatures, you can modify the 'files' list in the script to download only the data you want. @@ -105,18 +107,19 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, suffix = 'ACEs_293K' if '293' in f else '' with tarfile.open(f, 'r') as tgz: print('Extracting {}...'.format(f)) - tgz.extractall(os.path.join(ace_files_dir, suffix)) + tgz.extractall(ace_files_dir.joinpath(suffix)) # Remove thermal scattering tables from 293K data since they are # redundant if '293' in f: - for path in glob.glob(release_details[args.release]['redundant']): + for path in release_details[args.release]['redundant']: + print('removing ', path) os.remove(path) # ============================================================================== # CHANGE ZAID FOR METASTABLES -metastables = glob.glob(release_details[args.release]['metastables']) +metastables = release_details[args.release]['metastables'] for path in metastables: print(' Fixing {} (ensure metastable)...'.format(path)) text = open(path, 'r').read() @@ -129,17 +132,17 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, # GENERATE HDF5 LIBRARY -- NEUTRON FILES # Get a list of all ACE files -neutron_files = glob.glob(release_details[args.release]['neutron_files']) +neutron_files = release_details[args.release]['neutron_files'] # Group together tables for same nuclide tables = defaultdict(list) for filename in sorted(neutron_files): - dirname, basename = os.path.split(filename) - name = basename.split('.')[0] - tables[name].append(filename) + name = filename.stem + tables[name].append(filename.as_posix()) # Sort temperatures from lowest to highest for name, filenames in sorted(tables.items()): + print(filenames) filenames.sort(key=lambda x: int( x.split(os.path.sep)[1].split('_')[1][:-1])) @@ -159,7 +162,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, data.add_temperature_from_ace(filename) # Export HDF5 file - h5_file = os.path.join(args.destination, data.name + '.h5') + h5_file = args.destination.joinpath(data.name + '.h5') print('Writing {}...'.format(h5_file)) data.export_to_hdf5(h5_file, 'w', libver=args.libver) @@ -169,14 +172,12 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, # ============================================================================== # GENERATE HDF5 LIBRARY -- S(A,B) FILES -sab_files = glob.glob(release_details[args.release]['sab_files']) - # Group together tables for same nuclide tables = defaultdict(list) -for filename in sorted(sab_files): +for filename in sorted(release_details[args.release]['sab_files']): dirname, basename = os.path.split(filename) name = basename.split('-')[0] - tables[name].append(filename) + tables[name].append(filename.as_posix()) # Sort temperatures from lowest to highest for name, filenames in sorted(tables.items()): @@ -202,7 +203,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, data.add_temperature_from_ace(table) # Export HDF5 file - h5_file = os.path.join(args.destination, data.name + '.h5') + h5_file = args.destination.joinpath(data.name + '.h5') print('Writing {}...'.format(h5_file)) data.export_to_hdf5(h5_file, 'w', libver=args.libver) @@ -210,5 +211,4 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, library.register_file(h5_file) # Write cross_sections.xml -libpath = os.path.join(args.destination, 'cross_sections.xml') -library.export_to_xml(libpath) +library.export_to_xml(args.destination.joinpath('cross_sections.xml')) From d86dca74ee4e35cf5e07b7ee0742a36df76695e8 Mon Sep 17 00:00:00 2001 From: shimwell Date: Fri, 9 Aug 2019 23:43:15 +0100 Subject: [PATCH 06/15] removed unnecessary print statement --- convert_jeff32.py | 1 - 1 file changed, 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index f86ca23..b3a249a 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -142,7 +142,6 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, # Sort temperatures from lowest to highest for name, filenames in sorted(tables.items()): - print(filenames) filenames.sort(key=lambda x: int( x.split(os.path.sep)[1].split('_')[1][:-1])) From b8caa55d7b4348f786a4081b3033b7cff887325b Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 12 Aug 2019 19:37:59 +0100 Subject: [PATCH 07/15] review suggestion filename build method Co-Authored-By: Paul Romano --- convert_jeff32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index b3a249a..c67ea55 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -161,7 +161,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, data.add_temperature_from_ace(filename) # Export HDF5 file - h5_file = args.destination.joinpath(data.name + '.h5') + h5_file = args.destination / f'{data.name}.h5' print('Writing {}...'.format(h5_file)) data.export_to_hdf5(h5_file, 'w', libver=args.libver) From 1f33cde564bb88dd09fbb544b2823caa1f6f8678 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 12 Aug 2019 19:38:19 +0100 Subject: [PATCH 08/15] review suggestion filename method change Co-Authored-By: Paul Romano --- convert_jeff32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index c67ea55..08049b0 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -202,7 +202,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, data.add_temperature_from_ace(table) # Export HDF5 file - h5_file = args.destination.joinpath(data.name + '.h5') + h5_file = args.destination / f'{data.name}.h5' print('Writing {}...'.format(h5_file)) data.export_to_hdf5(h5_file, 'w', libver=args.libver) From 15d004871ed52d38e28f696a13774ff791f4fc2d Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 12 Aug 2019 19:40:13 +0100 Subject: [PATCH 09/15] review suggestion files construction changed Co-Authored-By: Paul Romano --- convert_jeff32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index 08049b0..e3c3c37 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -64,7 +64,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, release_details = { '3.2':{ 'base_url': 'https://www.oecd-nea.org/dbforms/data/eva/evatapes/jeff_32/Processed/', - 'files':['JEFF32-ACE-'+temperature+'K.tar.gz' for temperature in args.temperatures] + 'files': [f'JEFF32-ACE-{temperature}K.tar.gz' for temperature in args.temperatures] +['TSLs.tar.gz'], 'neutron_files':ace_files_dir.rglob('*.ACE'), 'metastables': ace_files_dir.rglob('*M.ACE'), From 2d61bcc321f845485fe8f0ac446b33c490b95b8a Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 12 Aug 2019 19:41:24 +0100 Subject: [PATCH 10/15] review suggestion / instead of joinpath Co-Authored-By: Paul Romano --- convert_jeff32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index e3c3c37..833f833 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -107,7 +107,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, suffix = 'ACEs_293K' if '293' in f else '' with tarfile.open(f, 'r') as tgz: print('Extracting {}...'.format(f)) - tgz.extractall(ace_files_dir.joinpath(suffix)) + tgz.extractall(ace_files_dir / suffix) # Remove thermal scattering tables from 293K data since they are # redundant From 4cd2dc3849ab58cf4b72fefbd68f0278779e9bdc Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 12 Aug 2019 19:41:48 +0100 Subject: [PATCH 11/15] review suggestion str instead of posix Co-Authored-By: Paul Romano --- convert_jeff32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index 833f833..5c9f5be 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -138,7 +138,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, tables = defaultdict(list) for filename in sorted(neutron_files): name = filename.stem - tables[name].append(filename.as_posix()) + tables[name].append(str(filename)) # Sort temperatures from lowest to highest for name, filenames in sorted(tables.items()): From 2359dcbf9273be82045797d563e7079e5c55183b Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 12 Aug 2019 19:43:30 +0100 Subject: [PATCH 12/15] review suggestion string formatting Co-Authored-By: Paul Romano --- convert_jeff32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index 5c9f5be..7d1828a 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -113,7 +113,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, # redundant if '293' in f: for path in release_details[args.release]['redundant']: - print('removing ', path) + print(f'removing {path}') os.remove(path) # ============================================================================== From 82dcb68acea581ec3ddd849694bd1160a12b0d36 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 12 Aug 2019 19:43:56 +0100 Subject: [PATCH 13/15] review suggestion str instead of posix Co-Authored-By: Paul Romano --- convert_jeff32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index 7d1828a..14a663b 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -176,7 +176,7 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, for filename in sorted(release_details[args.release]['sab_files']): dirname, basename = os.path.split(filename) name = basename.split('-')[0] - tables[name].append(filename.as_posix()) + tables[name].append(str(filename)) # Sort temperatures from lowest to highest for name, filenames in sorted(tables.items()): From 17318df1a258099474cfcf11750de8553fd2fcf1 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 12 Aug 2019 19:44:20 +0100 Subject: [PATCH 14/15] review suggestion \ instead of joinpath Co-Authored-By: Paul Romano --- convert_jeff32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index 14a663b..4b97aaf 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -210,4 +210,4 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, library.register_file(h5_file) # Write cross_sections.xml -library.export_to_xml(args.destination.joinpath('cross_sections.xml')) +library.export_to_xml(args.destination / 'cross_sections.xml') From 8cbfbfba65dad28e9cd50de2c1ec2a70838475d4 Mon Sep 17 00:00:00 2001 From: shimwell Date: Mon, 12 Aug 2019 20:16:57 +0100 Subject: [PATCH 15/15] fixed filenames to account for odd 800k zip file --- convert_jeff32.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/convert_jeff32.py b/convert_jeff32.py index 4b97aaf..8893255 100755 --- a/convert_jeff32.py +++ b/convert_jeff32.py @@ -64,8 +64,8 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, release_details = { '3.2':{ 'base_url': 'https://www.oecd-nea.org/dbforms/data/eva/evatapes/jeff_32/Processed/', - 'files': [f'JEFF32-ACE-{temperature}K.tar.gz' for temperature in args.temperatures] - +['TSLs.tar.gz'], + 'files': [f'JEFF32-ACE-{t}K.zip' if t=='800' else f'JEFF32-ACE-{t}K.tar.gz' for t in args.temperatures] + +['TSLs.tar.gz'], 'neutron_files':ace_files_dir.rglob('*.ACE'), 'metastables': ace_files_dir.rglob('*M.ACE'), 'sab_files': ace_files_dir.glob('ANNEX_6_3_STLs/*/*.ace'), @@ -78,17 +78,16 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, download_warning = """ WARNING: This script will download up to {} GB of data. Extracting and processing the data may require as much as {} GB of additional free disk -space. Note that if you don't need all 11 temperatures, you can modify the -'files' list in the script to download only the data you want. +space. Note that if you don't need all 11 temperatures, you can used the +--temperature argument to download only the temperatures you want. """.format(release_details[args.release]['compressed_file_size'], release_details[args.release]['uncompressed_file_size']) -print(download_warning) - # ============================================================================== # DOWNLOAD FILES FROM OECD SITE if args.download: + print(download_warning) for f in release_details[args.release]['files']: download(urljoin(release_details[args.release]['base_url'], f))