Skip to content

Commit

Permalink
Merge pull request #289 from mwcraig/add-name-to-passband-map
Browse files Browse the repository at this point in the history
Add name property to PassbandMap
  • Loading branch information
mwcraig authored Mar 27, 2024
2 parents 8d8085d + 30947b2 commit cda1ce3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
3 changes: 2 additions & 1 deletion stellarphot/photometry/tests/test_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@

# Passband map for the tests
PASSBAND_MAP = PassbandMap(
name="Example Passband Map",
your_filter_names_to_aavso={
"B": "B",
"rp": "SR",
}
},
)

DEFAULT_LOGGING_SETTINGS = LoggingSettings()
Expand Down
14 changes: 12 additions & 2 deletions stellarphot/settings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,10 @@ class PassbandMap(BaseModelWithTableRep):
Parameters
----------
name : str
Name of the passband map.
your_filter_names_to_aavso : list[`stellarphot.settings.PassbandMapEntry`]
A list of pairs of your filter name and the corresponding AAVSO filter name.
This is used to rename the passband entries in the output photometry table.
Expand All @@ -748,9 +752,12 @@ class PassbandMap(BaseModelWithTableRep):
Examples
--------
>>> from stellarphot.settings import PassbandMap
>>> passband_map = PassbandMap(your_filter_names_to_aavso={"B": "B", "rp": "SR"})
>>> passband_map = PassbandMap(
... name="Sample map",
... your_filter_names_to_aavso={"B": "B", "rp": "SR"}
... )
>>> passband_map
PassbandMap(your_filter_names_to_aavso=[PassbandMapEntry(your_filter_name='B',...
PassbandMap(name='Sample map', your_filter_names_to_aavso=[PassbandMapEntry(your_...
>>> # You can access the AAVSO filter name for a given filter name using dict syntax
>>> passband_map["B"]
'B'
Expand All @@ -766,6 +773,9 @@ class PassbandMap(BaseModelWithTableRep):
"""

name: Annotated[
str, Field(description="Name of the passband map", examples=["Filter wheel 1"])
]
your_filter_names_to_aavso: list[PassbandMapEntry] | None

def model_post_init(self, __context: Any) -> None:
Expand Down
7 changes: 4 additions & 3 deletions stellarphot/settings/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
)

DEFAULT_PASSBAND_MAP = dict(
name="Example map",
your_filter_names_to_aavso=[
PassbandMapEntry(
your_filter_name="V",
Expand All @@ -77,7 +78,7 @@
your_filter_name="rp",
aavso_filter_name="SR",
),
]
],
)

DEFAULT_LOGGING_SETTINGS = dict(
Expand Down Expand Up @@ -417,13 +418,13 @@ def test_deletion_fails(self):


def test_passband_map_init_with_none():
pb_map = PassbandMap(your_filter_names_to_aavso=None)
pb_map = PassbandMap(name="Test", your_filter_names_to_aavso=None)
assert pb_map._dict == {}


def test_passband_map_init_with_passband_map():
pb_map = PassbandMap(**DEFAULT_PASSBAND_MAP)
pb_map2 = PassbandMap(your_filter_names_to_aavso=pb_map)
pb_map2 = PassbandMap(name="Example map", your_filter_names_to_aavso=pb_map)
assert pb_map == pb_map2


Expand Down
11 changes: 8 additions & 3 deletions stellarphot/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@
max_data_value=50000 * u.adu,
)
feder_passbands = PassbandMap(
name="Feder Passbands",
your_filter_names_to_aavso={
"up": "SU",
"gp": "SG",
"rp": "SR",
"zp": "SZ",
"ip": "SI",
}
},
)
feder_obs = Observatory(
name="Feder Observatory", latitude=46.86678, longitude=-96.45328, elevation="311 m"
Expand Down Expand Up @@ -531,7 +532,9 @@ def test_photometry_data_short_filter_name():
phot_data = PhotometryData(
observatory=feder_obs,
camera=feder_cg_16m,
passband_map=PassbandMap(your_filter_names_to_aavso={"i": "SI"}),
passband_map=PassbandMap(
name="Test map", your_filter_names_to_aavso={"i": "SI"}
),
input_data=data,
)

Expand All @@ -558,7 +561,9 @@ def test_photometry_data_filter_name_map_preserves_original_names():
phot_data = PhotometryData(
observatory=feder_obs,
camera=feder_cg_16m,
passband_map=PassbandMap(your_filter_names_to_aavso={"i": "SI"}),
passband_map=PassbandMap(
name="Test map", your_filter_names_to_aavso={"i": "SI"}
),
input_data=data,
)

Expand Down

0 comments on commit cda1ce3

Please sign in to comment.