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

corrections to the pr to the pr to the pr #10

Merged
merged 4 commits into from
May 19, 2023

Conversation

bmorris3
Copy link

PR inception continues. Corrections for bmorris3#4 (for spacetelescope#2179).

@bmorris3 bmorris3 requested a review from pllim as a code owner May 19, 2023 16:59
@@ -169,7 +173,8 @@ def _parse_image(app, file_obj, data_label, ext=None):
# for outside_*_bounding_box should also be updated.
data.coords._orig_bounding_box = data.coords.bounding_box
data.coords.bounding_box = None
data_label = app.return_data_label(data_label, alt_name="image_data")
if not data.meta.get(wcs_only_key, False):
data_label = app.return_data_label(data_label, alt_name="image_data")
Copy link
Author

Choose a reason for hiding this comment

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

Without this correction, the data label still gets appended with "DATA".

arr = ndd.data
data = Data(label=data_label)
data.meta.update(standardize_metadata(ndd.meta))
data.coords = ndd.wcs
component = Component.autotyped(arr, units="")
data.add_component(component=component, label="DATA")
return data
yield (data, data_label)
Copy link
Author

Choose a reason for hiding this comment

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

This needs to be a generator.

Copy link
Owner

Choose a reason for hiding this comment

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

I didn't think it would be inside the parser, but now that it is, yes, it has to be a generator.

Also maybe rename to _wcsonly_to_glue_data to be consistent with other generator functions.

Comment on lines 142 to 145
if file_obj.meta.get(wcs_only_key, False):
data_iter = _wcsonly2data(file_obj, data_label)
else:
data_iter = _nddata_to_glue_data(file_obj, data_label)
Copy link
Author

Choose a reason for hiding this comment

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

Your PR never actually used _wcsonly2data, so I invoke it here.

@@ -26,6 +26,7 @@

INFO_MSG = ("The file contains more viewable extensions. Add the '[*]' suffix"
" to the file name to load all of them.")
wcs_only_key = "_WCS_ONLY"
Copy link
Owner

Choose a reason for hiding this comment

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

Can we use the app attribute instead of re-defining it here?

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@@ -169,7 +173,8 @@ def _parse_image(app, file_obj, data_label, ext=None):
# for outside_*_bounding_box should also be updated.
data.coords._orig_bounding_box = data.coords.bounding_box
data.coords.bounding_box = None
data_label = app.return_data_label(data_label, alt_name="image_data")
if not data.meta.get(wcs_only_key, False):
Copy link
Owner

Choose a reason for hiding this comment

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

Should we use the layer_is_wcs_only check here?

Copy link
Author

Choose a reason for hiding this comment

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

We could but it's the same check?

@@ -407,11 +412,11 @@ def _ndarray_to_glue_data(arr, data_label):
# ---- Functions that handle WCS-only data -----

def _wcsonly2data(ndd, data_label):
"""Return Data given NDData containly WCS-only data."""
"""Return Data given NDData containing WCS-only data."""
Copy link
Owner

Choose a reason for hiding this comment

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

Haha! What was I thinking?

