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

RAD-158: Changed image units. #389

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

- Updated product table names. [#382]

- Changed image units from e/s to DN/s (and added support for MJy/sr). [#389]


0.19.0 (2024-02-09)
-------------------
Expand Down
52 changes: 32 additions & 20 deletions src/rad/resources/schemas/wfi_image-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ properties:
tag: asdf://stsci.edu/datamodels/roman/tags/source_detection-1.0.0
required: [photometry, wcs]
data:
title: Science Data (electrons / s)
title: Science Data (DN / s) or (MJy / sr)
Copy link
Collaborator

@nden nden Mar 6, 2024

Choose a reason for hiding this comment

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

Is the conversion to MJy/sr applied in Level 2 or L3? If L2 (and I may be confused about this) then remove MJy/sr

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

L2, and the MJy/sr option was specifically requested in the ticket.

description: |
Science data, excluding border reference pixels.
Science data, excluding border reference pixels, in DNs per second
or MJ per steradian.
tag: tag:stsci.edu:asdf/unit/quantity-1.*
properties:
value:
Expand All @@ -37,8 +38,10 @@ properties:
exact_datatype: true
ndim: 2
unit:
tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["electron / s"]
oneOf:
- tag: tag:stsci.edu:asdf/unit/unit-1.*
- tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["DN / s", "MJy.sr**-1"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

@braingram Can one of the tags be dropped here? I believe DN/s is a VO unit and supported by astropy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the ping!

The oneOf here is needed as asdf-astropy will select which tag to use based on the unit (and if it is or is not a VO unit). See the relevant converter code here.

Writing out a ImageModel with DN / s data produces the following and uses the astropy tag:

  data: !unit/quantity-1.1.0
    unit: !<tag:astropy.org:astropy/units/unit-1.0.0> DN / s
    value: !core/ndarray-1.0.0
      source: 9
      datatype: float32
      byteorder: little
      shape: [4088, 4088]

whereas using MJy.sr**-1 produces the following and uses the stsci tag:

  data: !unit/quantity-1.1.0
    unit: !unit/unit-1.0.0 MJy.sr**-1
    value: !core/ndarray-1.0.0
      source: 9
      datatype: float32
      byteorder: little
      shape: [4088, 4088]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Huh! My bad! I checked DN/s but not MJy/sr as I thought that surely this is a VO unit. Apparently not!

dq:
title: Data Quality Flags
description: |
Expand All @@ -48,9 +51,9 @@ properties:
exact_datatype: true
ndim: 2
err:
title: Error (electrons / s)
title: Error (DN / s) or (MJy / sr)
description: |
Error in units of electrons per second.
Error in units of DNs per second or MJ per steradian.
tag: tag:stsci.edu:asdf/unit/quantity-1.*
properties:
value:
Expand All @@ -59,12 +62,15 @@ properties:
exact_datatype: true
ndim: 2
unit:
tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["electron / s"]
oneOf:
- tag: tag:stsci.edu:asdf/unit/unit-1.*
- tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["DN / s", "MJy.sr**-1"]
var_poisson:
title: Poisson Variance (electrons^2 / s^2)
title: Poisson Variance (DN^2 / s^2) or (MJy^2 / sr^2)
description: |
Poisson variance in units of electrons^2 / second^2.
Poisson variance in units of DN^2 / second^2
or MJ per steradian.
tag: tag:stsci.edu:asdf/unit/quantity-1.*
properties:
value:
Expand All @@ -73,12 +79,14 @@ properties:
exact_datatype: true
ndim: 2
unit:
tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["electron2 / s2"]
oneOf:
- tag: tag:stsci.edu:asdf/unit/unit-1.*
- tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["DN2 / s2", "MJy**2.sr**-2"]
var_rnoise:
title: Read Noise (electrons^2 / s^2)
title: Read Noise (DN^2 / s^2) or (MJy^2 / sr^2)
description: |
Read noise in units of electrons^2 / second^2.
Read noise in units of DN^2 / second^2 or MJ^2 per steradian^2.
tag: tag:stsci.edu:asdf/unit/quantity-1.*
properties:
value:
Expand All @@ -87,13 +95,15 @@ properties:
exact_datatype: true
ndim: 2
unit:
tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["electron2 / s2"]
oneOf:
- tag: tag:stsci.edu:asdf/unit/unit-1.*
- tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["DN2 / s2", "MJy**2.sr**-2"]
var_flat:
title: Variance for Estimate of Flat Pixel Flux (electrons^2 / s^2)
title: Variance for Estimate of Flat Pixel Flux (DN^2 / s^2) or (MJy^2 / sr^2)
description: |
Variance for estimate of flat pixel flux in units of
electrons^2 / second^2.
DN^2 / second^2 or MJ^2 per steradian^2.
tag: tag:stsci.edu:asdf/unit/quantity-1.*
properties:
value:
Expand All @@ -102,8 +112,10 @@ properties:
exact_datatype: true
ndim: 2
unit:
tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["electron2 / s2"]
oneOf:
- tag: tag:stsci.edu:asdf/unit/unit-1.*
- tag: tag:astropy.org:astropy/units/unit-1.*
enum: ["DN2 / s2", "MJy**2.sr**-2"]
amp33:
title: Amp 33 Reference Pixel Data (DN)
description: |
Expand Down