Home | Trees | Indices | Help |
|
---|
|
Functions to plot fields from Qtcm model objects and run.
Module Function: * nice_levels: Compute a vector of "levels" at "nice" increments.
* plot_ncdf_output: Plot data from QTCM1 netCDF output files.
Version: 0.1.2
Date: September 12, 2008
Author: Johnny Lin
|
|||
|
|||
|
|||
|
|
|||
__credits__ =
|
|||
__test__ =
|
|
Compute a vector of "levels" at "nice" increments. Returns a 1-D array of "levels" (e.g., contour levels) calculated to give an aesthetically pleasing and human-readable interval, if possible. If not, returns levels for approx_nlev levels between the maximum and minimum of data. In any event, the function will return no more than max_nlev levels. Keyword Input Parameter: * data: Array of values to calculate levels for. Can be of any size and shape. Keyword Input Parameter: * approx_nlev: Integer referring to approximately how many levels to return. This is the way of adjusting how "coarse" or "fine" to make the vector of levels. * max_nlev: The maximum number of levels the function will permit to be returned. The interval of levels will be adjusted to keep the number of levels returned under this value. If approx_nlev is chosen to be greater than or equal to max_nlev, an exception is raised. Output: * This function returns a 1-D array of contour levels. Function is adaptation of parts of IDL routine contour_plot.pro by Johnny Lin. This is why the capitalization conventions of Python are not strictly followed in this function. Examples: >>> z = N.array([-24.5, 50.3, 183.1, 20.]) >>> out = nice_levels(z) >>> ['%g' % out[i] for i in range(len(out))] ['-30', '0', '30', '60', '90', '120', '150', '180', '210'] >>> z = N.array([-24.5, 50.3, 183.1, 20.]) >>> out = nice_levels(z, approx_nlev=5) >>> ['%g' % out[i] for i in range(len(out))] ['-50', '0', '50', '100', '150', '200'] >>> z = N.array([-24.5, 50.3, 183.1, 20.]) >>> out = nice_levels(z, approx_nlev=10) >>> ['%g' % out[i] for i in range(len(out))] ['-30', '0', '30', '60', '90', '120', '150', '180', '210'] |
Return instring to handle super/subscripts of one character. The string returned expresses instring so that an exponent or subscript with a single character after it (e.g., ^2, _s) can be processed as a LaTeX exponent or superscript in Matplotlib. Any number of these super/subscripts can be present in instring. See http://www.scipy.org/Cookbook/Matplotlib/UsingTex by Darrin Dale for some code snippets incorporated in this function. Positional Input Parameter: * instring: String to be formatted. Output: * A string, processable by Matplotlib's LaTeX emulation module. Examples: >>> mpl_latex_script1('Precipitation [W/m^2]') 'Precipitation [W/m$^2$]' >>> mpl_latex_script1('u_0^2 and u_1^2 [m^2/s^2]') 'u$_0$$^2$ and u$_1$$^2$ [m$^2$/s$^2$]' |
Plot model field id from the data in netCDF file datafn. Positional Input Parameter: * id: Name of the id of the field to plot. String. * datafn: Filename containing the output data to plot. String. Input keyword parameter descriptions are found in the docstring for Qtcm methods ploti, plotm, and other methods that call this private method. In general, those methods take the keyword parameters they receive and pass it along unchanged as keyword parameters to this function. In that sense, this function is seldom used as a stand-alone function, but rather is usually used coupled with a Qtcm instance. The data fields read in from the netCDF output file are dimensioned (time, lat, lon). This is different than how the data is stored in the compiled QTCM model fields (lon, lat, time), and at the Python level (lon, lat). The reason this is the case is that f2py automatically makes the arrays passed between the Python and Fortran levels match. For a lat vs. lon plot, the contour plot is superimposed onto a cylindrical projection map of the Earth with continents drawn and labeled meridians and parallels. The title also includes the model time, and x- and y-axis labels are not drawn. All numerical data used for plotting come from the netCDF output file for consistency (e.g., the dimensions of u1). Currently this method only works for 3-D data arrays (two in space, one in time). |
|
__test__
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Sep 12 14:24:49 2008 | http://epydoc.sourceforge.net |