pyrfu.mms.db_init#

pyrfu.mms.db_init(default: Literal['local', 'sdc', 'aws'] | None = None, local: str | None = None, sdc: Literal['public', 'sitl'] | None = None, sdc_username: str | None = None, sdc_password: str | None = None, aws: str | None = None, reset: bool = False) → None[source]#

Manage the MMS data access configuration.

The default resource to access MMS data, the local path to use, the MMS SDC rights and username, and the Amazon Web Services (AWS) bucket name are saved in the MMS configuration file of the user configuration directory (pyrfu.mms.MMS_CFG_PATH). The MMS SDC password is saved in the system keyring (macOS Keychain, Windows Credential Locker, Secret Service on Linux) or, if there is none, in plain text in the keyring file in your home directory. It is never written in the configuration file.

Only the settings that are given are changed; the others keep their current value (or the default one if there is no configuration yet, or with reset=True).

Parameters:
  • default ({"local", "sdc", "aws"}, Optional) – Name of the default resource to access the MMS data. Default is local.

  • local (str, Optional) – Local path to MMS data. Default is the current directory.

  • sdc ({"public", "sitl"}, Optional) – Rights to access MMS data from SDC. Default is public. “sitl” needs the credentials of sdc_username in the keyring.

  • sdc_username (str, Optional) – MMS SDC username. Given alone, the configuration uses this user, whose password must already be in the keyring.

  • sdc_password (str, Optional) – MMS SDC password of sdc_username, saved in the keyring. It needs sdc_username.

  • aws (str, Optional) – Bucket name and prefix to MMS data in AWS S3, as “bucket/prefix”. Empty (the default) uses the public MMS archive on NASA HelioCloud (“gov-nasa-hdrl-data1/spdf/cdaweb/data/mms”, no AWS credentials needed).

  • reset (bool, Optional) – Start from the default settings instead of the current ones. The keyring is not changed. Default is False.

Raises:
  • NotImplementedError – If the default resource is not implemented.

  • FileNotFoundError – If the local path doesn’t exist.

  • ValueError – If the SDC rights are not “public” or “sitl”, or if sdc_password is given without sdc_username.

Examples

>>> from pyrfu import mms

Use the local data in /data/mms by default (the other settings are kept)

>>> mms.db_init(default="local", local="/data/mms")

Save the MMS SDC team credentials and use them

>>> mms.db_init(sdc="sitl", sdc_username="user", sdc_password="password")