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


Python astrodata.open函数代码示例

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


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


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