本文整理汇总了Python中MOSFIRE.IO.imarith方法的典型用法代码示例。如果您正苦于以下问题:Python IO.imarith方法的具体用法?Python IO.imarith怎么用?Python IO.imarith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOSFIRE.IO
的用法示例。
在下文中一共展示了IO.imarith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: imdiff
# 需要导入模块: from MOSFIRE import IO [as 别名]
# 或者: from MOSFIRE.IO import imarith [as 别名]
def imdiff(A, B, maskname, band, header, options):
s = "[0]"
targname = A[1]["targname"].rstrip(" ")
if targname == "":
objname = A[1]["object"].replace(" ", "_")
else:
objname = targname.replace(" ", "_")
operand1 = A[0] + '[0]'
operand2 = B[0] + '[0]'
imnumA = A[0].split('_')[-1].rstrip(".fits")
imnumB = B[0].split('_')[-1].rstrip(".fits")
dname = "{0}_{1}_{2}_{3}-{4}_{5}-{6}.fits".format(maskname, objname, band,
A[1]["frameid"], B[1]["frameid"], imnumA, imnumB)
try: os.remove(dname)
except:pass
print "Data Diff {0}-{1}".format(operand1,operand2)
IO.imarith(operand1, '-', operand2, dname)
''' Now handle variance '''
numreads = header["READS0"]
RN_adu = Detector.RN / np.sqrt(numreads) / Detector.gain
varname = "var_{0}_{1}_{2}_{3}+{4}_{5}+{6}.fits".format(maskname, objname, band,
A[1]["frameid"], B[1]["frameid"], imnumA, imnumB)
print "Var Sum {0}+{1}".format(operand1,operand2)
IO.imarith(operand1, '+', operand2, "tmp_" + varname)
try: os.remove(varname)
except: pass
print "Var add RN {0}+{1}".format(operand1,RN_adu**2)
IO.imarith("tmp_" + varname, '+', RN_adu**2, varname)
try: os.remove("tmp_" + varname)
except: pass
return dname, varname
示例2: handle_flats
# 需要导入模块: from MOSFIRE import IO [as 别名]
# 或者: from MOSFIRE.IO import imarith [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
#.........这里部分代码省略.........