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

feat(ch_ephem): CHIME ephemeris refactored from ch_util. #1

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

ketiltrout
Copy link
Member

Extracts a lot of ch_util.ephemeris into a separate package.

General changes:

  • Solar and lunar ephemeris functions have been converted into caput.time.Observer methods: feat(time): Solar/lunar ephemerides radiocosmology/caput#271
  • Other functions that take a Observer object, now use None as a default, and load the chime observer during execution if necessary. (This is to avoid unnecessarily importing ch_ephem.observers.)
  • Could use a test-suite, but this PR is big enough already.

More comments on specific submodules follow.

Catalogs:

This contains all the ch_util/catalogs plus a function (ch_ephem.catalogs.load) to read them and return the parsed JSON.

The standard source catalogues loaded by the sources submodule need to move to ch_ephem. The other catalogues could stay in ch_util, but it seems simpler to me to keep them all in the same place and provide a uniform interface to them.

Coord:

Co-ordinate transforms etc. These are essentially unchanged from their versions in ch_util.ephemeris.

Observers:

Re-creates all the caput.time.Observers which used to be created by ch_util.ephemeris, but for the most part, they have to be fetched via name from the get() function. The exception to this is the chime Observer, which can be directly imported, since it's the one usually needed.

Position data for the observers is now in a YAML data file instruments.yaml which is parsed at import time. New instrument Observer objects can be added to ch_ephem just by adding information for it to the YAML file.

Also note that Observers returned by this submodule have an extra attribute, rotation, inserted into their __dict__, which is not in caput. This rotation is needed by ch_ephem.coord.peak_ra. If we don't want to do this to these Observers, one other options would be to keep peak_ra in ch_util (moving it to, say, ch_util.tools), and then there's no need for rotation information in this module.

Like sources, this submodule reads data from disk at import time, so is not automatically imported into the base ch_ephem object.

Pointing:

Just Galt telescope pointing routines, unchanged from ch_util.ephemeris. These are another candidate we could consider putting somewhere else in ch_util, if we don't want them here.

Sources:

Loads the standard source catalogs, and provides the calibrator objects CasA, CygA, TauA, VirA. Like observers, this submodule reads data from disk at import time, so is not automatically imported into the base ch_ephem object.

Time:

Time utilities, largely unchanged from what was in ch_util.ephemeris.

@ketiltrout ketiltrout requested review from ljgray and rikvl July 25, 2024 22:38
@ketiltrout
Copy link
Member Author

To pull out one major question I had from the description that I'd like opinions on:

  • Should the rotation data be in ch_ephem? Or would it be better to keep it in ch_util and move the peak_ra function there? Or just delete peak_ra and keep rotation in ch_util?

ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Jul 25, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument rotation:

`ch_ephem` has also taken on the rotation data that was in `tools`
(where it's been re-imported from `ch_ephem`).  Not sure this is ideal.
Please comment on the `ch_ephem` PR if you can provide an opinion on
this.

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these is the unused `ch_util.tools._LAT_LON` which
had position data for various instruments which differed from the
position data provided by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
.github/workflows/linting.yaml Outdated Show resolved Hide resolved
ch_ephem/__init__.py Show resolved Hide resolved
ch_ephem/catalogs/__init__.py Show resolved Hide resolved
ch_ephem/time.py Outdated Show resolved Hide resolved
@ljgray
Copy link
Contributor

ljgray commented Jul 25, 2024

To pull out one major question I had from the description that I'd like opinions on:

  • Should the rotation data be in ch_ephem? Or would it be better to keep it in ch_util and move the peak_ra function there? Or just delete peak_ra and keep rotation in ch_util?

I don't mind moving the rotation data here, personally.

@ketiltrout ketiltrout force-pushed the ch_ephem branch 3 times, most recently from 885a8fb to 5247b97 Compare July 26, 2024 23:56
@ketiltrout
Copy link
Member Author

I've added ruff to the linting (which found all my typos) and move the rest of the geometry from ch_util.tools (roll and offset) over here, too.

ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Jul 27, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument geormetry:

`ch_ephem` has also taken on the geometry data (rotation, roll, offset)
that was in `tools` (where it's been re-imported from `ch_ephem`).

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these are the geometry constants from `ch_util.tools`
and the unused`ch_util.tools._LAT_LON` which had position data for
various instruments which differed from the position data provided
by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Jul 27, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument geormetry:

`ch_ephem` has also taken on the geometry data (rotation, roll, offset)
that was in `tools` (where it's been re-imported from `ch_ephem`).

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these are the geometry constants from `ch_util.tools`
and the unused`ch_util.tools._LAT_LON` which had position data for
various instruments which differed from the position data provided
by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Jul 27, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument geormetry:

`ch_ephem` has also taken on the geometry data (rotation, roll, offset)
that was in `tools` (where it's been re-imported from `ch_ephem`).

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these are the geometry constants from `ch_util.tools`
and the unused`ch_util.tools._LAT_LON` which had position data for
various instruments which differed from the position data provided
by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
@ketiltrout ketiltrout force-pushed the ch_ephem branch 2 times, most recently from 7514d20 to d704f6b Compare July 31, 2024 18:59
ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Jul 31, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument geormetry:

`ch_ephem` has also taken on the geometry data (rotation, roll, offset)
that was in `tools` (where it's been re-imported from `ch_ephem`).

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these are the geometry constants from `ch_util.tools`
and the unused`ch_util.tools._LAT_LON` which had position data for
various instruments which differed from the position data provided
by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
@ketiltrout ketiltrout force-pushed the ch_ephem branch 2 times, most recently from 1f8b5f7 to 7694836 Compare August 1, 2024 19:56
Extracts a lot of `ch_util.ephemeris` into a separate package.

General changes:

* Solar and lunar ephemeris functions have been converted into
  `caput.time.Observer` methods: radiocosmology/caput#271
* Other functions that take a `Observer` object, now use `None`
  as a default, and load the `chime` observer during execution if
  necessary.

More comments on specific submodules follow.

Catalogs:

This contains all the `ch_util/catalogs` plus a function
(`ch_ephem.catalogs.load`) to read them and return the parsed JSON.

The standard source catalogues loaded by the `sources` submodule need
to move to `ch_ephem`.  The other catalogues could stay in `ch_util`,
but it seems simpler to me to keep them all in the same place and
provide a uniform interface to them.

Coord:

Co-ordinate transforms etc.  These are essentially unchanged from
their versions in `ch_util.ephemeris`.

Observers:

Re-creates all the `caput.time.Observers` which used to be created
by `ch_util.ephemeris`, but for the most part, they have to be
fetched via name from the `get()` function.  The exception to this
is the `chime` Observer, which can be directly imported, since it's
the one usually needed.

Position data for the observers is now in a YAML data file
`instruments.yaml` which is parsed at import time.  New instrument
`Observer` objects can be added to `ch_ephem` just by adding information
for it to the YAML file.

Also note that `Observers` returned by this submodule have an extra
attribute, `rotation`, inserted into their `__dict__`, which is not
in `caput`.  This rotation is needed by `ch_ephem.coord.peak_ra`.
If we don't want to do this to these `Observers`, one other options
would be to keep `peak_ra` in `ch_util` (moving it to, say,
`ch_util.tools`), and then there's no need for rotation information
in this module.

Like `sources`, this submodule reads data from disk at import time,
so is not automatically imported into the base `ch_ephem` object.

Pointing:

Just Galt telescope pointing routines, unchanged from
`ch_util.ephemeris`.  These are another candidate we could consider
putting somewhere else in ch_util, if we don't want them here.

Sources:

Loads the standard source catalogs, and provides the calibrator objects
`CasA`, `CygA`, `TauA`, `VirA`.  Like `observers`, this submodule
reads data from disk at import time, so is not automatically imported
into the base `ch_ephem` object.

Time:

Time utilities, largely unchanged from what was in `ch_util.ephemeris`.
ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Aug 1, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument geormetry:

`ch_ephem` has also taken on the geometry data (rotation, roll, offset)
that was in `tools` (where it's been re-imported from `ch_ephem`).

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these are the geometry constants from `ch_util.tools`
and the unused`ch_util.tools._LAT_LON` which had position data for
various instruments which differed from the position data provided
by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
@ketiltrout ketiltrout merged commit ea10f69 into master Aug 1, 2024
2 checks passed
@ketiltrout ketiltrout deleted the ch_ephem branch August 1, 2024 22:20
ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Aug 1, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument geormetry:

`ch_ephem` has also taken on the geometry data (rotation, roll, offset)
that was in `tools` (where it's been re-imported from `ch_ephem`).

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these are the geometry constants from `ch_util.tools`
and the unused`ch_util.tools._LAT_LON` which had position data for
various instruments which differed from the position data provided
by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Aug 1, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument geormetry:

`ch_ephem` has also taken on the geometry data (rotation, roll, offset)
that was in `tools` (where it's been re-imported from `ch_ephem`).

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these are the geometry constants from `ch_util.tools`
and the unused`ch_util.tools._LAT_LON` which had position data for
various instruments which differed from the position data provided
by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Aug 1, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument geormetry:

`ch_ephem` has also taken on the geometry data (rotation, roll, offset)
that was in `tools` (where it's been re-imported from `ch_ephem`).

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these are the geometry constants from `ch_util.tools`
and the unused`ch_util.tools._LAT_LON` which had position data for
various instruments which differed from the position data provided
by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
ketiltrout added a commit to chime-experiment/ch_util that referenced this pull request Aug 1, 2024
This re-imports stuff moved to `ch_ephem`.  It both
re-imports everything that was moved back into `ch_util.ephemeris` for
backwards compatibility, but also removes references to
`ch_util.epheremis` from the code, using the newly-exported versions
of things directly.

This PR requires both:

* radiocosmology/caput#271
* chime-experiment/ch_ephem#1

Catalogs:

All the catalogs have been moved to `ch_ephem`, which provides a
standard interface to them via `ch_ephem.catalogs.load`.  To make this
change, `fluxcat.FluxCatalog.load` has been broken into two pieces.  The
new `fluxcat.FluxCatalog.load_dict` imports a catalog from an
already-parsed JSON dict (which is what `ch_ephem` provides).  The
original `fluxcat.FluxCatalog.load` works as it used to, but tail-calls
`load_dict` to do most of the importing.

Position data:

Position data (lat, lon, alt) is now obtained by fetching the parameter
out of the `caput.time.Observer` objects provided by `ch_ephem`.  The
constants in `ch_util.ephemeris` are populated by doing this.

Instrument geormetry:

`ch_ephem` has also taken on the geometry data (rotation, roll, offset)
that was in `tools` (where it's been re-imported from `ch_ephem`).

Private objects deleted:

I've also deleted a number of private objects which are no longer
being used (i.e. objects whose names start with a leading underscore).

Notable among these are the geometry constants from `ch_util.tools`
and the unused`ch_util.tools._LAT_LON` which had position data for
various instruments which differed from the position data provided
by `ch_util.ephemeris`.

Also removed are the long-deprectated `ch_util.ephemeris._get_chime` and
`ch_util.ephemeris.transit_RA`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants