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

Rcal 406 science array quantities #616

Merged
merged 22 commits into from
Jan 31, 2023

Conversation

PaulHuwe
Copy link
Collaborator

Resolves RCAL-406

This PR changes science products ndarrays to quantities.

Checklist

  • added entry in CHANGES.rst under the corresponding subsection
  • updated relevant tests
  • updated relevant documentation
  • updated relevant milestone(s)
  • added relevant label(s)

Copy link
Collaborator

@ddavis-stsci ddavis-stsci left a comment

Choose a reason for hiding this comment

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

Looks Good

ru.electron ** 2 / u.s ** 2, dtype=science.data.value.dtype)

err_sqrt = np.sqrt(science.var_poisson.value + science.var_rnoise.value + science.var_flat)
science.err = u.Quantity(err_sqrt, ru.electron / u.s, dtype=err_sqrt.dtype)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like we don't need to touch most of this section, since flat_data is unitless so things like science.data /= flat_data should do the right thing? What am I missing? One would only need to touch the except: AttributeError stanza, which was deleted 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.

Reverted

'weights': np.squeeze(weights),
'crmag': crmag
'crmag': u.Quantity(crmag, ru.electron, dtype=pedestal.dtype),
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we added these units back at the opt_info stage instead of here, we wouldn't need to repeat adding these units in create_image_model?

out_model.groupdq = out_data.groupdq[0]
# Roman 2D
out_model.pixeldq = out_data.pixeldq
out_model.err = out_data.err[0]
out_model.err = u.Quantity(out_data.err[0], ru.DN, dtype=out_data.err.dtype)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Staring at this; does it make more sense to add these units onto out_data in process(...) following the do_correction call? Harping on my usual imagination that our ideal model should be: units everywhere, except around the calls to stcal, where there's a step beforehand removing units and afterward adding them back?

@ddavis-stsci ddavis-stsci added this to the 23Q2_B9 milestone Jan 30, 2023
@PaulHuwe PaulHuwe merged commit 872b104 into spacetelescope:main Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants