当前位置: 首页>>代码示例>>Python>>正文


Python IO.imcombine方法代码示例

本文整理汇总了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)
开发者ID:Keck-DataReductionPipelines,项目名称:MosfireDRP_preWMKO,代码行数:12,代码来源:Flats.py

示例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)
开发者ID:themiyan,项目名称:MosfireDRP_Themiyan,代码行数:19,代码来源:Flats.py

示例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
#.........这里部分代码省略.........
开发者ID:Keck-DataReductionPipelines,项目名称:MosfireDRP,代码行数:103,代码来源:Flats.py


注:本文中的MOSFIRE.IO.imcombine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。