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

updated npol_to_mzp transformation by inverting Eq 44 #158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

s0larish
Copy link
Collaborator

@s0larish s0larish commented Sep 5, 2024

PR summary

What does this PR introduce?

Modifies npol_to_mzp in transforms.py by inverting Eq 44 in DeForest et al (2022)

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.

Project coverage is 91.48%. Comparing base (6e5febb) to head (5ead629).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
solpolpy/transforms.py 77.77% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #158      +/-   ##
==========================================
- Coverage   92.18%   91.48%   -0.70%     
==========================================
  Files           9        9              
  Lines         550      552       +2     
==========================================
- Hits          507      505       -2     
- Misses         43       47       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jmbhughes jmbhughes left a comment

Choose a reason for hiding this comment

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

See my comments please. Overall, can you describe why this is an improvement over the existing function?

if "Singular matrix" in str(err):
raise ValueError("Conversion matrix is degenerate")
else:
raise
Copy link
Member

Choose a reason for hiding this comment

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

What are you trying to raise here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the conversion matrix turns out to be singular and inversion could not be done

Copy link
Member

Choose a reason for hiding this comment

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

Yes. But you just have else: raise without anything actually being raised.

conv_matrix_inv = np.linalg.inv(conv_matrix)
except np.linalg.LinAlgError as err:
if "Singular matrix" in str(err):
raise ValueError("Conversion matrix is degenerate")
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this a custom error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is derived directly from IMAX module from @lowderchris

input_keys = list(input_collection.keys())
input_dict = {}
in_list = list(input_collection)
phi = [input_collection[key].meta['POLAR'] for key in input_keys if key != 'alpha']*u.degree
Copy link
Member

Choose a reason for hiding this comment

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

I know phi comes from the paper, but it's a bit of an opaque name.

("Z", NDCube(Bmzp[0 * u.degree], wcs=input_collection[input_keys[0]].wcs, mask=mask, meta=metaZ)),
("P", NDCube(Bmzp[60 * u.degree], wcs=input_collection[input_keys[0]].wcs, mask=mask, meta=metaP))]
for p_angle in in_list:
Bmzp_cube = [(key, NDCube(data_mzp_solar[:, :, i, 0], wcs=input_collection[input_keys[0]].wcs,
Copy link
Member

Choose a reason for hiding this comment

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

I don't really like calling this a cube. It's a list of cubes.

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.

2 participants