Skip to content

Commit

Permalink
Fix for two errors encountered in the tutorial (#3)
Browse files Browse the repository at this point in the history
* fixed issue where fits file containing float32 would break code due to strict enforcement of type hints via typeguard

* Slightly adjusted fix for float32 data, and added Exception for the case where the data is not float32 or float64

* fixed type hint typo that causes total_intensity to error

* forgot to uncomment a fix

* reverted small accidental change

* changed check of image data type as per comment in PR #3

* fixed issue with supported data types
  • Loading branch information
TomHilder committed Apr 24, 2023
1 parent af0ce0a commit 120fc2e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion diskmap/diskmap.py
Expand Up @@ -89,6 +89,17 @@ def __init__(self,

if self.image.shape[0] != self.image.shape[1]:
raise ValueError("The dimensions of the image should have the same size.")

if self.image.dtype == np.float32 or self.image.dtype == np.dtype('>f4'):
warnings.warn(
"The FITS file data is of type float32, this will be converted to float64"
)
self.image = self.image.astype(np.float64)

if self.image.dtype != np.float64 and self.image.dtype != np.dtype('>f8'):
raise ValueError(
f"The FITS file data should be either of type float32 or float64"
)

if image_type not in ["polarized", "total"]:
raise ValueError(
Expand Down Expand Up @@ -583,7 +594,7 @@ def r2_scaling(self,
self.im_scaled[i, j] = mask_planet[3] * self.image[i, j]

@typechecked
def total_intensity(self, pol_max: 1.0) -> None:
def total_intensity(self, pol_max: float = 1.0) -> None:
"""
Function for estimating the (stellar irradiation corrected)
total intensity image when ``fitsfile`` contains a polarized
Expand Down

0 comments on commit 120fc2e

Please sign in to comment.