本文整理汇总了Python中saltsafelog.logging函数的典型用法代码示例。如果您正苦于以下问题:Python logging函数的具体用法?Python logging怎么用?Python logging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了logging函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: saltcombine
def saltcombine(images,outimage, method='average', reject=None, mask=True, \
weight=True, blank=0, scale=None, statsec=None, lthresh=3, \
hthresh=3, clobber=False, logfile='salt.log',verbose=True):
with logging(logfile,debug) as log:
# Check the input images
infiles = saltio.argunpack ('Input',images)
#set reject as None
reject=saltio.checkfornone(reject)
if reject is not None: reject=reject.lower()
#set scale
scale=saltio.checkfornone(scale)
if scale is not None: scale=scale.lower()
#set statsec
statsec=saltio.checkfornone(statsec)
statsec=saltio.getSection(statsec, iraf_format=True)
#Fast combine the images
outstruct=imcombine(infiles, method=method, reject=reject, mask=mask, \
weight=weight, blank=blank, scale=scale, \
statsec=statsec, lthresh=lthresh, hthresh=hthresh)
# housekeeping keywords
fname, hist=history(level=1, wrap=False)
saltkey.housekeeping(outstruct[0],'SCOMBINE', 'File Combined by SALTCOMBINE', hist)
# write FITS file
saltio.writefits(outstruct, outimage)
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:32,代码来源:saltcombine.py
示例2: erroremail
def erroremail(obsdate, server='', username='', password='', sender='', recipient='', bcc='',
sdbhost='sdb.salt', sdbname='sdb', sdbuser='', sdbpass='', logfile='saltlog.log', verbose=True):
"""Update the PipelineStatistics table with the current information
about the pipeline
"""
with logging(logfile,debug) as log:
#connect the database
sdb=saltmysql.connectdb(sdbhost, sdbname, sdbuser, sdbpass)
#get the nightinfo_id
night_id=saltmysql.getnightinfoid(sdb, obsdate)
#create the message
try:
record=saltmysql.select(sdb, 'PipelineStatus, ErrorMessage', 'PipelineStatistics join PipelineStatus using (PipelineStatus_Id)', 'NightInfo_Id=%i' % night_id)
status, error_message=record[0]
except Exception, e:
raise SaltError('Unable to download information: %s' % e)
#set up the subject and message
subject='Pipeline Error on %s' % obsdate
message="Failure is simply the opportunity to begin again, this time more intelligently.--Henry Ford\n\n"
message+="%s" % error_message
log.message(message, with_stdout=verbose)
#send the email
saltio.email(server,username,password,sender,recipient,bcc, subject,message)
开发者ID:saltastro,项目名称:pipetools,代码行数:32,代码来源:erroremail.py
示例3: saltelserror
def saltelserror(obsdate, elshost, elsname, elsuser, elspass,
sdbhost,sdbname,sdbuser, password, clobber,logfile,verbose):
# set up
proposers = []
propids = []
pids = []
with logging(logfile,debug) as log:
#open the database
els=saltmysql.connectdb(elshost, elsname, elsuser, elspass)
sdb=saltmysql.connectdb(sdbhost,sdbname,sdbuser, password)
#create the values for the entire night
nid=saltmysql.getnightinfoid(sdb, obsdate)
stime, etime=saltmysql.select(sdb, 'EveningTwilightEnd,MorningTwilightStart', 'NightInfo', 'NightInfo_Id=%i' % nid)[0]
print stime, etime
errors=gettcserrors(els, stime, etime)
if not errors: return None
for e in errors:
i=e.index('T')
print i, error_list[i], e[-1]
print len(errors)
开发者ID:saltastro,项目名称:pipetools,代码行数:28,代码来源:saltelserror.py
示例4: saltobslog
def saltobslog(images,outfile,clobber=False,logfile='salt.log',verbose=True):
"""Create the observation log from the input files"""
#start the logging
with logging(logfile,debug) as log:
# Check the input images
infiles = saltio.argunpack ('Input',images)
#create the header dictionary
headerDict=obslog(infiles, log)
#clobber the output if it exists
if (clobber and os.path.isfile(outfile)):
saltio.delete(outfile)
#create the fits file
struct=createobslogfits(headerDict)
# close table file
saltio.writefits(struct, outfile)
#indicate the log was created
log.message('\nSALTLOG -- created observation log ' + outfile)
开发者ID:hlabathems,项目名称:pysalt,代码行数:25,代码来源:saltobslog.py
示例5: specselfid
def specselfid(images, outimages, outpref, refimage=None, ystart='middlerow',
rstep=3, clobber=False, logfile='salt.log', verbose=True):
with logging(logfile, debug) as log:
# set up the variables
infiles = []
outfiles = []
# Check the input images
infiles = saltio.argunpack('Input', images)
# create list of output files
outfiles = saltio.listparse(
'Outimages',
outimages,
outpref,
infiles,
'')
# set up defaults
if saltio.checkfornone(refimage) is not None:
rhdu = saltio.openfits(refimage)
else:
refimage = None
# read in rectify each image
for img, oimg, in zip(infiles, outfiles):
hdu = saltio.openfits(img)
log.message(
'Performing self-identification and rectification on %s' %
img)
for i in range(1, len(hdu)):
if hdu[i].name == 'SCI':
if refimage is None:
sdata = hdu[i].data
else:
sdata = rhdu[i].data
hdu[i].data = selfid(
hdu[i].data,
sdata,
ystart=ystart,
rstep=rstep)
if saltkey.found('VAREXT', hdu[i]):
varext = saltkey.get('VAREXT', hdu[i])
hdu[varext].data = selfid(
hdu[varext].data,
sdata,
ystart=ystart,
rstep=rstep)
if saltkey.found('BPMEXT', hdu[i]):
bpmext = saltkey.get('BPMEXT', hdu[i])
hdu[bpmext].data = selfid(
hdu[bpmext].data,
sdata,
ystart=ystart,
rstep=rstep)
# write out the oimg
saltio.writefits(hdu, oimg, clobber=clobber)
开发者ID:apodemus,项目名称:pysalt3,代码行数:60,代码来源:specselfid.py
示例6: saltfirst
def saltfirst(obsdate, imdir, prodir, server='smtp.saao.ac.za', readme='readme.fast.template', sdbhost='sdb.salt', sdbname='sdb', sdbuser='', password='',imreduce=True, sexfile='/home/ccd/tools/qred.sex', update=True, clobber=False,logfile='salt.log',verbose=True):
#Move into the working directory
if os.path.isdir(prodir):
if clobber:
shutil.rmtree(prodir)
os.mkdir(prodir)
else:
os.mkdir(prodir)
os.chdir(prodir)
with logging(logfile,debug) as log:
#create GUI
App = QtGui.QApplication([])
#Add information to gui
aw=FirstWindow(obsdate, imdir, prodir, server=server, readme=readme, sdbhost=sdbhost, sdbname=sdbname, sdbuser=sdbuser, password=password, imreduce=imreduce, sexfile=sexfile, update=update, clobber=clobber, log=log, verbose=verbose)
aw.setMinimumHeight(800)
aw.setMinimumWidth(500)
aw.show()
# Start application event loop
exit=App.exec_()
# Check if GUI was executed succesfully
if exit!=0:
raise SaltError('SALTFIRST GUI has unexpected exit status '+str(exit))
开发者ID:saltastro,项目名称:pysalt,代码行数:29,代码来源:saltfirst.py
示例7: saltillum
def saltillum(images, outimages, outpref, mbox=11, clobber=False, logfile="salt.log", verbose=True):
with logging(logfile, debug) as log:
# Check the input images
infiles = saltio.argunpack("Input", images)
# create list of output files
outfiles = saltio.listparse("Outfile", outimages, outpref, infiles, "")
# verify that the input and output lists are the same length
saltio.comparelists(infiles, outfiles, "Input", "output")
# open each raw image file
for infile, outfile in zip(infiles, outfiles):
struct = saltio.openfits(infile)
struct = illum_cor(struct, mbox)
# add any header keywords like history
fname, hist = history(level=1, wrap=False)
saltkey.housekeeping(struct[0], "SILLUM", "File Illumination corrected", hist)
# write it out and close it
saltio.writefits(struct, outfile, clobber=clobber)
saltio.closefits(struct)
# output the information
log.message("Illumination corrected image %s " % (infile), with_header=False, with_stdout=verbose)
开发者ID:saltastro,项目名称:pysalt,代码行数:29,代码来源:saltillum.py
示例8: hrsstack
def hrsstack(images, outimages, outpref, clobber=True, logfile='salt.log',verbose=True):
"""Convert MEF HRS data into a single image. If variance frames and BPMs, then
convert them to the same format as well. Returns an MEF image but that is
combined into a single frame
"""
with logging(logfile,debug) as log:
# Check the input images
infiles = saltio.argunpack ('Input',images)
# create list of output files
outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')
#verify that the input and output lists are the same length
saltio.comparelists(infiles,outfiles,'Input','output')
#open the file and write out as a fits files in the output directory
for img,oimg in zip(infiles, outfiles):
hdu=saltio.openfits(img)
hdu=stack(hdu)
log.message('Stacking HRS %s to %s' % (img, oimg), with_header=False)
saltio.writefits(hdu, oimg, clobber=clobber)
return
开发者ID:saltastro,项目名称:pysalt,代码行数:27,代码来源:hrsstack.py
示例9: bvitftp
def bvitftp(propcode, obsdate, sdbhost,sdbname,sdbuser, password,
server,username,sender, bcc, emailfile,
notify=False, clobber=True,logfile='salt.log',verbose=True):
# set up
proposers = []
propids = []
pids = []
with logging(logfile,debug) as log:
# are the arguments defined
if propcode.strip().upper()=='ALL':
pids=getbvitproposalcodes(str(obsdate))
else:
pids = saltio.argunpack('propcode',propcode)
if len(pids)==0:
#throw a warning adn exit if not data needs to be filterd
log.warning('No data to distribute\n', with_stdout=verbose)
return
#log into the database
sdb=saltmysql.connectdb(sdbhost,sdbname,sdbuser,password)
# check PI directories exist
ftpdir='/salt/ftparea/'
for datapath in pids:
pid=os.path.basename(datapath)
movebvitdata(pid, datapath, ftpdir, obsdate, sdb, clobber)
if notify:
notifybvituser(sdb, pid, obsdate, server,username,password,sender, bcc, emailfile)
开发者ID:saltastro,项目名称:pipetools,代码行数:35,代码来源:bvitftp.py
示例10: saltprepare
def saltprepare(images,outimages,outpref,createvar=False, badpixelimage=None, clobber=True,logfile='salt.log',verbose=True):
with logging(logfile,debug) as log:
# Check the input images
infiles = saltio.argunpack ('Input',images)
# create list of output files
outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')
#verify that the input and output lists are the same length
saltio.comparelists(infiles,outfiles,'Input','output')
# open the badpixel image
if saltio.checkfornone(badpixelimage) is None:
badpixelstruct=None
else:
try:
badpixelstruct = saltio.openfits(badpixelimage)
except saltio.SaltIOError,e:
msg='badpixel image must be specificied\n %s' % e
raise SaltError(msg)
# open each raw image file
for img, oimg, in zip(infiles, outfiles):
#open the fits file
struct=saltio.openfits(img)
#if createvar, throw a warning if it is using slotmode
if saltkey.fastmode(saltkey.get('DETMODE', struct[0])) and createvar:
msg='Creating variance frames for slotmode data in %s' % img
log.warning(msg)
# identify instrument
instrume,keyprep,keygain,keybias,keyxtalk,keyslot = saltkey.instrumid(struct)
# has file been prepared already?
try:
key = struct[0].header[keyprep]
message = 'ERROR -- SALTPREPARE: File ' + infile
message += ' has already been prepared'
raise SaltError(message)
except:
pass
# prepare file
struct=prepare(struct,createvar=createvar, badpixelstruct=badpixelstruct)
# housekeeping keywords
fname, hist=history(level=1, wrap=False, exclude=['images', 'outimages', 'outpref'])
saltkey.housekeeping(struct[0],keyprep, 'File prepared for IRAF', hist)
# write FITS file
saltio.writefits(struct,oimg, clobber=clobber)
saltio.closefits(struct)
message = 'SALTPREPARE -- %s => %s' % (img, oimg)
log.message(message, with_header=False)
开发者ID:cmccully,项目名称:pysalt,代码行数:60,代码来源:saltprepare.py
示例11: masktool
def masktool(catalog='', image='', logfile='salt.log', verbose=True):
with logging(logfile,debug) as log:
app = QtGui.QApplication([])
myapp = SlitMaskGui(infile=catalog, inimage=image)
myapp.show()
app.exec_()
开发者ID:apodemus,项目名称:pysalt3,代码行数:7,代码来源:masktool.py
示例12: saltsurface
def saltsurface(images,outimages,outpref, mask=True, order=3, minlevel=0,
clobber=False, logfile='salt.log',verbose=True):
with logging(logfile,debug) as log:
# Check the input images
infiles = saltio.argunpack ('Input',images)
# create list of output files
outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')
#verify that the input and output lists are the same length
saltio.comparelists(infiles,outfiles,'Input','output')
# open each raw image file
for infile, outfile in zip(infiles,outfiles):
struct = saltio.openfits(infile)
struct = surface_fit(struct, order=order, mask=mask, minlevel=minlevel)
#add any header keywords like history
fname, hist=history(level=1, wrap=False)
saltkey.housekeeping(struct[0],'SURFIT', 'File fit by a surface', hist)
#write it out and close it
saltio.writefits(struct,outfile,clobber=clobber)
saltio.closefits(struct)
#output the information
log.message('Surface fitted image %s ' % (infile), with_header=False, with_stdout=verbose)
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:32,代码来源:saltsurface.py
示例13: specsky
def specsky(images,outimages,outpref, method='normal', section=None,
function='polynomial', order=2,
clobber=True,logfile='salt.log',verbose=True):
with logging(logfile,debug) as log:
# Check the input images
infiles = saltio.argunpack ('Input',images)
# create list of output files
outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')
if method not in ['normal', 'fit']:
msg='%s mode is not supported yet' % method
raise SALTSpecError(msg)
if section is None:
section=saltio.getSection(section)
msg='This mode is not supported yet'
raise SALTSpecError(msg)
else:
section=saltio.getSection(section)
# Identify the lines in each file
for img, ofile in zip(infiles, outfiles):
log.message('Subtracting sky spectrum in image %s into %s' % (img, ofile))
#open the images
hdu=saltio.openfits(img)
#sky subtract the array
hdu=skysubtract(hdu, method=method, section=section, funct=function, order=order)
#write out the image
if clobber and os.path.isfile(ofile): saltio.delete(ofile)
hdu.writeto(ofile)
开发者ID:dr-jpk,项目名称:pysalt,代码行数:35,代码来源:specsky.py
示例14: saltarchive
def saltarchive(obsdate,archpath, clobber,logfile,verbose):
"""Archive the SALT data. Move the data to /salt/data after it has been run by the pipeline"""
with logging(logfile,debug) as log:
#check the entries
saltio.argdefined('obsdate',obsdate)
saltio.argdefined('archpath',archpath)
# create the directory if it does not already exist
if (not os.path.exists(archpath+obsdate[:4])):
saltio.createdir(archpath+obsdate[:4])
#cleen up the directory if it already exists
archdir=archpath+obsdate[:4]+'/'+obsdate[4:]
if (os.path.exists(archdir) and clobber):
for root, dirs, files in os.walk(archpath+obsdate[:4]+'/'+obsdate[4:],topdown=False):
for file in files:
os.remove(os.path.join(root,file))
for dir in dirs:
os.rmdir(os.path.join(root,dir))
os.rmdir(archpath+obsdate[:4]+'/'+obsdate[4:])
elif (os.path.exists(archdir) and not clobber):
message = 'Cannot overwrite '+archpath+obsdate[:4]+'/'+obsdate[4:]
raise SaltError(message)
elif (not os.path.exists(archdir)):
pass
saltio.move(obsdate,archdir)
开发者ID:saltastro,项目名称:pipetools,代码行数:28,代码来源:saltarchive.py
示例15: hrsprepare
def hrsprepare(images, outimages, outpref, clobber=True, logfile='salt.log',verbose=True):
"""Convert .fit files to .fits files and place HRS data into
standard SALT FITS format
"""
with logging(logfile,debug) as log:
# Check the input images
infiles = saltio.argunpack ('Input',images)
# create list of output files
outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')
#verify that the input and output lists are the same length
saltio.comparelists(infiles,outfiles,'Input','output')
#open the file and write out as a fits files in the output directory
for img,oimg in zip(infiles, outfiles):
hdu=saltio.openfits(img)
hdu=prepare(hdu)
log.message('Preparing HRS %s to %s' % (img, oimg), with_header=False)
saltio.writefits(hdu, oimg, clobber=clobber)
return
开发者ID:apodemus,项目名称:pysalt3,代码行数:26,代码来源:hrsprepare.py
示例16: specidentify
def specidentify(images,linelist, outfile, guesstype, guessfile, function, \
order, rstep, interact, clobber,logfile,verbose,status):
with logging(logfile,debug) as log:
#set up the variables
infiles = []
outfiles = []
status = 0
# Check the input images
infiles = saltsafeio.argunpack ('Input',images)
# create list of output files
outfiles = saltsafeio.argunpack ('Input',outfile)
#if outfiles is a single image, turn it into a list
#of the same length as infiles
if len(outfiles)!=len(infiles):
if len(outfiles)==1:
outfiles=outfiles*len(infiles)
elif len(outfiles)==0:
outfiles=[None]*len(infiles)
else:
msg='Please enter an appropriate number of outfiles'
raise SALTSpecError(msg)
# open the line lists
slines, sfluxes = readlinelist(linelist)
# Identify the lines in each file
for img, oimg in zip(infiles, outfiles):
identify(img, oimg, slines, sfluxes, guesstype, guessfile, function,
order, rstep, interact, clobber, verbose)
开发者ID:dr-jpk,项目名称:pysalt,代码行数:34,代码来源:specidentify.v1.py
示例17: saltfpskyring
def saltfpskyring(
images,
outimages,
outpref,
axc,
ayc,
arad,
rxc,
ryc,
pmin,
pmax,
swindow=5,
clobber=False,
logfile="salt.log",
verbose=True,
):
"""Sky subtracts Fabry-Perot images"""
# start log now that all parameter are set up
with logging(logfile, debug) as log:
# Check the input images
infiles = saltio.argunpack("Input", images)
# create list of output files
outfiles = saltio.listparse("Outfile", outimages, outpref, infiles, "")
# verify that the input and output lists are the same length
saltio.comparelists(infiles, outfiles, "Input", "output")
for img, oimg in zip(infiles, outfiles):
# open up the file
hdu = saltio.openfits(img)
# determine the azimuthally averaged profile
rpro, radial_profile = median_radial_profile(
hdu[0].data, xc=axc, yc=ayc, rmax=arad, nbins=100, pmin=pmin, pmax=pmax
)
if swindow > 1:
radial_profile = np.convolve(radial_profile, np.ones(swindow), mode="same") / swindow
# calculate the indices from the image
y, x = np.indices(hdu[0].data.shape)
radius = np.hypot(x - axc, y - ayc)
# subtract off the sky data
mdata = hdu[0].data - np.interp(radius, rpro, radial_profile)
hdu[0].data = mdata
# write FITS file
saltio.writefits(hdu, oimg, clobber=clobber)
saltio.closefits(hdu)
message = "SALTFPSKYRING -- Subtracted sky from %s" % (img)
log.message(message, with_header=False)
开发者ID:saltastro,项目名称:pysalt,代码行数:58,代码来源:saltfpskyring.py
示例18: saltxtalk
def saltxtalk(images,outimages,outpref,xtalkfile=None, usedb=False,
clobber=True, logfile='salt.log',verbose=True):
#start logging
with logging(logfile,debug) as log:
# Check the input images
infiles = saltio.argunpack ('Input',images)
# create list of output files
outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')
# are input and output lists the same length?
saltio.comparelists(infiles,outfiles,'Input','output')
# does crosstalk coefficient data exist
if usedb:
xtalkfile = xtalkfile.strip()
xdict = saltio.readxtalkcoeff(xtalkfile)
else:
xdict=None
for img, oimg in zip(infiles, outfiles):
#open the fits file
struct=saltio.openfits(img)
#find the best xcoeff for the image if using the db
if usedb:
obsdate=saltkey.get('DATE-OBS', struct[0])
obsdate=int('%s%s%s' % (obsdate[0:4],obsdate[5:7], obsdate[8:]))
xkey=np.array(xdict.keys())
date=xkey[abs(xkey-obsdate).argmin()]
xcoeff=xdict[date]
else:
xcoeff=[]
# identify instrument
instrume,keyprep,keygain,keybias,keyxtalk,keyslot = saltkey.instrumid(struct)
# has file been prepared already?
if saltkey.found(keyxtalk, struct[0]):
message='%s has already been xtalk corrected' % img
raise SaltError(message)
#apply the cross-talk correction
struct = xtalk(struct, xcoeff, log=log, verbose=verbose)
# housekeeping keywords
fname, hist=history(level=1, wrap=False, exclude=['images', 'outimages', 'outpref'])
saltkey.housekeeping(struct[0], 'SXTALK', 'Images have been xtalk corrected', hist)
# write FITS file
saltio.writefits(struct,oimg, clobber=clobber)
saltio.closefits(struct)
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:56,代码来源:saltxtalk.py
示例19: saltcrclean
def saltcrclean(images,outimages,outpref,crtype='fast',thresh=5,mbox=3, \
bthresh=3, flux_ratio=0.2, bbox=11, gain=1, rdnoise=5, fthresh=5,\
bfactor=2, gbox=3, maxiter=5, multithread=False, update=True,
clobber=True, logfile='salt.log', verbose=True):
with logging(logfile,debug) as log:
# Check the input images
infiles = saltio.argunpack ('Input',images)
# create list of output files
outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')
#verify that the input and output lists are the same length
saltio.comparelists(infiles,outfiles,'Input','output')
#check to see if multithreading is available
if mp:
pass
else:
multithread=False
log.warning('multiprocessing module is not available. Setting multiththread=False')
# Begin processes each file
for infile,outfile in zip(infiles,outfiles):
#open the infile
struct=saltio.openfits(infile)
#clean the cosmic rays
if multithread and len(struct)>1:
struct=multicrclean(struct, crtype, thresh, mbox, bbox, bthresh, flux_ratio, \
gain, rdnoise, bfactor, fthresh, gbox, maxiter, log, verbose=verbose)
else:
struct=crclean(struct, crtype, thresh, mbox, bbox, bthresh, flux_ratio, \
gain, rdnoise, bfactor, fthresh, gbox, maxiter, update, log, verbose=verbose)
#log the call
#log.message('Cleaned %i cosmic rays from %s using %s method' % (totcr, infile, crtype), with_header=False)
log.message('', with_header=False, with_stdout=verbose)
#add house keeping keywords
saltkey.put('SAL-TLM',time.asctime(time.localtime()), struct[0])
#add the history keyword
fname, hist=history(level=1, wrap=False)
saltkey.history(struct[0],hist)
#write out the file
saltio.writefits(struct, outfile, clobber=clobber)
#close the image
saltio.closefits(struct)
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:56,代码来源:saltcrclean.py
示例20: specsens
def specsens(specfile, outfile, stdfile, extfile, airmass=None, exptime=None,
stdzp=3.68e-20, function='polynomial', order=3, thresh=3, niter=5,
clobber=True, logfile='salt.log',verbose=True):
with logging(logfile,debug) as log:
#read in the specfile and create a spectrum object
obs_spectra=st.readspectrum(specfile, error=True, ftype='ascii')
#read in the std file and convert from magnitudes to fnu
#then convert it to fwave (ergs/s/cm2/A)
std_spectra=st.readspectrum(stdfile, error=False, ftype='ascii')
std_spectra.flux=Spectrum.magtoflux(std_spectra.flux, stdzp)
std_spectra.flux=Spectrum.fnutofwave(std_spectra.wavelength, std_spectra.flux)
#read in the extinction file (leave in magnitudes)
ext_spectra=st.readspectrum(extfile, error=False, ftype='ascii')
#determine the airmass if not specified
if saltio.checkfornone(airmass) is None:
message='Airmass was not supplied'
raise SALTSpecError(message)
#determine the exptime if not specified
if saltio.checkfornone(airmass) is None:
message='Exposure Time was not supplied'
raise SALTSpecError(message)
#calculate the calibrated spectra
log.message('Calculating the calibration curve for %s' % specfile)
cal_spectra=sensfunc(obs_spectra, std_spectra, ext_spectra, airmass, exptime)
#fit the spectra--first take a first cut of the spectra
#using the median absolute deviation to throw away bad points
cmed=np.median(cal_spectra.flux)
cmad=saltstat.mad(cal_spectra.flux)
mask=(abs(cal_spectra.flux-cmed)<thresh*cmad)
mask=(cal_spectra.flux>0)
#now fit the data
fit=interfit(cal_spectra.wavelength[mask], cal_spectra.flux[mask], function=function, order=order, thresh=thresh, niter=niter)
fit.interfit()
#print 'plotting...'
#figure()
#plot(cal_spectra.wavelength, cal_spectra.flux)
#plot(obs_spectra.wavelength, obs_spectra.flux*cal_spectra.flux.mean()/obs_spectra.flux.mean())
#plot(std_spectra.wavelength, std_spectra.flux*cal_spectra.flux.mean()/std_spectra.flux.mean())
#plot(cal_spectra.wavelength, fit(cal_spectra.wavelength))
#show()
#write the spectra out
cal_spectra.flux=fit(cal_spectra.wavelength)
st.writespectrum(cal_spectra, outfile, ftype='ascii')
开发者ID:dr-jpk,项目名称:pysalt,代码行数:55,代码来源:specsens.py
注:本文中的saltsafelog.logging函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论