swarmpal.io._datafetchers
=========================

.. py:module:: swarmpal.io._datafetchers

.. autoapi-nested-parse::

   Tools to connect to the outside world and get/create xarray Datasets



Classes
-------

.. autoapisummary::

   swarmpal.io._datafetchers.Parameters
   swarmpal.io._datafetchers.ViresParameters
   swarmpal.io._datafetchers.HapiParameters
   swarmpal.io._datafetchers.FileParameters
   swarmpal.io._datafetchers.CDFFileParameters
   swarmpal.io._datafetchers.NetCDFFileParameters
   swarmpal.io._datafetchers.ManualParameters
   swarmpal.io._datafetchers.DataFetcherBase
   swarmpal.io._datafetchers.ViresDataFetcher
   swarmpal.io._datafetchers.HapiDataFetcher
   swarmpal.io._datafetchers.NetCDFfileDataFetcher
   swarmpal.io._datafetchers.CDFfileDataFetcher
   swarmpal.io._datafetchers.ManualDataFetcher


Functions
---------

.. autoapisummary::

   swarmpal.io._datafetchers.get_fetcher


Module Contents
---------------

.. py:class:: Parameters

   Control which dataset is accessed, and how the fetcher behaves


   .. py:attribute:: pad_times
      :type:  tuple[datetime.timedelta]
      :value: ()



.. py:class:: ViresParameters

   Bases: :py:obj:`Parameters`


   Control which dataset is accessed, and how the fetcher behaves


   .. py:attribute:: collection
      :type:  str
      :value: ''



   .. py:attribute:: measurements
      :type:  list[str]
      :value: []



   .. py:attribute:: start_time
      :type:  str | datetime.datetime
      :value: ''



   .. py:attribute:: end_time
      :type:  str | datetime.datetime
      :value: ''



   .. py:attribute:: server_url
      :type:  str
      :value: 'https://vires.services/ows'



   .. py:attribute:: models
      :type:  list[str]
      :value: []



   .. py:attribute:: auxiliaries
      :type:  list[str]
      :value: []



   .. py:attribute:: sampling_step
      :type:  str | None
      :value: None



   .. py:attribute:: filters
      :type:  list[str]
      :value: []



   .. py:attribute:: options
      :type:  dict


.. py:class:: HapiParameters

   Bases: :py:obj:`Parameters`


   Control which dataset is accessed, and how the fetcher behaves


   .. py:attribute:: server
      :type:  str
      :value: ''



   .. py:attribute:: dataset
      :type:  str
      :value: ''



   .. py:attribute:: parameters
      :type:  str
      :value: ''



   .. py:attribute:: start
      :type:  str
      :value: ''



   .. py:attribute:: stop
      :type:  str
      :value: ''



   .. py:attribute:: options
      :type:  dict


.. py:class:: FileParameters

   Bases: :py:obj:`Parameters`


   Control which dataset is accessed, and how the fetcher behaves


   .. py:attribute:: filename
      :type:  os.PathLike | None
      :value: None



.. py:class:: CDFFileParameters

   Bases: :py:obj:`FileParameters`


   Control which dataset is accessed, and how the fetcher behaves


.. py:class:: NetCDFFileParameters

   Bases: :py:obj:`FileParameters`


   Control which dataset is accessed, and how the fetcher behaves


   .. py:attribute:: group
      :type:  str | None
      :value: None



.. py:class:: ManualParameters

   Bases: :py:obj:`Parameters`


   Control which dataset is accessed, and how the fetcher behaves


.. py:class:: DataFetcherBase

   Bases: :py:obj:`abc.ABC`


   Interface with an external data source


   .. py:property:: source
      :type: str

      :abstractmethod:


      String to identify the data source type (e.g. 'vires', 'hapi')


   .. py:property:: parameters
      :type: Parameters

      :abstractmethod:


      Set of parameters to control how/what data is accessed


   .. py:method:: fetch_data() -> xarray.Dataset
      :abstractmethod:


      Command to get data as an xarray Dataset



   .. py:method:: config() -> dict


.. py:class:: ViresDataFetcher(**parameters)

   Bases: :py:obj:`DataFetcherBase`


   Connects to and retrieves data from VirES through viresclient


   .. py:property:: source
      :type: str


      String to identify the data source type (e.g. 'vires', 'hapi')


   .. py:property:: parameters
      :type: ViresParameters


      Set of parameters to control how/what data is accessed


   .. py:attribute:: vires_request


   .. py:method:: _initialise_request() -> viresclient.SwarmRequest

      Use the set parameters to initialise the request



   .. py:method:: fetch_data() -> xarray.Dataset

      Process the request on VirES and load an xarray Dataset



.. py:class:: HapiDataFetcher(**parameters)

   Bases: :py:obj:`DataFetcherBase`


   Connects to and retrieves data from a HAPI server through hapiclient


   .. py:property:: source
      :type: str


      String to identify the data source type (e.g. 'vires', 'hapi')


   .. py:property:: parameters
      :type: HapiParameters


      Set of parameters to control how/what data is accessed


   .. py:method:: _hapi_to_xarray(data: numpy.typing.ArrayLike, meta: dict) -> xarray.Dataset
      :staticmethod:



   .. py:method:: _get_hapi_info() -> dict


   .. py:method:: fetch_data() -> xarray.Dataset

      Make a HAPI query and load an xarray Dataset



.. py:class:: NetCDFfileDataFetcher(filename: os.PathLike, group: str | None = None)

   Bases: :py:obj:`DataFetcherBase`


   Interface with an external data source


   .. py:property:: source
      :type: str


      String to identify the data source type (e.g. 'vires', 'hapi')


   .. py:property:: parameters
      :type: NetCDFFileParameters


      Set of parameters to control how/what data is accessed


   .. py:method:: fetch_data() -> xarray.Dataset

      Command to get data as an xarray Dataset



.. py:class:: CDFfileDataFetcher(**parameters)

   Bases: :py:obj:`DataFetcherBase`


   Interface with an external data source


   .. py:property:: source
      :type: str


      String to identify the data source type (e.g. 'vires', 'hapi')


   .. py:property:: parameters
      :type: CDFFileParameters


      Set of parameters to control how/what data is accessed


   .. py:method:: fetch_data() -> xarray.Dataset

      Command to get data as an xarray Dataset



.. py:class:: ManualDataFetcher(xarray_dataset: xarray.Dataset)

   Bases: :py:obj:`DataFetcherBase`


   Interface with an external data source


   .. py:property:: source
      :type: str


      String to identify the data source type (e.g. 'vires', 'hapi')


   .. py:property:: parameters
      :type: FileParameters


      Set of parameters to control how/what data is accessed


   .. py:attribute:: _xarray


   .. py:method:: fetch_data() -> xarray.Dataset

      Command to get data as an xarray Dataset



.. py:function:: get_fetcher(source) -> DataFetcherBase

