From f1108d0ddc583096b281f70d9d19ff59b52e2c25 Mon Sep 17 00:00:00 2001 From: Henrik Norman Date: Thu, 18 Aug 2022 11:04:34 +0200 Subject: [PATCH 1/2] Allow position to be set by WCS for TOAST imagesets --- wwt_data_formats/imageset.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wwt_data_formats/imageset.py b/wwt_data_formats/imageset.py index 021d132..48b0f21 100644 --- a/wwt_data_formats/imageset.py +++ b/wwt_data_formats/imageset.py @@ -463,7 +463,7 @@ class ImageSet(LockedXmlTraits, UrlContainer): if cd_det < 0: cd_sign = -1 - if self.tile_levels > 0: + if self.tile_levels > 0 and self.projection != ProjectionType.TOAST: raise Exception( "WCS for tiled imagery must have top-down/negative/JPEG_like parity" ) @@ -532,7 +532,8 @@ class ImageSet(LockedXmlTraits, UrlContainer): self.rotation_deg = rot_rad * 180 / math.pi if self.tile_levels > 0: # are we tiled? - self.projection = ProjectionType.TAN + if self.projection != ProjectionType.TOAST: + self.projection = ProjectionType.TAN self.bottoms_up = False self.offset_x = (width / 2 - refpix_x) * scale_x self.offset_y = (refpix_y - height / 2) * scale_y From cb88cb8f4c31860df87a7dc318a21758718360d8 Mon Sep 17 00:00:00 2001 From: Henrik Norman Date: Mon, 22 Aug 2022 13:59:36 +0200 Subject: [PATCH 2/2] Useless properties for TOAST (offset, rotation, base_degrees_per_tile) are no longer set when setting position from WCS --- wwt_data_formats/imageset.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/wwt_data_formats/imageset.py b/wwt_data_formats/imageset.py index 48b0f21..2ca74e5 100644 --- a/wwt_data_formats/imageset.py +++ b/wwt_data_formats/imageset.py @@ -486,8 +486,8 @@ class ImageSet(LockedXmlTraits, UrlContainer): if not abs(cd_det) > 0: raise ValueError("determinant of the CD matrix is not positive") - scale_x = math.sqrt(cd1_1 ** 2 + cd1_2 ** 2) - scale_y = math.sqrt(cd2_1 ** 2 + cd2_2 ** 2) + scale_x = math.sqrt(cd1_1**2 + cd1_2**2) + scale_y = math.sqrt(cd2_1**2 + cd2_2**2) if abs(scale_x - scale_y) / (scale_x + scale_y) > TOL: raise ValueError("WWT cannot express non-square pixels, which this WCS has") @@ -531,22 +531,22 @@ class ImageSet(LockedXmlTraits, UrlContainer): self.center_y = dec_deg self.rotation_deg = rot_rad * 180 / math.pi - if self.tile_levels > 0: # are we tiled? - if self.projection != ProjectionType.TOAST: + if self.projection != ProjectionType.TOAST: + if self.tile_levels > 0: # are we tiled? self.projection = ProjectionType.TAN - self.bottoms_up = False - self.offset_x = (width / 2 - refpix_x) * scale_x - self.offset_y = (refpix_y - height / 2) * scale_y - self.base_degrees_per_tile = scale_y * 256 * 2 ** self.tile_levels - else: - self.projection = ProjectionType.SKY_IMAGE - self.bottoms_up = cd_sign == -1 - self.offset_x = refpix_x - self.offset_y = height - refpix_y - self.base_degrees_per_tile = scale_y + self.bottoms_up = False + self.offset_x = (width / 2 - refpix_x) * scale_x + self.offset_y = (refpix_y - height / 2) * scale_y + self.base_degrees_per_tile = scale_y * 256 * 2**self.tile_levels + else: + self.projection = ProjectionType.SKY_IMAGE + self.bottoms_up = cd_sign == -1 + self.offset_x = refpix_x + self.offset_y = height - refpix_y + self.base_degrees_per_tile = scale_y - if self.bottoms_up: - self.rotation_deg = -self.rotation_deg + if self.bottoms_up: + self.rotation_deg = -self.rotation_deg if place is not None: place.set_ra_dec(center_ra_deg / 15.0, center_dec_deg)