jdat_notebooks
jdat_notebooks copied to clipboard
ValueError: The image shapes must match.
Hi,
I'm trying to follow this sample code with real JWST data
/NIRCam_multiband_photometry.ipynb
In the sample F200W, F150W and F090W are all the same shape (1000, 1000)
In JWST data the shapes are different.
ValueError: The image shapes must match. r: (12487, 14593), g: (12375, 14426) b: (12481, 14586)
Is there a way to make this Python code work with real JWST data?
Thank you,
Joseph Karpinski


Thanks @JosephKarpinski when I get more time I can certainly look into writing a solution, but off the cuff, I have 2 short term answers:
- This is just a matter of cropping and aligning your images before entering them into the function. Ideally, a user can figure that out. Like I said, when I get more time, I can help, but it may not be immediately.
- This code is making a RGB color image. Ideally, our team would like to replace this snippet with using our Jdaviz tools rather than matplotlib. I have put together a little informal and unofficial tutorial and movie for you if you'd like to try yourself. https://github.com/orifox/jwst_ero
Haven’t had a chance to look at this yet. Couldn’t get jdaviz to run under VSCode. Submitted an issue record. Just got the recommended fix today and tested it out.
Re: [spacetelescope/jdaviz] [BUG] Imviz: AttributeError: 'NoneType' object has no attribute 'group' (Issue #1533)
Could you upgrade ipypopout to >= 0.0.11 ? This version prevents this error
Sent from my iPad
On Jul 31, 2022, at 10:46 AM, Ori Fox @.***> wrote:
Thanks @JosephKarpinski when I get more time I can certainly look into writing a solution, but off the cuff, I have 2 short term answers:
This is just a matter of cropping and aligning your images before entering them into the function. Ideally, a user can figure that out. Like I said, when I get more time, I can help, but it may not be immediately. This code is making a RGB color image. Ideally, our team would like to replace this snippet with using our Jdaviz tools rather than matplotlib. I have put together a little informal and unofficial tutorial and movie for you if you'd like to try yourself. https://github.com/orifox/jwst_ero — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.
2. This code is making a RGB color image. Ideally, our team would like to replace this snippet with using our Jdaviz tools rather than matplotlib. I have put together a little informal and unofficial tutorial and movie for you if you'd like to try yourself. https://github.com/orifox/jwst_ero
I'll (unofficially ;-) second this recommendation for a good starting point.
To get further towards creating an RGB image, the following steps may be helpful, assuming you have loaded 3 image data sets into the imviz
instance:
imviz.link_data(link_type='wcs') # Align all datasets to matching world coordinates
viewer.state.color_mode = 'One color per layer'
colours = ('#0000ffff', '#00ff00ff', '#ff0000ff') # Pick pure blue, green, red for the three channels – to be experimented with
for layer, colour in zip(imviz.default_viewer.layers, colours):
layer.state.color = colour
imviz.show() # Might want to display in a separate window for maximising size with `imviz.show('popout')`
viewer.save('My_Image')
viewer.figure.save_png('My_Image_upscaled', scale=2)
Exporting images this way the resolution is based on the viewport resolution, so not really suitable for high-resolution pictures. The second option is directly accessing the bqplot.figure
instance to use its scale
option, but I think this still simply oversamples the viewer
data, so is not much of an improvement.
Might also be worth looking into make_lupton_rgb
for some more sophisticated algorithms for assigning the colour channels.
This is two years old and much has changed since then. Please open another issue if you still have problems. Thank you!