Custom Behavior (rc file)

Some classes have attributes that customize how specific files, datasets and grids behave. These attributes can be set globally, or on a per-instance basis. An instance picks up the value from the class when it’s created, so changing things globally is recommended before any files are loaded. These attributes can also be set from ~/.viscidrc.

Note

By default, Viscid tries to parse the rc file with PyYaml. If PyYaml is not installed, it parses using a modified JSON format. Unlike standard JSON, you can include comments using ‘#’ or ‘//’ as well as trailing commas.

Here is an example rc file,

# ~/.viscidrc

{
  ### For Everything
  ## use shell copies so we don't have to call unload()
  "grid.Grid.longterm_field_caches": false,

  ### for OpenGGCM
  ## try to get extra run information
  "readers.openggcm.GGCMFile.read_log_file": true,
  ## everyone likes GSE coords :)
  "readers.openggcm.GGCMGrid.mhd_to_gse_on_read": "auto",

  ### For Athena
  ## this doesn't work for some reason
  # "readers.athena_bin.AthenaBinFileWrapper.var_type": "prim",

  # evaluator control for security
  "calculator.evaluator.enabled": true,

  # matplotlib (>= 1.5.0) styling
  "mpl_style.use_styles": ["seaborn-talk", "seaborn-white", "viscid-default",
                           "viscid-colorblind"],
  # rc params can also be overridden individually
  # "plot.mpl_style.rc_params": {"image.cmap": "inferno"},

  # # For matplotlib < 1.5.0, you can use vseaborn as a shim to seaborn
  # # for nice styles
  # "plot.vseaborn.enabled": true,
  # "plot.vseaborn.context": "poster",
  # "plot.vseaborn.style": "ticks",
}

Common Customizations

viscid.plot.mpl_style

  • use_styles: a list of style sheet names to activate
  • rc_params: dictionary of parameters that get directly injected into matplotlib.rcParams
  • rc: specify rc parameters through matplotlib.rc(…). Keys are groups and the values should be dictionaries that will be unpacked into the rc function call.

viscid.plot.mpl_extra

These are deprecated and should be set using matplotlib rc parametrs with the leading group name viscid, i.e., “viscid.symmetric_cmap”. Note that there is no “viscid.default_cmap” since that is already a matplotlib rc parameter (“image.cmap”)

  • default_cmap: Changes the default color maps for plots made using viscid.plot.vpyplot
  • symmetric_cmap: Changes the default color maps for plots that are symmetric about 0
  • default_cbarfmt: Change the default tick formatter for colbars
  • default_majorfmt: Change the default major tick formatter for axes
  • default_minorfmt: Change the default major tick formatter for axes
  • default_majorloc: Change the default major tick locator for axes
  • default_minorloc: Change the default major tick locator for axes

viscid.grid.Grid

  • force_vecter_layout (field.LAYOUT_*): force all vectors to be of a certain layout when they’re created (Default: LAYOUT_DEFAULT)
  • longterm_field_caches (bool): If True, then when a field is cached, it must be explicitly removed from memory with “unload” or using the ‘with’ statemnt. If False, “shell copies” of fields are made so that memory is freed when the returned instance is garbage collected. (Default: False)

viscid.readers.openggcm.GGCMGrid

  • mhd_to_gse_on_read (bool): flips arrays on load to be in GSE crds (Default: False)
  • copy_on_transform (bool): True means array will be contiguous after transform (if one is done), but makes data load 50%-60% slower (Default: True)

viscid.readers.openggcm.GGCMFile

  • read_log_file (bool): search for a log file to load some of the libmrc runtime parameters. This does not read parameters from all libmrc classes, but can be customized with viscid.readers.ggcm_logfile.GGCMLogFile.watched_classes. (Default: False due to performance)