speasy.webservices.amda.ws module

class speasy.webservices.amda.ws.AMDA_Webservice(server_url: str = 'https://amda.irap.omp.eu')[source]

Bases: DataProvider

build_inventory(root: SpeasyIndex)[source]
build_private_inventory(root: SpeasyIndex)[source]
dataset_range(dataset_id: str) DateTimeRange | None[source]

Get product time range.

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 -> ...>
get_catalog(catalog_id: str, **kwargs) Catalog | None[source]

Get catalog data by ID.

Parameters:
catalog_id: str or AMDACatalogIndex

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) SpeasyVariable | TimeTable | Catalog | Dataset | None[source]

Get product data by id.

Parameters:
product: str or AMDAIndex

product id

start_time: str or datetime.datetime

desired data start time

stop_time: str datetime.datetime

desired data stop time

Returns:
Optional[Union[SpeasyVariable, TimeTable, Catalog, Dataset]]

product data if available

Examples

>>> import speasy as spz
>>> imf_data = spz.amda.get_data("imf", "2019-02-24T19:20:05", "2019-02-25")
>>> print(imf_data.columns)
['imf[0]', 'imf[1]', 'imf[2]']
>>> 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 AMDADatasetIndex

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 -> 2000-01-01T23:59:55>
get_parameter(product, start_time, stop_time, extra_http_headers: Dict | None = None, output_format: str | None = None, **kwargs) SpeasyVariable | None[source]
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) Catalog | None[source]

Get user catalog. Raises an exception if user is not authenticated.

Parameters:
catalog_id: str or AMDACatalogIndex

catalog id

Returns:
Optional[Catalog]

user catalog

Warning

Calling get_user_catalog() without having defined AMDA_Webservice login credentials will result in a UndefinedConfigEntry 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) SpeasyVariable | None[source]

Get user parameter. Raises an exception if user is not authenticated.

Parameters:
parameter_id: str or AMDAParameterIndex

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 a UndefinedConfigEntry 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) 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 a UndefinedConfigEntry exception being raised.

Examples

>>> import speasy as spz
>>> spz.amda.get_user_timetable("tt_0") 
<TimeTable: test_alexis>
has_time_restriction(product_id: str, start_time: str, stop_time: str)[source]

Check if product is restricted for a given time range.

Parameters:
product_id: str or SpeasyIndex

product id

start_time: str or datetime

desired data start time

stop_time: str or datetime

desired data stop time

Returns:
bool

True if product is restricted for the given time range, False otherwise.

static is_server_up(server_url: str = 'https://amda.irap.omp.eu') bool[source]

Check if AMDA Webservice is up by sending a dummy request to the AMDA Webservice URL with a short timeout.

Parameters:
server_url: str

AMDA Webservice URL, default is https://amda.irap.omp.eu

Returns:
bool

True if AMDA Webservice is up, False otherwise.

is_user_catalog(catalog_id: str)[source]
is_user_parameter(parameter_id: str)[source]
is_user_timetable(timetable_id: str)[source]
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 dataset id available in AMDA_Webservice

Returns:
List[AMDADatasetIndex]

list if dataset ids

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 a UndefinedConfigEntry 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 a UndefinedConfigEntry 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 a UndefinedConfigEntry 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 product time range.

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) ProductType[source]

Returns product type for any known ADMA product from its index or ID.

Parameters:
product_id: str or AMDAIndex

product id

Returns:
ProductType

Type of product IE ProductType.DATASET, ProductType.TIMETABLE, …

Examples

>>> import speasy as spz
>>> spz.amda.product_type("imf")
<ProductType.PARAMETER: 2>
>>> spz.amda.product_type("ace-imf-all")
<ProductType.DATASET: 1>
product_version(parameter_id: str)[source]

Get date of last modification of dataset or parameter.

Parameters:
parameter_id: str or AMDAParameterIndex

parameter id

Returns:
str

product version

class speasy.webservices.amda.ws.ProductType(value)[source]

Bases: Enum

Enumeration of the type of products available in AMDA_Webservice.

CATALOG = 5
COMPONENT = 3
DATASET = 1
PARAMETER = 2
TIMETABLE = 4
UNKNOWN = 0