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


Python fits.Header方法代码示例

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


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

示例1: get_header

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def get_header(self, ext=0):
        """Returns the metadata embedded in the file.

        Target Pixel Files contain embedded metadata headers spread across three
        different FITS extensions:

        1. The "PRIMARY" extension (``ext=0``) provides a metadata header
           providing details on the target and its CCD position.
        2. The "PIXELS" extension (``ext=1``) provides details on the
           data column and their coordinate system (WCS).
        3. The "APERTURE" extension (``ext=2``) provides details on the
           aperture pixel mask and the expected coordinate system (WCS).

        Parameters
        ----------
        ext : int or str
            FITS extension name or number.

        Returns
        -------
        header : `~astropy.io.fits.header.Header`
            Header object containing metadata keywords.
        """
        return self.hdu[ext].header 
开发者ID:KeplerGO,项目名称:lightkurve,代码行数:26,代码来源:targetpixelfile.py

示例2: ApertureHDU

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def ApertureHDU(model):
    '''
    Construct the HDU containing the aperture used to de-trend.

    '''

    # Get mission cards
    cards = model._mission.HDUCards(model.meta, hdu=3)

    # Add EVEREST info
    cards.append(('COMMENT', '************************'))
    cards.append(('COMMENT', '*     EVEREST INFO     *'))
    cards.append(('COMMENT', '************************'))
    cards.append(('MISSION', model.mission, 'Mission name'))
    cards.append(('VERSION', EVEREST_MAJOR_MINOR, 'EVEREST pipeline version'))
    cards.append(('SUBVER', EVEREST_VERSION, 'EVEREST pipeline subversion'))
    cards.append(('DATE', strftime('%Y-%m-%d'),
                  'EVEREST file creation date (YYYY-MM-DD)'))

    # Create the HDU
    header = pyfits.Header(cards=cards)
    hdu = pyfits.ImageHDU(data=model.aperture,
                          header=header, name='APERTURE MASK')

    return hdu 
开发者ID:rodluger,项目名称:everest,代码行数:27,代码来源:fits.py

示例3: test_makes_a_sensible_master_flat

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def test_makes_a_sensible_master_flat(mock_namer):
    mock_namer.return_value = lambda *x: 'foo.fits'
    nimages = 50
    flat_level = 10000.0
    nx = 100
    ny = 100
    master_flat_variation = 0.05

    image_header = Header({'DATE-OBS': '2019-12-04T14:34:00',
                           'DETSEC': '[1:100,1:100]',
                           'DATASEC': '[1:100,1:100]',
                           'FLATLVL': flat_level,
                           'OBSTYPE': 'SKYFLAT',
                           'RA': 0.0,
                           'DEC': 0.0})

    flat_pattern = np.random.normal(1.0, master_flat_variation, size=(ny, nx))
    images = [FakeLCOObservationFrame(hdu_list=[FakeCCDData(data=flat_pattern + np.random.normal(0.0, 0.02, size=(ny, nx)),
                                                            meta=image_header)])
              for _ in range(nimages)]

    maker = FlatMaker(FakeContext())
    stacked_image = maker.do_stage(images)
    np.testing.assert_allclose(stacked_image.primary_hdu.data, flat_pattern, atol=0.1, rtol=0.1) 
开发者ID:LCOGT,项目名称:banzai,代码行数:26,代码来源:test_flat_maker.py

示例4: test_header_cal_type_dark

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def test_header_cal_type_dark(mock_namer):
    mock_namer.return_value = lambda *x: 'foo.fits'
    nx = 100
    ny = 100
    maker = DarkMaker(FakeContext())

    image_header = Header({'DATE-OBS': '2019-12-04T14:34:00',
                           'DETSEC': '[1:100,1:100]',
                           'DATASEC': '[1:100,1:100]',
                           'OBSTYPE': 'DARK'})

    image = maker.do_stage([FakeLCOObservationFrame(hdu_list=[FakeCCDData(data=np.zeros((ny,nx)),
                                                                           meta=image_header)])
                             for x in range(6)])

    assert image.meta['OBSTYPE'].upper() == 'DARK' 
开发者ID:LCOGT,项目名称:banzai,代码行数:18,代码来源:test_dark_maker.py

示例5: test_makes_a_sensible_master_dark

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def test_makes_a_sensible_master_dark(mock_namer):
    mock_namer.return_value = lambda *x: 'foo.fits'
    nimages = 20
    nx = 100
    ny = 100
    image_header = Header({'DATE-OBS': '2019-12-04T14:34:00',
                           'DETSEC': '[1:100,1:100]',
                           'DATASEC': '[1:100,1:100]',
                           'OBSTYPE': 'DARK'})
    images = [FakeLCOObservationFrame(hdu_list=[FakeCCDData(data=np.ones((ny, nx)) * x,
                                                            meta=image_header)])
              for x in range(nimages)]

    expected_master_dark = stats.sigma_clipped_mean(np.arange(nimages), 3.0)
    maker = DarkMaker(FakeContext())
    stacked_image = maker.do_stage(images)

    assert (stacked_image.data == expected_master_dark).all() 
