本文整理汇总了Python中MOSFIRE.IO.imcombine方法的典型用法代码示例。如果您正苦于以下问题:Python IO.imcombine方法的具体用法?Python IO.imcombine怎么用?Python IO.imcombine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOSFIRE.IO
的用法示例。
在下文中一共展示了IO.imcombine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: combine
# 需要导入模块: from MOSFIRE import IO [as 别名]
# 或者: from MOSFIRE.IO import imcombine [as 别名]
def combine(flatlist, maskname, band, options):
'''
combine list of flats into a flat file'''
out = os.path.join("combflat_2d_%s.fits"
% (band))
if os.path.exists(out):
os.remove(out)
IO.imcombine(flatlist, out, options, reject="minmax", nlow=1, nhigh=1)
示例2: combine
# 需要导入模块: from MOSFIRE import IO [as 别名]
# 或者: from MOSFIRE.IO import imcombine [as 别名]
def combine(flatlist, maskname, band, options, lampsOff=False):
'''
combine list of flats into a flat file'''
if lampsOff:
out = os.path.join("combflat_lamps_off_2d_%s.fits"
% (band))
else:
out = os.path.join("combflat_2d_%s.fits"
% (band))
if os.path.exists(out):
os.remove(out)
if len(flatlist)>1:
IO.imcombine(flatlist, out, options, reject="minmax", nlow=1, nhigh=1)
else:
IO.imcombine(flatlist, out, options, reject="none", nlow=1, nhigh=1)
示例3: handle_flats
# 需要导入模块: from MOSFIRE import IO [as 别名]
# 或者: from MOSFIRE.IO import imcombine [as 别名]
def handle_flats(flatlist, maskname, band, options, extension=None,edgeThreshold=450,lampOffList=None,longslit=None):
'''
handle_flats is the primary entry point to the Flats module.
handle_flats takes a list of individual exposure FITS files and creates:
1. A CRR, dark subtracted, pixel-response flat file.
2. A set of polynomials that mark the edges of a slit
Inputs:
flatlist:
maskname: The name of a mask
band: A string indicating the bandceil
Outputs:
file {maskname}/flat_2d_{band}.fits -- pixel response flat
file {maskname}/edges.np
'''
tick = time.time()
# Check
bpos = np.ones(92) * -1
#Retrieve the list of files to use for flat creation.
flatlist = IO.list_file_to_strings(flatlist)
if len(flatlist) == 0:
print('WARNING: No flat files found.')
raise IOError('No flat files found')
# Print the filenames to Standard-out
for flat in flatlist:
debug(str(flat))
#Determine if flat files headers are in agreement
for fname in flatlist:
hdr, dat, bs = IO.readmosfits(fname, options, extension=extension)
try: bs0
except: bs0 = bs
if np.any(bs0.pos != bs.pos):
print("bs0: "+str(bs0.pos)+" bs: "+str(bs.pos))
error("Barset do not seem to match")
raise Exception("Barsets do not seem to match")
if hdr["filter"] != band:
error ("Filter name %s does not match header filter name "
"%s in file %s" % (band, hdr["filter"], fname))
raise Exception("Filter name %s does not match header filter name "
"%s in file %s" % (band, hdr["filter"], fname))
for i in range(len(bpos)):
b = hdr["B{0:02d}POS".format(i+1)]
if bpos[i] == -1:
bpos[i] = b
else:
if bpos[i] != b:
error("Bar positions are not all the same in "
"this set of flat files")
raise Exception("Bar positions are not all the same in "
"this set of flat files")
bs = bs0
# Imcombine the lamps ON flats
info("Attempting to combine files in {}".format(flatlist))
out = os.path.join("combflat_2d_{:s}.fits".format(band))
IO.imcombine(flatlist, out, options, reject="minmax", nlow=1, nhigh=1)
# Imcombine the lamps OFF flats and subtract the off from the On sets
if lampOffList != None:
#Retrieve the list of files to use for flat creation.
info("Attempting to combine Lamps off files in {}".format(lampOffList))
lampOffList = IO.list_file_to_strings(lampOffList)
for flat in lampOffList:
debug(str(flat))
out = os.path.join("combflat_lamps_off_2d_{:s}.fits".format(band))
IO.imcombine(flatlist, out, options, reject="minmax", nlow=1, nhigh=1)
file_on = os.path.join("combflat_2d_{:s}.fits".format(band))
file_off = os.path.join("combflat_lamps_off_2d_{:s}.fits".format(band))
file_on_save = os.path.join("combflat_lamps_on_2d_{:s}.fits".format(band))
IO.imarith(file_on, '-', file_off, file_on_save)
debug("Combined '%s' to '%s'" % (flatlist, maskname))
# info("Combined flats for '%s'" % (maskname))
path = "combflat_2d_%s.fits" % band
(header, data) = IO.readfits(path, use_bpm=True)
info("Flat written to %s" % path)
# Edge Trace
if bs.long_slit:
info( "Long slit mode recognized")
info( "Central row position: "+str(longslit["row_position"]))
info( "Upper and lower limits: "+str(longslit["yrange"][0])+" "+str(longslit["yrange"][1]))
results = find_longslit_edges(data,header, bs, options, edgeThreshold=edgeThreshold, longslit=longslit)
elif bs.long2pos_slit:
info( "Long2pos mode recognized")
results = find_long2pos_edges(data,header, bs, options, edgeThreshold=edgeThreshold, longslit=longslit)
else:
info('Finding slit edges in {}'.format(path))
results = find_and_fit_edges(data, header, bs, options,edgeThreshold=edgeThreshold)
results[-1]["maskname"] = maskname
#.........这里部分代码省略.........