Open astro-pablo opened 7 months ago
SpectralCube
s are intentionally not mutable - mutability requires loading the whole object into memory, in general.
y.copy()
is copying a OneDSpectrum
object, which is not a SpectralCube
object. If you want a copy of a cube, you can get that easily enough with:
cubecopy = cube[:]
If you're trying to baseline-subtract a cube, you can do:
baseline = np.polynomial.Polynomial(params['coef'])(x) * spectrum_avg.unit
baseline_subtracted_cube = cube - baseline[:,None,None]
based on your code. It will not - and cannot, by construction - update the original cube in place.
I can not update the intensity values within a SpectralCube after baseline subtraction:
output:
I tried by updating the values of a copy of the cube, but I get the following error when creating the copy:
output:
which is very strange since the y.copy() in the previous code just works fine.