import numpy import math import correlation import os path = '/home/rabrahm/Desktop/spec2/' spectra = os.listdir(path) cant = len(spectra) m = 0 Tv = numpy.zeros(cant, float) Gv = numpy.zeros(cant, float) Zv = numpy.zeros(cant, float) Vv = numpy.zeros(cant, float) """print spectra""" m = 5 print spectra while m < cant: Tv[m], Gv[m], Zv[m], Vv[m] = correlation.CCF(path, spectra[m]) m = m + 1 m = 0 while m < cant: print spectra[m], Tv[m], Gv[m], Zv[m], Vv[m] m = m + 1
hdu = GLOBALutils.update_header(hdu, 'HIERARCH SIMBAD SPTYP', sp_type_query) pars_file = dirout + fsim.split('/')[-1][:-4] + '_stellar_pars.txt' if os.access(pars_file, os.F_OK) == False or force_stellar_pars: print "\t\t\tEstimating atmospheric parameters:" Rx = np.around(1. / np.sqrt(1. / 40000.**2 - 1. / ref_RES**2)) spec2 = spec.copy() for i in range(spec.shape[1]): IJ = np.where(spec[5, i] != 0.)[0] spec2[5, i, IJ] = GLOBALutils.convolve(spec[0, i, IJ], spec[5, i, IJ], Rx) T_eff, logg, Z, vsini, vel0, ccf = correlation.CCF( spec2, model_path=models_path, npools=npools) line = "%6d %4.1f %4.1f %8.1f %8.1f\n" % (T_eff, logg, Z, vsini, vel0) f = open(pars_file, 'w') f.write(line) f.close() else: print "\t\t\tAtmospheric parameters loaded from file:" T_eff, logg, Z, vsini, vel0 = np.loadtxt(pars_file, unpack=True) print "\t\t\t\tT_eff=", T_eff, "log(g)=", logg, "Z=", Z, "vsin(i)=", vsini, "vel0", vel0 else: T_eff, logg, Z, vsini, vel0 = -999, -999, -999, -999, -999
import correlation dire = '/home/rabrahm/Desktop/spec2/' mods = os.listdir(dire) t = [] g = [] z = [] r = [] v = [] nam = [] mods = mods[:-5] for fits in mods: print fits sc = pyfits.getdata(dire + fits) L, F = sc[0], sc[1] Ln, Fn = continuum.NORM2(L, F) Tfin, Gfin, Zfin, rot, velo2 = correlation.CCF(Ln, Fn) t.append(Tfin) g.append(Gfin) z.append(Zfin) r.append(rot) v.append(velo2) nam.append(fits) cant = len(t) o = 0 while o < cant: print nam[o], t[o], g[o], z[o], r[o], v[o] o += 1