nanograv / pint_pal

A long-lived repository for NANOGrav Pulsar Timing workflows and analysis.
MIT License
6 stars 19 forks source link

Allow configuration of data repository location, BIPM version, etc. #63

Closed rossjjennings closed 6 months ago

rossjjennings commented 6 months ago

This addresses #57 and #58. I have added a "config" submodule, which replaces defaults.py for configuring things like the BIPM and JPL ephemeris versions used in checks. The intended use case is for data repositories like the NG20 repository to include a file called pint_pal_project.yaml in the root of the repository that specifies these settings, and then notebooks, etc., will call pint_pal.set_data_root(), passing in the path to the root of the data repository. This will cause PINT Pal to read in the pint_pal_project.yaml file, and also inform it of the path to the data repository so that it can be used in resolving tim-directory, par-directory, and similar paths specified in the per-pulsar YAML files.

rossjjennings commented 6 months ago

OK, tests are passing locally now (you can't see them here because PR #62 hasn't been merged yet). The configuration variables live in pint_pal.config, and the default values are loaded from defaults.yaml. When pint_pal.set_data_root() is called, it will look for a file in the provided directory called pint_pal_project.yaml and load the corresponding settings from there (some can be omitted, and it will fall back on the default values).

A couple of somewhat weird things about this solution are:

tcromartie commented 6 months ago

Code looks good but would be helpful to test out more use cases (running from different directories, etc.). Ross said he'll wait til PR #63 is merged in.

rossjjennings commented 6 months ago

Just tried running a notebook from outside the main directory with this -- it worked just fine! I've added a couple more things just for convenience. There is now a function reset_data_root() that allows you to undo the effect of set_data_root(), which I realized wasn't straightforward. And I've tweaked set_data_root() and the TimingConfiguration constructor to allow you to use ~ as an abbreviation for your home directory in paths.

rossjjennings commented 6 months ago

There's now a related MR on the NG20 repository to add the pint_pal_project.yaml file.