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

Python tables.entries_from_dir函数代码示例

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

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



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

示例1: _download_and_collect_entries

    def _download_and_collect_entries(self, query_result, client=None,
            path=None, progress=False):
        if client is None:
            client = VSOClient()

        paths = client.get(query_result, path).wait(progress=progress)

        for (path, block) in zip(paths, query_result):
            qr_entry = tables.DatabaseEntry._from_query_result_block(block)

            if os.path.isfile(path):
                entries = tables.entries_from_file(path, self.default_waveunit)
            elif os.path.isdir(path):
                entries = tables.entries_from_dir(path, self.default_waveunit)
            else:
                raise ValueError('The path is neither a file nor directory')

            for entry in entries:
                entry.source = qr_entry.source
                entry.provider = qr_entry.provider
                entry.physobs = qr_entry.physobs
                entry.fileid = qr_entry.fileid
                entry.observation_time_start = qr_entry.observation_time_start
                entry.observation_time_end = qr_entry.observation_time_end
                entry.instrument = qr_entry.instrument
                entry.size = qr_entry.size
                entry.wavemin = qr_entry.wavemin
                entry.wavemax = qr_entry.wavemax
                entry.path = path
                entry.download_time = datetime.utcnow()
                yield entry
开发者ID:abigailStev,项目名称:sunpy,代码行数:31,代码来源:database.py


示例2: add_from_dir

    def add_from_dir(self, path, recursive=False, pattern='*',
                     ignore_already_added=False, time_string_parse_format=None):
        """Search the given directory for FITS files and use their FITS headers
        to add new entries to the database. Note that one entry in the database
        is assigned to a list of FITS headers, so not the number of FITS headers
        but the number of FITS files which have been read determine the number
        of database entries that will be added. FITS files are detected by
        reading the content of each file, the `pattern` argument may be used to
        avoid reading entire directories if one knows that all FITS files have
        the same filename extension.

        Parameters
        ----------
        path : string
            The directory where to look for FITS files.

        recursive : bool, optional
            If True, the given directory will be searched recursively.
            Otherwise, only the given directory and no subdirectories are
            searched. The default is `False`, i.e. the given directory is not
            searched recursively.

        pattern : string, optional
            The pattern can be used to filter the list of filenames before the
            files are attempted to be read. The default is to collect all
            files. This value is passed to the function :func:`fnmatch.filter`,
            see its documentation for more information on the supported syntax.

        ignore_already_added : bool, optional
            See :meth:`sunpy.database.Database.add`.

        time_string_parse_format : str, optional
            Fallback timestamp format which will be passed to
            `~datetime.datetime.strftime` if `sunpy.time.parse_time` is unable to
            automatically read the `date-obs` metadata.

        """
        cmds = CompositeOperation()
        entries = tables.entries_from_dir(
            path, recursive, pattern, self.default_waveunit,
            time_string_parse_format=time_string_parse_format)
        for database_entry, filepath in entries:
            if database_entry in list(self) and not ignore_already_added:
                raise EntryAlreadyAddedError(database_entry)
            cmd = commands.AddEntry(self.session, database_entry)
            if self._enable_history:
                cmds.add(cmd)
            else:
                cmd()
            self._cache.append(database_entry)
        if cmds:
            self._command_manager.do(cmds)
开发者ID:DanRyanIrish,项目名称:sunpy,代码行数:52,代码来源:database.py


示例3: _download_and_collect_entries

    def _download_and_collect_entries(self, query_result, **kwargs):

        client = kwargs.pop('client', None)
        path = kwargs.pop('path', None)
        progress = kwargs.pop('progress', False)
        methods = kwargs.pop('methods', ('URL-FILE_Rice', 'URL-FILE'))

        if kwargs:
            k, v = kwargs.popitem()
            raise TypeError('unexpected keyword argument {0!r}'.format(k))

        if client is None:
            client = VSOClient()

        paths = client.get(query_result, path, methods).wait(progress=progress)

        for (path, block) in zip(paths, query_result):
            qr_entry = tables.DatabaseEntry._from_query_result_block(block)

            if os.path.isfile(path):
                entries = tables.entries_from_file(path, self.default_waveunit)
            elif os.path.isdir(path):
                entries = tables.entries_from_dir(path, self.default_waveunit)
            else:
                raise ValueError('The path is neither a file nor directory')

            for entry in entries:
                entry.source = qr_entry.source
                entry.provider = qr_entry.provider
                entry.physobs = qr_entry.physobs
                entry.fileid = qr_entry.fileid
                entry.observation_time_start = qr_entry.observation_time_start
                entry.observation_time_end = qr_entry.observation_time_end
                entry.instrument = qr_entry.instrument
                entry.size = qr_entry.size
                entry.wavemin = qr_entry.wavemin
                entry.wavemax = qr_entry.wavemax
                entry.path = path
                entry.download_time = datetime.utcnow()
                yield entry
开发者ID:Punyaslok,项目名称:sunpy,代码行数:40,代码来源:database.py


示例4: test_entries_from_dir_recursively_false

def test_entries_from_dir_recursively_false():
    entries = list(
        entries_from_dir(testdir, False, default_waveunit='angstrom'))
    assert len(entries) == 39
开发者ID:ChrisIAm101,项目名称:sunpy,代码行数:4,代码来源:test_tables.py


示例5: test_entries_from_dir

def test_entries_from_dir():
    entries = list(entries_from_dir(waveunitdir))
    assert len(entries) == 4
    for entry, filename in entries:
        if filename.endswith('na120701.091058.fits'):
            break
    assert entry.path in (os.path.join(waveunitdir, filename), filename)
    assert filename.startswith(waveunitdir)
    assert len(entry.fits_header_entries) == 42
    assert entry.fits_header_entries == [
        FitsHeaderEntry('SIMPLE', True),
        FitsHeaderEntry('BITPIX', -32),
        FitsHeaderEntry('NAXIS', 3),
        FitsHeaderEntry('NAXIS1', 256),
        FitsHeaderEntry('NAXIS2', 256),
        FitsHeaderEntry('NAXIS3', 1),
        FitsHeaderEntry('DATE', '27-OCT-82'),
        FitsHeaderEntry('DATE-OBS', '2012-07-01'),
        FitsHeaderEntry('DATE_OBS', '2012-07-01T09:10:58.200Z'),
        FitsHeaderEntry('DATE_END', '2012-07-01T09:10:58.200Z'),
        FitsHeaderEntry('WAVELNTH', 1.98669),
        FitsHeaderEntry('WAVEUNIT', 'm'),
        FitsHeaderEntry('PHYSPARA', 'STOKESI'),
        FitsHeaderEntry('OBJECT', 'FS'),
        FitsHeaderEntry('OBS_TYPE', 'RADIO'),
        FitsHeaderEntry('OBS_MODE', 'IMAGE'),
        FitsHeaderEntry('LONGITUD', 0.0),
        FitsHeaderEntry('LATITUDE', 0.0),
        FitsHeaderEntry('INSTITUT', 'MEUDON'),
        FitsHeaderEntry('CMP_NAME', 'ROUTINE'),
        FitsHeaderEntry('CONTACT', ' A. KERDRAON'),
        FitsHeaderEntry('TELESCOP', 'NRH'),
        FitsHeaderEntry('INSTRUME', 'NRH2'),
        FitsHeaderEntry('FILENAME', 'nrh2_1509_h80_20120701_091058c02_i.fts'),
        FitsHeaderEntry('NRH_DATA', '2DB'),
        FitsHeaderEntry('ORIGIN', 'wrfits'),
        FitsHeaderEntry('FREQ', 150.9),
        FitsHeaderEntry('FREQUNIT', 6),
        FitsHeaderEntry('BSCALE', 1.0),
        FitsHeaderEntry('BZERO', 0.0),
        FitsHeaderEntry('BUNIT', 'K'),
        FitsHeaderEntry('EXPTIME', 1168576512),
        FitsHeaderEntry('CTYPE1', 'Solar-X'),
        FitsHeaderEntry('CTYPE2', 'Solar-Y'),
        FitsHeaderEntry('CTYPE3', 'StokesI'),
        FitsHeaderEntry('CRPIX1', 128),
        FitsHeaderEntry('CRPIX2', 128),
        FitsHeaderEntry('CDELT1', 0.015625),
        FitsHeaderEntry('CDELT2', 0.015625),
        FitsHeaderEntry('SOLAR_R', 64.0),
        FitsHeaderEntry('COMMENT', ''),
        FitsHeaderEntry('HISTORY', '')]
    assert entry.fits_key_comments == [
        FitsKeyComment('WAVEUNIT', 'in meters'),
        FitsKeyComment('NAXIS2', 'number of rows'),
        FitsKeyComment('CDELT2', 'pixel scale y, in solar radius/pixel'),
        FitsKeyComment('CRPIX1', 'SUN CENTER X, pixels'),
        FitsKeyComment('CRPIX2', 'SUN CENTER Y, pixels'),
        FitsKeyComment('SOLAR_R', 'SOLAR RADIUS, pixels'),
        FitsKeyComment('NAXIS1', 'number of columns'),
        FitsKeyComment('CDELT1', 'pixel scale x, in solar radius/pixel'),
        FitsKeyComment('NAXIS3', 'StokesI'),
        FitsKeyComment('TELESCOP', 'Nancay Radioheliograph'),
        FitsKeyComment('INSTRUME', 'Nancay 2D-images Radioheliograph'),
        FitsKeyComment('BUNIT', 'Brightness temperature'),
        FitsKeyComment('BITPIX', 'IEEE 32-bit floating point values'),
        FitsKeyComment('DATE', 'Date of file creation'),
        FitsKeyComment('FREQUNIT', 'in MHz'),
        FitsKeyComment('EXPTIME', 'in seconds')]
