Esempio n. 1
0
    def test_load_spectrum_three_cols(self):

        spectrum = io.load_sed(test_directory+'case1.dat',
                               sed_type='spectrum')

        self.assertEqual(spectrum.x[0], 814.020019531)
        self.assertEqual(spectrum.y[3], -1.21521716301e-14)

        sed = io.load_sed(test_directory+'case1.dat', sed_type='sed')

        self.assertEqual(sed[0].x, 814.020019531)
        self.assertEqual(sed[3].y, -1.21521716301e-14)
Esempio n. 2
0
    def test_load_spectrum_three_cols_no_col_names(self):
        
        spectrum = io.load_sed(test_directory+'case2_3columnsNoNames.dat',
                               sed_type='spectrum')

        #testing.assert_array_equal(sed.x, control_x)
        #testing.assert_array_equal(sed.y, control_y)
        #testing.assert_array_equal(sed.yerr, control_yerr)
        #testing.assert_array_equal(sed.xunit, control_xunit)
        #testing.assert_array_equal(sed.yunit, control_yunit)

        pass
Esempio n. 3
0
    def test_load_sed_no_yerr_no_col_names(self):

        sed = io.load_sed(test_directory+'case4_2columnsNoNames.dat',
                          sed_type='sed')

        control_x = array([814.020019531, 814.538879394, 815.057678223,
                           815.576538086, 816.095336914])
        control_y = array([-1.21828545516e-14, -1.21726630511e-14,
                            -1.21624715507e-14, -1.21521716301e-14,
                            -1.21419801297e-14])
        control_yerr = array([nan, nan, nan, nan, nan])
        control_xunit = array(['AA','AA','AA','AA','AA'])
        control_yunit = array(['erg/s/cm**2/AA','erg/s/cm**2/AA',
                               'erg/s/cm**2/AA','erg/s/cm**2/AA',
                               'erg/s/cm**2/AA'])
        
        testing.assert_array_almost_equal(sed.x, control_x)
        testing.assert_array_almost_equal(sed.y, control_y)
        testing.assert_array_almost_equal(sed.yerr, control_yerr)
        testing.assert_array_equal(sed.xunit, control_xunit)
        testing.assert_array_equal(sed.yunit, control_yunit)
start = time.clock()
logger_io=logging.getLogger('sedstacker.io')
logger_io.setLevel(logging.ERROR)
logger_sed=logging.getLogger('sedstacker.sed')
logger_sed.setLevel(logging.ERROR)

test_directory = os.path.dirname(sedstacker.__file__)+"/tests/resources/spectra/"

os.system('rm '+test_directory+'stacked_spectra_maskcc10.dat')
files = os.listdir(test_directory)

specs = []
counter = 0
while counter < 14:
    spec = load_sed(test_directory+files[counter], sed_type="spectrum")
    specs.append(spec)
    counter += 1

#specs = [load_sed(test_directory+f, sed_type="spectrum") for f in files]
for spec in specs:
    spec.z = np.random.random_sample()

aggsed = AggregateSed(specs)

norm_aggsed = aggsed.normalize_at_point(3500.0, 1.0)

stack_spectra = stack(norm_aggsed, 10.0, 'avg', fill='fill')

stack_spectra.write(test_directory+'stacked_spectra_maskcc10.dat')