def load_templates(v="vmatrix.default.dat", l="lambda.default.dat", templates_dir='data/templates'): vfile = os.path.join(os.environ['KCORRECT_DIR'], templates_dir, v) if not os.path.isfile(vfile): raise _kcorrect.error('file: %s not found'%vfile) lfile = os.path.join(os.environ['KCORRECT_DIR'], templates_dir, l) if not os.path.isfile(lfile): raise _kcorrect.error('file: %s not found'%lfile) _kcorrect.load_templates(vfile, lfile)
def load_templates(v="vmatrix.default.dat", l="lambda.default.dat", templates_dir='data/templates'): vfile = os.path.join(os.environ['KCORRECT_DIR'], templates_dir, v) if not os.path.isfile(vfile): raise _kcorrect.error('file: %s not found' % vfile) lfile = os.path.join(os.environ['KCORRECT_DIR'], templates_dir, l) if not os.path.isfile(lfile): raise _kcorrect.error('file: %s not found' % lfile) _kcorrect.load_templates(vfile, lfile)
def read_basel(solarname, silent=False): """ Read a spectrum from a Basel spectrum file. """ filename = os.path.join( os.getenv('KCORRECT_DIR'), 'data/basel', solarname) if not os.path.isfile(filename): raise _kcorrect.error('%s not found'%filename) with open(filename,'r') as f: returndata = {'flux':[], 'model':[], 'teff':[], 'logg':[], 'mh':[], 'vturb':[], 'xh':[]} rawdata = f.read() alldata = rawdata.replace("\n", '').split() returndata['wavelength'] = numpy.array(alldata[0:1221], dtype=numpy.float32) del alldata[0:1221] nunits = int(len(alldata)/(1227)) if not silent: print ("%d block(s) of spectra" % nunits) for u in range(nunits): returndata['model'].append(int(alldata[0])) returndata['teff'].append(int(alldata[1])) returndata['logg'].append(float(alldata[2])) returndata['mh'].append(float(alldata[3])) returndata['vturb'].append(float(alldata[4])) returndata['xh'].append(float(alldata[5])) returndata['flux'].append(numpy.array(alldata[6:1227], dtype=numpy.float32)) del alldata[0:1227] return returndata
def fit_coeffs(c): c = numpy.array(c, dtype='float32') if len(c) == 11: return _kcorrect.fit_coeffs(c) else: raise _kcorrect.error( 'for this deault sdss filters, number of argument should be 11')
def load_filters(f="sdss_filters.dat", band_shift=0., filters_dir='data/templates'): ffile = os.path.join(os.environ['KCORRECT_DIR'], filters_dir, f) if not os.path.isfile(ffile): raise _kcorrect.error('file: %s not found' % ffile) _kcorrect.load_filters(ffile, band_shift)
def project_filters(wavelength, flux, band_shift=0., filterlist='sdss_filters.dat', filterlist_dir='data/templates', zmin=0., zmax=1.,nz=100): filename = os.path.join( os.getenv('KCORRECT_DIR'), filterlist_dir, filterlist) if not os.path.isfile(filename): raise _kcorrect.error('filter list %s not found.'%filename) return _kcorrect.projection_table(wavelength, flux, \ band_shift, \ filename, \ zmin, zmax, nz)
def project_filters(wavelength, flux, band_shift=0., filterlist='sdss_filters.dat', filterlist_dir='data/templates', zmin=0., zmax=1., nz=100): filename = os.path.join(os.getenv('KCORRECT_DIR'), filterlist_dir, filterlist) if not os.path.isfile(filename): raise _kcorrect.error('filter list %s not found.' % filename) return _kcorrect.projection_table(wavelength, flux, \ band_shift, \ filename, \ zmin, zmax, nz)
def read_basel(solarname, silent=False): """ Read a spectrum from a Basel spectrum file. """ filename = os.path.join(os.getenv('KCORRECT_DIR'), 'data/basel', solarname) if not os.path.isfile(filename): raise _kcorrect.error('%s not found' % filename) with open(filename, 'r') as f: returndata = { 'flux': [], 'model': [], 'teff': [], 'logg': [], 'mh': [], 'vturb': [], 'xh': [] } rawdata = f.read() alldata = rawdata.replace("\n", '').split() returndata['wavelength'] = numpy.array(alldata[0:1221], dtype=numpy.float32) del alldata[0:1221] nunits = int(len(alldata) / (1227)) if not silent: print("%d block(s) of spectra" % nunits) for u in range(nunits): returndata['model'].append(int(alldata[0])) returndata['teff'].append(int(alldata[1])) returndata['logg'].append(float(alldata[2])) returndata['mh'].append(float(alldata[3])) returndata['vturb'].append(float(alldata[4])) returndata['xh'].append(float(alldata[5])) returndata['flux'].append( numpy.array(alldata[6:1227], dtype=numpy.float32)) del alldata[0:1227] return returndata
def template(t, templates_dir='data/templates'): tfile = os.path.join(os.environ['KCORRECT_DIR'], templates_dir, t) if not os.path.isfile(tfile): raise _kcorrect.error('file: %s not found' % tfile) return _kcorrect.template(tfile)
def template(t, templates_dir='data/templates'): tfile = os.path.join(os.environ['KCORRECT_DIR'], templates_dir, t) if not os.path.isfile(tfile): raise _kcorrect.error('file: %s not found'%tfile) return _kcorrect.template(tfile)
def fit_coeffs(c): c = numpy.array(c, dtype='float32') if len(c) == 11: return _kcorrect.fit_coeffs(c) else: raise _kcorrect.error('for this deault sdss filters, number of argument should be 11')
def load_filters(f="sdss_filters.dat", band_shift=0., filters_dir='data/templates'): ffile = os.path.join(os.environ['KCORRECT_DIR'], filters_dir, f) if not os.path.isfile(ffile): raise _kcorrect.error('file: %s not found'%ffile) _kcorrect.load_filters(ffile, band_shift)