Exemple #1
0
def Preprocessing4(path):
    files = []
    for filename in glob.glob(path):
        files.append(filename)
    #spectrum's S/N >= 15
    Better_files = []
    for input_file in files:
        spec = ls.rdspec(input_file)
        if spec.snr[0] >= 15:
            Better_files.append(input_file)
    #read and normalize spectrum
    samples = []
    for input_file in Better_files:
        spec = ls.rdspec(input_file)
        flux = np.array(spec.flux)
        wavelength = np.array(spec.wave)
        flux_norm, flux_cont = norm.normalize_spectrum(wavelength, flux,
                                                       (3500., 9500.), 100.)
        num_end = 0
        num_head = 0
        for i in range(len(wavelength)):
            if wavelength[i] <= 9500:
                num_end += 1
            if wavelength[i] <= 3500:
                num_head += 1
        data_spec = [wavelength[num_head:num_end], flux_norm[num_head:num_end]]
        samples.append(data_spec)
    return samples
Exemple #2
0
def Preprocessing3(path):
    files = []
    for filename in glob.glob(path):
        files.append(filename)
    #spectrum's S/N >= 15
    Better_files = []
    for input_file in files:
        spec = ls.rdspec(input_file)
        if spec.snr[0] >= 15:
            Better_files.append(input_file)
    #read and normalize spectrum
    samples = []
    for input_file in Better_files:
        hdu_list = fits.open(input_file, memmap=True)
        data = Table(hdu_list[1].data)
        flux = np.array(data['flux'])
        wavelength = np.array(10**data['loglam'])
        flux_norm, flux_cont = norm.normalize_spectrum(wavelength, flux,
                                                       (3500., 9500.), 100.)
        num_end = 0
        num_head = 0
        for i in range(len(wavelength)):
            if wavelength[i] <= 9500:
                num_end += 1
            if wavelength[i] <= 3500:
                num_head += 1
        data_spec = [wavelength[num_head:num_end], flux_norm[num_head:num_end]]
        samples.append(data_spec)
    return samples
Exemple #3
0
def Preprocessing6(path):
    files = []
    for filename in glob.glob(path):
        files.append(filename)
    samples = []
    for input_file in files:
        spec = ls.rdspec(input_file)
        flux = np.array(spec.flux)
        wavelength = np.array(spec.wave)
        flux_norm, flux_cont = norm.normalize_spectrum(wavelength, flux,
                                                       (3500., 9500.), 100.)
        #         num_end = 0
        #         num_head = 0
        #         for i in range(len(wavelength)):
        #             if wavelength[i] <= 9500:
        #                 num_end += 1
        #             if wavelength[i] <= 3500:
        #                 num_head += 1
        data_spec = [wavelength, flux_norm]
        samples.append(data_spec)
    return samples