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

RHE code does not handle nan's and masked pixel correctly. #253

Open
bberkeyU opened this issue Dec 19, 2024 · 4 comments
Open

RHE code does not handle nan's and masked pixel correctly. #253

bberkeyU opened this issue Dec 19, 2024 · 4 comments
Labels
Bug Probably a bug.

Comments

@bberkeyU
Copy link

bberkeyU commented Dec 19, 2024

Describe the bug

In cases with a non-radially symmetric mask in the data, such as an occulter post, the RHE code treats these masked pixels as normal in the ranking calculation. It assigns intensity values based on their rankings. These should be left out of the ranking calculations and left as nans.

To Reproduce

from  sunkit_image import radial
from astropy.io import fits
import copy
from sunpy.map import Map
ucomp_file = '20240409.180747.ucomp.1074.l2.fts'
with fits.open(ucomp_file) as ucomp_hdul:

        ucomp_enhanced_intensity_1074 = ucomp_hdul[2].data
        ucomp_mask = ucomp_hdul[6].data 
        ucomp_mask[ucomp_mask==0] = np.nan
        ucomp_primary_header = ucomp_hdul[0].header
        ucomp_enhanced_intensity_header = ucomp_hdul[2].header
        ucomp_primary_header_naxis = copy.deepcopy(ucomp_primary_header)
        ucomp_primary_header_naxis["NAXIS1"] = ucomp_enhanced_intensity_header["NAXIS1"]
        ucomp_primary_header_naxis["NAXIS2"] = ucomp_enhanced_intensity_header["NAXIS2"]
        ucomp_primary_header_naxis["WAVELNG "] = ucomp_enhanced_intensity_header["WAVELNG "]
        del ucomp_primary_header_naxis["NAXIS"]
        ucomp_map = Map(ucomp_enhanced_intensity_1074*ucomp_mask, ucomp_primary_header)
        ucomp_map.meta["wavelnth"] = ucomp_enhanced_intensity_header["WAVELNG "]
        radial.rhef(ucomp_map).plot()

Screenshots

RHE giving ranked values under the occulter and occulter post
Quicklook data without RHE applied

System Details

import sunpy; sunpy.util.system_info();import sunkit_image; print("sunkit_image:",sunkit_image.version.version)

sunpy Installation Information

General
#######
OS: Windows 10 10.0.19045
Arch: 64bit, (Intel64 Family 6 Model 165 Stepping 2, GenuineIntel)
sunpy: 6.0.2
Installation path: C:\Users.......\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\sunpy-6.0.2.dist-info

Required Dependencies
#####################
astropy: 6.1.4
numpy: 2.1.2
packaging: 24.1
parfive: 2.1.0
pyerfa: 2.0.1.4
requests: 2.32.3

Optional Dependencies
#####################
sunpy: 6.0.2
sunkit_image: 0.5.2.dev55+gd902102.d20241218

Installation method

git checkout

@nabobalis nabobalis added the Bug Probably a bug. label Dec 19, 2024
@nabobalis
Copy link
Contributor

Thanks for the report, where can I get this FITS file?

@bberkeyU
Copy link
Author

I have put a copy at https://download.hao.ucar.edu/pub/berkey/20240409.180747.ucomp.1074.l2.fts

I also have a solution to the problem: I am working on getting the pull request generated.

@bberkeyU
Copy link
Author

I can't figure out the correct workflow. Vscode GitHub extension and GitHub desktop seem to be pushing to create a new branch and publish that branch before I can create a PR.

I created and published a fork of the REPO, this let me make a PR, and I think it was sent to the main sunpy project. It seems like I must have made a mistake somewhere along the way. This doesn't match the workflow I expect based on googling how to make PRs.

@nabobalis
Copy link
Contributor

The standard workflow (as far I know) is to create a fork of the repository, push code changes to a branch on your own fork and then submit a pull request from that. This is pretty much how its done for most projects on GitHub.

You can't make a branch on this repository without write access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Probably a bug.
Projects
None yet
Development

No branches or pull requests

2 participants