开发者ID:LCOGT,项目名称:banzai,代码行数:20,代码来源:test_dark_maker.py

示例6: test_header_cal_type_bias

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def test_header_cal_type_bias(mock_namer):
    mock_namer.return_value = lambda *x: 'foo.fits'
    nx = 100
    ny = 100

    maker = BiasMaker(FakeContext())

    image_header = Header({'DATE-OBS': '2019-12-04T14:34:00',
                           'DETSEC': '[1:100,1:100]',
                           'DATASEC': '[1:100,1:100]',
                           'OBSTYPE': 'BIAS', 'RA': 0.0, 'DEC': 0.0})

    image = maker.do_stage([FakeLCOObservationFrame(hdu_list=[FakeCCDData(data=np.zeros((ny, nx)),
                                                                           meta=image_header,
                                                                           bias_level=0.0)])
                             for x in range(6)])

    assert image.meta['OBSTYPE'].upper() == 'BIAS' 
开发者ID:LCOGT,项目名称:banzai,代码行数:20,代码来源:test_bias_maker.py

示例7: test_bias_level_is_average_of_inputs

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def test_bias_level_is_average_of_inputs(mock_namer):
    mock_namer.return_value = lambda *x: 'foo.fits'
    nimages = 20
    bias_levels = np.arange(nimages, dtype=float)

    images = [FakeLCOObservationFrame(hdu_list=[FakeCCDData(data=np.random.normal(i, size=(99,99)),
                                                            bias_level=i, meta=Header({'DATE-OBS': '2019-12-04T14:34:00',
                                                                                       'DETSEC': '[1:100,1:100]',
                                                                                       'DATASEC': '[1:100,1:100]',
                                                                                       'OBSTYPE': 'BIAS',
                                                                                       'RA': 0.0,
                                                                                       'DEC': 0.0}))])
              for i in bias_levels]

    fake_context = FakeContext()
    maker = BiasMaker(fake_context)
    master_bias = maker.do_stage(images)

    assert master_bias.meta['BIASLVL'] == np.mean(bias_levels) 
开发者ID:LCOGT,项目名称:banzai,代码行数:21,代码来源:test_bias_maker.py

示例8: test_makes_a_sensible_master_bias

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def test_makes_a_sensible_master_bias(mock_namer):
    mock_namer.return_value = lambda *x: 'foo.fits'
    nimages = 20
    expected_readnoise = 15.0

    images = [FakeLCOObservationFrame(hdu_list=[FakeCCDData(data=np.random.normal(0.0, size=(99, 99), scale=expected_readnoise),
                                                            bias_level=0.0,
                                                            read_noise= expected_readnoise,
                                                            meta=Header({'DATE-OBS': '2019-12-04T14:34:00',
                                                                         'DETSEC': '[1:100,1:100]',
                                                                         'DATASEC': '[1:100,1:100]',
                                                                         'OBSTYPE': 'BIAS', 'RA': 0.0, 'DEC': 0.0}))])
              for i in range(nimages)]

    maker = BiasMaker(FakeContext())
    stacked_image = maker.do_stage(images)
    master_bias = stacked_image.data
    assert np.abs(np.mean(master_bias)) < 0.1
    actual_readnoise = np.std(master_bias)
    assert np.abs(actual_readnoise - expected_readnoise / (nimages ** 0.5)) < 0.2 
开发者ID:LCOGT,项目名称:banzai,代码行数:22,代码来源:test_bias_maker.py

示例9: init_master_header

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def init_master_header(old_header, images):
        header = fits.Header()
        for key in old_header.keys():
            try:
                # Dump empty header keywords and ignore old histories.
                if len(key) > 0 and key != 'HISTORY':
                    for i in range(old_header.count(key)):
                        header[key] = (old_header[(key, i)], old_header.comments[(key, i)])
            except ValueError as e:
                logger.error('Could not add keyword {key}: {error}'.format(key=key, error=e))
                continue
        header = fits_utils.sanitize_header(header)
        observation_dates = [image.dateobs for image in images]
        mean_dateobs = date_utils.mean_date(observation_dates)

        header['DATE-OBS'] = (date_utils.date_obs_to_string(mean_dateobs), '[UTC] Mean observation start time')
        header['DAY-OBS'] = (max(images, key=lambda x: datetime.datetime.strptime(x.epoch, '%Y%m%d')).epoch, '[UTC] Date at start of local observing night')
        header['ISMASTER'] = (True, 'Is this a master calibration frame')

        header.add_history("Images combined to create master calibration image:")
        for i, image in enumerate(images):
            header[f'IMCOM{i+1:03d}'] = (image.filename, 'Image combined to create master')
        return header 
开发者ID:LCOGT,项目名称:banzai,代码行数:25,代码来源:lco.py

