Customizing sunpy

The sunpyrc file

Sunpy uses sunpyrc configuration files to customize certain properties. You can control a number of key features of SunPy such as where your data will download to. SunPy looks for sunpyrc in two locations, in the following order:

  1. .sunpy/sunpyrc, for the user’s default customizations.
  2. INSTALL/sunpy/data/sunpyrc, where INSTALL is something like /usr/lib/python2.5/site-packages on Linux, and maybe C:\Python25\Lib\site-packages on Windows. Every time you install SunPy, this file will be overwritten, so if you want your customizations to be saved, please move this file to your .sunpyrc directory.

To display where the currently active sunpyrc file was loaded from, one can do the following:

>>> import sunpy
>>> sunpy.print_config()

The default sunpyrc file lives in sunpy/data/. We recommend that you make a copy of this file and put it where Sunpy will find it. 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 sunpy package. Settings can be modified directly, for example:

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

A sample sunpyrc file

(download)

;
; SunPy Configuration
;
; This is a sample sunpy configuration file - you can find a copy
; of it on your system in site-packages/sunpy/data/sunpyrc.  If you edit it
; there, please note that it will be overridden in your next install.
; If you want to keep a permanent local copy that will not be
; over-written, place it in HOME/.sunpy/sunpyrc (unix/linux
; like systems) and C:\Documents and Settings\yourname\.sunpy
; (win32 systems).
;
; Note that any relative filepaths specified in the SunPy configuration file
; will be relative to SunPy's working directory.
;

;;;;;;;;;;;;;;;;;;;
; General Options ;
;;;;;;;;;;;;;;;;;;;
[general]

; The SunPy working directory is the parent directory where all generated
; and download files will be stored.
; Default Value: <user's home directory>/sunpy
; working_dir = /home/$USER/sunpy

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

; Location to save download data to. Path should be specified relative to the
; SunPy working directory.
; Default value: data/
;download_dir = /tmp
download_dir = data
Read the Docs v: v0.3.2
Versions
stable
latest
v0.3.2
v0.3.1
v0.3.0
0.2.0
v0.1
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.