• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python astrodata.open函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中astrodata.open函数的典型用法代码示例。如果您正苦于以下问题:Python open函数的具体用法?Python open怎么用?Python open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_append_whole_instance

def test_append_whole_instance(test_path):

    ad = astrodata.open(os.path.join(test_path, 'GMOS/N20160524S0119.fits'))
    ad2 = astrodata.open(os.path.join(test_path, 'GMOS/N20110826S0336.fits'))

    with pytest.raises(ValueError):
        ad2.append(ad)
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_astrodata_fits_object_construction.py


示例2: test_append_slice_to_extension

def test_append_slice_to_extension(test_path):

    ad = astrodata.open(os.path.join(test_path, 'GMOS/N20160524S0119.fits'))
    ad2 = astrodata.open(os.path.join(test_path, 'GMOS/N20110826S0336.fits'))

    with pytest.raises(ValueError):
        ad2[0].append(ad[0], name="FOOBAR")
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_astrodata_fits_object_construction.py


示例3: test_append_non_single_slice

def test_append_non_single_slice(test_path):

    ad = astrodata.open(os.path.join(test_path, 'GMOS/N20160524S0119.fits'))
    ad2 = astrodata.open(os.path.join(test_path, 'GMOS/N20110826S0336.fits'))

    with pytest.raises(ValueError):
        ad2.append(ad[1:])
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_astrodata_fits_object_construction.py


示例4: test_clip_auxiliary_data

 def test_clip_auxiliary_data(self):
     ad = astrodata.open(os.path.join(TESTDATAPATH, 'NIRI',
                                       'N20160620S0035.fits'))
     bpm_ad = astrodata.open('geminidr/niri/lookups/BPM/NIRI_bpm.fits')
     ret = gt.clip_auxiliary_data(ad, bpm_ad, 'bpm', np.int16)
     assert ret[0].data.shape == ad[0].data.shape
     assert np.all(ret[0].data == bpm_ad[0].data[256:768,256:768])
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_gemini_tools.py


示例5: atd4

def atd4():
    """
    Verify that a  mosaicAD class  method can create a tiled array from 
    extensions of a given name.

    The test creates a mosaic ndarray using the method mosaic_image_data 
    with the parameter 'tile=True'  which avoids the transformation step.

    """
    print('\n atd4 REQUIREMENT.......')
    print('Tile all IMAGE extensions matching a given extension name')
    gmos_file='../data/gS20120420S0033.fits'
    gsaoi_file='../data/guS20120413S0048.fits'
    ad = astrodata.open(gmos_file)
    mo = MosaicAD(ad, gemini_mosaic_function)
    #     Now use the mosaic_image_data method to create
    #     the mosaic tile array from the 'SCI' extname.
    tile_data = mo.mosaic_image_data(tile=True, extname='SCI') 

    # ----- Comparing input and output. GMOS image 

    #     The tester should feel free to verify any input and output
    #     pixel location.

    #     For example: A GMOS image:
    #     The lower left corner (2x2) pixels the first GMOS 
    #     data extension. For a GSAOI is the second extension

    corner_gmos = ad['SCI',1].data   # For a GMOS file    
    print('ad["SCI",1].data[:2,:2]\n',corner_gmos[:2,:2])

    #     From the output mosaic. We should get the same values.
    print('tile_data[:2,:2]\n',tile_data[:2,:2])

    # The top right corner of the mosaic
    nexts = ad.count_exts('SCI')
    block = ad['SCI', nexts].data    # There is one amp per block
    print('\nad["SCI",last].data[-2:-2]\n', block[-2:,-2:])

    # The mosaic top corner
    print('\ntile_data[-2:,-2:]\n',tile_data[-2:,-2:])

    # ----- GSAOI data
    ad = astrodata.open(gsaoi_file)
    mo = MosaicAD(ad, gemini_mosaic_function)
    tile_data = mo.mosaic_image_data(tile=True, extname='SCI') 

    print('\nGSAOI data')
    corner_gsaoi = ad['SCI',2].data   # For a GSAOI file    
    print('ad["SCI",2].data\n', corner_gsaoi[:2,:2])
    print('tile_data[:2,:2]\n', tile_data[:2,:2])

    #     The top right corner of the mosaic
    block4 = ad['SCI',4].data    # There is one amp per block
    print('\nblock4[-2:,-2:]\n', block4[-2:,-2:])
    print('tile_data[-2:,-2:]\n', tile_data[-2:,-2:])
    return
