speasy.core package
- class speasy.core.AllowedKwargs(allowed_list)[source]
Bases:
object
A decorator that prevent from passing unexpected kwargs to a function
- speasy.core.all_of_type(collection: Sequence, expected_type: Type) bool [source]
Returns true only if the type of all elements in given collection is expected_type
- Parameters:
- collection: Sequence
Any iterable object
- expected_type: Type
the type you expect to match
- Returns:
- bool
True only if the type of all elements in given collection is expected_type
Examples
>>> all_of_type([1,2,3], int) True
>>> all_of_type([1,2,3.], int) False
- speasy.core.datetime64_to_epoch(datetime64_array: array) array [source]
Converts an array of numpy datetime64[ns] to an array of floats encoded as Unix Epoch (seconds since 1970)
- Parameters:
- datetime64_arraynp.array
Input array of datetime64[ns]
- Returns:
- np.array
Output array of floats (Epoch)
Examples
>>> datetime64_to_epoch(np.array(['1970-01-01T00:00:00.000000000', '1970-01-01T00:00:01.000000000'], ... dtype='datetime64[ns]')) array([0., 1.])
- speasy.core.deprecation(message: str) None [source]
Shows a deprecation warning.
- Parameters:
- message: str
Custom message to show
- speasy.core.epoch_to_datetime64(epoch_array: array) array [source]
Converts an array of floats encoded as Unix Epoch (seconds since 1970) to an array of numpy datetime64[ns]
- Parameters:
- epoch_arraynp.array
Input array of folats (Epoch)
- Returns:
- np.array
Output array of datetime64[ns]
Examples
>>> epoch_to_datetime64(np.arange(2)) array(['1970-01-01T00:00:00.000000000', '1970-01-01T00:00:01.000000000'], dtype='datetime64[ns]')
- speasy.core.fix_name(name: str)[source]
Makes given input compatible with python charset https://docs.python.org/3/reference/lexical_analysis.html#identifiers
- Parameters:
- name: str
input string to sanitize
- Returns:
- str
a string compatible with python naming rules
Examples
>>> fix_name('Parker Solar Probe (PSP)') 'Parker_Solar_Probe_PSP'
>>> fix_name('IS⊙ISEPI_Lo') 'ISoISEPI_Lo'
>>> fix_name('all_Legal_strings_123') 'all_Legal_strings_123'
- speasy.core.is_collection(value: Any) bool [source]
- Parameters:
- valueAny
- Returns:
- bool
True if given value is collection like object but not a string
- speasy.core.listify(obj: Any) List [source]
Wraps inside a list anything that is not a list. Useful in for loops when you can’t be sure the object you want to iterate is a list.
- Parameters:
- obj: Any
Any object or list
- Returns:
- list
list(obj) if obj is not a list
Examples
>>> for i in listify(1): ... print(i) ... 1
>>> for i in listify([1,2,3]): ... print(i) ... 1 2 3
- speasy.core.make_utc_datetime(input_dt: str | datetime | float64 | float | datetime64) datetime [source]
Makes UTC datetime from given input.
- Parameters:
- input_dt: str or datetime or np.float64 or float
Datetime to convert, can be either en Epoch, a datetime or a string
- Returns:
- datetime
A datetime.datetime object forced to UTC time zone
Examples
>>> make_utc_datetime('2018-01-02') datetime.datetime(2018, 1, 2, 0, 0, tzinfo=datetime.timezone.utc)
>>> make_utc_datetime(0.) datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
>>> from datetime import datetime >>> make_utc_datetime(datetime(2020,1,1)) datetime.datetime(2020, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
- speasy.core.make_utc_datetime64(input_dt: str | datetime | float64 | float | datetime64) datetime64 [source]
Makes UTC np.datetime64 from given input.
- Parameters:
- input_dt: str or datetime or np.float64 or float
Datetime to convert, can be either en Epoch, a datetime or a string
- Returns:
- np.datetime64
A numpy datetime64 object forced to UTC time zone
Examples
>>> make_utc_datetime64('2018-01-02') np.datetime64('2018-01-02T00:00:00.000000000')
>>> make_utc_datetime64(0.) np.datetime64('1970-01-01T00:00:00.000000')
>>> from datetime import datetime >>> make_utc_datetime64(datetime(2020,1,1)) np.datetime64('2020-01-01T00:00:00.000000000')
- speasy.core.mkdir(directory: str) None [source]
Creates directory and parents if they do not exist
- Parameters:
- directory: str
Path to create
- speasy.core.pack_kwargs(**kwargs: Any) Dict [source]
Packs given keyword arguments into a dictionary
- Parameters:
- kwargs: Any
Any keyword argument is accepted
- Returns:
- dict
A dict with all kwargs packed
Examples
>>> pack_kwargs(a=1, b="2") {'a': 1, 'b': '2'}
Subpackages
- speasy.core.cache package
- speasy.core.cdf package
- speasy.core.codecs package
- speasy.core.direct_archive_downloader package
- speasy.core.impex package
ImpexProductType
ImpexProvider
ImpexProvider.build_inventory()
ImpexProvider.build_private_inventory()
ImpexProvider.credential_are_valid()
ImpexProvider.dataset_range()
ImpexProvider.find_parent_dataset()
ImpexProvider.get_catalog()
ImpexProvider.get_data()
ImpexProvider.get_dataset()
ImpexProvider.get_parameter()
ImpexProvider.get_timetable()
ImpexProvider.get_user_catalog()
ImpexProvider.get_user_parameter()
ImpexProvider.get_user_timetable()
ImpexProvider.is_user_catalog()
ImpexProvider.is_user_parameter()
ImpexProvider.is_user_product()
ImpexProvider.is_user_timetable()
ImpexProvider.list_catalogs()
ImpexProvider.list_datasets()
ImpexProvider.list_parameters()
ImpexProvider.list_timetables()
ImpexProvider.list_user_catalogs()
ImpexProvider.list_user_parameters()
ImpexProvider.list_user_timetables()
ImpexProvider.parameter_range()
ImpexProvider.product_type()
ImpexProvider.reset_credentials()
ImpexProvider.to_index()
- Submodules
- speasy.core.index package
- speasy.core.inventory package
- speasy.core.proxy package
- speasy.core.requests_scheduling package
Submodules
- speasy.core.any_files module
- speasy.core.data_containers module
DataContainer
DataContainer.copy()
DataContainer.dtype
DataContainer.empty_like()
DataContainer.from_dictionary()
DataContainer.is_time_dependent
DataContainer.meta
DataContainer.name
DataContainer.nbytes
DataContainer.ndim
DataContainer.ones_like()
DataContainer.reserve_like()
DataContainer.reshape()
DataContainer.select()
DataContainer.shape
DataContainer.to_dictionary()
DataContainer.unit
DataContainer.unit_applied()
DataContainer.values
DataContainer.view()
DataContainer.zeros_like()
DataContainerProtocol
DataContainerProtocol.from_dictionary()
DataContainerProtocol.is_time_dependent
DataContainerProtocol.name
DataContainerProtocol.nbytes
DataContainerProtocol.reserve_like()
DataContainerProtocol.select()
DataContainerProtocol.shape
DataContainerProtocol.to_dictionary()
DataContainerProtocol.unit
DataContainerProtocol.values
DataContainerProtocol.view()
VariableAxis
VariableTimeAxis
VariableTimeAxis.from_dictionary()
VariableTimeAxis.is_time_dependent
VariableTimeAxis.meta
VariableTimeAxis.name
VariableTimeAxis.nbytes
VariableTimeAxis.reserve_like()
VariableTimeAxis.select()
VariableTimeAxis.shape
VariableTimeAxis.to_dictionary()
VariableTimeAxis.unit
VariableTimeAxis.values
VariableTimeAxis.view()
- speasy.core.dataprovider module
- speasy.core.datetime_range module
- speasy.core.http module
- speasy.core.span_utils module
- speasy.core.url_utils module