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


Python AstroData.append方法代码示例

本文整理汇总了Python中astrodata.AstroData.append方法的典型用法代码示例。如果您正苦于以下问题:Python AstroData.append方法的具体用法?Python AstroData.append怎么用?Python AstroData.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astrodata.AstroData的用法示例。


在下文中一共展示了AstroData.append方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _init_as_astrodata

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
    def _init_as_astrodata(self):
        """
           Initialize parameters to be used by as_astrodata.

           Creates a WCS object (pywcs) from the SCI header and
           form the output AD object with the PHU and MDF from
           the input AD. We are adding the TRACEFP extension as well 
           for later use on the spectral reduction process. 

           Input:
              self.ad:  AD object.
           Output:
              adout:  Output AD object with AD phu and MDF 
        """

        ad = self.ad
        # Start output AD with the original phu and the MDF extension.
        adout = AstroData(phu=ad.phu)
        adout.append(ad['MDF'])
        adout.append(ad['TRACEFP'])

        # Get wcs information. It is in the PHU
        try:
            self.wcs = pywcs.WCS(ad.phu.header)
            if not hasattr(self.wcs.wcs, 'cd'):
                self.wcs = None
        except:   # Something wrong with WCS, set it to None
            self.wcs = None

        return adout
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:32,代码来源:extract.py

示例2: runappend

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
def runappend(f1=None, f2=None, auto=False):
    ad = AstroData(f1)
    md = AstroData(f2)
    pstr = "\n\n             >>>>>>>     AD     <<<<<<<<\n"
    pstr += str(ad.infostr())
    pstr += "\n\n             >>>>>>>    AD APPEND   <<<<<<<<\n"
    pstr += str(md.infostr())
    ad.append(moredata=md, auto_number=auto)
    pstr +="\n\n             >>>>>>>  NEW AD <<<<<<<<\n"
    pstr += str(ad.infostr())
    print(pstr)
    return ad
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:14,代码来源:testutil.py

示例3: test_method_close_2

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
def test_method_close_2():
    ad = AstroData(TESTFILE)
    ad.close()
    with pytest.raises(AstroDataError):
        ad.append(moredata=hdu1)
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_AstroDataAPI.py

示例4: test_method_append_9

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
def test_method_append_9():
    ad = AstroData(TESTFILE)
    ad.append(header=header1, data=data1, extname='TESTH', extver=1)
    assert ad[('TESTH', 1)]
开发者ID:mmorage,项目名称:DRAGONS,代码行数:6,代码来源:test_AstroDataAPI.py

示例5: test_method_append_8

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
def test_method_append_8():
    ad = AstroData(TESTFILE)
    ad.append(header=header1, data=data1, extname='TESTH', extver=2)
    assert ad[3].header['EXTVER'] == 2
开发者ID:mmorage,项目名称:DRAGONS,代码行数:6,代码来源:test_AstroDataAPI.py

示例6: test_method_append_6

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
def test_method_append_6():
    ad = AstroData(TESTFILE)
    initial_len = len(ad)
    ad.append(header=header1, data=data1, auto_number=True)
开发者ID:mmorage,项目名称:DRAGONS,代码行数:6,代码来源:test_AstroDataAPI.py

示例7: test_method_append_5

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
def test_method_append_5():
    ad = AstroData(TESTFILE)
    ad.append(moredata=hdu1, auto_number=True)
    assert ad.hdulist[-1] == hdu1
开发者ID:mmorage,项目名称:DRAGONS,代码行数:6,代码来源:test_AstroDataAPI.py

示例8: test_method_append_4

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
def test_method_append_4():
    ad = AstroData(TESTFILE)
    initial_len = len(ad)
    ad.append(moredata=hdu1, auto_number=True)
    assert len(ad) == initial_len + 1
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_AstroDataAPI.py

示例9: test_method_append_2

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
def test_method_append_2():
    ad = AstroData(TESTFILE)
    ad2 = AstroData(TESTFILE2)
    with pytest.raises(AstroDataError):
        ad.append(moredata=ad2)
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_AstroDataAPI.py

