Customization and Global Configuration

The configrc file

This package uses a configrc configuration file to customize certain properties. You can control a number of key features of such as where your data will download to. SWxSOC packages look for this configuration file in a platform specific directory, which you can see the path for by running:

>>> import swxsoc
>>> swxsoc.print_config()  

Using your own configrc file

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

Warning

Do not edit the configrc 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 configrc file inside your config folder.

If you work in our developer environment you can place your configuration file in this directory:

/home/vscode/.config/swxsoc/

If you do not use our developer environment, you can run the following code to see where to place it on your specific machine as well:

>>> from swxsoc import util
>>> print(util.config._get_user_configdir())
/home/vscode/.config/swxsoc

Note

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

To learn more about how to set-up your development environment see Developer Environment.

See below (A sample configrc file) for an example configuration file.

Dynamic settings

You can also dynamically change most of the default settings. One setting that cannot be changed is the location of the log file which is set on import. All settings are stored in a Python ConfigParser instance called swxsoc.config, which is global to the package. Settings can be modified directly, for example:

import swxsoc
swxsoc.config.set('downloads', 'download_dir', '/home/user/Downloads')

A sample configrc file

(download)

;
; Configuration
;
; This is the default configuration file

;;;;;;;;;;;;;;;;;;;
; General Options ;
;;;;;;;;;;;;;;;;;;;
[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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Mission-Specific Configuration ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[mission]
; This should be overwritten by each SWxSOC affiliated Mission to incliude their
; own mission-specific project name and instrument names

; used for Project Name Global Attribute and data file naming conventions
mission_name = swxsoc

inst_names = ["eea", "nemisis", "merit", "spani"]
inst_shortnames = ["eea", "nms", "mrt", "spn"]
inst_fullnames = [
        "Electron Electrostatic Analyzer",
        "Noise Eliminating Magnetometer Instrument in a Small Integrated System",
        "Miniaturized Electron pRoton Telescope",
        "Solar Probe Analyzer for Ions"
    ]
inst_targetnames = ["EEA", "MAG", "MERIT", "SPANI"]

;;;;;;;;;;;;;
; Downloads ;
;;;;;;;;;;;;;
[downloads]

; Location to save download data to. Path should be specified relative to the
; SWxSOC working directory.
; Default value: data/
download_dir = data

;;;;;;;;;;;;
; Logger   ;
;;;;;;;;;;;;
[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 = INFO

# Whether to use color for the level names
use_color = True

# Whether to log warnings.warn calls
log_warnings = True

# Whether to log exceptions before raising them
log_exceptions = True

# Whether to always log messages to a log file
log_to_file = True

# The file to log messages to
log_file_path = swxsoc.log

# Threshold for logging messages to log_file_path
log_file_level = INFO

# Format for log file entries
log_file_format = %(asctime)s, %(origin)s, %(levelname)s, %(message)s