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


Python Scraper.filelist方法代码示例

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


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

示例1: testFilesRange_sameDirectory_local

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
def testFilesRange_sameDirectory_local():
    s = Scraper('/'.join(['file:/', rootdir,
                          'EIT', 'efz%Y%m%d.%H%M%S_s.fits']))
    print(s.pattern)
    print(s.now)
    startdate = parse_time((2004, 3, 1, 4, 0))
    enddate = parse_time((2004, 3, 1, 6, 30))
    assert len(s.filelist(TimeRange(startdate, enddate))) == 3
    startdate = parse_time((2010, 1, 10, 20, 30))
    enddate = parse_time((2010, 1, 20, 20, 30))
    assert len(s.filelist(TimeRange(startdate, enddate))) == 0
开发者ID:Cadair,项目名称:sunpy,代码行数:13,代码来源:test_scraper.py

示例2: testFilesRange_sameDirectory_remote

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
def testFilesRange_sameDirectory_remote():
    pattern = "http://solarmonitor.org/data/%Y/%m/%d/" "fits/{instrument}/" "{instrument}_00174_fd_%Y%m%d_%H%M%S.fts.gz"
    s = Scraper(pattern, instrument="swap")
    startdate = datetime.datetime(2014, 5, 14, 0, 0)
    enddate = datetime.datetime(2014, 5, 14, 6, 30)
    timerange = TimeRange(startdate, enddate)
    assert len(s.filelist(timerange)) == 2
    startdate = datetime.datetime(2014, 5, 14, 21, 0)
    enddate = datetime.datetime(2014, 5, 14, 23, 30)
    timerange = TimeRange(startdate, enddate)
    assert len(s.filelist(timerange)) == 0
开发者ID:ZachWerginz,项目名称:sunpy,代码行数:13,代码来源:test_scraper.py

示例3: testFilesRange_sameDirectory_local

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
def testFilesRange_sameDirectory_local():
    # Fails due to an IsADirectoryError, wrapped in a URLError, after `requests`
    # tries to open a directory as a binary file.
    s = Scraper('/'.join(['file:/', rootdir,
                          'EIT', 'efz%Y%m%d.%H%M%S_s.fits']))
    startdate = parse_time((2004, 3, 1, 4, 0))
    enddate = parse_time((2004, 3, 1, 6, 30))
    assert len(s.filelist(TimeRange(startdate, enddate))) == 3
    startdate = parse_time((2010, 1, 10, 20, 30))
    enddate = parse_time((2010, 1, 20, 20, 30))
    assert len(s.filelist(TimeRange(startdate, enddate))) == 0
开发者ID:PritishC,项目名称:sunpy,代码行数:13,代码来源:test_scraper.py

示例4: testFilesRange_sameDirectory_remote

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
def testFilesRange_sameDirectory_remote():
    pattern = ('http://solarmonitor.org/data/%Y/%m/%d/'
               'fits/{instrument}/'
               '{instrument}_00174_fd_%Y%m%d_%H%M%S.fts.gz')
    s = Scraper(pattern, instrument='swap')
    startdate = parse_time((2014, 5, 14, 0, 0))
    enddate = parse_time((2014, 5, 14, 6, 30))
    timerange = TimeRange(startdate, enddate)
    assert len(s.filelist(timerange)) == 2
    startdate = parse_time((2014, 5, 14, 21, 0))
    enddate = parse_time((2014, 5, 14, 23, 30))
    timerange = TimeRange(startdate, enddate)
    assert len(s.filelist(timerange)) == 0
开发者ID:Cadair,项目名称:sunpy,代码行数:15,代码来源:test_scraper.py

示例5: test_filelist_url_missing_directory

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
def test_filelist_url_missing_directory():
    # Asserts solution to ticket #2684.
    # Attempting to access data for the year 1960 results in a 404, so no files are returned.
    pattern = 'http://lasp.colorado.edu/eve/data_access/evewebdataproducts/level2/%Y/%j/'
    s = Scraper(pattern)
    timerange = TimeRange('1960/01/01 00:00:00', '1960/01/02 00:00:00')
    assert len(s.filelist(timerange)) == 0
开发者ID:PritishC,项目名称:sunpy,代码行数:9,代码来源:test_scraper.py

示例6: _get_url_for_timerange

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
    def _get_url_for_timerange(self, timerange, **kwargs):
        """
        Returns the url for Fermi/GBM data for the given date.

        Parameters
        ----------
        timerange : `sunpy.time.TimeRange`
            The time range for which to download the data.

        Returns
        -------
        `str`:
            The url(s) for time of interest.
        """
        # Checks if detector keyword
        # If not defaults to detector 5
        if 'detector' in kwargs:
            det = _check_detector(kwargs['detector'])
        else:
            det = 'n5'

        # Check for resolution keyword - either CSPEC or CTIME
        # Default type is CSPEC
        if 'resolution' in kwargs:
            data_type = _check_type(kwargs['resolution'])
        else:
            data_type = 'cspec'

        gbm_pattern = ('https://heasarc.gsfc.nasa.gov/FTP/fermi/data/gbm/daily/'
                       '%Y/%m/%d/current/glg_{data_type}_{det}_%y%m%d_v00.pha')
        gbm_files = Scraper(gbm_pattern, data_type=data_type, det=det)
        urls = gbm_files.filelist(timerange)

        return urls
