Skip to content

Have Spectrum1D(spectrum,...) constructor copy a spectrum with individual attributes set. #605

@eteq

Description

@eteq

#600 adds an example of spectral shifting by creating a new Spectrum1D object. As it stands this makes sense, but the method shown there has the flow that it requires the user to specify everything the want to copy over manually. So if e.g. there's an uncertainty, or a meta or a mask, the user has to remember to include them by hand.

Instead, I think it would be better if this worked:

>>> original_spectrum = ...
>>> shifted_spectrum =  Spectrum1D(original_spectrum, spectral_axis=original_spectrum + shift)

i.e., the Spectrum1D(spec, ...something else..) construct would be understood to copy everything in spec except anything explicitly overridden in something else.

Right now Spectrum1D(original_spectrum, spectral_axis=original_spectrum + shift) works, but silently fails to update the spectral_axis. So I think this may just be a bug that needs fixing... but once it's fixed the example in #600 should be updated to reflect this idiom instead of explicitly copying the spectral axis.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions