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

Add name property to PassbandMap #289

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo on line 770 "namee" instead of "name".

>>> # 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