def test_muse_header(self): """WCS class: testing MUSE header specifities.""" d = dict(crval=4750., crpix=1., ctype='AWAV', cdelt=1.25, cunit=u.angstrom, shape=3681) wave = WaveCoord(**d) start = d['crval'] end = d['crval'] + d['cdelt'] * (d['shape'] - 1) assert wave.get_step() == d['cdelt'] assert wave.get_crval() == start assert wave.get_start() == start assert wave.get_end() == end assert_array_equal(wave.get_range(), [start, end]) assert wave.get_crpix() == d['crpix'] assert wave.get_ctype() == d['ctype'] def to_nm(val): return (val * u.angstrom).to(u.nm).value assert wave.get_step(u.nm) == to_nm(d['cdelt']) assert wave.get_crval(u.nm) == to_nm(start) assert wave.get_start(u.nm) == to_nm(start) assert wave.get_end(u.nm) == to_nm(end) assert_array_equal(wave.get_range(u.nm), [to_nm(start), to_nm(end)])
def test_get(self): """WaveCoord class: testing getters""" wave = WaveCoord(crval=0, crpix=1, cunit=u.nm, shape=10) assert wave.get_step(unit=u.nm) == 1.0 assert wave.get_start(unit=u.nm) == 0.0 assert wave.get_end(unit=u.nm) == 9.0 wave.set_crval(2, unit=2*u.nm) assert wave.get_crval() == 4.0 wave.set_crpix(2) assert wave.get_crpix() == 2.0 wave.set_step(2) assert wave.get_step() == 2.0 wave.set_step(2, unit=2*u.nm) assert wave.get_step() == 4.0
def test_rebin(self): """WCS class: testing rebin method""" wave = WaveCoord(crval=0, cunit=u.nm, shape=10) wave.rebin(factor=2) assert wave.get_step(unit=u.nm) == 2.0 assert wave.get_start(unit=u.nm) == 0.5 assert wave.coord(2, unit=u.nm) == 4.5 assert wave.shape == 5