From 7e65bcbbcfc108cade5246f30f06239f6299f1c4 Mon Sep 17 00:00:00 2001 From: akremin Date: Thu, 19 Sep 2024 21:49:48 -0400 Subject: [PATCH] rename desi_reformat_proctables and desi_reformat_exptables --- bin/desi_reformat_exposure_tables | 40 ---------------------- bin/desi_reformat_exptables | 12 +++++++ bin/desi_reformat_processing_tables | 33 ------------------ bin/desi_reformat_proctables | 14 ++++++++ py/desispec/scripts/reformat_exptables.py | 28 +++++++++++++-- py/desispec/scripts/reformat_proctables.py | 31 +++++++++++++---- 6 files changed, 76 insertions(+), 82 deletions(-) delete mode 100755 bin/desi_reformat_exposure_tables create mode 100755 bin/desi_reformat_exptables delete mode 100755 bin/desi_reformat_processing_tables create mode 100755 bin/desi_reformat_proctables diff --git a/bin/desi_reformat_exposure_tables b/bin/desi_reformat_exposure_tables deleted file mode 100755 index e651dd34a..000000000 --- a/bin/desi_reformat_exposure_tables +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -import argparse - -## Import some helper functions, you can see their definitions by uncomenting the bash shell command -from desispec.scripts.reformat_exptables import update_exposure_tables - - -def get_parser(): - """ - Creates an arguments parser for the desi_reformat_exposure_tables script - """ - parser = argparse.ArgumentParser(usage = "{prog} [options]") - parser.add_argument("-n", "--nights", type=str, default=None, help="nights as comma separated string") - parser.add_argument("--night-range", type=str, default=None, help="comma separated pair of nights in form YYYYMMDD,YYYYMMDD"+\ - "for first_night,last_night specifying the beginning"+\ - "and end of a range of nights to be generated. "+\ - "last_night should be inclusive.") - parser.add_argument("--obstypes", type=str, default=None, help="comma separated list of exposure types to include in "+\ - "the exposure table, e.g. science,arc,flat,dark,zero, ...") - parser.add_argument("-i", "--path-to-data", type=str, default=None, help="path to the raw input data") - parser.add_argument("-o","--exp-table-path", type=str, default=None, help="path to save exposure tables, without monthly subdirectory") - parser.add_argument("--orig-filetype", type=str, default='csv', help="format type for original exposure tables") - parser.add_argument("--out-filetype", type=str, default='csv', help="format type for output exposure tables") - parser.add_argument("--verbose", action="store_true", help="print verbose output") - parser.add_argument("--dry-run", action="store_true", - help="Perform a dry run, printing the changes that would be made and the final output table "+ - "but not overwriting the actual files on disk.") - parser.add_argument("--no-specprod", action="store_true", help="Create exposure table in repository location "+\ - "rather than the SPECPROD location.") - return parser - - - -if __name__ == '__main__': - parser = get_parser() - args = parser.parse_args() - - update_exposure_tables(**args.__dict__) \ No newline at end of file diff --git a/bin/desi_reformat_exptables b/bin/desi_reformat_exptables new file mode 100755 index 000000000..8852bd9c1 --- /dev/null +++ b/bin/desi_reformat_exptables @@ -0,0 +1,12 @@ +#!/usr/bin/env python +# coding: utf-8 + +## Import some helper functions, you can see their definitions by uncomenting the bash shell command +from desispec.scripts.reformat_exptables import get_parser, reformat_exposure_tables + + +if __name__ == '__main__': + parser = get_parser() + args = parser.parse_args() + + reformat_exposure_tables(**args.__dict__) \ No newline at end of file diff --git a/bin/desi_reformat_processing_tables b/bin/desi_reformat_processing_tables deleted file mode 100755 index d020dfd7f..000000000 --- a/bin/desi_reformat_processing_tables +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -import argparse - -## Import some helper functions, you can see their definitions by uncomenting the bash shell command -from desispec.scripts.reformat_proctables import update_processing_tables - - -def get_parser(): - """ - Creates an arguments parser for the desi_reformat_processing_tables script - """ - parser = argparse.ArgumentParser(usage = "{prog} [options]") - parser.add_argument("-n", "--nights", type=str, default=None, help="nights as comma separated string") - parser.add_argument("--night-range", type=str, default=None, help="comma separated pair of nights in form YYYYMMDD,YYYYMMDD"+\ - "for first_night,last_night specifying the beginning"+\ - "and end of a range of nights to be generated. "+\ - "last_night should be inclusive.") - parser.add_argument("--orig-filetype", type=str, default='csv', help="format type for original exposure tables") - parser.add_argument("--out-filetype", type=str, default='csv', help="format type for output exposure tables") - parser.add_argument("--dry-run", action="store_true", - help="Perform a dry run, printing the changes that would be made and the final output table "+ - "but not overwriting the actual files on disk.") - return parser - - - -if __name__ == '__main__': - parser = get_parser() - args = parser.parse_args() - - update_processing_tables(**args.__dict__) \ No newline at end of file diff --git a/bin/desi_reformat_proctables b/bin/desi_reformat_proctables new file mode 100755 index 000000000..ed4e8107e --- /dev/null +++ b/bin/desi_reformat_proctables @@ -0,0 +1,14 @@ +#!/usr/bin/env python +# coding: utf-8 + +## Import some helper functions, you can see their definitions by uncomenting the bash shell command +from desispec.scripts.reformat_proctables import get_parser, reformat_processing_tables + + + + +if __name__ == '__main__': + parser = get_parser() + args = parser.parse_args() + + reformat_processing_tables(**args.__dict__) \ No newline at end of file diff --git a/py/desispec/scripts/reformat_exptables.py b/py/desispec/scripts/reformat_exptables.py index 115bd10ac..b5f0a3eae 100644 --- a/py/desispec/scripts/reformat_exptables.py +++ b/py/desispec/scripts/reformat_exptables.py @@ -1,8 +1,9 @@ """ -desispec.scripts.updateexptables +desispec.scripts.reformat_exptables ================================ """ +import argparse import os import sys import numpy as np @@ -20,8 +21,31 @@ from desispec.scripts.exposuretable import create_exposure_tables +def get_parser(): + """ + Creates an arguments parser for the desi_reformat_exposure_tables script + """ + parser = argparse.ArgumentParser(usage = "{prog} [options]") + parser.add_argument("-n", "--nights", type=str, default=None, help="nights as comma separated string") + parser.add_argument("--night-range", type=str, default=None, help="comma separated pair of nights in form YYYYMMDD,YYYYMMDD"+\ + "for first_night,last_night specifying the beginning"+\ + "and end of a range of nights to be generated. "+\ + "last_night should be inclusive.") + parser.add_argument("--obstypes", type=str, default=None, help="comma separated list of exposure types to include in "+\ + "the exposure table, e.g. science,arc,flat,dark,zero, ...") + parser.add_argument("-i", "--path-to-data", type=str, default=None, help="path to the raw input data") + parser.add_argument("-o","--exp-table-path", type=str, default=None, help="path to save exposure tables, without monthly subdirectory") + parser.add_argument("--orig-filetype", type=str, default='csv', help="format type for original exposure tables") + parser.add_argument("--out-filetype", type=str, default='csv', help="format type for output exposure tables") + parser.add_argument("--verbose", action="store_true", help="print verbose output") + parser.add_argument("--dry-run", action="store_true", + help="Perform a dry run, printing the changes that would be made and the final output table "+ + "but not overwriting the actual files on disk.") + parser.add_argument("--no-specprod", action="store_true", help="Create exposure table in repository location "+\ + "rather than the SPECPROD location.") + return parser -def update_exposure_tables(nights=None, night_range=None, path_to_data=None, +def reformat_exposure_tables(nights=None, night_range=None, path_to_data=None, exp_table_path=None, obstypes=None, orig_filetype='csv', out_filetype='csv', verbose=False, no_specprod=False, dry_run=False): diff --git a/py/desispec/scripts/reformat_proctables.py b/py/desispec/scripts/reformat_proctables.py index d511e1523..097d9c237 100644 --- a/py/desispec/scripts/reformat_proctables.py +++ b/py/desispec/scripts/reformat_proctables.py @@ -1,8 +1,9 @@ """ -desispec.scripts.updateexptables +desispec.scripts.reformat_proctables ================================ """ +import argparse import os import glob import sys @@ -19,8 +20,24 @@ from desispec.scripts.exposuretable import create_exposure_tables - -def update_processing_tables(nights=None, night_range=None, orig_filetype='csv', +def get_parser(): + """ + Creates an arguments parser for the desi_reformat_processing_tables script + """ + parser = argparse.ArgumentParser(usage = "{prog} [options]") + parser.add_argument("-n", "--nights", type=str, default=None, help="nights as comma separated string") + parser.add_argument("--night-range", type=str, default=None, help="comma separated pair of nights in form YYYYMMDD,YYYYMMDD"+\ + "for first_night,last_night specifying the beginning"+\ + "and end of a range of nights to be generated. "+\ + "last_night should be inclusive.") + parser.add_argument("--orig-filetype", type=str, default='csv', help="format type for original exposure tables") + parser.add_argument("--out-filetype", type=str, default='csv', help="format type for output exposure tables") + parser.add_argument("--dry-run", action="store_true", + help="Perform a dry run, printing the changes that would be made and the final output table "+ + "but not overwriting the actual files on disk.") + return parser + +def reformat_processing_tables(nights=None, night_range=None, orig_filetype='csv', out_filetype='csv', dry_run=False): """ Generates updated processing tables for the nights requested. Requires @@ -28,15 +45,15 @@ def update_processing_tables(nights=None, night_range=None, orig_filetype='csv', Args: nights: str, int, or comma separated list. The night(s) to generate - procesing tables for. + processing tables for. night_range: str. comma separated pair of nights in form YYYYMMDD,YYYYMMDD for first_night,last_night specifying the beginning and end of a range of nights to be generated. first_night and last_night are inclusive. - orig_filetype: str. The file extension (without the '.') of the exposure + orig_filetype: str. The file extension (without the '.') of the processing tables. - out_filetype: str. The file extension for the outputted exposure tables + out_filetype: str. The file extension for the outputted processing tables (without the '.'). Returns: @@ -174,4 +191,4 @@ def update_processing_tables(nights=None, night_range=None, orig_filetype='csv', ## Flush the outputs sys.stdout.flush() sys.stderr.flush() - print("Exposure table regenerations complete") + print("Processing table regenerations complete")