Recent Changes - Search:

Project Status

Project Documents

Discussion

Bug Tracking

edit SideBar

PhotizoGraph

Photizo Graph

Imported python modules:

+ the string module: imports the Template class from the string module. The Template class is used for variable substitution in the graph titles.

+ the optparse module: parses command-line options

+ os.path: to dynamically create paths for the graph files

+ sys: used for command-line arguments

+ time: to parse the timestamps

+ matplotlib: a plotting library which produces graphing figures in a variety of formats

+ Agg: a backend used by matplotlib to support running scripts in batch or interactively

+ date2num: used to convert dates into the format matplotlib uses to do date axes

+ photizo common config: reads the ini file

+ photizo DSI: backend agnostic interface to photizo data storage

+ photizo legacy:

BaseGraph: module containing a class to format graphs, filter data based on the data type (temperature, water level, precipitation etc) and creates proper axes based on data type and timeframe (one week, two weeks, six months etc)
GWSFigures: module containing the class to create the figure that will be drawn by matplotlib based on the number of graphs (one to three). Size is normally standard but may be affected by the number of sensor outputs plotted in a single graph. Different classes exist but unless specified the default is applied. Generally, one class per network (cchrc, nslakes etc) is used.
graph_lib: functions that read in data for data plots and calculating start/end dates based on a given date and time period
windplot: function to plot wind direction on a circular graph, defining a colormap, legend size and the size of the bars and sectors, among other parameters

+ photizo common util: defines functions for handling floats not in python 2.4, defines the 'all' function not in python 2.4, formats floats based on number of digits specified after the decimal point. Joins pathname components to build the urls.

listify: If a value is a string, returns a list with a single element. This prevents data-type run-time errors when reading in config/ini file values.
AttrDict: Allows dictionaries to be accessed via dot notation as well as subscripts ([]), the default.

Instantiate dictionaries for the time increment plotted (day, month, year) and to cache DSI objects by station and table

def get_opts():

Parse options such as the time period, the width and height of the graphs and the station name. Some of these options must be provided (time increment, path to the config file) while others are optional arguments (station name, figure type).

def do_figure():

Create the figure using the attributes in the dict 'fi'. These attributes include X and Y coordinates, a data list and a legend list with station, table and sensor data read in from the photizo DSI module. The date range is read in from graph_lib (see above). This function supports creating standard and windrose figures as a subclass of BaseFigure, a legacy module that creates the image, sets the figure size and adds graphs to the figure.

def_main():

Read in the config file and the options (network, station name, period length), the figure to be used (default = GWSFigures) and specify command-line output. Reads in data from the current conditions tables for plotting as specified in the config file. Organizes graphs by station into a dictionary.
Create an attribute dictionary for the figure with the following data: period length, period type, start date, end date, figure class, X and Y coordinates, path to the database and network name. This is used for the figure definition, a dictionary that associates the stations with the graphs and the names of the figures that contain them. If this fails, issue an error message to stdout.
Read the path to output the graph from the config file and if the path does not exist, print an error message. Assigns a file name to the graph that includes the name specified in the config file for the graph type + time period + the png extension. Use the template module to dynamically assign a title to the graph based on the station name, description and ID. If a caption is defined in the config file for the graph type (temperature, snow depth, diagnostics etc), use it.
Read in the values from attribute dictionary for the figures and applies them to the graphs, adding graph type, legend names, line colors, and units. (The legend names are read in from the data store and the graph types and line colors are likewise found in the config file.) Call the do_figure() function.
Repeat the process for multistation graphs.
Call do_figure() with an argument to determine if you want the station name in the legend (only necessary for multiStation graphs - the graph definition in the ini file should specify this requirement)

(:notoc:)

Edit - History - Print - Recent Changes - Search
Page last modified on April 01, 2010, at 12:22 AM