コード例 #1
0
ファイル: test_Stack.py プロジェクト: jbudynk/sedstacker
    def test_shift_NoRedshift(self):

        segment1 = Spectrum(x = numpy.arange(1000,10000,10),
                            y = numpy.arange(1000,10000,10),
                            z=1.0)
        segment2 = Sed(x=numpy.arange(1000,10000,500),
                       y=numpy.arange(1000,10000,500))
        segment3 = Sed(x=numpy.arange(1000,10000,500),
                       y=numpy.arange(1000,10000,500),
                       z = 0.35)

        aggsed = Stack([segment1, segment2, segment3])

        shift_aggsed = aggsed.shift(0.5)

        self.assertEqual(len(shift_aggsed), 2)
        self.assertAlmostEqual(shift_aggsed.x[0][1], 757.5)
        self.assertAlmostEqual(shift_aggsed.x[1][1], 1666.6666667)
コード例 #2
0
ファイル: test_Stack.py プロジェクト: jbudynk/sedstacker
    def test_shift(self):

        segment1 = Spectrum(x = numpy.arange(1000,10000,10),
                            y = numpy.arange(1000,10000,10),
                            z = 1.0)
        segment2 = Sed(x=numpy.arange(1000,10000,500),
                       y=numpy.arange(1000,10000,500),
                       z = 0.5)
        segment3 = Sed(x=numpy.arange(1000,10000,500),
                       y=numpy.arange(1000,10000,500),
                       z = 0.35)

        aggsed = Stack([segment1, segment2, segment3])

        shift_aggsed = aggsed.shift(0.4)

        self.assertEqual(shift_aggsed[0].z, shift_aggsed[1].z)
        self.assertEqual(shift_aggsed[0].z, 0.4)
        self.assertAlmostEqual(shift_aggsed.x[0][10], 770.0)
コード例 #3
0
ファイル: test_Stack.py プロジェクト: jbudynk/sedstacker
    def test_norm_by_int_correct_flux(self):
        
        segment1 = Spectrum(x=numpy.arange(1000,10000,10),
                            y=numpy.arange(1000,10000,10),
                            yerr=numpy.arange(1000,10000,10)*.01,
                            z=0.0)
        segment2 = Sed(x=numpy.arange(1000,10000,500),
                       y=numpy.arange(1000,10000,500),
                       yerr=numpy.arange(1000,10000,500)*.01,
                       z=0.0)
        segment3 = Sed(x=numpy.arange(1000,10000,500),
                       y=numpy.arange(1000,10000,500),
                       yerr=numpy.arange(1000,10000,500)*.01,
                       z = 0)
        segment4 = Spectrum(x=numpy.arange(1000,10000,10),
                            y=numpy.arange(1000,10000,10),
                            yerr=numpy.arange(1000,10000,10)*.01,
                            z=0)

        aggsed = Stack([segment1, segment2, segment3, segment4])

        norm_aggsed = aggsed.normalize_by_int(correct_flux=True, z0=[1,.5,.1,1])

        aggsed[0].z=1.0
        aggsed[1].z=0.5
        aggsed[2].z=0.1
        aggsed[3].z=1.0
        rf_aggsed=aggsed.shift(0.0)
        rf_aggsed0=rf_aggsed[0].shift(1.0, correct_flux=False)
        rf_aggsed1=rf_aggsed[1].shift(0.5, correct_flux=False)
        rf_aggsed2=rf_aggsed[2].shift(0.1, correct_flux=False)
        rf_aggsed3=rf_aggsed[3].shift(1.0, correct_flux=False)
        rf_aggsed=Stack([rf_aggsed0,rf_aggsed1,rf_aggsed2,rf_aggsed3])
        control_norm_aggsed = rf_aggsed.normalize_by_int()

        self.assertAlmostEqual(norm_aggsed.segments[0].norm_constant, control_norm_aggsed[0].norm_constant)
        self.assertAlmostEqual(norm_aggsed[1].norm_constant,1.4939309057e-08)
        numpy.testing.assert_array_almost_equal(control_norm_aggsed[0].y,norm_aggsed[0].y)
        sed=norm_aggsed[1]
        control_sed=control_norm_aggsed[1]
        numpy.testing.assert_array_almost_equal(control_sed.y,sed.y)
        numpy.testing.assert_array_almost_equal(control_sed.y,sed.y)
コード例 #4
0
ファイル: test_iris_sed.py プロジェクト: jbudynk/sedstacker
    def test_redshift_correct_flux(self):

        sed1 = IrisSed(x=self.x,y=self.y,yerr=self.yerr, id='sed1', z=0.1)
        sed2 = IrisSed(x=numpy.array([2,4,5,8,10]), y=numpy.arange(5)+1.0, yerr=numpy.arange(5)+1.0*0.1, id='sed2', z=0.1)
        y = numpy.array([5.0, 15.0, 7.0, 4.5, 13.5, 10.5])
        x = numpy.array([0.5, 1.5, 3.0, 5.0, 10.5, 21.0])
        sed3 = IrisSed(x=x, y=y, yerr=y*0.1, id='sed3', z=0.1)

        iris_stack = IrisStack([sed1, sed2, sed3])
        shifted_iris_stack = iris_stack.shift(0.0, correct_flux=True)

        sed1 = IrisSed(x=self.x,y=self.y,yerr=self.yerr, z=0.1)
        sed2 = IrisSed(x=numpy.array([2,4,5,8,10]), y=numpy.arange(5)+1.0, yerr=numpy.arange(5)+1.0*0.1, z=0.2)
        y = numpy.array([5.0, 15.0, 7.0, 4.5, 13.5, 10.5])
        x = numpy.array([0.5, 1.5, 3.0, 5.0, 10.5, 21.0])
        sed3 = IrisSed(x=x, y=y, yerr=y*0.1, z=0.3)

        stack = Stack([sed1, sed2, sed3])

        shifted_stack = stack.shift(0.0, correct_flux=True)

        self.assertEqual(len(shifted_iris_stack.segments), 3)
        numpy.testing.assert_array_almost_equal(shifted_stack[0].x, shifted_iris_stack[0].x)
        numpy.testing.assert_array_almost_equal(shifted_stack[0].y, shifted_iris_stack[0].y)