示例10: makeFringeFrame

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]
    def makeFringeFrame(self,rc):

        # Instantiate the log
        log = gemLog.getGeminiLog(logType=rc["logType"],
                                  logLevel=rc["logLevel"])

        # Log the standard "starting primitive" debug message
        log.debug(gt.log_message("primitive", "makeFringeFrame", 
                                 "starting"))

        # Initialize the list of output AstroData objects
        adoutput_list = []

        # Check for at least 3 input frames
        adinput = rc.get_inputs_as_astrodata()
        if len(adinput)<3:
            log.stdinfo('Fewer than 3 frames provided as input. ' +
                        'Not making fringe frame.')

            # Report the empty list to the reduction context
            rc.report_output(adoutput_list)
        
        else:
            rc.run("correctBackgroundToReferenceImage"\
                       "(remove_zero_level=True)")

            # If needed, do a rough median on all frames, subtract,
            # and then redetect to help distinguish sources from fringes
            sub_med = rc["subtract_median_image"]
            if sub_med:
                adinput = rc.get_inputs_as_astrodata()

                # Get data by science extension
                data = {}
                for ad in adinput:
                    for sciext in ad["SCI"]:
                        key = (sciext.extname(),sciext.extver())
                        if data.has_key(key):
                            data[key].append(sciext.data)
                        else:
                            data[key] = [sciext.data]


                # Make a median image for each extension
                import pyfits as pf
                median_ad = AstroData()
                median_ad.filename = gt.filename_updater(
                    adinput=adinput[0], suffix="_stack_median", strip=True)
                for key in data:
                    med_data = np.median(np.dstack(data[key]),axis=2)
                    hdr = pf.Header()
                    ext = AstroData(data=med_data, header=hdr)
                    ext.rename_ext(key)
                    median_ad.append(ext)

                # Subtract the median image
                rc["operand"] = median_ad
                rc.run("subtract")

                # Redetect to get a good object mask
                rc.run("detectSources")

                # Add the median image back in to the input
                rc.run("add")

            # Add the object mask into the DQ plane
            rc.run("addObjectMaskToDQ")
            
            # Stack frames with masking from DQ plane
            rc.run("stackFrames(operation=%s)" % rc["operation"])

        yield rc
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:74,代码来源:primitives_GMOS_IMAGE.py

示例11: as_astrodata

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import append [as 别名]

#.........这里部分代码省略.........

        adout.phu.header.update('TILED', ['FALSE', 'TRUE'][tile],
                 'False: Image Mosaicked, True: tiled')

        # Set up extname lists with all the extension names that are going to 
        # be mosaiced and table extension names to associate.
        #
        if extname is None:                     # Let's work through all extensions
            if self.associated_im_extns:
                extname_list = self.associated_im_extns
            else:
                extname_list = self.im_extnames
        else:
            self.ref_extname = extname          # Redefine reference extname
            if extname in self.associated_im_extns:
                self.associated_im_extns = [extname]    # We need this extname only
                extname_list = [extname]
            elif extname in self.non_associated_extns: 
                # Extname is not in associated lists; so clear these lists.
                extname_list = []                       
                self.associated_im_extns = []
                self.associated_tab_extns = []
            elif extname in self.associated_tab_extns:
                # Extname is an associated bintable.
                extname_list = []                       
                self.associated_im_extns = []
                self.associated_tab_extns = [extname]
            else:
                extname_list = [extname]

        # ------ Create mosaic ndarrays, update the output WCS, create an 
        #        AstroData object and append to the output list. 
        
        # Make the list to have the order 'sci','var','dq'
        svdq = [k for k in ['SCI','VAR','DQ'] if k in extname_list]
        # add the rest of the extension names.
        extname_list = svdq + list(set(extname_list)-set(svdq))

        for extn in  extname_list:
            # Mosaic the IMAGE extensions now
            mosarray = self.mosaic_image_data(extn,tile=tile,block=block,
                                          return_ROI=return_ROI)
            # Create the mosaic FITS header using the reference 
            # extension header.
            header = self.mosaic_header(mosarray.shape,block,tile)

            # Generate WCS object to be used in the merging the object
            # catalog table for updating the objects pixel coordinates
            # w/r to the new crpix1,2.
            ref_wcs = pywcs.WCS(header)

            # Setup output AD 
            new_ext = AstroData(data=mosarray,header=header)

            # Reset extver to 1.
            new_ext.rename_ext(name=extn,ver=1)
            adout.append(new_ext)

        if return_associated_bintables:
            # If we have associated bintables with image extensions, then
            # merge the tables.
            for tab_extn in self.associated_tab_extns:
                # adout will get the merge table
                new_tab = self.merge_table_data(ref_wcs, tile, tab_extn, block, 
                            update_catalog_method) 
                adout.append(new_tab[0])
        
        # If we have a list of extension names that have not tables extension
        # names associated, then mosaic them.
        #
        if return_non_associations:
            for extn in self.non_associated_extns:
                # Now get the list of extver to append
                if extn in self.im_extnames:   #  Image extensions
                    # We need to mosaic image extensions having more
                    # than one extver.
                    #
                    if adin.count_exts(extn) > 1:
                        mosarray = self.mosaic_image_data(extn,
                                    tile=tile,block=block,
                                    return_ROI=return_ROI)

                        # Get reference extension header
                        header = self.mosaic_header(mosarray.shape,block,tile)
                        new_ext = AstroData(data=mosarray,header=header)

                        # Reset extver to 1.
                        new_ext.rename_ext(name=extn,ver=1)
                        adout.append(new_ext)
                    else:
                        self.log.warning("as_astrodata: extension '"+extn+\
                                         "' has 1 extension.")
                        adout.append(adin[extn])

                if extn in self.tab_extnames:   # We have a list of extvers
                    for extv in self.tab_extnames[extn]:
                        adout.append(adin[extn,extv]) 
        # rediscover classifications.
        adout.refresh_types()
        return adout
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:104,代码来源:mosaicAD.py


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