开发者ID:mmorage,项目名称:DRAGONS,代码行数:57,代码来源:atp_mosaic.py


示例6: test_clip_auxliary_data_GSAOI

 def test_clip_auxliary_data_GSAOI(self):
     ad = astrodata.open(os.path.join(TESTDATAPATH, 'GSAOI',
                                       'S20150528S0112.fits'))
     bpm_ad = astrodata.open('geminidr/gsaoi/lookups/BPM/gsaoibpm_high_full.fits')
     ret = gt.clip_auxiliary_data_GSAOI(ad, bpm_ad, 'bpm', np.int16)
     for rd, cd, bd in zip(ret.data, ad.data, bpm_ad.data):
         assert rd.shape == cd.shape
         # Note this only works for unprepared data because of the ROI
         # row problem
         assert np.all(rd == bd[512:1536,512:1536])
     pass
开发者ID:mmorage,项目名称:DRAGONS,代码行数:11,代码来源:test_gemini_tools.py


示例7: test_append_single_slice

def test_append_single_slice(test_path):

    ad = astrodata.open(os.path.join(test_path, 'GMOS/N20160524S0119.fits'))
    ad2 = astrodata.open(os.path.join(test_path, 'GMOS/N20110826S0336.fits'))

    lbefore = len(ad2)
    last_ever = ad2[-1].nddata.meta['header'].get('EXTVER', -1)
    ad2.append(ad[1])

    assert len(ad2) == (lbefore + 1)
    assert np.all(ad2[-1].data == ad[1].data)
    assert last_ever < ad2[-1].nddata.meta['header'].get('EXTVER', -1)
开发者ID:mmorage,项目名称:DRAGONS,代码行数:12,代码来源:test_astrodata_fits_object_construction.py


示例8: test_can_overwrite_existing_file

    def test_can_overwrite_existing_file(self, test_path, filename):

        ad = astrodata.open(os.path.join(test_path, filename))
        test_file_location = os.path.join(test_path,
                                          'test_fits_overwrite.fits')
        if os.path.exists(test_file_location):
            os.remove(test_file_location)
        ad.write(test_file_location)

        assert os.path.exists(test_file_location)

        adnew = astrodata.open(test_file_location)
        adnew.write(overwrite=True)

        # erasing file for cleanup
        os.remove(test_file_location)
开发者ID:mmorage,项目名称:DRAGONS,代码行数:16,代码来源:test_astrodata_fits.py


示例9: test_iterate_over_single_slice

    def test_iterate_over_single_slice(self, test_path, filename):
        ad = astrodata.open(os.path.join(test_path, filename))

        metadata = ('SCI', 1)

        for ext in ad[0]:
            assert (ext.hdr['EXTNAME'], ext.hdr['EXTVER']) == metadata
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_astrodata_fits.py


示例10: test_tags

    def test_tags(self, test_path):

        ad = astrodata.open(os.path.join(test_path, filename))
        tags = ad.tags
        expected = {'UNPREPARED', 'RAW', 'SPECT', 'GEMINI', 'GRACES'}

        assert expected.issubset(tags)
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_graces.py


