speasy.core.impex package
- class speasy.core.impex.ImpexProductType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enumeration of the type of products available in an impex webservice.
- CATALOG = 5
- COMPONENT = 3
- DATASET = 1
- PARAMETER = 2
- TIMETABLE = 4
- UNKNOWN = 0
- class speasy.core.impex.ImpexProvider(provider_name: str, server_url: str, max_chunk_size_days: int = 10, capabilities: ~typing.List = None, username: str = '', password: str = '', name_mapping: ~typing.Dict = None, output_format: str = 'CDF', min_proxy_version=<Version('0.12.0')>)[source]
Bases:
DataProvider
ImpexProvider class. This class is the main interface to interact with the Impex data providers such as AMDA or CLWeb.
- build_inventory(root: SpeasyIndex)[source]
Build public inventory from the specified Impex data provider.
- Parameters:
- root: SpeasyIndex
root index in which to add all the indexes in the data provider’s inventory
- Returns:
- SpeasyIndex
root index populated with public inventory
- build_private_inventory(root: SpeasyIndex)[source]
Build private inventory, requires user authentication.
- Parameters:
- root: SpeasyIndex
root index in which to add all the indexes in the data provider’s inventory
- Returns:
- SpeasyIndex
root index populated with user private inventory
- credential_are_valid()[source]
Tels if credential are valid. It only checks they are not empty. It does not check if they are correct.
- Returns:
- bool
True if credentials are valid, False otherwise.
- dataset_range(dataset_id: str) DateTimeRange | None [source]
Get dataset time range as defined in the inventory.
- Parameters:
- dataset_id: str or DatasetIndex
parameter id
- Returns:
- Optional[DateTimeRange]
Data time range
Examples
>>> import speasy as spz >>> spz.amda.dataset_range("ace-imf-all") <DateTimeRange: 1997-09-02T00:00:12+00:00 -> ...>
- find_parent_dataset(product_id: str | DatasetIndex | ParameterIndex | TemplatedParameterIndex | ComponentIndex) str | None [source]
- get_catalog(catalog_id: str, **kwargs) Catalog | None [source]
Get catalog data by ID.
- Parameters:
- catalog_id: str or CatalogIndex
catalog id
- Returns:
- Optional[Catalog]
catalog data
Examples
>>> import speasy as spz >>> spz.amda.get_catalog("sharedcatalog_22") <Catalog: model_regions_plasmas_mms_2019>
- get_data(product, start_time=None, stop_time=None, **kwargs) SpeasyProduct | List[SpeasyProduct] | None [source]
Get product data by id, start and stop time if applicable. The product can be a parameter, a dataset, a catalog or a timetable. The method will automatically determine the product type and call the appropriate underlying method.
- Parameters:
- product: str or SpeasyIndex
product id
- start_time: str or datetime.datetime
desired data start time
- stop_time: str datetime.datetime
desired data stop time
- Returns:
- MaybeAnyProduct
product data if available, None otherwise
Examples
>>> import speasy as spz >>> imf_data = spz.amda.get_data("imf", "2019-02-24T19:20:05", "2019-02-25") >>> print(imf_data.columns) ['bx', 'by', 'bz'] >>> print(imf_data.values.shape) (1050, 3)
- get_dataset(dataset_id: str, start: str, stop: str, **kwargs) Dataset [source]
Get dataset contents. Returns list of SpeasyVariable objects, one for each parameter in the dataset.
- Parameters:
- dataset_id: str or DatasetIndex
dataset id
- start: str or datetime
desired data start
- stop: str or datetime
desired data end
- Returns:
- Dataset or None
dataset content as a collection of SpeasyVariable if it succeeds or None
Examples
>>> import speasy as spz >>> import datetime >>> dataset = spz.amda.get_dataset("ace-imf-all", datetime.datetime(2000,1,1), datetime.datetime(2000,1,2)) >>> dataset <Dataset: final / prelim variables: ['|b|', 'b_gse', 'b_gsm'] time range: <DateTimeRange: 2000-01-01T00:00:11+00:00 -> 2000-01-01T23:59:55+00:00>
- get_parameter(product, start_time, stop_time, extra_http_headers: Dict = None, output_format: str = None, **kwargs) SpeasyVariable | None [source]
Get parameter data.
- Parameters:
- product: str or ParameterIndex
parameter id
- start_time:
desired data start time
- stop_time:
desired data stop time
- extra_http_headers: dict
reserved for internal use
- output_format: str
request output format in case of success, allowed values are ASCII and CDF_ISTP
- Returns:
- Optional[SpeasyVariable]
product data if available
Examples
>>> import speasy as spz >>> import datetime >>> imf_data = spz.amda.get_parameter("imf", "2018-01-01", "2018-01-01T01") >>> print(imf_data.columns) ['bx', 'by', 'bz'] >>> print(imf_data.values.shape) (225, 3)
- get_timetable(timetable_id: str, **kwargs) TimeTable | None [source]
Get timetable data by ID.
- Parameters:
- timetable_id: str or TimetableIndex
time table id
- Returns:
- Optional[TimeTable]
timetable data
Examples
>>> import speasy as spz >>> spz.amda.get_timetable("sharedtimeTable_0") <TimeTable: FTE_c1>
- get_user_catalog(catalog_id: str, **kwargs) Catalog | None [source]
Get user catalog. Raises an exception if user is not authenticated.
- Parameters:
- catalog_id: str or CatalogIndex
catalog id
- Returns:
- Optional[Catalog]
user catalog
Warning
Calling
get_user_catalog()
without having defined AMDA_Webservice login credentials will result in aUndefinedConfigEntry
exception being raised.Examples
>>> import speasy as spz >>> spz.amda.get_user_catalog("tt_0") <Catalog: test_alexis>
- get_user_parameter(parameter_id: str, start_time: datetime, stop_time: datetime, **kwargs) SpeasyVariable | None [source]
Get user parameter. Raises an exception if user is not authenticated.
- Parameters:
- parameter_id: str or ParameterIndex
parameter id
- start_time: datetime or str
begining of data time
- stop_time: datetime or str
end of data time
- Returns:
- Optional[SpeasyVariable]
user parameter
Warning
Calling
get_user_parameter()
without having defined AMDA_Webservice login credentials will result in aUndefinedConfigEntry
exception being raised.Examples
>>> import speasy as spz >>> user_param = spz.amda.get_user_parameter("ws_0", "2019-02-24T19:20:05", "2019-02-25") >>> print(user_param.columns) ['ws_test_param'] >>> print(user_param.values.shape) (2, 1)
- get_user_timetable(timetable_id: str, **kwargs) TimeTable | None [source]
Get user timetable. Raises an exception if user is not authenticated.
- Parameters:
- timetable_id: str
timetable id
- Returns:
- Optional[TimeTable]
user timetable
Warning
Calling
get_user_timetable()
without having defined AMDA_Webservice login credentials will result in aUndefinedConfigEntry
exception being raised.Examples
>>> import speasy as spz >>> spz.amda.get_user_timetable("tt_0") <TimeTable: test_alexis>
- is_user_catalog(catalog_id: str)[source]
Tels if a product is a user catalog
- Parameters:
- catalog_id: str or CatalogIndex
product id
- Returns:
- bool
True if the product is a user catalog, False otherwise.
- is_user_parameter(parameter_id: str)[source]
Tells if a product is a user parameter
- Parameters:
- parameter_id: str or ParameterIndex
product id
- Returns:
- bool
True if the product is a user parameter, False otherwise.
- is_user_timetable(timetable_id: str)[source]
Tels if a product is a user timetable
- Parameters:
- timetable_id: str or TimetableIndex
product id
- Returns:
- bool
True if the product is a user timetable, False otherwise.
- list_catalogs() List[CatalogIndex] [source]
Get the list of public catalog IDs:
- Returns:
- List[AMDACatalogIndex]
list of catalog IDs
Examples
>>> import speasy as spz >>> amda_catalogs = spz.amda.list_catalogs() >>> len(amda_catalogs) > 0 True >>> amda_catalogs[0] <CatalogIndex: model_regions_plasmas_mms_2019>
- list_datasets() List[DatasetIndex] [source]
Get the list of datasets available
- Returns:
- List[DatasetIndex]
list of dataset indexes
Examples
>>> import speasy as spz >>> amda_datasets = spz.amda.list_datasets() >>> len(amda_datasets) > 0 True >>> amda_datasets[0] <DatasetIndex: ...> >>> amda_datasets[0].desc '...'
- list_parameters(dataset_id: str | None = None) List[ParameterIndex] [source]
Get the list of parameter indexes available in AMDA or a given dataset
- Parameters:
- dataset_id: Optional[str or AMDADatasetIndex]
optional parent dataset id
- Returns:
- List[AMDAParameterIndex]
the list of parameter indexes
Examples
>>> import speasy as spz >>> amda_parameters = spz.amda.list_parameters() >>> len(amda_parameters) > 0 True >>> amda_parameters[0] <ParameterIndex: ...>
- list_timetables() List[TimetableIndex] [source]
Get list of public timetables.
- Returns:
- List[AMDATimetableIndex]
list of timetable IDs.
Examples
>>> import speasy as spz >>> spz.amda.list_timetables()[::50] [<TimetableIndex: ...>, <TimetableIndex: ...>, <TimetableIndex: ...>]
- list_user_catalogs() List[CatalogIndex] [source]
Get the list of user catalogs. User catalogs are represented as dictionary objects.
- Returns:
- List[AMDACatalogIndex]
list of user catalogs.
Warning
Calling
get_user_catalogs()
without having defined AMDA_Webservice login credentials will result in aUndefinedConfigEntry
exception being raised.Examples
>>> import speasy as spz >>> spz.amda.list_user_catalogs() [<CatalogIndex: MyCatalog>]
- list_user_parameters() List[ParameterIndex] [source]
Get the list of user parameters. User parameters are represented as dictionary objects.
- Returns:
- List[AMDAParameterIndex]
list of user parameters
Warning
Calling
get_user_parameter()
without having defined AMDA_Webservice login credentials will result in aUndefinedConfigEntry
exception being raised.Examples
>>> import speasy as spz >>> spz.amda.list_user_parameters() [<ParameterIndex: test_param>]
- list_user_timetables() List[TimetableIndex] [source]
Get the list of user timetables. User timetable are represented as dictionary objects.
- Returns:
- List[AMDATimetableIndex]
list of user timetables.
Warning
Calling
get_user_timetables()
without having defined AMDA_Webservice login credentials will result in aUndefinedConfigEntry
exception being raised.Examples
>>> import speasy as spz >>> spz.amda.list_user_timetables() [<TimetableIndex: test_alexis>, <TimetableIndex: test_alexis2>, <TimetableIndex: tt3>]
- parameter_range(parameter_id: str) DateTimeRange | None [source]
Get parameter time range as defined in the inventory.
- Parameters:
- parameter_id: str or ParameterIndex
parameter id
- Returns:
- Optional[DateTimeRange]
Data time range
Examples
>>> import speasy as spz >>> spz.amda.parameter_range("imf") <DateTimeRange: 1997-09-02T00:00:12+00:00 -> ...>
- product_type(product_id: str) ImpexProductType [source]
Returns product type for any known Impex product from its index or ID.
- Parameters:
- product_id: str or SpeasyIndex
product id
- Returns:
- ImpexProductType
Type of product IE ImpexProductType.DATASET, ImpexProductType.TIMETABLE, …
Examples
>>> import speasy as spz >>> spz.amda.product_type("imf") <ImpexProductType.PARAMETER: 2> >>> spz.amda.product_type("ace-imf-all") <ImpexProductType.DATASET: 1>
- reset_credentials(username: str = '', password: str = '')[source]
Reset user credentials and update the inventory by replacing the information contained in the configuration
- Parameters:
- username: Optional[str]
username in the related service
- password: Optional[str]
user password in the related service
- to_index(product_id: str) ParameterIndex | TemplatedParameterIndex | DatasetIndex | TimetableIndex | CatalogIndex | ComponentIndex [source]
Submodules
- speasy.core.impex.client module
ImpexClient
ImpexClient.auth()
ImpexClient.credential_are_valid()
ImpexClient.get_catalog()
ImpexClient.get_catalog_list()
ImpexClient.get_credentials()
ImpexClient.get_derived_parameter_list()
ImpexClient.get_obs_data_tree()
ImpexClient.get_parameter()
ImpexClient.get_status()
ImpexClient.get_time_table_list()
ImpexClient.get_timetable()
ImpexClient.in_progress()
ImpexClient.is_alive()
ImpexClient.is_capable()
ImpexClient.reachable()
ImpexClient.reset_credentials()
ImpexEndpoint
- speasy.core.impex.exceptions module
- speasy.core.impex.parser module
ImpexXMLParser
ImpexXMLParser.fix_names()
ImpexXMLParser.fix_xmlid()
ImpexXMLParser.index_ctor_args()
ImpexXMLParser.make_any_node()
ImpexXMLParser.make_catalog_node()
ImpexXMLParser.make_component_node()
ImpexXMLParser.make_dataset_node()
ImpexXMLParser.make_parameter_node()
ImpexXMLParser.make_path_node()
ImpexXMLParser.make_timetable_node()
ImpexXMLParser.make_user_parameter_node()
ImpexXMLParser.parse()
ImpexXMLParser.parse_template_argument()
ImpexXMLParser.parse_template_arguments()
to_xmlid()
- speasy.core.impex.utils module