示例10: __init__

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def __init__(self, campaign=0, channel=1, cadenceno=1, data_store=None,
                 shape=KEPLER_CHANNEL_SHAPE, add_background=False, time=None,
                 quality=None, dateobs=None, dateend=None, mjdbeg=None, 
                 mjdend=None, template_tpf_header0=None,
                 template_tpf_header1=None):
        self.campaign = campaign
        self.channel = channel
        self.cadenceno = cadenceno
        self.data_store = data_store
        self.header = fits.Header()
        self.data = np.empty(shape, dtype=np.float32)
        self.data[:] = np.nan
        self.uncert = np.empty(shape, dtype=np.float32)
        self.uncert[:] = np.nan
        self.add_background = add_background
        self.time = time
        self.quality = quality
        self.template_tpf_header0 = template_tpf_header0
        self.template_tpf_header1 = template_tpf_header1
        self.dateobs = dateobs
        self.dateend = dateend
        self.mjdbeg = mjdbeg
        self.mjdend = mjdend 
开发者ID:KeplerGO,项目名称:k2mosaic,代码行数:25,代码来源:mosaic.py

示例11: from_tree

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def from_tree(cls, data, ctx):
        hdus = []
        first = True
        for hdu_entry in data:
            header = fits.Header([fits.Card(*x) for x in hdu_entry['header']])
            data = hdu_entry.get('data')
            if data is not None:
                try:
                    data = data.__array__()
                except ValueError:
                    data = None
            if first:
                hdu = fits.PrimaryHDU(data=data, header=header)
                first = False
            elif data.dtype.names is not None:
                hdu = fits.BinTableHDU(data=data, header=header)
            else:
                hdu = fits.ImageHDU(data=data, header=header)
            hdus.append(hdu)
        hdulist = fits.HDUList(hdus)
        return hdulist 
开发者ID:holzschu,项目名称:Carnets,代码行数:23,代码来源:fits.py

示例12: test_set_card_value

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def test_set_card_value(self):
        """Similar to test_update_header_card(), but tests the the
        `header['FOO'] = 'bar'` method of updating card values.
        """

        header = fits.Header()
        comment = 'number of bits per data pixel'
        card = fits.Card.fromstring(f'BITPIX  = 32 / {comment}')
        header.append(card)

        header['BITPIX'] = 32

        assert 'BITPIX' in header
        assert header['BITPIX'] == 32
        assert header.cards[0].keyword == 'BITPIX'
        assert header.cards[0].value == 32
        assert header.cards[0].comment == comment 
开发者ID:holzschu,项目名称:Carnets,代码行数:19,代码来源:test_core.py

示例13: test_writeto_2

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def test_writeto_2(self):
        """
        Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/107

        Test of `writeto()` with a trivial header containing a single keyword.
        """
        filename = self.temp('array.fits')
        data = np.zeros((100, 100))
        header = fits.Header()
        header.set('CRPIX1', 1.)
        fits.writeto(filename, data, header=header,
                     overwrite=True, output_verify='silentfix')
        with fits.open(filename) as hdul:
            assert len(hdul) == 1
            assert (data == hdul[0].data).all()
            assert 'CRPIX1' in hdul[0].header
            assert hdul[0].header['CRPIX1'] == 1.0 
开发者ID:holzschu,项目名称:Carnets,代码行数:19,代码来源:test_core.py

示例14: copy

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def copy(self):
        """Create a mutable and independent copy of the header."""
        # This method exists because io.fits.Header.copy has a docstring that
        # refers to `Header` which breaks sphinx...
        return super().copy() 
开发者ID:mhvk,项目名称:baseband,代码行数:7,代码来源:header.py

示例15: fromfile

# 需要导入模块: from astropy.io import fits [as 别名]
# 或者: from astropy.io.fits import Header [as 别名]
def fromfile(cls, fh, verify=True):
        """Reads in GUPPI header block from a file.

        Parameters
        ----------
        fh : filehandle
            To read data from.
        verify: bool, optional
            Whether to do basic checks on whether the header is valid. Verify
            is automatically called by `~astropy.io.fits.Header.fromstring`, so
            this flag exists only to standardize the API.
        """
        header_start = fh.tell()
        # Find the size of the header.  GUPPI header entries are 80 char long
        # with <=8 char keyword names.  "=" is always the 9th char.
        line = '========='
        while line[8] in ('=', ' '):
            line = fh.read(80).decode('ascii')
            if line[:3] == 'END':
                break
            if line == '':
                raise EOFError

        header_end = fh.tell()
        fh.seek(header_start)
        hdr = fh.read(header_end - header_start).decode('ascii')
        # Create the header using the base class.
        self = cls.fromstring(hdr)
        self.mutable = False
        if verify:
            self.verify()
        # GUPPI headers are not a proper FITS standard, and we're reading
        # from a file that the user likely cannot control, so let's not bother
        # with card verification (this avoids warnings in repr(); gh-282)
        for c in self.cards:
            c._verified = True
        return self 
开发者ID:mhvk,项目名称:baseband,代码行数:39,代码来源:header.py


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