@@ -383,7 +383,7 @@ def _prepare_rotated_nddata(real_image_shape, wcs, rotation_angle, refdata_shape
# create a fake NDData (we use arange so data boundaries show up in Imviz
# if it ever is accidentally exposed) with the rotated GWCS:
ndd = NDData(
data=np.arange(sum(refdata_shape), dtype=np.int8).reshape(refdata_shape),
data=np.arange(np.prod(refdata_shape), dtype=np.int8).reshape(refdata_shape),
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm does plain sum not work for you? The shape should be a plain tuple if ints.

Copy link
Author

Choose a reason for hiding this comment

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

If shape is (10, 10), sum is 20. We want the product (100).

Copy link
Owner

Choose a reason for hiding this comment

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

Oh, right... I didn't catch that with (2, 2). Doh!

jdaviz/configs/imviz/plugins/parsers.py Outdated Show resolved Hide resolved
jdaviz/configs/imviz/plugins/parsers.py Outdated Show resolved Hide resolved
@@ -383,7 +383,7 @@ def _prepare_rotated_nddata(real_image_shape, wcs, rotation_angle, refdata_shape
# create a fake NDData (we use arange so data boundaries show up in Imviz
# if it ever is accidentally exposed) with the rotated GWCS:
ndd = NDData(
data=np.arange(sum(refdata_shape), dtype=np.int8).reshape(refdata_shape),
data=np.arange(np.prod(refdata_shape), dtype=np.int8).reshape(refdata_shape),
Copy link
Owner

Choose a reason for hiding this comment

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

Oh, right... I didn't catch that with (2, 2). Doh!

@pllim
Copy link
Owner

pllim commented May 19, 2023

Thanks! I'll merge this and then clean up my PR to your PR. Hang in there!

@pllim pllim merged commit b856b4a into pllim:pr-to-pr2179 May 19, 2023
pllim added a commit that referenced this pull request Nov 3, 2023
#4)

* Lim edits

* Improve verbiage in docstring

Co-authored-by: Brett M. Morris <[email protected]>

* Address review comments from bmorris3

* Add multi WCS-only test back

* Update concept notebook

* corrections to the pr to the pr to the pr (#10)

* corrections to the pr to the pr to the pr

* using app-level attr

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

---------

Co-authored-by: P. L. Lim <[email protected]>

* Follow up to PR to my PR to your PR

* WCS-only must be loaded
into viewer but not visible.

Fix concept notebook

---------

Co-authored-by: Brett M. Morris <[email protected]>
pllim added a commit that referenced this pull request Nov 15, 2023
#4)

* Lim edits

* Improve verbiage in docstring

Co-authored-by: Brett M. Morris <[email protected]>

* Address review comments from bmorris3

* Add multi WCS-only test back

* Update concept notebook

* corrections to the pr to the pr to the pr (#10)

* corrections to the pr to the pr to the pr

* using app-level attr

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

---------

Co-authored-by: P. L. Lim <[email protected]>

* Follow up to PR to my PR to your PR

* WCS-only must be loaded
into viewer but not visible.

Fix concept notebook

---------

Co-authored-by: Brett M. Morris <[email protected]>
pllim added a commit that referenced this pull request Dec 8, 2023
#4)

* Lim edits

* Improve verbiage in docstring

Co-authored-by: Brett M. Morris <[email protected]>

* Address review comments from bmorris3

* Add multi WCS-only test back

* Update concept notebook

* corrections to the pr to the pr to the pr (#10)

* corrections to the pr to the pr to the pr

* using app-level attr

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

---------

Co-authored-by: P. L. Lim <[email protected]>

* Follow up to PR to my PR to your PR

* WCS-only must be loaded
into viewer but not visible.

Fix concept notebook

---------

Co-authored-by: Brett M. Morris <[email protected]>
pllim added a commit that referenced this pull request Dec 8, 2023
#4)

* Lim edits

* Improve verbiage in docstring

Co-authored-by: Brett M. Morris <[email protected]>

* Address review comments from bmorris3

* Add multi WCS-only test back

* Update concept notebook

* corrections to the pr to the pr to the pr (#10)

* corrections to the pr to the pr to the pr

* using app-level attr

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

---------

Co-authored-by: P. L. Lim <[email protected]>

* Follow up to PR to my PR to your PR

* WCS-only must be loaded
into viewer but not visible.

Fix concept notebook

---------

Co-authored-by: Brett M. Morris <[email protected]>
pllim added a commit that referenced this pull request Jan 23, 2024
#4)

* Lim edits

* Improve verbiage in docstring

Co-authored-by: Brett M. Morris <[email protected]>

* Address review comments from bmorris3

* Add multi WCS-only test back

* Update concept notebook

* corrections to the pr to the pr to the pr (#10)

* corrections to the pr to the pr to the pr

* using app-level attr

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

* Update jdaviz/configs/imviz/plugins/parsers.py

Co-authored-by: P. L. Lim <[email protected]>

---------

Co-authored-by: P. L. Lim <[email protected]>

* Follow up to PR to my PR to your PR

* WCS-only must be loaded
into viewer but not visible.

Fix concept notebook

---------

Co-authored-by: Brett M. Morris <[email protected]>
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