开发者ID:Cadair,项目名称:sunpy,代码行数:36,代码来源:fermi_gbm.py

示例7: testFilesRange_sameDirectory_months_remote

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
def testFilesRange_sameDirectory_months_remote():
    pattern = ('http://www.srl.caltech.edu/{spacecraft}/DATA/{instrument}/'
               'Ahead/1minute/AeH%y%b.1m')
    s = Scraper(pattern, spacecraft='STEREO', instrument='HET')
    startdate = parse_time((2007, 8, 1))
    enddate = parse_time((2007, 9, 10))
    timerange = TimeRange(startdate, enddate)
    assert len(s.filelist(timerange)) == 2
开发者ID:Cadair,项目名称:sunpy,代码行数:10,代码来源:test_scraper.py

示例8: _get_url_for_timerange

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
    def _get_url_for_timerange(self, timerange, **kwargs):
        """
        Returns list of URLS corresponding to value of input timerange.

        Parameters
        ----------
        timerange: `sunpy.time.TimeRange`
            time range for which data is to be downloaded.

        Returns
        -------
        urls : list
            list of URLs corresponding to the requested time range
        """

        # We allow queries with no Wavelength but error here so that the query
        # does not get passed to VSO and spit out garbage.
        if 'wavelength' not in kwargs.keys() or not kwargs['wavelength']:
            raise ValueError("Queries to NORH should specify either 17GHz or 34GHz as a Wavelength."
                             "see https://solar.nro.nao.ac.jp/norh/doc/manuale/node65.html")
        else:
            wavelength = kwargs['wavelength']

        # If wavelength is a single value GenericClient will have made it a
        # Quantity in the kwargs.
        if not isinstance(wavelength, u.Quantity):
            raise ValueError("Wavelength to NORH must be one value not {}.".format(wavelength))

        wavelength = wavelength.to(u.GHz, equivalencies=u.spectral())
        if wavelength == 34 * u.GHz:
            freq = 'tcz'
        elif wavelength == 17 * u.GHz:
            freq = 'tca'
        else:
            raise ValueError("NORH Data can be downloaded for 17GHz or 34GHz,"
                             " see https://solar.nro.nao.ac.jp/norh/doc/manuale/node65.html")

        # If start of time range is before 00:00, converted to such, so
        # files of the requested time ranger are included.
        # This is done because the archive contains daily files.
        if timerange.start.strftime('%M-%S') != '00-00':
            timerange = TimeRange(timerange.start.strftime('%Y-%m-%d'),
                                  timerange.end)

        norh = Scraper(BASEURL, freq=freq)
        # TODO: warn user that some files may have not been listed, like for example:
        #       tca160504_224657 on ftp://solar-pub.nao.ac.jp/pub/nsro/norh/data/tcx/2016/05/
        #       as it doesn't follow pattern.

        return norh.filelist(timerange)
开发者ID:Cadair,项目名称:sunpy,代码行数:52,代码来源:norh.py

示例9: _get_url_for_timerange

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
    def _get_url_for_timerange(self, timerange, **kwargs):
        """
        Return list of URLS corresponding to value of input timerange.

        Parameters
        ----------
        timerange: `sunpy.time.TimeRange`
            time range for which data is to be downloaded.

        Returns
        -------
        urls : list
            list of URLs corresponding to the requested time range

        """
        # If start of time range is before 00:00, converted to such, so
        # files of the requested time ranger are included.
        # This is done because the archive contains daily files.
        if timerange.start.time() != datetime.time(0, 0):
            timerange = TimeRange('{:%Y-%m-%d}'.format(timerange.start), timerange.end)
        eve = Scraper(BASEURL)
        return eve.filelist(timerange)
开发者ID:bwgref,项目名称:sunpy,代码行数:24,代码来源:eve.py

示例10: test_ftp

# 需要导入模块: from sunpy.util.scraper import Scraper [as 别名]
# 或者: from sunpy.util.scraper.Scraper import filelist [as 别名]
def test_ftp():
    pattern = 'ftp://solar-pub.nao.ac.jp/pub/nsro/norh/data/tcx/%Y/%m/tca%y%m%d'
    s = Scraper(pattern)
    timerange = TimeRange('2016/5/18 15:28:00', '2016/5/20 16:30:50')
    assert len(s.filelist(timerange)) == 2
开发者ID:Cadair,项目名称:sunpy,代码行数:7,代码来源:test_scraper.py


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