mth5.clients.geomag
Created on Mon Nov 14 13:58:44 2022
@author: jpeacock
Classes
Get geomagnetic data from observatories. |
|
Module Contents
- class mth5.clients.geomag.GeomagClient(**kwargs)[source]
Get geomagnetic data from observatories.
key words
observatory: Geogmangetic observatory ID
type: type of data to get ‘adjusted’
start: start date time to request UTC
end: end date time to request UTC
elements: components to get
sampling_period: samples between measurements in seconds
format: JSON or IAGA2002
- get_chunks()[source]
Get the number of chunks of allowable sized to request, includes the elements
So the max length is the maximum time period that can be requested but includes the number of elements in the request. So if the max length is 172800 seconds and the sampling period is 1 second, then the maximum number of elements that can be requested is 172800 / (1 * len(elements)).
- Returns:
DESCRIPTION
- Return type:
TYPE
- get_data(run_id='001')[source]
Get data from geomag client at USGS based on the request. This might have to be done in chunks depending on the request size. The returned output is a json object, which we should turn into a ChannelTS object
For now read into a pandas dataframe and then into a ChannelTS
In the future, if the request is large, think about writing directly to an MTH5 for better efficiency.
- Returns:
DESCRIPTION
- Return type:
TYPE
- class mth5.clients.geomag.USGSGeomag(**kwargs)[source]
-
- validate_request_df(request_df)[source]
Make sure the input request dataframe has the appropriate columns
- Parameters:
request_df (
pandas.DataFrame) – request dataframe- Returns:
valid request dataframe
- Return type:
pandas.DataFrame
- add_run_id(request_df)[source]
Add run id to request df
- Parameters:
request_df (
pandas.DataFrame) – request dataframe- Returns:
add a run number to unique time windows for each observatory at each unique sampling period.
- Return type:
pandas.DataFrame
- make_mth5_from_geomag(request_df)[source]
Download geomagnetic observatory data from USGS webservices into an MTH5 using a request dataframe or csv file.
- Parameters:
request_df (
pandas.DataFrame, str or Path if csv file) –DataFrame with columns
’observatory’ –> Observatory code
’type’ –> data type [ ‘variation’ | ‘adjusted’ | ‘quasi-definitive’ | ‘definitive’ ]
’elements’ –> Elements to get [D, DIST, DST, E, E-E, E-N, F, G, H, SQ, SV, UK1, UK2, UK3, UK4, X, Y, Z]
’sampling_period’ –> sample period [ 1 | 60 | 3600 ]
’start’ –> Start time YYYY-MM-DDThh:mm:ss
’end’ –> End time YYYY-MM-DDThh:mm:ss
- Returns:
if interact is True an MTH5 object is returned otherwise the path to the file is returned
- Return type:
Path or
mth5.mth5.MTH5