Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Will Barnes <[email protected]>
  • Loading branch information
nabobalis and wtbarnes authored Jan 8, 2025
1 parent 278ee4c commit eec4966
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions aiapy/calibrate/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
"0a3f2db39d05c44185f6fdeec928089fb55d1ce1e0a805145050c6356cbc6e98",
)
}
_URL_HASH_CORRECTION_TABLE['latest'] = _URL_HASH_CORRECTION_TABLE[10]


@manager.require("correction_table_v10", *_URL_HASH_CORRECTION_TABLE[10])
def _fetch_correction_table_v10():
return manager.get("correction_table_v10")
@manager.require("correction_table_latest", *_URL_HASH_CORRECTION_TABLE['latest'])
def _fetch_correction_table_latest():
return manager.get("correction_table_latest")

Check warning on line 55 in aiapy/calibrate/util.py

View check run for this annotation

Codecov / codecov/patch

aiapy/calibrate/util.py#L55

Added line #L55 was not covered by tests


def get_correction_table(source):
Expand All @@ -71,7 +72,7 @@ def get_correction_table(source):
source: pathlib.Path, str
The source of the correction table. If it is a `pathlib.Path`, it must be a file.
A string file path will error as an invalid source.
If source is a string, it must either be "JSOC" which will fetch the most recent version from the JSOC or "SSW" which will fetch the most recent version (V10) from SSW.
If source is a string, it must either be "JSOC" which will fetch the most recent version from the JSOC or "SSW" which will fetch the most recent version from SSW.
Returns
-------
Expand All @@ -85,7 +86,7 @@ def get_correction_table(source):
if isinstance(source, pathlib.Path):
table = QTable(astropy.io.ascii.read(source))
elif isinstance(source, str) and source.lower() == "ssw":
table = QTable(astropy.io.ascii.read(_fetch_correction_table_v10()))
table = QTable(astropy.io.ascii.read(_fetch_correction_table_latest()))

Check warning on line 89 in aiapy/calibrate/util.py

View check run for this annotation

Codecov / codecov/patch

aiapy/calibrate/util.py#L89

Added line #L89 was not covered by tests
elif isinstance(source, str) and source.lower() == "jsoc":
# NOTE: the [!1=1!] disables the drms PrimeKey logic and enables
# the query to find records that are ordinarily considered
Expand Down Expand Up @@ -147,7 +148,7 @@ def _select_epoch_from_correction_table(channel: u.angstrom, obstime, correction
if len(table) == 0:
extra_msg = " Max version is 3." if channel == 4500 * u.AA else ""
raise ValueError(
f"Correction table does not contain calibration for {channel}." + extra_msg,
f"Correction table does not contain calibration for {channel}.{extra_msg}",
)
# Select the epoch for the given observation time
obstime_in_epoch = np.logical_and(obstime >= table["T_START"], obstime < table["T_STOP"])
Expand Down

0 comments on commit eec4966

Please sign in to comment.