Beispiel #1
0
def pickl(fname):
    try:
        cor = cor_exp(fname)
        sub_con = np.copy(cor)
        sub_fit = np.copy(cor)
        pickle.dump(
            cor,
            open(
                '/mnt/gastro/sarel/sdss/no_smooth/none_trial/sub_exposures/%s.p'
                % fname, 'wb'))
        for j in range(len(sub_con)):
            sub_con[j][1], sub_fit[j][1] = continuum(cor[j][0],
                                                     cor[j][1],
                                                     is_new=True)
        pickle.dump(
            sub_con,
            open(
                '/mnt/gastro/sarel/sdss/no_smooth/none_trial/after_division/%s.p'
                % fname, 'wb'))
        pickle.dump(
            sub_fit,
            open(
                '/mnt/gastro/sarel/sdss/no_smooth/none_trial/just_cont/%s.p' %
                fname, 'wb'))
        logging.info('%s done' % fname)
    except Exception:
        logging.error('Problem with %s' % fname)
Beispiel #2
0
def SNlist(fname):
    data = cor_exp(fname)
    sn_exp = [0]*len(data)
    for i in range(len(data)):
        sn_exp[i] = SN(data[i][0], data[i][1], 3737)
    sn_exp.insert(0, fname)
    return sn_exp
Beispiel #3
0
def ewlist(fname):
    data = cor_exp(fname)
    ew_exp = [0]*len(data)
    for i in range(len(data)):
        ew_exp[i] = oiii(data[i][0], data[i][1])[0]
    ew_exp.insert(0, fname)
    return ew_exp
Beispiel #4
0
def pick_l(fname):
    # for i in range(len(fnames)):
    try:
        cor = cor_exp(fname)
        sub_con = np.copy(cor)
        sub_fit = np.copy(cor)
        pickle.dump(
            cor,
            open('./new_fits/sdss/no smooth/sub exposures/%s.p' % fname, 'wb'))
        for j in range(len(sub_con)):
            sub_con[j][1], sub_fit[j][1] = continuum(cor[j][0],
                                                     cor[j][1],
                                                     is_new=True)
        pickle.dump(
            sub_con,
            open('./new_fits/sdss/no smooth/after division/%s.p' % fname,
                 'wb'))
        pickle.dump(
            sub_fit,
            open('./new_fits/sdss/no smooth/just cont/%s.p' % fname, 'wb'))
        print('%s done' % fname)
    except Exception:
        print('Problem with %s' % fname)
Beispiel #5
0
from EW_lines import continuum
import astropy.modeling as mod
import numpy as np
import scipy.integrate as int
from diff_expo_plot import cor_exp
from matplotlib import pyplot as plt

data = cor_exp(490, 51929, 359)
x = data[6][0]
y = data[6][1]

# subtract the contiuum
y = continuum(x, y)

# isolate the OII line
for i in range(len(x)):
    if x[i] >= (3727 - 30):
        xfi = i
        break

for i in range(len(x)):
    if x[i] >= (3727 + 30):
        xff = i
        break

x1 = np.zeros(abs(xff - xfi))
y1 = np.zeros(abs(xff - xfi))

for i in range(len(x1)):
    x1[i] = x[xfi + i]
    y1[i] = y[xfi + i]
Beispiel #6
0
     tup[40] * np.exp(-((x - tup[41]) ** 2) / (2 * (tup[42] ** 2))) +
     tup[43] * np.exp(-((x - tup[44]) ** 2) / (2 * (tup[45] ** 2))) +
     tup[46] * np.exp(-((x - tup[47]) ** 2) / (2 * (tup[48] ** 2))) +
     tup[49] * np.exp(-((x - tup[50]) ** 2) / (2 * (tup[51] ** 2))) +
     tup[52] * np.exp(-((x - tup[53]) ** 2) / (2 * (tup[54] ** 2))) +
     tup[55] * np.exp(-((x - tup[56]) ** 2) / (2 * (tup[57] ** 2))) +
     tup[58] * np.exp(-((x - tup[59]) ** 2) / (2 * (tup[60] ** 2))) +
     tup[61] * np.exp(-((x - tup[62]) ** 2) / (2 * (tup[63] ** 2))) +
     tup[64] * np.exp(-((x - tup[65]) ** 2) / (2 * (tup[66] ** 2))) +
     tup[67] * np.exp(-((x - tup[68]) ** 2) / (2 * (tup[69] ** 2))) +
     tup[70] * np.exp(-((x - tup[71]) ** 2) / (2 * (tup[72] ** 2))) +
     tup[73] * np.exp(-((x - tup[74]) ** 2) / (2 * (tup[75] ** 2))) +
     tup[76] * np.exp(-((x - tup[77]) ** 2) / (2 * (tup[78] ** 2))) + 1)


data = cor_exp(491, 51942, 1)[0]

x = data[0]
y = data[1]

initial = (tup, 20, 3000, 0.5)


def error(x, tup, b, c, d):
    return y - func(x, tup, b, c, d)


g = opt.leastsq(error(x, tup, 20, 3000, 0.5), initial)

plt.plot(x, y, 'b')
plt.plot(x, func(x, tup, 20, 3000, 0.5), 'r')
Beispiel #7
0
from diff_expo_plot import cor_exp
from EW_lines import oii, sii
import numpy as np

# data = cor_exp(491, 51942, 1)
data = cor_exp('spec-0491-51942-0001.fits')

ewo = np.zeros(len(data))
ews1 = np.zeros(len(data))
ews2 = np.zeros(len(data))
ampo = np.zeros(len(data))
amps1 = np.zeros(len(data))
amps2 = np.zeros(len(data))

for i in range(len(data)):
    x, y = data[i]
    ewo[i], ampo[i] = oii(x, y)
    ews1[i], ews2[i], amps1[i], amps2[i] = sii(x, y)

ampo_avg = np.mean(ampo)
amps1_avg = np.mean(amps1)
amps2_avg = np.mean(amps2)

amp = (ampo_avg, amps1_avg, amps2_avg)

stddev = [0] * 3
stddev[0] = np.std(ewo)
stddev[1] = np.std(ews1)
stddev[2] = np.std(ews2)

print(np.mean(ewo), np.mean(ews1), np.mean(ews2))
Beispiel #8
0
from diff_expo_plot import cor_exp
import pickle
from os import listdir
from EW_lines import continuum
import numpy as np

# list all the files in the folder
fnames = listdir('./new_fits/boss400/files')
del fnames[0]

# pickle to three different folders the continuum fits, divided spectra and raw fits
for i in range(len(fnames)):
    try:
        cor = cor_exp(fnames[i])
        sub_con = np.copy(cor)
        sub_fit = np.copy(cor)
        pickle.dump(cor, open('./new_fits/boss400/sub exposures/%s.p' % fnames[i], 'wb'))
        for j in range(len(sub_con)):
            sub_con[j][1], sub_fit[j][1] = continuum(cor[j][0], cor[j][1], is_new=True)
        pickle.dump(sub_con, open('./new_fits/boss400/after division/%s.p' % fnames[i], 'wb'))
        pickle.dump(sub_fit, open('./new_fits/boss400/just cont/%s.p' % fnames[i], 'wb'))
    except Exception:
        print('Problem with %s' % fnames[i])