-
Notifications
You must be signed in to change notification settings - Fork 74
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
[Feature Request] let imviz load jwst data model objects directly #3252
Comments
@eteq , is still a problem on your end? I cannot reproduce the error. The image loads fine with jdaviz 4.1.dev (current |
@eteq you can load this file just fine, by passing the filename to |
First I just want to confirm: @pllim , when you say you got it to work, do you mean you did it the https://jdaviz.readthedocs.io/en/stable/imviz/import_data.html#jwst-datamodels way, or the way my snippet shows above? @rosteen - thanks for the pointer, I didn't notice that snippet! That said, it has two major problem that makes it not work for my use case:
And one minor problem:
Is there a reason why a more complete version of that snippet (e.g. with the copy=False's in place and the metadata copied over) can't be implemented? I forget now if imviz uses unified-I/O or similar, but that would seem to be the way to do it... |
Yes sorry, I was only trying the ways we officially support, not the exact snippet using objects. |
I wouldn't call loading model objects into Imviz a basic use case. Most users would pass in the filename and be done with it. |
I disagree! There are many science use cases where the objects are the only available object. It is very not safe to assume a file is even present, and the regularity of which that's assumed is probably my single top "minor-to-moderate" annoyance when interacting with code as a scientist (not jdaviz specifically, which is much better than most, to be fair! I'm talking about the whole Python ecosystem). At any rate, to be clear, I'm willing to spin up a PR myself to do this since I think I know the API-level interface of relevance. What I don't know is where the best place is to put more specific code like this - i.e., is there a unified I/O hook somewhere, or would I need to add a case to |
Can you please clarify? Did someone send you a pickled object instead of the JWST data product? |
Checking for object at the And this is sounds like a feature request, not a bug. |
Ah, point taken this is a feature request. Will re-label! |
But still, how does a scientist only has access to an object and not the actual file? |
Some examples:
In practice, the majority of my image use cases (probably of order 80%) fall under one of those three. Additionally, 1 will be much more common in a science platform setting, which will be mandatory usage for certain future astronomy settings (e.g. Rubin, and Roman) |
(to be clear: in all of those cases, one can simply write to disk and then load that data, but that's pretty annoying and sometimes problematic from a storage perspective. In practice with code where I'm forced to do that, I regularly say "not worth it, I'll find some other package or roll my own") |
For 1, streaming is currently not supported. It is an entirely different ticket/epic/whatever. For 2 and 3, as Ricky pointed out, you can still stuff it into NDData. I am pretty sure it does not make copies but given @bmorris3 is also If you insist on native support for specific objects, please list them and point us to where they are documented. Thanks. |
Sorry, miscommunication there. I mean something like:
This is a CORE WORKFLOW for some major science cases. Of course you're right if there's an NDData adapter available that is already included, but I was trying to answer your question of what the science cases are and why you can't just use a file. |
I thought the NDData had the problem of the missing header? or did i misunderstand? |
The snippet in the docs indeed are missing the metadata. so you are understanding that right (although there's surely a way to do that, it's annoying that I have to do that with the datamodel object instead of it loading as straightforwardly as loading the file directly is) |
(Oh, and I'm not insisting on specific objects to support, but rather trying to understand how to plug in support for specific objects - i.e., like how unified I/O is used in specutils to let lots of people make PRs to support various data objects.) |
Not pretty but I guess... still need to know what models to support though. There are many available in JWST, right? jdaviz/jdaviz/configs/imviz/plugins/parsers.py Lines 22 to 27 in 1f57249
Yes, I understand and I agree. I was just saying that is already covered in a separate ticket somewhere (for Roman, I think).
That is a small doc update to fix. You can pass in
As you pointed out, spectra are handled via specutils I/O. I don't think unified I/O for imaging should be in |
that's a good point, but just to be clear I'm realizing I was being a bit confusing in my wording above so will clarify here: What I'm thinking about is something akin to the unified I/O in that it's pluggable and external players might contribute their own if they want support, but it's different in that it's not about file I/O but rather sort of a "translation layer" for data objects. I.e., some short snippets that translate a jwst datamodel (with certain limited assumptions) into an NDData like what the snippet does. Having said that it's debatable where that code best lives: in |
If we limit this request to ASDF models (instead of arbitrary format), I think it makes sense to have that layer in |
Ah, that might be a good direction to consider, @pllim . I think the key, though, is ensuring it carries enough contextual information over. I think I worked out the magic incantation to do what I need, and I'll make a PR shortly to fix the doc section about this. Note, though, that does not close this, because I still think it's really annoying to do it that way vs the above, but I'm with you that this might in practice than be an upstream fix needed to do it. |
Alright, I checked and at least for my science case the change I'm suggesting in #3279 makes an NDData object that seems to have no copying ( |
If you open a feature request for |
Jdaviz component
Imviz
Description
The documentation for
Imviz.load_data
implies that it should be possible to load asdf-in-fits files from jwst directly. However, when I try to do that (see "how to reproduce"), I get the error below.Note if I load using
stdatamodels.asdf_in_fits
instead ofjwst.datamodels
I get a different error but still an error:How to Reproduce
can substitute
stdatamodels.asdf_in_fits
forjwst.datamodels
and I still get an errorExpected behavior
The image should load without complaint.
Browser
Latest Stable Chrome
Jupyter
Software versions
import platform; print(platform.platform())
import sys; print("Python", sys.version)
import numpy; print("Numpy", numpy.version)
import astropy; print("astropy", astropy.version)
import matplotlib; print("matplotlib", matplotlib.version)
import scipy; print("scipy", scipy.version)
import skimage; print("scikit-image", skimage.version)
import asdf; print("asdf", asdf.version)
import stdatamodels; print("stdatamodels", stdatamodels.version)
import gwcs; print("gwcs", gwcs.version)
import regions; print("regions", regions.version)
import specutils; print("specutils", specutils.version)
import specreduce; print("specreduce", specreduce.version)
import photutils; print("photutils", photutils.version)
import astroquery; print("astroquery", astroquery.version)
import yaml; print("pyyaml", yaml.version)
import asteval; print("asteval", asteval.version)
import idna; print("idna", idna.version)
import traitlets; print("traitlets", traitlets.version)
import bqplot; print("bqplot", bqplot.version)
import bqplot_image_gl; print("bqplot-image-gl", bqplot_image_gl.version)
import glue; print("glue-core", glue.version)
import glue_jupyter; print("glue-jupyter", glue_jupyter.version)
import glue_astronomy; print("glue-astronomy", glue_astronomy.version)
import echo; print("echo", echo.version)
import ipyvue; print("ipyvue", ipyvue.version)
import ipyvuetify; print("ipyvuetify", ipyvuetify.version)
import ipysplitpanes; print("ipysplitpanes", ipysplitpanes.version)
import ipygoldenlayout; print("ipygoldenlayout", ipygoldenlayout.version)
import ipypopout; print("ipypopout", ipypopout.version)
import jinja2; print("Jinja2", jinja2.version)
import solara; print("solara", solara.version)
import vispy; print("vispy", vispy.version)
import sidecar; print("sidecar", sidecar.version)
import jdaviz; print("Jdaviz", jdaviz.version)
🐱
The text was updated successfully, but these errors were encountered: