本文整理汇总了Python中saltsafekey.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: stack
def stack(hdu):
"""Convert MEF HRS data into a single extension.
"""
#set the detector
detname=saltkey.get('DETNAM', hdu[0])
print detname
if detname=='08443-03-01' or detname=='HRDET':
detector='hrdet'
elif detname=='04434-23-02' or detname=='HBDET':
detector='hbdet'
else:
raise SaltError('%s is not an HRS detector' % detnam)
print detector
#get key parameters
try:
nccd=saltkey.get('CCDAMPS', hdu[0])
except:
nccd=saltkey.get('CCDNAMPS', hdu[0])
#determine the shape of the CCD
if detector=='hbdet':
toty=hdu[1].shape[0]
totx=hdu[1].shape[1]+hdu[2].shape[1]
elif detector=='hrdet':
toty=hdu[1].shape[0]+hdu[3].shape[0]
totx=hdu[1].shape[1]+hdu[2].shape[1]
data=np.zeros((toty,totx),np.float32)
#embed the ccds
for j in range(nccd):
i=j+1
y2,x2=hdu[i].data.shape
if detector=='hbdet':
if i==1:
y1=0
x1=0
y2=y2
x2=x2
else:
y1=0
x1=x2
x2=x1+x2
elif detector=='hrdet':
y1=0
if i%2==1: x1=0
if i%2==0:
x1=x2
x2=x1+x2
if i>2:
y1=y2
y2=y1+y2
data[y1:y2,x1:x2]=hdu[i].data
ihdu = pyfits.ImageHDU(data)
nhdu = pyfits.HDUList([hdu[0], ihdu])
return nhdu
开发者ID:saltastro,项目名称:pysalt,代码行数:60,代码来源:hrsstack.py
示例3: flat
def flat(struct,fstruct):
"""flat applies a flatfield to salt CCD data
return struct
"""
# Determine the number of extensions
nextend=len(struct)
#flat field the data
for i in range(nextend):
if struct[i].name=='SCI' or len(struct)==1:
#Account for variance frames
if saltkey.found('VAREXT', struct[i]):
varext=saltkey.get('VAREXT', struct[i])
if saltkey.found('VAREXT', fstruct[i]):
fvarext=saltkey.get('VAREXT', fstruct[i])
fvar=fstruct[fvarext].data
else:
fvar=0
struct[varext].data=(struct[i].data/fstruct[i].data)*(struct[varext].data/struct[i].data**2+fvar/fstruct[i].data**2)
#flatten the data
struct[i].data = struct[i].data / fstruct[i].data
return struct
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:25,代码来源:saltflat.py
示例4: extract
def extract(hdu, ext=1, method='normal', section=[],
minsize=3.0, thresh=3.0, convert=True):
"""For a given image, extract a 1D spectra from the image
and write the spectra to the output file
"""
ap_list = []
i = ext
if hdu[i].name == 'SCI':
# set up the data, variance, and bad pixel frames
# first step is to find the region to extract
data_arr = hdu[i].data
try:
var_arr = hdu[hdu[i].header['VAREXT']].data
except:
var_arr = None
try:
bpm_arr = hdu[hdu[i].header['BPMEXT']].data
except:
bpm_arr = None
var_arr = None
bpm_arr = None
xarr = np.arange(len(data_arr[0]))
# convert using the WCS information
try:
w0 = saltkey.get('CRVAL1', hdu[i])
dw = saltkey.get('CD1_1', hdu[i])
except Exception as e:
msg = 'Error on Ext %i: %s' % (i, e)
raise SALTSpecError(msg)
warr = w0 + dw * xarr
# convert from air to vacuum
if convert:
warr = Spectrum.air2vac(warr)
# set up the sections in case of findobj
if section is None:
section = findobj.findObjects(
data_arr,
method='median',
specaxis=1,
minsize=minsize,
thresh=thresh,
niter=5)
# extract all of the regions
for sec in section:
ap = apext.apext(warr, data_arr, ivar=var_arr)
y1, y2 = sec
ap.flatten(y1, y2)
ap_list.append(ap)
return ap_list
开发者ID:apodemus,项目名称:pysalt3,代码行数:57,代码来源:specextract.py
示例5: checkforpropid
def checkforpropid(image,propids):
"""subroutine to check to see if the propid keyword exists
returns status
"""
#open up the image
struct=pyfits.open(image, mode='update')
if struct:
#get proposal code
propid=saltkey.get('PROPID', struct[0])
#check to see if it is none
if saltio.checkfornone(propid) is None or propid is 'None':
message='\nNo value in PROPID keyword for %s' % image
raise SaltError(message)
#check to see if it is an eng or cal proposal
if propid.count('ENG_') or propid.count('CAL_'):
return
#clean up junk ones
if propid in ['BIAS','COMMON','JUNK','TEST','UNKNOWN']:
return
#check to see if it is in the sdb
if propid not in propids:
message='\n%s for PROPID keyword for %s is invalid' % (propid, image)
raise SaltError(message)
开发者ID:saltastro,项目名称:pipetools,代码行数:29,代码来源:saltpipe.py
示例6: illum_cor
def illum_cor(struct,mbox):
"""Apply an illumination correction to a set of images
return struct
"""
# Determine the number of extensions
nextend=len(struct)
#flat field the data
for i in range(nextend):
if struct[i].name=='SCI' or len(struct)==1:
#create the median image
mdata=median_filter(struct[i].data, size=(mbox, mbox))
#create the data
struct[i].data=struct[i].data/mdata
#Account for variance frames
if saltkey.found('VAREXT', struct[i]):
varext=saltkey.get('VAREXT', struct[i])
struct[varext].data=struct[varext].data/mdata
return struct
开发者ID:apodemus,项目名称:pysalt3,代码行数:25,代码来源:saltillum.py
示例7: 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
示例8: clean
def clean(struct, createvar=False, badpixelstruct=None, mult=True, dblist=None, ampccd=2,
xdict=[], subover=True,trim=True, subbias=False, bstruct=None,
median=False, function='polynomial',order=3,rej_lo=3,rej_hi=3,niter=10,
plotover=False, log=None, verbose=True):
infile=struct
#prepare the files
struct=prepare(struct, createvar=createvar, badpixelstruct=badpixelstruct)
#reset the names in the structures
for i in range(1,len(struct)):
struct[i].name=struct[i].header['EXTNAME']
#gain correct the files
usedb=False
if dblist: usedb=True
struct=gain(struct, mult=mult,usedb=usedb, dblist=dblist, ampccd=ampccd, log=log, verbose=verbose)
#xtalk correct the files
usedb=False
if xdict:
obsdate=saltkey.get('DATE-OBS', struct[0])
try:
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]
except Exception,e :
msg='WARNING--Can not find xtalk coefficient for %s because %s' % (e, infile)
if log: log.warning(msg)
xcoeff=xdict[xdict.keys()[-1]]
开发者ID:dr-jpk,项目名称:pysalt,代码行数:33,代码来源:saltclean.py
示例9: surface_fit
def surface_fit(struct,order=3, mask=True, minlevel=0):
"""Fit a surface to an image
return struct
"""
# Determine the number of extensions
nextend=len(struct)
#flat field the data
for i in range(nextend):
if struct[i].name=='SCI' or len(struct)==1:
#create the median image
if mask:
bpmext = saltkey.get('BPMEXT', struct[i])
mask_arr = (struct[bpmext].data == 0) * (struct[i].data > minlevel)
else:
mask_arr = (struct[i].data < minlevel)
#create the data
coef=fit_surface(struct[i].data, mask=mask_arr, xorder=order, yorder=order, xyorder=0)
y, x = np.indices(struct[i].data.shape)
sf=surface(coef, xorder=order, yorder=order, xyorder=0)
print coef
struct[i].data=sf(x,y)
#Account for variance frames
if mask:
struct[bpmext].data = struct[bpmext].data*0
return struct
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:32,代码来源:saltsurface.py
示例10: skysubtract
def skysubtract(hdu, method='normal', section=[], funct='polynomial', order=2):
"""For a given image, extract a measurement of the sky from
the image and then subtract that measurement from the
overall image
and write the spectra to the output file
"""
for i in range(len(hdu)):
if hdu[i].name == 'SCI':
# set up the data, variance, and bad pixel frames
# first step is to find the region to extract
data_arr = hdu[i].data
if saltkey.found('VAREXT', hdu[i]):
var_ext = saltkey.get('VAREXT', hdu[i])
var_arr = hdu[var_ext].data
else:
var_arr = None
var_ext = None
try:
bpm_ext = saltkey.get('BPMEXT', hdu[i])
bpm_arr = hdu[hdu[i].header['BPMEXT']].data
except:
bpm_ext = None
bpm_arr = None
# creat the xarr for the purposes of extracting the data
xarr = np.arange(len(data_arr[0]))
# TODO: The variance array does not fully work at the moment
var_arr = None
if method == 'normal':
sdata = normalsky(xarr, data_arr, var_arr, section)
elif method == 'fit':
sdata = fitsky(xarr, data_arr, var_arr, section)
# subtract the data
hdu[i].data = data_arr - sdata
# correct the variance frame
if var_ext:
hdu[var_ext].data = hdu[var_ext].data # +ap.lvar/nrows
return hdu
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:47,代码来源:specsky.py
示例11: prepare
def prepare(struct,createvar=False, badpixelstruct=None, namps=2):
#set up the file name
infile=saltkey.getimagename(struct[0])
#include information about which headers are science extensoisn
#and check to make sure each array is a data array
nextend=len(struct)-1
nsciext=nextend
for i in range(1,nextend+1):
try:
struct[i].header['XTENSION'] == 'IMAGE'
except:
msg='Extension %i in %s is not an image data'
raise SaltError(msg)
saltkey.new('EXTNAME','SCI','Extension name',struct[i])
saltkey.new('EXTVER',i,'Extension number',struct[i])
#check the number of amplifiers
#TODO: This is current hardwired at a value of 2
nccds = saltkey.get('NCCDS',struct[0])
if (nextend%(nccds*namps) != 0):
message = 'ERROR -- SALTPREPARE: Number of file extensions and '
message += 'number of amplifiers are not consistent in ' + infile
raise SaltError(message)
#Add the inv. variance frame if requested--assumes no variance frame
#and the science frames are in the first n frames
if createvar:
#create the inv. variance frames
for i in range(1, nsciext+1):
try:
hdu=CreateVariance(struct[i], i, nextend+i)
except Exception as e:
msg='Cannot create variance frame in extension %i of %s because %s' % (nextend+i, infile, e)
raise SaltError(msg)
struct[i].header.update('VAREXT',nextend+i, comment='Extension for Variance Frame')
struct.append(hdu)
nextend+=nsciext
#create the badpixelframes
for i in range(1, nsciext+1):
try:
hdu=createbadpixel(struct, badpixelstruct, i, nextend+i)
except Exception as e:
msg='Could not create bad pixel extension in ext %i of %s because %s' % (nextend+i, infile, e)
raise SaltError(msg)
struct[i].header.update('BPMEXT',nextend+i, comment='Extension for Bad Pixel Mask')
struct.append(hdu)
nextend+=nsciext
#update the number of extensions
saltkey.new('NSCIEXT',nsciext,'Number of science extensions', struct[0])
saltkey.new('NEXTEND',nextend,'Number of data extensions', struct[0])
return struct
开发者ID:apodemus,项目名称:pysalt3,代码行数:58,代码来源:saltprepare.py
示例12: 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
示例13: readtimefix
def readtimefix(hdu, dsteps=7, transtime=4e-3):
"""Update the hdu with the correct time for when the exposure started
and add the READTIME keyword
dsteps--the number of readouts to correct for
transtime--the transfer time between each frame
"""
#check for if the data has already been processed
if saltkey.found('READTIME', hdu):
raise SaltIOError(' has already been processed')
#determine the UTC time
utctime=saltkey.get('UTC-OBS', hdu)
timeobs=saltkey.get('TIME-OBS', hdu)
dateobs=saltkey.get('DATE-OBS', hdu)
exptime=float(saltkey.get('EXPTIME', hdu))
#add the readtime header
saltkey.new("READTIME",utctime,'Time of the readout of the frame', hdu)
#correct the utctime--first switch to datetime to properly handle
#dates around changes in hours
y,m,d=dateobs.split('-')
H,M,S=utctime.split(':')
s=int(float(S))
ms=int(1e6*(float(S)-s))
newtime=datetime.datetime(int(y),int(m),int(d),int(H),int(M),s,ms)
#correct the datetime
dtime=dsteps*(exptime+transtime)
s=int(dtime)
ms=int(1e6*(dtime-s))
newtime=newtime-datetime.timedelta(0, s, ms)
#update the headkeywords
hdu.header.update("UTC-OBS", str(newtime.time()))
saltkey.put("UTC-OBS", str(newtime.time()), hdu)
saltkey.put("TIME-OBS", str(newtime.time()), hdu)
saltkey.put("DATE-OBS", str(newtime.date()), hdu)
return hdu
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:42,代码来源:slotreadtimefix.py
示例14: calc_resolution
def calc_resolution(hdu):
"""Calculate the resolution for a setup"""
instrume=saltkey.get('INSTRUME', hdu[0]).strip()
grating=saltkey.get('GRATING', hdu[0]).strip()
grang=saltkey.get('GR-ANGLE', hdu[0])
grasteps=saltkey.get('GRTILT', hdu[0])
arang=saltkey.get('AR-ANGLE', hdu[0])
arsteps=saltkey.get('CAMANG', hdu[0])
rssfilter=saltkey.get('FILTER', hdu[0])
specmode=saltkey.get('OBSMODE', hdu[0])
masktype=saltkey.get('MASKTYP', hdu[0]).strip().upper()
slitname=saltkey.get('MASKID', hdu[0])
xbin, ybin = saltkey.ccdbin( hdu[0], '')
slit=st.getslitsize(slitname)
#create RSS Model
rss=RSSModel.RSSModel(grating_name=grating.strip(), gratang=grang, \
camang=arang,slit=slit, xbin=xbin, ybin=ybin, \
)
res=1e7*rss.calc_resolelement(rss.alpha(), -rss.beta())
return res
开发者ID:cmccully,项目名称:pysalt,代码行数:21,代码来源:quickspec.py
示例15: getimagedetails
def getimagedetails(hdu):
"""Return all the pertinant image header details"""
filename=hdu._HDUList__file.name
imlist=[filename]
print filename
for k in headerList[1:]:
try:
value=saltkey.get(k, hdu[0])
except SaltIOError:
value=''
imlist.append(value)
return imlist
开发者ID:saltastro,项目名称:pysalt,代码行数:12,代码来源:saltfirst.py
示例16: make_calring
def make_calring(hdu, method=None, thresh=5, niter=3, conv=0.05, minsize=10, axc=None, ayc=None):
"""Open each image and measure the position of the ring including its center and radius
Return the information about the calibration ring
"""
# setup the data
data = hdu[0].data
# extract the time and convert to decimal hours
utctime = saltkey.get("UTC-OBS", hdu[0])
utctime = salttime.time_obs2hr((utctime.split()[-1]))
# determine the correct etalon and information to extract
etstate = saltkey.get("ET-STATE", hdu[0])
if etstate.count("S2"):
etz = saltkey.get("ET1Z", hdu[0])
elif etstate.count("S3"):
etz = saltkey.get("ET2Z", hdu[0])
else:
msg = "This etalon state is not currently supported"
raise SaltError(msg)
# extract the ring
ring_list = findrings(data, thresh=thresh, niter=niter, minsize=minsize, axc=axc, ayc=ayc)
# assumes only one ring in the data set
ring = ring_list[0]
# determine the center and radius of the ring
if method is not None:
ring = findcenter(data, ring, method, niter=niter, conv=conv)
if axc:
ring.xc = axc
if ayc:
ring.yc = ayc
return ring.xc, ring.yc, ring.prad, ring.prad_err, etz, utctime
开发者ID:saltastro,项目名称:pysalt,代码行数:39,代码来源:saltfpcalring.py
示例17: obslog
def obslog(infiles, log=None):
"""For a set of input files, create a dictionary contain all the header
information from the files. Will print things to a saltlog if log is
not None
returns Dictionary
"""
#create the header dictionary
headerDict={}
for k in headerList: headerDict[k]=[]
for k in scamheaderList: headerDict[k]=[]
for k in rssheaderList: headerDict[k]=[]
# interate over and open image files
infiles.sort()
for infile in infiles:
#open the file
struct = saltio.openfits(infile)
# instrument
scam = False
rss = False
instrume = saltkey.get('INSTRUME', struct[0])
if (instrume=='RSS'): rss = True
if (instrume=='SALTICAM'): scam=True
#add in the image name
headerDict['FILENAME'].append(os.path.basename(infile))
# ingest primary keywords from files in the image list
for k,f in zip(headerList[1:], formatList[1:]):
default=finddefault(f)
headerDict[k].append(getkey(struct[0], k, default=default, log=log, warn=True))
# ingest scam specific primary keywords from files in the image list
for k,f in zip(scamheaderList[1:], scamformatList[1:]):
default=finddefault(f)
headerDict[k].append(getkey(struct[0], k, default=default, log=log, warn=scam))
# ingest rss specific primary keywords from files in the image list
for k,f in zip(rssheaderList[1:], rssformatList[1:]):
default=finddefault(f)
headerDict[k].append(getkey(struct[0], k, default=default, log=log, warn=rss))
# close image files
saltio.closefits(struct)
if log: log.message('SALTOBSLOG -- read %s' % infile, with_header=False)
return headerDict
开发者ID:hlabathems,项目名称:pysalt,代码行数:51,代码来源:saltobslog.py
示例18: saltembed
def saltembed(images,outimages,outpref, 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 each raw image file
for img, oimg, in zip(infiles, outfiles):
#open the fits file
struct=saltio.openfits(img)
#get the number of CCDs
nccd=saltkey.get('NCCDS', struct[0])
#set the number of amps per CCD--*TODO* Read from header
namps=2
#get the number of windows--try to read from header
try:
nwindows=saltkey.get('NWINDOWS', struct[0])
except:
nwindows=len(struct)/(nccd*namps)
outstruct=embedimage(struct, nccd, namps, nwindows)
saltio.writefits(outstruct, oimg, clobber=clobber)
message = 'SALTEMBED -- %s => %s' % (img, oimg)
log.message(message, with_header=False)
开发者ID:apodemus,项目名称:pysalt3,代码行数:37,代码来源:saltembed.py
示例19: updateheaders
def updateheaders(struct, ext, tdiff, real_expt, utc, infile):
# exit if tdiff wasn't updated
if tdiff == real_expt:
msg='No adequate correction found for frame %i in file %s' % (ext, infile)
raise SaltError(msg)
return struct
# calculate the new utc value
try:
ntime=salttime.sex2dec(utc)
ntime=ntime-tdiff/3600.0
newutc=salttime.dec2sex(ntime)
except Exception as e:
msg='Could not update UTC in %i header of image %s because %s' % (ext, infile, e)
raise SaltError(msg)
return struct
# update the headers
if utc==saltsafekey.get('UTC-OBS', struct):
expt_string='%5.4f' % real_expt
td_string='%5.4f' % tdiff
if not saltsafekey.found('DUTC', struct):
try:
saltsafekey.put('UTC-OBS', newutc, struct, infile)
saltsafekey.put('TIME-OBS', newutc, struct, infile)
saltsafekey.new('DWETIME', expt_string, 'Dwell Time', struct, infile)
saltsafekey.new('DUTC', td_string, 'Change in UTC time', struct, infile)
except Exception as e:
msg='Could not update %i header of image %s because %s' % (ext, infile, e)
raise SaltIOError(msg)
else:
try:
saltsafekey.put('UTC-OBS', newutc, struct, infile)
saltsafekey.put('TIME-OBS', newutc, struct, infile)
saltsafekey.put('DWETIME', real_expt, struct, infile)
saltsafekey.put('DUTC', tdiff, struct, infile)
except Exception as e:
msg='Could not update %i header of image %s because %s' % (ext, infile, e)
raise SaltError(msg)
else:
raise SaltIOError('Frame missing from list of times')
return struct
开发者ID:apodemus,项目名称:pysalt3,代码行数:45,代码来源:slotutcfix.py
示例20: read_slits_from_fits
def read_slits_from_fits(simg):
"""Read the slit definitions from a FITS fiel where the slit
definitions have been stored in a table in the FITS file under an
extension with the name
"""
# first check if the file exists
saltio.fileexists(simg)
# open the slit image
struct = saltio.openfits(simg)
# get the extension of the slit table
slitext = saltkey.get('SLITEXT', struct[0])
# extract the order of the fit and the positions of each of the slits
order, slit_positions = mt.read_slits_HDUtable(struct[slitext])
return order, slit_positions
开发者ID:hlabathems,项目名称:pysalt,代码行数:19,代码来源:specslit.py
注:本文中的saltsafekey.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论