<p>I was able to get my hands on some NIRspec IFU data cubes from JWST, and I was trying to combine two adjacent FOVs for getting the complete picture of my system. I used CASA prior to this to remove continuum emission from the source. I wanted to co-add them, and tried a few things:</p>
<ol>
<li>reproject_and_coadd function of reproject package. Problem is, the function does not work for 3D cubes (dimensions - RA, DEC, WAVE) but rather on 2D images. Sending in the cubes slice by slice does not seem to be a good option at this point, I am assuming there is a better way to go about this.</li>
<li>MontagePy package by IPAC. Problem is, I don't think they account for different background levels of the two FOVs (which I think reproject_and_coadd accounts for?). Their background correction executables only work for 2D images, not 3D cubes. For example, here is what I see after combining my IFU cubes with MontagePy:</li>
</ol>
<p><a href="https://i.sstatic.net/KnbeW5lG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KnbeW5lG.png" alt="a H_2 transition line that I am interested in" /></a></p>
<p>See the artifact in the middle? That is the overlap region of the two IFU cubes. I am stumped as of now as to how to rectify this, and I am pretty sure it is doable. I was curious if anyone has combined NIRSpec IFU cubes before with the JWST pipeline? If it is that I could combine the two IFU FOVs in the pipeline, then I might just do that (I wasn't able to find anything on this in the JWST documentation, they talked only about stacking 2D images)</p>
<p>Thanks!</p>

CC BY-SA 4.0
2024-08-12T16:24:39.403Z
If the wavelength axis is orthogonal to the spatial axes, I would recommend just using reproject since 3D resampling is much less efficient than multiple 2D resampling.
Roy Smart
CC BY-SA 4.0
2024-08-13T02:59:40.757Z
Yes, the wavelength axis is orthogonal to the spatial axes, no issues there. However, mosaicking is not really a thing mentioned in the documentation of reproject, for 3D spectral cubes (the function mentioned, as far as I've played with it, takes in only 2D images). I can perhaps use reproject_and_coadd only if I send in the cube wavelength by wavelength.
Senku02
CC BY-SA 4.0
2024-08-13T03:17:00.540Z
Yeah, unfortunately I think that is the best option right now. I agree it would be nice if reproject could vectorized along the wavelength axis, but alas it has not been implemented yet.
Roy Smart
<radio-astronomy><james-webb-space-telescope><astropy><fits>
Co-adding IFU data cubes
Senku02
# Co-adding IFU data cubes

(Asked by: username_0 on 2024-08-12)

I was able to get my hands on some NIRspec IFU data cubes from JWST, and I was trying to combine two adjacent FOVs for getting the complete picture of my system. I used CASA prior to this to remove continuum emission from the source. I wanted to co-add them, and tried a few things:

1. reproject\_and\_coadd function of reproject package. Problem is, the function does not work for 3D cubes (dimensions - RA, DEC, WAVE) but rather on 2D images. Sending in the cubes slice by slice does not seem to be a good option at this point, I am assuming there is a better way to go about this.
2. MontagePy package by IPAC. Problem is, I don't think they account for different background levels of the two FOVs (which I think reproject\_and\_coadd accounts for?). Their background correction executables only work for 2D images, not 3D cubes. For example, here is what I see after combining my IFU cubes with MontagePy:

[![a H_2 transition line that I am interested in](https://i.sstatic.net/KnbeW5lG.png)](https://i.sstatic.net/KnbeW5lG.png)

See the artifact in the middle? That is the overlap region of the two IFU cubes. I am stumped as of now as to how to rectify this, and I am pretty sure it is doable. I was curious if anyone has combined NIRSpec IFU cubes before with the JWST pipeline? If it is that I could combine the two IFU FOVs in the pipeline, then I might just do that (I wasn't able to find anything on this in the JWST documentation, they talked only about stacking 2D images)

Thanks!

**Tags:** radio-astronomy, james-webb-space-telescope, astropy, fits
> **Comments:**
> **username_1**: If the wavelength axis is orthogonal to the spatial axes, I would recommend just using reproject since 3D resampling is much less efficient than multiple 2D resampling.  
> **username_0**: Yes, the wavelength axis is orthogonal to the spatial axes, no issues there. However, mosaicking is not really a thing mentioned in the documentation of reproject, for 3D spectral cubes (the function mentioned, as far as I've played with it, takes in only 2D images). I can perhaps use reproject_and_coadd only if I send in the cube wavelength by wavelength.  
> **username_1**: Yeah, unfortunately I think that is the best option right now. I agree it would be nice if reproject could vectorized along the wavelength axis, but alas it has not been implemented yet.  

---

## 0 answers

