本文整理汇总了Python中MOSFIRE.IO.badpixelmask方法的典型用法代码示例。如果您正苦于以下问题:Python IO.badpixelmask方法的具体用法?Python IO.badpixelmask怎么用?Python IO.badpixelmask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOSFIRE.IO
的用法示例。
在下文中一共展示了IO.badpixelmask方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_rectification
# 需要导入模块: from MOSFIRE import IO [as 别名]
# 或者: from MOSFIRE.IO import badpixelmask [as 别名]
def handle_rectification(maskname, in_files, wavename, band_pass, barset_file, options,
commissioning_shift=3.0):
'''Handle slit rectification and coaddition.
Args:
maskname: The mask name string
in_files: List of stacked spectra in electron per second. Will look
like ['electrons_Offset_1.5.txt.fits', 'electrons_Offset_-1.5.txt.fits']
wavename: path (relative or full) to the wavelength stack file, string
band_pass: Band pass name, string
barset_file: Path to a mosfire fits file containing the full set of
FITS extensions for the barset. It can be any file in the list
of science files.
Returns:
None
Writes files:
[maskname]_[band]_[object name]_eps.fits --
The rectified, background subtracted, stacked eps spectrum
[maskname]_[band]_[object name]_sig.fits --
Rectified, background subtracted, stacked weight spectrum (STD/itime)
[maskname]_[band]_[object_name]_itime.fits
Rectified, CRR stacked integration time spectrum
[maskname]_[band]_[object_name]_snrs.fits
Rectified signal to noise spectrum
'''
global edges, dats, vars, itimes, shifts, lambdas, band, fidl, all_shifts
band = band_pass
dlambda = Wavelength.grating_results(band)
hpp = Filters.hpp[band]
fidl = np.arange(hpp[0], hpp[1], dlambda)
lambdas = IO.readfits(wavename, options)
if np.any(lambdas[1].data < 0) or np.any(lambdas[1].data > 29000):
print "***********WARNING ***********"
print "The file {0} may not be a wavelength file.".format(wavename)
print "Check before proceeding."
print "***********WARNING ***********"
edges, meta = IO.load_edges(maskname, band, options)
shifts = []
posnames = []
postoshift = {}
for file in in_files:
print ":: ", file
II = IO.read_drpfits(maskname, file, options)
off = np.array((II[0]["decoff"], II[0]["raoff"]),dtype=np.float64)
if "yoffset" in II[0]:
off = -II[0]["yoffset"]
else:
# Deal with data taken during commissioning
if II[0]["frameid"] == 'A': off = 0.0
else: off = commissioning_shift
try: off0
except: off0 = off
shift = off - off0
shifts.append(shift)
posnames.append(II[0]["frameid"])
postoshift[II[0]['frameid']] = shift
print "Position {0} shift: {1:2.2f} as".format(off, shift)
plans = Background.guess_plan_from_positions(set(posnames))
all_shifts = []
for plan in plans:
to_append = []
for pos in plan:
to_append.append(postoshift[pos])
all_shifts.append(to_append)
# Reverse the elements in all_shifts to deal with an inversion
all_shifts.reverse()
theBPM = IO.badpixelmask()
all_solutions = []
cntr = 0
for plan in plans:
p0 = plan[0].replace("'", "p")
p1 = plan[1].replace("'", "p")
suffix = "%s-%s" % (p0,p1)
print "Handling plan %s" % suffix
fname = "bsub_{0}_{1}_{2}.fits".format(maskname,band,suffix)
EPS = IO.read_drpfits(maskname, fname, options)
EPS[1] = np.ma.masked_array(EPS[1], theBPM, fill_value=0)
#.........这里部分代码省略.........