scitools.basics

Import modules and definitions for the scitools library.

Import of Numerical Python

  • If scipy is installed, a from scipy import * is executed. scipy requires numpy as basic array library, and scipy replaces numpy functionality (at some cost of speed since scipy functions are more general).

    The user can turn off import of scipy in the configuration file (see below).

  • If scipy is not available or not wanted, two options are possible, depending on what is set in the “numpy” section of the configuration file:

    1. from numpy import * (configuration file: numpytools = no)
    2. from numpytools import * which allows the user to transparently use Numeric, numarray, and numpy (configuration file: numpytools = yes)

To make numpy/scipy and math more similar (and thereby ease vectorization of user-defined functions), we introduce the math function names asin, acos, and atan for numpy/scipy’s arcsin, arccos, and arctan.

Other modules

The from scitools.basics import * statement performs a from numpy (or scipy) import * as explained above, plus an import of the modules os, sys, operator, and math. The modules StringFunction and glob are also imported.

Definition of variables

  • SciTools defines a series of variables to monitor execution of programs: SAFECODE, OPTIMIZATION, backend (for Easyviz), VERBOSE, DEBUG, has_scipy. Many of these are set in a configuration file (see below) or in environment variables (SCITOOLS_SAFECODE, SCITOOLS_VERBOSE, SCITOOLS, SCITOOLS_DEBUG, SCITOOLS_easyviz_backend).

All these variables are contained in basics.py.

Debug functions

The following functions are imported from the debug module:

  • watch(var): print out the name, type, and value of a variable and where in a program this output was requested (used to monitor variables).
  • trace(message): print a message and where in the program this message was requested (used to trace the execution).

These debug functions require the DEBUG variable to be different from 0.

Default configuration file

; Default configuration file scitools.cfg ; ; Items in this default file can be overridden by ; .scitools.cfg in the directory where the Python program is started ; .scitools.cfg in the user’s home directory

; Some variables in this file can also be overridden by environment ; variables. The name of the environment variable is ; prefix_section_option, where section and option are the section and ; option names as given below and prefix is set below. ; Examples: SCITOOLS_globals_VERBOSE, SCITOOLS_easyviz_backend

[modes] ; Enable setting variables by environment variables with ; prefix_variablename, e.g., SCITOOLS_globals_DEBUG envir prefix = SCITOOLS

; Enable reading from command line through –variablename option, ; e.g., –SCITOOLS_globals_DEBUG ; (such command-line options and values are removed from sys.argv ; after being read such that the rest of the code is not affected) command line arguments = on

[globals] SAFECODE = <bool> on ; boolean: safety checks or not OPTIMIZATION = <str> off ; ‘F77’, ‘C’, ‘vectorization’, ‘on’, etc. VERBOSE = <int> 0 ; an int for the level of verbosity in output DEBUG = <int> 0 ; debug level (0=off) ; python -O implies that DEBUG is set to 0

[scipy] ;load = <bool> yes ; yes: from scipy import * (may have side effects) load = <bool> no ; yes: from scipy import * (may have side effects)

[numpy] numpytools = <bool> no ; no: load numpy and numpyutils, yes: load numpytools

; Configuration of SciPy/NumPy: see documentation of scitools.basics

[easyviz] backend = matplotlib ; default backend ; backends are gnuplot, matplotlib, matlab, veusz, grace, dx, pyx, vtk show = <bool> yes ; screenplot after each plot command interactive = <bool> yes ; update backend after each change color = <bool> no ; hardcopy with color? linestyleorder = <eval> [‘-‘] ; line styles for plots with multiple lines colororder = <eval> [‘b’,’g’,’r’,’c’,’m’,’y’,’k’] ; same for colors clevels = <int> 8 ; default number of contour levels in a contour plot hold = <bool> off ; hold or clear plot between plotting commands grid = <bool> off ; turn grid on or off by default box = <bool> off ; box around boundaries of the axes hidden = <bool> on ; use hidden line removal on meshes colormap = <eval> None ; default colormap fontsize = <int> 12 ; font size used in titles, labels, ... fontname = <str> Helvetica ; font used for titles, labels, ... fgcolor = <eval> (0,0,0) ; foreground color (titles, labels, axes, ...) bgcolor = <eval> (1,1,1) ; axis background color cblocation = <str> EastOutside ; default location for a color bar size = <eval> [None,None] ; default figure size

[gnuplot] ; See gp_unix.py in the Gnuplot.py source for details about the meaning ; of these options. ;gnuplot_command = <str> gnuplot ;recognizes_persist = <eval> None prefer_persist = <int> 1 ;recognizes_binary_splot = <int> 1 ;prefer_inline_data = <int> 0 ;support_fifo = <int> 1 ;prefer_fifo_data = <int> 1 ;default_term = <str> x11 ;default_term = <str> wxt ; wxWidgets ;default_lpr = <str> | lpr ;prefer_enhanced_postscript = <int> 1

[matplotlib] ; Override values from the matplotlib configuration file backend = TkAgg ; default backend ; other backends are ps, Qt4Agg, GTK, GTKAgg, svg, agg, cairo, MacOSX, GTKCairo, WXAgg, TkAgg, QtAgg, FltkAgg, pdf, CocoaAgg, emf, gdk, template, WX ;font.size = <int> 10 ;axes.labelsize = <int> 10 ;text.fontsize = <int> 10 ;xtick.labelsize = <int> 8 ;ytick.labelsize = <int> 8 text.usetex = <bool> false ; use LaTeX or not

Import statements in this module: from globaldata import * from numpy import * from numpyutils import * import sys, operator, math from StringFunction import StringFunction from glob import glob from debug import watch, trace

Table Of Contents

Next topic

scitools.configdata

This Page