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

        sed1 = IrisSed(x=self.x,y=self.y,yerr=self.yerr, id='sed1')
        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')
        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')

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

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

        self.assertEqual(len(shifted_stack.segments), 3)
        self.assertRaises((InvalidRedshiftError, NoRedshiftError), sed1.shift, -5.0)

        self.assertEqual(shifted_stack.excluded, ['sed1', 'sed2', 'sed3'])
コード例 #2
0
ファイル: test_iris_sed.py プロジェクト: jbudynk/sedstacker
    def test_redshift_no_correct_flux(self):

        # what the yerrs should be
        yerr = numpy.array([
            [0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, numpy.nan, 0.92,],
            [0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, numpy.nan, 0.09, 0.09, 0.09, 0.09, 0.82,],
            [0.09, 0.09, 0.09, numpy.nan, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.78,],
            [0.63, 0.36, 0.44, 0.16, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.81,],
            [0.11, 0.09, 0.13, 0.13, 0.09, 0.09, 0.09, 0.21, 0.09, 0.09, 0.09, 0.09, 0.09, 0.78,],
            [0.68, 0.30, 0.35, 0.30, 0.22, 0.25, 0.63, 0.51, 0.14, 0.14, 0.14, 0.14, 0.14, 1.22,]
        ])

        # make dummy data
        y = numpy.array([
            [0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 1.0, 0.92,],
            [0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 1.0, 0.09, 0.09, 0.09, 0.09, 0.82,],
            [0.09, 0.09, 0.09, 1.0, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.78,],
            [0.63, 0.36, 0.44, 0.16, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.81,],
            [0.11, 0.09, 0.13, 0.13, 0.09, 0.09, 0.09, 0.21, 0.09, 0.09, 0.09, 0.09, 0.09, 0.78,],
            [0.68, 0.30, 0.35, 0.30, 0.22, 0.25, 0.63, 0.51, 0.14, 0.14, 0.14, 0.14, 0.14, 1.22,]
        ])
        x = numpy.arange(len(y[0]))
        x = numpy.array([x, x[0:13], x, x, x, x])
        z = [1,2,3,4,5,6]

        # populate IrisStack
        seds = []
        for i in range(6):
            seds.append(IrisSed(x=x[i], y=y[i], yerr=yerr[i], z=z[i]))
        seds = IrisStack(seds)

        # shift the stack without correcting for flux
        shifted_seds = seds.shift(0, correct_flux=False)

        # The y-errors should be the same before and after the shift
        for i, sed in enumerate(shifted_seds):
            numpy.testing.assert_array_almost_equal(yerr[i], sed.yerr)
コード例 #3
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)