Skip to content

Commit

Permalink
RCAL-831: Add statistics field to TVAC and FPS Models (#351)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
PaulHuwe and pre-commit-ci[bot] authored May 14, 2024
1 parent 085b8c0 commit 09b8435
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

- Separated TVAC and FPS into their own makers to freeze from from main development. [#347]

- Added statistics blocks to the TVAC and FS models. [#351]

- Fix bug that prevented proper handling of ``np.NDArray``\s. [#350]


Expand Down
10 changes: 9 additions & 1 deletion src/roman_datamodels/maker_utils/_fps.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,22 @@ def mk_fps_common_meta(**kwargs):
dict (defined by the ground_common-1.0.0 schema)
"""
# prevent circular import
from ._fps_common_meta import mk_fps_cal_step, mk_fps_exposure, mk_fps_guidestar, mk_fps_ref_file, mk_fps_wfi_mode
from ._fps_common_meta import (
mk_fps_cal_step,
mk_fps_exposure,
mk_fps_guidestar,
mk_fps_ref_file,
mk_fps_statistics,
mk_fps_wfi_mode,
)

meta = mk_fps_basic_meta(**kwargs)
meta["cal_step"] = mk_fps_cal_step(**kwargs.get("cal_step", {}))
meta["exposure"] = mk_fps_exposure(**kwargs.get("exposure", {}))
meta["guidestar"] = mk_fps_guidestar(**kwargs.get("guidestar", {}))
meta["instrument"] = mk_fps_wfi_mode(**kwargs.get("instrument", {}))
meta["ref_file"] = mk_fps_ref_file(**kwargs.get("ref_file", {}))
meta["statistics"] = mk_fps_statistics(**kwargs.get("statistics", {}))
meta["hdf5_meta"] = kwargs.get("hdf5_meta", {"test": NOSTR})
meta["hdf5_telemetry"] = kwargs.get("hdf5_telemetry", NOSTR)
meta["gw_meta"] = kwargs.get("gw_meta", {"test": NOSTR})
Expand Down
19 changes: 19 additions & 0 deletions src/roman_datamodels/maker_utils/_fps_common_meta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
from astropy import time
from astropy import units as u

from roman_datamodels import stnode

Expand Down Expand Up @@ -57,6 +58,24 @@ def mk_fps_guidestar(**kwargs):
return guide


def mk_fps_statistics(**kwargs):
"""
Create a dummy Statistics instance with valid values for attributes
required by the schema. Utilized by the model maker utilities below.
Returns
-------
roman_datamodels.stnode.FpsStatistics
"""
stats = stnode.FpsStatistics()
stats["mean_counts_per_sec"] = kwargs.get("mean_counts_per_sec", NONUM * (u.DN / u.s))
stats["median_counts_per_sec"] = kwargs.get("median_counts_per_sec", NONUM * (u.DN / u.s))
stats["min_counts"] = kwargs.get("min_counts", u.Quantity(NONUM, u.DN, dtype=np.int32))
stats["max_counts"] = kwargs.get("max_counts", u.Quantity(NONUM, u.DN, dtype=np.int32))

return stats


def mk_fps_wfi_mode(**kwargs):
"""
Create a dummy WFI mode instance with valid values for attributes
Expand Down
10 changes: 9 additions & 1 deletion src/roman_datamodels/maker_utils/_tvac.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,22 @@ def mk_tvac_common_meta(**kwargs):
dict (defined by the ground_common-1.0.0 schema)
"""
# prevent circular import
from ._tvac_common_meta import mk_tvac_cal_step, mk_tvac_exposure, mk_tvac_guidestar, mk_tvac_ref_file, mk_tvac_wfi_mode
from ._tvac_common_meta import (
mk_tvac_cal_step,
mk_tvac_exposure,
mk_tvac_guidestar,
mk_tvac_ref_file,
mk_tvac_statistics,
mk_tvac_wfi_mode,
)

meta = mk_tvac_basic_meta(**kwargs)
meta["cal_step"] = mk_tvac_cal_step(**kwargs.get("cal_step", {}))
meta["exposure"] = mk_tvac_exposure(**kwargs.get("exposure", {}))
meta["guidestar"] = mk_tvac_guidestar(**kwargs.get("guidestar", {}))
meta["instrument"] = mk_tvac_wfi_mode(**kwargs.get("instrument", {}))
meta["ref_file"] = mk_tvac_ref_file(**kwargs.get("ref_file", {}))
meta["statistics"] = mk_tvac_statistics(**kwargs.get("statistics", {}))
meta["hdf5_meta"] = kwargs.get("hdf5_meta", {"test": NOSTR})
meta["hdf5_telemetry"] = kwargs.get("hdf5_telemetry", NOSTR)
meta["gw_meta"] = kwargs.get("gw_meta", {"test": NOSTR})
Expand Down
21 changes: 20 additions & 1 deletion src/roman_datamodels/maker_utils/_tvac_common_meta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
from astropy import time
from astropy import units as u

from roman_datamodels import stnode

Expand Down Expand Up @@ -35,7 +36,7 @@ def mk_tvac_exposure(**kwargs):

def mk_tvac_guidestar(**kwargs):
"""
Create a dummy BaseGuidestar instance with valid values for attributes
Create a dummy Guidestar instance with valid values for attributes
required by the schema. Utilized by the model maker utilities below.
Returns
Expand All @@ -57,6 +58,24 @@ def mk_tvac_guidestar(**kwargs):
return guide


def mk_tvac_statistics(**kwargs):
"""
Create a dummy Statistics instance with valid values for attributes
required by the schema. Utilized by the model maker utilities below.
Returns
-------
roman_datamodels.stnode.TvacStatistics
"""
stats = stnode.TvacStatistics()
stats["mean_counts_per_sec"] = kwargs.get("mean_counts_per_sec", NONUM * (u.DN / u.s))
stats["median_counts_per_sec"] = kwargs.get("median_counts_per_sec", NONUM * (u.DN / u.s))
stats["min_counts"] = kwargs.get("min_counts", u.Quantity(NONUM, u.DN, dtype=np.int32))
stats["max_counts"] = kwargs.get("max_counts", u.Quantity(NONUM, u.DN, dtype=np.int32))

return stats


def mk_tvac_wfi_mode(**kwargs):
"""
Create a dummy WFI mode instance with valid values for attributes
Expand Down

0 comments on commit 09b8435

Please sign in to comment.