mobspy.plot_scripts package
Submodules
mobspy.plot_scripts.default_plots module
- mobspy.plot_scripts.default_plots.deterministic_plot(species, data, plot_params)
Design default deterministic plot using MobsPy plotting hierarchy. It them passes the parameters for plotting in the hierarchical plot module
- Parameters:
species – (list of str) list of species names in MobsPy str format (queries are performed
with the query plot data function) :param data: (dict) data in MobsPy format Simulation.results[‘data’] :param plot_params: (dict) dictionary with the plot parameters supplied by the user before the modifications from this function
- mobspy.plot_scripts.default_plots.parametric_plot(species, data, plot_params)
- mobspy.plot_scripts.default_plots.raw_plot(data, parameters_or_file)
Plots data from a json or parameter dictionary configured according to the hierarchical plot structure Does not accept parameters from a Simulation object, it must be given the parameters in it’s entirety
- Parameters:
data – (dict) data in MobsPy format Simulation.results[‘data’]
parameters_or_file – (dict, str) Dictionary originated from a JSON or JSON file name
- mobspy.plot_scripts.default_plots.read_plot_json(plot_json_filename)
This function converts a plot_json file into a dictionary
- Parameters:
plot_json_filename – (str) JSON file name
- Returns:
json_data (dict) converted JSON as dictionary
- mobspy.plot_scripts.default_plots.set_plot_units(new_plot_params)
Sets the plot labels to the unit names by adding to the xlabel and ylabel
- Parameters:
new_plot_params – (dict) plot parameters after some changes
- mobspy.plot_scripts.default_plots.stochastic_plot(species, data, plot_params)
Design default stochastic plot using MobsPy plotting hierarchy. It them passes the parameters for plotting in the hierarchical plot module
- Parameters:
species – (list of str) list of species names in MobsPy str format (queries are performed with the
query plot data function) :param data: (dict) data in MobsPy format Simulation.results[‘data’] :param plot_params: (dict) dictionary with the plot parameters supplied by the user before the modifications from this function
mobspy.plot_scripts.hierarchical_plot module
- class mobspy.plot_scripts.hierarchical_plot.Color_cycle
Bases:
object
This class is responsible for cycling through the different colors for different curves
- Parameters:
index – (int) Current position in the color cycle
color_list – (list) = list of available colors
- mobspy.plot_scripts.hierarchical_plot.figure_hash(current_figure, axis_matrix)
This function allows one to acess the figure grid with a linear input For instance one can access a 2x2 grid using 0, 1, 2, 3 0 becomes 0,0 1 becomes 1,0 2 becomes 0,1 3 becomes 1,1
- Parameters:
current_figure – (int) linear number of the figure
axis_matrix – (1D or 2D numpy array) a list with all the created axis on the multiple figure subplot
- Returns:
the correct axis based on the number provided
- mobspy.plot_scripts.hierarchical_plot.figure_hash_creation(total_figure_number, max_lines=None)
This is hash used to create the figure grid automatically according to the number of figures desired by the user and the maximum number of lines
For instance 4 figures with 2 as max_lines creates a 2x2 figure grid automatically
- Parameters:
total_figure_number – (int) Number of total figures to create
max_lines – (int) Maximum number of lines in the grid
- Returns:
fig and axs = Figures grid will all the respective axis
- mobspy.plot_scripts.hierarchical_plot.find_parameter(params, key, index=None)
This is the hearth of the plotting structure, this functions allows one to simply set multiple characteristics for only one figure
The priority for parameter search is plots => figures => global, with plot overriding others and so on
If a parameter is defined globally it will be applied to all figures, if it defined inside a figure element it will only apply to that figure, if it is defined in a plot element it will only apply to that curve
Check the readme or the tutorials for more details on the plotting structure. It is simple and versatile
- Parameters:
params – (dict) Plot parameters from python dictionary (after json conversion)
key – (str) Key necessary to access the parameters
index – (int) None for global search, one index for figure search, and two for figure curve search
- Returns:
The parameter if found, and None if nothing is found
- mobspy.plot_scripts.hierarchical_plot.find_species_time_series(spe, data)
There can be different time-series in MobsPy data (even experimental data, as long as it is in MobPy format) This function finds all the time-series the species is present in and returns it for looping thorugh all of them This function is implemented to allow for the comparison of models with experimental data or other models
- Parameters:
spe – (str) Species name
- Pram data:
(dict) Data in MobsPy format
- mobspy.plot_scripts.hierarchical_plot.get_total_figure_number(axis_matrix)
Gets the number of figures from an axis_matrix generated by pyplot. Used by the hash to place configs in the correct part of the axis_matrix
- Parameters:
axis_matrix – (1D or 2D numpy array) Array returned by pyplot once multiple figures are introduced into
a single plot
- Returns:
total_figure_number (int) Total number of figures
- mobspy.plot_scripts.hierarchical_plot.plot_curves(data, axs, figure_index, plot_params)
This function plots the programmed curves in the assigned figure
- Parameters:
axs – (pyplot axe) axs to plot the data in
data – (dict) data given in MobsPy format results[‘data’]
figure_index – (int) index of the current figure to plot curves in
plot_params – parameters for plotting
- mobspy.plot_scripts.hierarchical_plot.plot_data(data, plot_params)
This function plots the simulation results according to the specifications
- Parameters:
data – (dict) Data in MobsPy format
plot_params – (dict) Plot parameters received
- mobspy.plot_scripts.hierarchical_plot.set_figure_characteristics(axis_matrix, plot_params)
Sets the characteristics for each figure
- Parameters:
axis_matrix – (axis from pyplot subplot) Array of all axis in the grid
plot_params – (dict) Plot parameters received
- mobspy.plot_scripts.hierarchical_plot.set_global_parameters(fig, plot_params)
Sets the characteristics the plot window
- Parameters:
fig – (fig from pyplot subplot) Array of all axis in the grid
plot_params – (dict) Plot parameters received
mobspy.plot_scripts.process_plot_data module
- mobspy.plot_scripts.process_plot_data.check_plot_parameters(species, plot_params)
Performs a check of the plot_parameters given. To see if the parameters are correctly named
- Parameters:
species – (str) Species in str format
plot_params – (dict) Plot parameter dictionary
- mobspy.plot_scripts.process_plot_data.query_plot_data(species, data)
Performs a query of the plot data, when one wishes to plot species with characteristics It creates a new data structure with the results from the query added to it for the plotting structure
- Parameters:
species – (str) Species name in string format
data – (dict) Data in MobsPy dictionary format
- mobspy.plot_scripts.process_plot_data.time_filter_operation(low, high, time_data, data)
mobspy.plot_scripts.statistics_calculations module
- mobspy.plot_scripts.statistics_calculations.average_plus_standard_deviation(species_string, mobspy_ts, average_series=None, deviation_series=None)
Standard deviation between all RUNS inside a single time-series
- Parameters:
species_string – (str) Species string
mobspy_ts – (MobsPy TimeSeries) MobsPy time series object
average_series – (list) if the average series is given it is not recalculated
deviation_series – (list) if the deviation is given it is not recalculated
- Returns:
series_average (list) = average value of the run, plus (list) = average + deviation,
minus (list) = average - deviation,
- mobspy.plot_scripts.statistics_calculations.standard_deviation(species_string, mobspy_ts, average_series=None)
Standard deviation between all RUNS inside a single time-series
- Parameters:
species_string – (str) Species string
mobspy_ts – (MobsPy TimeSeries) MobsPy time series object
average_series – (list) if the average series is given it is not recalculated
- Returns:
deviation_series (list) a list with the standard deviation values from all runs
- mobspy.plot_scripts.statistics_calculations.time_series_average(species_string, mobspy_ts)
Badly named function - Average between all RUNS inside a single time-series
- Parameters:
species_string – (str) species string to perform the average upon
mobspy_ts – (MobsPy TimeSeries) MobsPy time series object
- Returns:
average_series (list) a list with the average values from all runs