开发者ID:ChrisIAm101,项目名称:sunpy,代码行数:69,代码来源:test_tables.py


示例6: _download_and_collect_entries

    def _download_and_collect_entries(self, query_result, **kwargs):

        client = kwargs.pop('client', None)
        path = kwargs.pop('path', None)
        progress = kwargs.pop('progress', False)
        methods = kwargs.pop('methods', ('URL-FILE_Rice', 'URL-FILE'))
        overwrite = kwargs.pop('overwrite', False)

        if kwargs:
            k, v = kwargs.popitem()
            raise TypeError('unexpected keyword argument {0!r}'.format(k))

        if client is None:
            client = VSOClient()

        remove_list = []
        delete_entries = []
        for qr in query_result:
            temp = tables.DatabaseEntry._from_query_result_block(qr)
            for database_entry in self:
                if database_entry.path is not None and temp._compare_attributes(
                    database_entry, ["source", "provider", "physobs", "fileid",
                                     "observation_time_start", "observation_time_end",
                                     "instrument", "size", "wavemin", "wavemax"]):
                    if not overwrite:
                        remove_list.append(qr)
                    else:
                        delete_entries.append(database_entry)

        for temp in remove_list:
            query_result = [x for x in query_result if x != temp]

        for temp in delete_entries:
            self.remove(temp)

        paths = client.fetch(query_result, path).wait(progress=progress)

        for (path, block) in zip(paths, query_result):
            qr_entry = tables.DatabaseEntry._from_query_result_block(block)

            if os.path.isfile(path):
                entries = tables.entries_from_file(path, self.default_waveunit)
            elif os.path.isdir(path):
                entries = tables.entries_from_dir(path, self.default_waveunit)
            else:
                raise ValueError('The path is neither a file nor directory')

            for entry in entries:
                entry.source = qr_entry.source
                entry.provider = qr_entry.provider
                entry.physobs = qr_entry.physobs
                entry.fileid = qr_entry.fileid
                entry.observation_time_start = qr_entry.observation_time_start
                entry.observation_time_end = qr_entry.observation_time_end
                entry.instrument = qr_entry.instrument
                entry.size = qr_entry.size
                entry.wavemin = qr_entry.wavemin
                entry.wavemax = qr_entry.wavemax
                entry.path = path
                entry.download_time = datetime.utcnow()
                yield entry
开发者ID:DanRyanIrish,项目名称:sunpy,代码行数:61,代码来源:database.py


示例7: test_entries_from_dir_recursively_false

def test_entries_from_dir_recursively_false():
    entries = list(entries_from_dir(testdir, False,
                                    default_waveunit='angstrom',
                                    time_string_parse_format='%d/%m/%Y'))
    assert len(entries) == 81
开发者ID:bwgref,项目名称:sunpy,代码行数:5,代码来源:test_tables.py


示例8: test_entries_from_dir_recursively_true

def test_entries_from_dir_recursively_true():
    entries = list(entries_from_dir(testdir, True, default_waveunit="angstrom"))
    assert len(entries) == 28
开发者ID:karpateyogesh,项目名称:sunpy,代码行数:3,代码来源:test_tables.py


示例9: test_entries_from_dir

