Customization and Global Configuration

The config.yml file

This package uses a config.yml configuration file to customize certain properties. ccsdspy packages look for this configuration file in a platform-specific directory, which you can see the path for by running:

>>> import ccsdspy
>>> ccsdspy.print_config()

Using your own config.yml file

To maintain your own customizations, you must place your customized config.yml inside the appropriate configuration folder (which is based on the operating system you are working on). The AppDirs module provided by the sunpy package is used to determine where to look for your configuration file.

Warning

Do not edit the config.yml file directly in the Python package as it will get overwritten every time you re-install or update the package.

You can copy the file below, customize it, and then place your customized config.yml file inside your config folder. You can run the following code to see where to place it on your specific machine as well:

>>> ffrom ccsdspy.config import _get_user_configdir
>>> print(_get_user_configdir())

Note

For more information on where to place your configuration file depending on your operating system, you can refer to the AppDirs Python package.

A sample config.yml file

# Configuration
# This is the default configuration file

general:
  # Time Format to be used for displaying time in output (e.g. graphs)
  # The default time format is based on ISO8601 (replacing the T with space)
  # note that the extra '%'s are escape characters
  time_format: "%Y-%m-%d %H:%M:%S"

logger:
  # Threshold for the logging messages. Logging messages that are less severe
  # than this level will be ignored. The levels are 'DEBUG', 'INFO', 'WARNING', 'ERROR'
  log_level: DEBUG

  log_format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"

  # Whether to always log messages to a log file
  log_to_file: true

  # Whether the log file should be in JSON format
  log_file_json: false

  # The file to log messages to
  log_file_path: ccsdspy.log

  # Threshold for logging messages to log_file_path
  log_file_level: INFO

  # Format for log file entries
  log_file_format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"