From 14e1225c7341e82293984e93034788236fb9041b Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 8 Aug 2022 13:41:16 -0500 Subject: [PATCH 1/4] added a little debug output to clock export --- src/pint/observatory/topo_obs.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pint/observatory/topo_obs.py b/src/pint/observatory/topo_obs.py index 29b2f5b34..1b5c4ffc4 100644 --- a/src/pint/observatory/topo_obs.py +++ b/src/pint/observatory/topo_obs.py @@ -350,16 +350,25 @@ def export_all_clock_files(directory): """ directory = Path(directory) if pint.observatory._gps_clock is not None: + log.debug( + f"Exporting GPS clock file to {directory / Path(pint.observatory._gps_clock.filename).name}" + ) pint.observatory._gps_clock.export( directory / Path(pint.observatory._gps_clock.filename).name ) for version, clock in pint.observatory._bipm_clock_versions.items(): + log.debug( + f"Exporting BIPM ({version}) clock file to {directory / Path(clock.filename).name}" + ) clock.export(directory / Path(clock.filename).name) for name in Observatory.names(): o = get_observatory(name) if hasattr(o, "_clock") and o._clock is not None: for clock in o._clock: if clock.filename is not None: + log.debug( + f"Exporting clock file for {o.name} to {directory / Path(clock.filename).name}" + ) clock.export(directory / Path(clock.filename).name) From 301d28b8359faaf5ec8fbc06e549446aaa3cf3f5 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 8 Aug 2022 13:41:32 -0500 Subject: [PATCH 2/4] script to export clock info --- setup.cfg | 1 + src/pint/scripts/export_clocks.py | 50 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/pint/scripts/export_clocks.py diff --git a/setup.cfg b/setup.cfg index be00d71ad..d7aef2b17 100644 --- a/setup.cfg +++ b/setup.cfg @@ -57,6 +57,7 @@ console_scripts = pintk = pint.scripts.pintk:main convert_parfile = pint.scripts.convert_parfile:main compare_parfiles = pint.scripts.compare_parfiles:main + export_clocks = pint.scripts.export_clocks:main # See the docstring in versioneer.py for instructions. Note that you must diff --git a/src/pint/scripts/export_clocks.py b/src/pint/scripts/export_clocks.py new file mode 100644 index 000000000..8811a0afd --- /dev/null +++ b/src/pint/scripts/export_clocks.py @@ -0,0 +1,50 @@ +import argparse +import os +import sys + +import pint.logging +from loguru import logger as log + +pint.logging.setup(level=pint.logging.script_level) + +import pint.observatory +import pint.observatory.topo_obs + +__all__ = ["main"] + + +def main(argv=None): + parser = argparse.ArgumentParser( + description="PINT tool for export clock files", + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + ) + parser.add_argument( + "observatories", help="Observatories to export", type=str, nargs="+" + ) + parser.add_argument( + "-o", + "--out", + default=os.path.abspath(os.curdir), + type=str, + dest="directory", + help="Destination directory", + ) + parser.add_argument( + "--log-level", + type=str, + choices=("TRACE", "DEBUG", "INFO", "WARNING", "ERROR"), + default="WARNING", + help="Logging level", + dest="loglevel", + ) + args = parser.parse_args(argv) + pint.logging.setup(level=args.loglevel) + if not os.path.isdir(args.directory): + log.error(f"Destination {args.directory} is not a directory") + sys.exit(1) + + for obsname in args.observatories: + obs = pint.observatory.get_observatory(obsname) + obs._load_clock_corrections() + + pint.observatory.topo_obs.export_all_clock_files(os.path.abspath(os.curdir)) From e6c8a60203f80ec5bc4586e6971cec85a6534ae2 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 8 Aug 2022 13:45:59 -0500 Subject: [PATCH 3/4] fixed dir specification --- src/pint/scripts/export_clocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pint/scripts/export_clocks.py b/src/pint/scripts/export_clocks.py index 8811a0afd..9ac569812 100644 --- a/src/pint/scripts/export_clocks.py +++ b/src/pint/scripts/export_clocks.py @@ -47,4 +47,4 @@ def main(argv=None): obs = pint.observatory.get_observatory(obsname) obs._load_clock_corrections() - pint.observatory.topo_obs.export_all_clock_files(os.path.abspath(os.curdir)) + pint.observatory.topo_obs.export_all_clock_files(args.directory) From 986ff18eed8732b6da9d7a28a472c2112de533a3 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Mon, 8 Aug 2022 14:01:19 -0500 Subject: [PATCH 4/4] added more help info --- src/pint/scripts/export_clocks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pint/scripts/export_clocks.py b/src/pint/scripts/export_clocks.py index 9ac569812..e562e91ab 100644 --- a/src/pint/scripts/export_clocks.py +++ b/src/pint/scripts/export_clocks.py @@ -17,6 +17,7 @@ def main(argv=None): parser = argparse.ArgumentParser( description="PINT tool for export clock files", formatter_class=argparse.ArgumentDefaultsHelpFormatter, + epilog=f"Example: export_clocks -o clock_dir/ GBT Arecibo CHIME VLA", ) parser.add_argument( "observatories", help="Observatories to export", type=str, nargs="+" @@ -27,7 +28,7 @@ def main(argv=None): default=os.path.abspath(os.curdir), type=str, dest="directory", - help="Destination directory", + help="Destination directory (set $PINT_CLOCK_OVERRIDE to this value to look here first for clock files)", ) parser.add_argument( "--log-level",