Beispiel #1
0
def test_spectrum1dref_copy():
    """
    Test the ability to duplicate a Spectrum1DRef object.
    """
    wcs = WCS({"CUNIT1": "Angstrom", "CRVAL1": 200.0, "CDELT1": 1.0})
    data = np.random.sample(100)
    disp = np.arange(100)
    spectrum = Spectrum1DRef.from_array(data,
                                        dispersion=disp,
                                        unit=u.Unit("Jy"),
                                        dispersion_unit=u.Unit("Angstrom"),
                                        wcs=wcs,
                                        meta={'author': 'me'})

    spectrum_copy = Spectrum1DRef.copy(spectrum)

    # Check data
    assert (spectrum.data == spectrum_copy.data).all()
    assert (spectrum.dispersion == spectrum_copy.dispersion).all()

    # Check unit, wcs, meta
    assert spectrum.unit == spectrum_copy.unit
    assert spectrum.wcs.wcs.cunit[0] == spectrum_copy.wcs.wcs.cunit[0]
    assert spectrum.wcs.wcs.crval[0] == spectrum_copy.wcs.wcs.crval[0]
    assert spectrum.wcs.wcs.cdelt[0] == spectrum_copy.wcs.wcs.cdelt[0]
    assert spectrum.meta == spectrum_copy.meta
def test_spectrum1dref_from_array():
    """
    Test the ability to create a spectrum object from data and dispersion
    arrays with optional units.
    """
    data = np.random.sample(100)
    disp = np.arange(100)
    spectrum = Spectrum1DRef.from_array(data, dispersion=disp,
                                        unit=u.Unit("Jy"),
                                        dispersion_unit=u.Unit("Angstrom"))

    # Compare units
    assert spectrum.unit == u.Unit("Jy")
    assert spectrum.dispersion_unit == u.Unit("Angstrom")

    # Test data
    assert (spectrum.data == data).all()
    assert (spectrum.dispersion == disp).all()
Beispiel #3
0
def test_spectrum1dref_from_array():
    """
    Test the ability to create a spectrum object from data and dispersion
    arrays with optional units.
    """
    data = np.random.sample(100)
    disp = np.arange(100)
    spectrum = Spectrum1DRef.from_array(data,
                                        dispersion=disp,
                                        unit=u.Unit("Jy"),
                                        dispersion_unit=u.Unit("Angstrom"))

    # Compare units
    assert spectrum.unit == u.Unit("Jy")
    assert spectrum.dispersion_unit == u.Unit("Angstrom")

    # Test data
    assert (spectrum.data == data).all()
    assert (spectrum.dispersion == disp).all()
def test_spectrum1dref_copy():
    """
    Test the ability to duplicate a Spectrum1DRef object.
    """
    wcs = WCS({"CUNIT1": "Angstrom", "CRVAL1": 200.0, "CDELT1": 1.0})
    data = np.random.sample(100)
    disp = np.arange(100)
    spectrum = Spectrum1DRef.from_array(data, dispersion=disp,
                                        unit=u.Unit("Jy"),
                                        dispersion_unit=u.Unit("Angstrom"),
                                        wcs=wcs, meta={'author': 'me'})

    spectrum_copy = Spectrum1DRef.copy(spectrum)

    # Check data
    assert (spectrum.data == spectrum_copy.data).all()
    assert (spectrum.dispersion == spectrum_copy.dispersion).all()

    # Check unit, wcs, meta
    assert spectrum.unit == spectrum_copy.unit
    assert spectrum.wcs.wcs.cunit[0] == spectrum_copy.wcs.wcs.cunit[0]
    assert spectrum.wcs.wcs.crval[0] == spectrum_copy.wcs.wcs.crval[0]
    assert spectrum.wcs.wcs.cdelt[0] == spectrum_copy.wcs.wcs.cdelt[0]
    assert spectrum.meta == spectrum_copy.meta