示例11: test_airmass_descriptor_is_none_or_float

 def test_airmass_descriptor_is_none_or_float(self, test_path, filename):
     ad = astrodata.open(os.path.join(test_path, "Archive/", filename))
     try:
         assert ((type(ad.airmass()) == float)
                 or (ad.airmass() is None))
     except Exception as err:
         print("{} failed on call: {}".format(ad.airmass, str(err)))
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_descriptor_types.py


示例12: test_can_make_and_write_ad_object

    def test_can_make_and_write_ad_object(self, test_path):

        # Creates data and ad object
        phu = fits.PrimaryHDU()
        pixel_data = np.random.rand(100, 100)

        hdu = fits.ImageHDU()
        hdu.data = pixel_data

        ad = astrodata.create(phu)
        ad.append(hdu, name='SCI')

        # Write file and test it exists properly
        test_file_location = os.path.join(
            test_path, 'created_fits_file.fits')

        if os.path.exists(test_file_location):
            os.remove(test_file_location)
        ad.write(test_file_location)

        assert os.path.exists(test_file_location)
        # Opens file again and tests data is same as above

        adnew = astrodata.open(test_file_location)
        assert np.array_equal(adnew[0].data, pixel_data)
        os.remove(test_file_location)
开发者ID:mmorage,项目名称:DRAGONS,代码行数:26,代码来源:test_astrodata_fits.py


示例13: atd1

def atd1():
    """
    With a GMOS AstroData object, the test instantiates a MosaicAD object
    containing 'coords' as one of the attributes. The test verify that 
    coords['amp_mosaic_coord'] and ad['SCI'].detector_array.as_dict() values
    match.

    """
    print('\n atd1 REQUIREMENT.......')
    print ('Instantiate an object from a supported AstroData objec')
    gmos_file   = '../data/gS20120420S0033.fits'
    gsaoi_file  = '../data/guS20110324S0146.fits'
    nongem_file = '../data/kp620765.fits'

    #    Success Criterion 1. (GMOS data)
    #    The tester should provide her/his own GMOS file.
    for tfile in [gmos_file, gsaoi_file, nongem_file]:
        ad = astrodata.open(tfile)
        print('\n ...........CASE for:', ad.filename, ad.instrument())
        mo = MosaicAD(ad, gemini_mosaic_function)

        #    print DETECTOR values for all the 'SCI' extensions as
        #    a dictionary.
        print(ad.detector_section())
          
        #    print the 'amp_mosaic_coord' key value from the 'coords'
        #    attribute. This list is in increasing order of extver.
        print(mo.coords['amp_mosaic_coord'])
    return
开发者ID:mmorage,项目名称:DRAGONS,代码行数:29,代码来源:atp_mosaic.py


示例14: test_prepare

 def test_prepare(self):
     ad = astrodata.open(os.path.join(TESTDATAPATH, 'NIRI',
                             'N20070819S0104.fits'))
     p = NIRIImage([ad])
     ad = p.prepare()[0]
     assert ad_compare(ad, os.path.join(TESTDATAPATH, 'NIRI',
                             'N20070819S0104_prepared.fits'))
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_standardize.py


示例15: test_array_information

 def test_array_information(self):
     ad = astrodata.open(os.path.join(TESTDATAPATH, 'GMOS',
                                         'N20110524S0358_varAdded.fits'))
     ret = gt.array_information(ad)
     assert ret == {'amps_per_array': {1: 1, 2: 1, 3: 1},
                   'amps_order': [0, 1, 2], 'array_number': [1, 2, 3],
                   'reference_extension': 2}
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_gemini_tools.py


示例16: test_nonlinearityCorrect

 def test_nonlinearityCorrect(self):
     ad = astrodata.open(os.path.join(TESTDATAPATH, 'NIRI',
                             'N20070819S0104_varAdded.fits'))
     p = NIRIImage([ad])
     ad = p.nonlinearityCorrect()[0]
     assert ad_compare(ad, os.path.join(TESTDATAPATH, 'NIRI',
                             'N20070819S0104_nonlinearityCorrected.fits'))
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_primitives_niri.py


