diff --git a/python/PiFinder/ui/object_details.py b/python/PiFinder/ui/object_details.py index 6baed477..6ca6394e 100644 --- a/python/PiFinder/ui/object_details.py +++ b/python/PiFinder/ui/object_details.py @@ -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 @@ -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"] @@ -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( @@ -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), ) @@ -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() @@ -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(