當前位置: 首頁>>代碼示例>>Python>>正文


Python IO.badpixelmask方法代碼示例

本文整理匯總了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)
#.........這裏部分代碼省略.........
開發者ID:followthesheep,項目名稱:MosfireDRP,代碼行數:103,代碼來源:Rectify.py


注:本文中的MOSFIRE.IO.badpixelmask方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。