示例17: test_addVAR

 def test_addVAR(self):
     ad = astrodata.open(os.path.join(TESTDATAPATH, 'NIRI',
                             'N20070819S0104_ADUToElectrons.fits'))
     p = NIRIImage([ad])
     ad = p.addVAR(read_noise=True, poisson_noise=True)[0]
     assert ad_compare(ad, os.path.join(TESTDATAPATH, 'NIRI',
                             'N20070819S0104_varAdded.fits'))
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_standardize.py


示例18: flushPixels

    def flushPixels(self, adinputs=None, force=False):
        """
        This primitive saves the inputs to disk and then reopens them so
        the pixel data are out of memory
        """
        def is_lazy(ad):
            """Determine whether an AD object is lazily-loaded"""
            for ndd in ad.nddata:
                for attr in ('_data', '_mask', '_uncertainty'):
                    item = getattr(ndd, attr)
                    if item is not None and not (hasattr(item, 'lazy') and item.lazy):
                        return False
            return True

        log = self.log

        for i, ad in enumerate(adinputs):
            if not force and is_lazy(ad):
                log.fullinfo("{} is lazily-loaded; not writing to "
                          "disk".format(ad.filename))
            else:
                # Write in current directory (hence ad.filename specified)
                log.fullinfo("Writing {} to disk and reopening".format(ad.filename))
                ad.write(ad.filename, overwrite=True)
                # We directly edit elements in the list to ensure the versions
                # in the primitivesClass stream are affected too. We also want
                # the files to retain their orig_filename attributes, which
                # would otherwise change upon loading.
                orig_filename = ad.orig_filename
                adinputs[i] = astrodata.open(ad.filename)
                adinputs[i].orig_filename = orig_filename
        return adinputs
开发者ID:mmorage,项目名称:DRAGONS,代码行数:32,代码来源:primitives_bookkeeping.py


示例19: test_read_a_keyword_from_hdr_deprecated

    def test_read_a_keyword_from_hdr_deprecated(self):
        ad = astrodata.open('N20110826S0336.fits')

        with pytest.raises(AttributeError):
            assert ad.hdr.CCDNAME == [
                'EEV 9273-16-03', 'EEV 9273-20-04', 'EEV 9273-20-03'
            ]
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_astrodata_fits.py


示例20: atd8

def atd8():
    """
    From a given AstroData object, the system shall offer an option to
    prevent the creation of merged table associations.

    The test creates an output AstroData object using the method 
    as_astrodata with the     parameter 'return_associated_bintables'
    set to False which prevents the creation of     associated binary 
    tables to the reference image extension name.

    Resources:

    file: N20120121S0175_ccMeasured.fits. Contains SCI,VAR,DQ
         OBJCAT (Bintable) and REFFACT (Bintable)

    """
    print('\n atd8 REQUIREMENT.......')
    print ('Offer an option to prevent merged table associations')
    file = '../data/N20120121S0175_ccMeasured.fits'
    ad = astrodata.open(file)
    #    Creates a mosaicAD object using the input ad
    #    and the default mosaic function named 
    #    gemini_mosaic_function. 'SCI' is the default extname
    mo = MosaicAD(ad, gemini_mosaic_function)
    outad = mo.as_astrodata()
    print('.......OUTPUT AD with all extensions')
    print(outad.info())
    outad = mo.as_astrodata(return_associated_bintables=False)
    #    The tester should see that there is no BINTABLE 
    #    extension name associated with the reference image 
    #    extension name in this output.
    print('.......OUTPUT AD with no associated BINTABLE extensions')
    print(outad.info())
    return
开发者ID:mmorage,项目名称:DRAGONS,代码行数:34,代码来源:atp_mosaic.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python astrodata.AstroData类代码示例发布时间:2022-05-24
下一篇:
Python utils.pbar函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap