예제 #1
0
def test_get_Spectrum(spec_var):
    """Spectrum class: testing getters"""
    wave = WaveCoord(crpix=2.0, cdelt=3.0, crval=0.5, cunit=u.nm)
    spectrum1 = Spectrum(data=np.array([0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) * 2.3,
                         wave=wave)
    a = spectrum1[1:7]
    assert a.shape[0] == 6
    a = spectrum1.subspec(1.2, 15.6, unit=u.nm)
    assert a.shape[0] == 6

    unit = spec_var.wave.unit
    spvarcut = spec_var.subspec(5560, 5590, unit=unit)
    assert spvarcut.shape[0] == 48
    assert_almost_equal(spvarcut.get_start(unit=unit), 5560.25, 2)
    assert_almost_equal(spvarcut.get_end(unit=unit), 5589.89, 2)
    assert_almost_equal(spvarcut.get_step(unit=unit), 0.63, 2)
예제 #2
0
파일: steps.py 프로젝트: musevlt/origin
    def run(self, orig, grid_dxy=0, spectrum_size_fwhm=6):
        self.Cat2, line_est, line_var = estimation_line(
            orig.Cat1,
            orig.cube_raw,
            orig.var,
            orig.PSF,
            orig.wfields,
            orig.wcs,
            orig.wave,
            size_grid=grid_dxy,
            criteria='flux',
            order_dct=30,
            horiz_psf=1,
            horiz=5,
        )
        _format_cat(self.Cat2)

        self._loginfo('Save the updated catalog in self.Cat2 (%d lines)',
                      len(self.Cat2))

        # Radius for spectrum trimming
        radius = np.ceil(np.array(orig.FWHM_profiles) * spectrum_size_fwhm / 2)
        radius = radius.astype(int)

        self.spectra = OrderedDict()
        for row, data, vari in zip(self.Cat2, line_est, line_var):
            profile, z, num_line = row['profile', 'z', 'num_line']
            z_min = z - radius[profile]
            z_max = z + radius[profile]
            if len(data) > 1:  # RB test for bug in GridAnalysis
                sp = Spectrum(data=data,
                              var=vari,
                              wave=orig.wave,
                              mask=np.ma.nomask,
                              copy=False)
                self.spectra[num_line] = sp.subspec(z_min, z_max, unit=None)

        self._loginfo('Save estimated spectrum of each line in self.spectra')