From 0ec4028a2f4efaf7af7344563b72408a78ea026b Mon Sep 17 00:00:00 2001 From: Wim De Meester Date: Mon, 23 Dec 2024 14:23:22 +0100 Subject: [PATCH 1/5] Show contrast reserve in the object details page. --- python/PiFinder/ui/object_details.py | 36 ++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/python/PiFinder/ui/object_details.py b/python/PiFinder/ui/object_details.py index 6baed477..0dd7e9f0 100644 --- a/python/PiFinder/ui/object_details.py +++ b/python/PiFinder/ui/object_details.py @@ -5,7 +5,7 @@ This module contains all the UI Module classes """ - +import pydeepskylog as pds from PiFinder import cat_images from PiFinder.ui.marking_menus import MarkingMenuOption, MarkingMenu from PiFinder.obj_types import OBJ_TYPES @@ -120,8 +120,40 @@ def _layout_designator(self): designator_color = 255 if not self.object.last_filtered_result: designator_color = 128 + # 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: + contrast = "" + else: + # Calculate contrast reserve. The object diameters are given in arc seconds. + magnification = self.config_object.equipment.calc_magnification( + self.config_object.equipment.active_telescope, self.config_object.equipment.active_eyepiece) + if self.object.mag_str == "-": + contrast = "" + else: + try: + 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: + contrast = "" + try: + contrast = f"{contrast: .2f}" + except: + print(contrast) + contrast = "" + + # layout the name - contrast reserve line + space_calculator = SpaceCalculatorFixed(14) + + _, typeconst = space_calculator.calculate_spaces( + self.object.display_name, contrast + ) return self.simpleTextLayout( - self.object.display_name, + typeconst, font=self.fonts.large, color=self.colors.get(designator_color), ) From bab48d056a4ca10578015bded59157d24ef63451 Mon Sep 17 00:00:00 2001 From: Wim De Meester Date: Mon, 23 Dec 2024 15:05:36 +0100 Subject: [PATCH 2/5] Only calculate contrast reserve when changing the object. --- python/PiFinder/ui/object_details.py | 58 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/python/PiFinder/ui/object_details.py b/python/PiFinder/ui/object_details.py index 0dd7e9f0..54fc8e5d 100644 --- a/python/PiFinder/ui/object_details.py +++ b/python/PiFinder/ui/object_details.py @@ -46,6 +46,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 +72,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,37 +121,12 @@ def _layout_designator(self): designator_color = 255 if not self.object.last_filtered_result: designator_color = 128 - # 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: - contrast = "" - else: - # Calculate contrast reserve. The object diameters are given in arc seconds. - magnification = self.config_object.equipment.calc_magnification( - self.config_object.equipment.active_telescope, self.config_object.equipment.active_eyepiece) - if self.object.mag_str == "-": - contrast = "" - else: - try: - 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: - contrast = "" - try: - contrast = f"{contrast: .2f}" - except: - print(contrast) - contrast = "" # layout the name - contrast reserve line space_calculator = SpaceCalculatorFixed(14) _, typeconst = space_calculator.calculate_spaces( - self.object.display_name, contrast + self.object.display_name, self.contrast ) return self.simpleTextLayout( typeconst, @@ -259,6 +235,32 @@ 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. The object diameters are given in arc seconds. + 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: + 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: + self.contrast = "" + try: + self.contrast = f"{self.contrast: .2f}" + except: + self.contrast = "" + def active(self): self.activation_time = time.time() @@ -466,7 +468,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( From 5a65b7ddb01ebb075d4c8ad8489f1eddd84670e1 Mon Sep 17 00:00:00 2001 From: Wim De Meester Date: Mon, 23 Dec 2024 15:05:36 +0100 Subject: [PATCH 3/5] Only calculate contrast reserve when changing the object. --- python/PiFinder/ui/object_details.py | 68 ++++++++++++++++------------ 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/python/PiFinder/ui/object_details.py b/python/PiFinder/ui/object_details.py index 0dd7e9f0..edeffdfe 100644 --- a/python/PiFinder/ui/object_details.py +++ b/python/PiFinder/ui/object_details.py @@ -5,6 +5,7 @@ This module contains all the UI Module classes """ + import pydeepskylog as pds from PiFinder import cat_images from PiFinder.ui.marking_menus import MarkingMenuOption, MarkingMenu @@ -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,37 +122,12 @@ def _layout_designator(self): designator_color = 255 if not self.object.last_filtered_result: designator_color = 128 - # 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: - contrast = "" - else: - # Calculate contrast reserve. The object diameters are given in arc seconds. - magnification = self.config_object.equipment.calc_magnification( - self.config_object.equipment.active_telescope, self.config_object.equipment.active_eyepiece) - if self.object.mag_str == "-": - contrast = "" - else: - try: - 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: - contrast = "" - try: - contrast = f"{contrast: .2f}" - except: - print(contrast) - contrast = "" # layout the name - contrast reserve line space_calculator = SpaceCalculatorFixed(14) _, typeconst = space_calculator.calculate_spaces( - self.object.display_name, contrast + self.object.display_name, self.contrast ) return self.simpleTextLayout( typeconst, @@ -259,6 +236,41 @@ 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. The object diameters are given in arc seconds. + 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: + 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() @@ -466,7 +478,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( From 27e7923fe2824f6d1379ad5e54490b9a8e1bfb76 Mon Sep 17 00:00:00 2001 From: Wim De Meester Date: Mon, 23 Dec 2024 15:33:50 +0100 Subject: [PATCH 4/5] Update code documentation --- python/PiFinder/ui/object_details.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/PiFinder/ui/object_details.py b/python/PiFinder/ui/object_details.py index edeffdfe..3b0aa8c5 100644 --- a/python/PiFinder/ui/object_details.py +++ b/python/PiFinder/ui/object_details.py @@ -247,7 +247,8 @@ def update_object_info(self): ): self.contrast = "" else: - # Calculate contrast reserve. The object diameters are given in arc seconds. + # 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, @@ -256,6 +257,7 @@ def update_object_info(self): self.contrast = "" else: try: + # 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, From 159a947a5317a5e22dc2fdd70cca62910bc4395a Mon Sep 17 00:00:00 2001 From: Wim De Meester Date: Mon, 23 Dec 2024 15:35:56 +0100 Subject: [PATCH 5/5] Update code documentation --- python/PiFinder/ui/object_details.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/PiFinder/ui/object_details.py b/python/PiFinder/ui/object_details.py index 3b0aa8c5..6ca6394e 100644 --- a/python/PiFinder/ui/object_details.py +++ b/python/PiFinder/ui/object_details.py @@ -257,6 +257,7 @@ def update_object_info(self): 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,