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

Add tests with a jsoc cutout file and update MGN to convert int to float #215

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

nabobalis
Copy link
Contributor

@nabobalis nabobalis commented Jun 28, 2024

Fixes #211

Issue was reported with JSOC cutouts and the datatype breaking these routines.

@nabobalis nabobalis force-pushed the cutout branch 3 times, most recently from 95113e3 to 03da3d7 Compare June 28, 2024 23:15
@nabobalis nabobalis marked this pull request as ready for review June 28, 2024 23:36
sunkit_image/enhance.py Outdated Show resolved Hide resolved
sunkit_image/enhance.py Outdated Show resolved Hide resolved
sunkit_image/enhance.py Outdated Show resolved Hide resolved
@nabobalis nabobalis force-pushed the cutout branch 4 times, most recently from 41daef1 to 6667eff Compare July 8, 2024 17:08
@nabobalis nabobalis force-pushed the cutout branch 7 times, most recently from 80f9d85 to bd778e0 Compare July 20, 2024 00:05
sunkit_image/asda.py Outdated Show resolved Hide resolved
sunkit_image/granule.py Outdated Show resolved Hide resolved
@nabobalis nabobalis added this to the 0.6.0 milestone Jul 23, 2024
@nabobalis nabobalis marked this pull request as draft July 31, 2024 21:57
@nabobalis nabobalis force-pushed the cutout branch 9 times, most recently from 42a55b1 to e36cba5 Compare July 31, 2024 23:06
@nabobalis nabobalis force-pushed the cutout branch 5 times, most recently from e511b03 to 9e2dfd8 Compare August 1, 2024 01:17
@alasdairwilson

This comment was marked as outdated.

@wtbarnes

This comment was marked as outdated.

@nabobalis

This comment was marked as outdated.

@nabobalis nabobalis force-pushed the cutout branch 2 times, most recently from de4eecf to 4cb4a41 Compare October 28, 2024 18:57
@nabobalis nabobalis force-pushed the cutout branch 3 times, most recently from 38cf515 to 80c7c3e Compare November 13, 2024 16:32
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is jut a end of file character change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is jut a end of file character change.

@nabobalis nabobalis force-pushed the cutout branch 3 times, most recently from ecc31e0 to 16d6fd9 Compare November 13, 2024 16:47
for s, weight in zip(sigma, weights, strict=True):
# 2 & 3 Create kernel and convolve with image
# Refer to equation (1) in the paper
ndimage.gaussian_filter(data, sigma=s, truncate=truncate, mode="nearest", output=conv)

# 4. Calculate difference between image and the local mean image,
# square the difference, and convolve with kernel. Square-root the
# resulting image to give `local standard deviation` image sigmaw
# Refer to equation (2) in the paper
conv = data - conv
ndimage.gaussian_filter(conv**2, sigma=s, truncate=truncate, mode="nearest", output=sigmaw)
np.sqrt(sigmaw, out=sigmaw)
Copy link
Contributor Author

@nabobalis nabobalis Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>           np.sqrt(sigmaw, out=sigmaw)
E           numpy._core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'sqrt' output from dtype('float32') to dtype('int16') with casting rule 'same_kind'

So this is the original issue that we need to fix.

To fix this, I just always cast the input data to float32.

@nabobalis nabobalis changed the title Add tests with a jsoc cutout file Add tests with a jsoc cutout file and update MGM to convert int to float Nov 13, 2024
@nabobalis nabobalis changed the title Add tests with a jsoc cutout file and update MGM to convert int to float Add tests with a jsoc cutout file and update MGN to convert int to float Nov 13, 2024
@nabobalis nabobalis merged commit 2ee3205 into main Nov 13, 2024
19 of 21 checks passed
@nabobalis nabobalis deleted the cutout branch November 13, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test code with cutouts
3 participants