def test_entries_from_dir():
    entries = list(entries_from_dir(waveunitdir))
    assert len(entries) == 4
    for entry, filename in entries:
        if filename.endswith("na120701.091058.fits"):
            break
    assert entry.path == os.path.join(waveunitdir, filename)
    assert filename.startswith(waveunitdir)
    assert len(entry.fits_header_entries) == 42
    assert entry.fits_header_entries == [
        FitsHeaderEntry("SIMPLE", True),
        FitsHeaderEntry("BITPIX", -32),
        FitsHeaderEntry("NAXIS", 3),
        FitsHeaderEntry("NAXIS1", 256),
        FitsHeaderEntry("NAXIS2", 256),
        FitsHeaderEntry("NAXIS3", 1),
        FitsHeaderEntry("DATE", "27-OCT-82"),
        FitsHeaderEntry("DATE-OBS", "2012-07-01"),
        FitsHeaderEntry("DATE_OBS", "2012-07-01T09:10:58.200Z"),
        FitsHeaderEntry("DATE_END", "2012-07-01T09:10:58.200Z"),
        FitsHeaderEntry("WAVELNTH", 1.98669),
        FitsHeaderEntry("WAVEUNIT", "m"),
        FitsHeaderEntry("PHYSPARA", "STOKESI"),
        FitsHeaderEntry("OBJECT", "FS"),
        FitsHeaderEntry("OBS_TYPE", "RADIO"),
        FitsHeaderEntry("OBS_MODE", "IMAGE"),
        FitsHeaderEntry("LONGITUD", 0.0),
        FitsHeaderEntry("LATITUDE", 0.0),
        FitsHeaderEntry("INSTITUT", "MEUDON"),
        FitsHeaderEntry("CMP_NAME", "ROUTINE"),
        FitsHeaderEntry("CONTACT", " A. KERDRAON"),
        FitsHeaderEntry("TELESCOP", "NRH"),
        FitsHeaderEntry("INSTRUME", "NRH2"),
        FitsHeaderEntry("FILENAME", "nrh2_1509_h80_20120701_091058c02_i.fts"),
        FitsHeaderEntry("NRH_DATA", "2DB"),
        FitsHeaderEntry("ORIGIN", "wrfits"),
        FitsHeaderEntry("FREQ", 150.9),
        FitsHeaderEntry("FREQUNIT", 6),
        FitsHeaderEntry("BSCALE", 1.0),
        FitsHeaderEntry("BZERO", 0.0),
        FitsHeaderEntry("BUNIT", "K"),
        FitsHeaderEntry("EXPTIME", 1168576512),
        FitsHeaderEntry("CTYPE1", "Solar-X"),
        FitsHeaderEntry("CTYPE2", "Solar-Y"),
        FitsHeaderEntry("CTYPE3", "StokesI"),
        FitsHeaderEntry("CRPIX1", 128),
        FitsHeaderEntry("CRPIX2", 128),
        FitsHeaderEntry("CDELT1", 0.015625),
        FitsHeaderEntry("CDELT2", 0.015625),
        FitsHeaderEntry("SOLAR_R", 64.0),
        FitsHeaderEntry("COMMENT", ""),
        FitsHeaderEntry("HISTORY", ""),
    ]
    assert entry.fits_key_comments == [
        FitsKeyComment("WAVEUNIT", "in meters"),
        FitsKeyComment("NAXIS2", "number of rows"),
        FitsKeyComment("CDELT2", "pixel scale y, in solar radius/pixel"),
        FitsKeyComment("CRPIX1", "SUN CENTER X, pixels"),
        FitsKeyComment("CRPIX2", "SUN CENTER Y, pixels"),
        FitsKeyComment("SOLAR_R", "SOLAR RADIUS, pixels"),
        FitsKeyComment("NAXIS1", "number of columns"),
        FitsKeyComment("CDELT1", "pixel scale x, in solar radius/pixel"),
        FitsKeyComment("NAXIS3", "StokesI"),
        FitsKeyComment("TELESCOP", "Nancay Radioheliograph"),
        FitsKeyComment("INSTRUME", "Nancay 2D-images Radioheliograph"),
        FitsKeyComment("BUNIT", "Brightness temperature"),
        FitsKeyComment("BITPIX", "IEEE 32-bit floating point values"),
        FitsKeyComment("DATE", "Date of file creation"),
        FitsKeyComment("FREQUNIT", "in MHz"),
        FitsKeyComment("EXPTIME", "in seconds"),
    ]
开发者ID:karpateyogesh,项目名称:sunpy,代码行数:71,代码来源:test_tables.py


示例10: test_entries_from_dir_recursively_false

def test_entries_from_dir_recursively_false():
    with pytest.warns(AstropyUserWarning, match='File may have been truncated'):
        entries = list(entries_from_dir(testdir, False,
                                        default_waveunit='angstrom',
                                        time_string_parse_format='%d/%m/%Y'))
    assert len(entries) == 109
开发者ID:Cadair,项目名称:sunpy,代码行数:6,代码来源:test_tables.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tables.entries_from_file函数代码示例发布时间:2022-05-27
下一篇:
Python commands.CompositeOperation类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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