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

[WIP] Contrast reserve #261

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
53 changes: 50 additions & 3 deletions python/PiFinder/ui/object_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

"""

import pydeepskylog as pds
from PiFinder import cat_images
from PiFinder.ui.marking_menus import MarkingMenuOption, MarkingMenu
from PiFinder.obj_types import OBJ_TYPES
Expand Down Expand Up @@ -46,6 +47,7 @@ class UIObjectDetails(UIModule):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.contrast = None
self.screen_direction = self.config_object.get_option("screen_direction")
self.mount_type = self.config_object.get_option("mount_type")
self.object = self.item_definition["object"]
Expand All @@ -71,7 +73,7 @@ def __init__(self, *args, **kwargs):
),
)

# Used for displaying obsevation counts
# Used for displaying observation counts
self.observations_db = ObservationsDatabase()

self.simpleTextLayout = functools.partial(
Expand Down Expand Up @@ -120,8 +122,15 @@ def _layout_designator(self):
designator_color = 255
if not self.object.last_filtered_result:
designator_color = 128

# layout the name - contrast reserve line
space_calculator = SpaceCalculatorFixed(14)

_, typeconst = space_calculator.calculate_spaces(
self.object.display_name, self.contrast
)
return self.simpleTextLayout(
self.object.display_name,
typeconst,
font=self.fonts.large,
color=self.colors.get(designator_color),
)
Expand Down Expand Up @@ -227,6 +236,44 @@ def update_object_info(self):
burn_in=self.object_display_mode in [DM_POSS, DM_SDSS],
)

# Calculate contrast reserve
# TODO: Get the SQM from the shared state
# sqm = self.shared_state.get_sky_brightness()
sqm = 20.15
# Check if a telescope and eyepiece are set
if (
self.config_object.equipment.active_eyepiece is None
or self.config_object.equipment.active_eyepiece is None
):
self.contrast = ""
else:
# Calculate contrast reserve.
# Get the used magnification from the equipment configuration
magnification = self.config_object.equipment.calc_magnification(
self.config_object.equipment.active_telescope,
self.config_object.equipment.active_eyepiece,
)
if self.object.mag_str == "-":
self.contrast = ""
else:
try:
# Calculate the contrast reserve.
# The object diameters are given in arc minutes, but expected in arc seconds.
self.contrast = pds.contrast_reserve(
sqm=sqm,
telescope_diameter=self.config_object.equipment.active_telescope.aperture_mm,
magnification=magnification,
magnitude=float(self.object.mag_str),
object_diameter1=float(self.object.size) * 60.0,
object_diameter2=float(self.object.size) * 60.0,
)
except Exception:
self.contrast = ""
try:
self.contrast = f"{self.contrast: .2f}"
except Exception:
self.contrast = ""

def active(self):
self.activation_time = time.time()

Expand Down Expand Up @@ -434,7 +481,7 @@ def mm_cancel(self, _marking_menu, _menu_item) -> bool:

def mm_align(self, _marking_menu, _menu_item) -> bool:
"""
Called from marking menu to align on curent object
Called from marking menu to align on current object
"""
self.message("Aligning...", 0.1)
if align_on_radec(
Expand Down
Loading