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. sunpy looks for this configuration file in a platform specific directory, which you can see the path for by running:

>>> import hermes_core
>>> hermes_core.print_config()  

To maintain your own customizations place a copy of the default file into the first path printed above. Do not edit the default file directly as every time you install or update, this file will be overwritten.

See below for the example config file.

Dynamic settings

You can also dynamically change the default settings in a Python script or interactively from the python shell. All of the settings are stored in a Python ConfigParser instance called sunpy.config, which is global to the package. Settings can be modified directly, for example:

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

A sample sunpyrc 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

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

; Location to save download data to. Path should be specified relative to the
; SunPy 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 = hermes.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