speasy.core.direct_archive_downloader.direct_archive_downloader module
- class speasy.core.direct_archive_downloader.direct_archive_downloader.RandomSplitDirectDownload[source]
Bases:
object- static get_product(url_pattern: str, variable: str, start_time: str | ~datetime.datetime | ~numpy.float64 | float | ~numpy.datetime64, stop_time: str | ~datetime.datetime | ~numpy.float64 | float | ~numpy.datetime64, fname_regex: str, split_frequency: str = 'daily', date_format=None, file_reader: ~typing.Callable[[...], ~speasy.products.variable.SpeasyVariable | None] = <function _read_cdf>, **kwargs) SpeasyVariable | None[source]
- class speasy.core.direct_archive_downloader.direct_archive_downloader.RegularSplitDirectDownload[source]
Bases:
object- static get_product(url_pattern: str, variable: str, start_time: str | ~datetime.datetime | ~numpy.float64 | float | ~numpy.datetime64, stop_time: str | ~datetime.datetime | ~numpy.float64 | float | ~numpy.datetime64, use_file_list: bool = False, split_frequency: str = 'daily', file_reader: ~typing.Callable[[...], ~speasy.products.variable.SpeasyVariable | None] = <function _read_cdf>, **kwargs) SpeasyVariable | None[source]
- speasy.core.direct_archive_downloader.direct_archive_downloader.apply_date_format(txt: str, date: datetime) str[source]
- speasy.core.direct_archive_downloader.direct_archive_downloader.filter_ranges(ranges: List[Tuple[str, Tuple[datetime, datetime]]], start: str | datetime | float64 | float | datetime64, stop: str | datetime | float64 | float | datetime64) List[str][source]
Given a list of (file, (start, stop)) tuples, filter those that overlap with the specified time range. Parameters ———- ranges : List[Tuple[str, Tuple[datetime, datetime]]]
List of (file, (start, stop)) tuples sorted by start time of each range in ascending order.
- startAnyDateTimeType
Time range start
- stopAnyDateTimeType
Time range stop
Returns
- List[str]
List of files that overlap with the specified time range.
- speasy.core.direct_archive_downloader.direct_archive_downloader.get_product(url_pattern: str, split_rule: str, variable: str, start_time: str | ~datetime.datetime | ~numpy.float64 | float | ~numpy.datetime64, stop_time: str | ~datetime.datetime | ~numpy.float64 | float | ~numpy.datetime64, use_file_list: bool = False, file_reader: ~typing.Callable[[...], ~speasy.products.variable.SpeasyVariable | None] = <function _read_cdf>, codec: str | None = None, **kwargs) SpeasyVariable | None[source]
- speasy.core.direct_archive_downloader.direct_archive_downloader.map_ranges(url, fname_regex: str | Pattern, date_format: str | None = None) List[Tuple[str, Tuple[datetime, datetime]]][source]
- speasy.core.direct_archive_downloader.direct_archive_downloader.spilt_range(split_frequency: str, start_time: str | datetime | float64 | float | datetime64, stop_time: str | datetime | float64 | float | datetime64)[source]
Given a split frequency (daily, yearly) and a time range, generate the list of start time of each fragment given a split frequency (daily, yearly) and a time range to split.
- Parameters:
- split_frequencystr
Fragments spilt frequency (daily, monthly, yearly)
- start_timeAnyDateTimeType
Time range start
- stop_timeAnyDateTimeType
Time range stop
- Returns:
- List[datetime]
Ordered list of start time of each fragment composing the given input range
Examples
>>> spilt_range('daily', "2018-01-02", "2018-01-03") [datetime.datetime(2018, 1, 2, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2018, 1, 3, 0, 0, tzinfo=datetime.timezone.utc)]