phase_new module

Phase history container. When you think of a phase value, think of that value at a specific point in time. This container holds the historic data of a phase; its species and quantities. This implementation treats access of time stamps within a tolerance. All searches for time stamped values are subjected to an approximation of the time stamp to avoid storing values too close to each other in time, and/or to return the closest value in time searched or no value if none can be found according to the tolerance.


TODO: ATTENTION: The species (list of Species) AND quantities (list of Quantity) data members have ARBITRARY density values either at an arbitrary point in the history or at no point in the history. This needs to be removed in the future to avoid confusion.

To obtain history values, associated to the phase, at a particular point in time, use the GetValue() method to access the history data frame (pandas) via columns and rows. ALERT: The corresponding values in species and quantities are OVERRIDEN and NOT to be used through the phase interface.

Author: Valmor F. de Almeida; vfda Sat Sep 5 01:26:53 EDT 2015

Cortix: a program for system-level modules coupling, execution, and analysis.

class phase_new.PhaseNew(name=None, time_stamp=None, time_unit=None, species=None, quantities=None)[source]

Bases: object

Phase history container. A Phase consists of Species and Quantities varying with time. This container is meant to reproduce the basic idea of a material phase.


Set species and quantities of history to a given value (default to zero value), all time stamps are preserved.

Parameters:value (float) –

Returns the list of Quantities. The values in each Quantity are synchronized with the Phase data frame.

Return type:list
ResetHistory(try_time_stamp=None, value=None)[source]

Set species and quantities of history to a given value (default to zero value) only one time stamp is preserved (default to last time stamp).

__init__(name=None, time_stamp=None, time_unit=None, species=None, quantities=None)[source]

Sometimes an empty Phase object is created by user code. This case needs adequate logic for None types. Note on usage: when passing quantities, do set the value argument explicitly to help define the type and avoid set_value() errors with Pandas. This is to be investigated later. Also, the usage of a DataFrame needs to be re-evaluated. Maybe better to use a Quantity object and a Species object with a Pandas Series history as a value to avoid the existance of a value in Quantity and a value in Phase that are not in sync.


Returns a list of names of all the actors in the phase history.

Return type:list

Adds a new quantity object to the dataframe. See for more details on the quantity class.

Parameters:new_quant (object) –
add_row(try_time_stamp, row_values)[source]

Adds a row to the DataFrame, with a timestamp equal to try_time_stamp and row values equal to row_values. The length of row_values must match the number of columns in the data frame.

  • try_time_stamp (float) –
  • row_values (list) –

Adds a new specie object to the phase history. See for more details on the Species class.

Parameters:new_species (obj) –

Die hard access.


Returns an entire column of data. A column is the entire history of data associated with a specific actor.

Parameters:actor (str) –
Return type:, actor]): list
get_quantity(name, try_time_stamp=None)[source]

Get the quantity name at a point in time closest to try_time_stamp up to a tolerance. If no time stamp is passed, the value at the last time stamp is returned.

  • name (str) –
  • try_time_stamp (float, int or None) – Time stamp of desired quantity value. Default: None, returns the value at the last time stamp.


Return type:

float or int or other


Create a Quantity name history. This will create a fully qualified Quantity object and return to the caller. The function is typically needed for data output to a file through pickle. Since the value attribute of a quantity can be any data structure, a time-series is built on the fly and stored in the value attribute. In addition the time unit is added to the final return value as a tuple.

Parameters:name (str) –
Return type:tuple(Quantity,str)

Returns an entire row of the phase dataframe. A row is a series of values that are all at the same time stamp.

Parameters:try_time_stamp (float) –
Return type:]): list

Returns the species specified by name if it exists, or None if it doesn’t.

Parameters:name (str) –
Return type:str
get_species_concentration(name, try_time_stamp=None)[source]

Returns the species concentration at try_time_stamp.

  • name (str) –
  • try_time_time_stamp (float) –


Return type:


get_value(actor, try_time_stamp=None)[source]

Returns the value associated with a specified actor at a specified time stamp.

  • actor (str) –
  • try_time_stamp (float) – Default is None which returns the last time stamp.

self.__df.loc[time_stamp, actor]

Return type:



Checks to see if try_time_stamp exists in the phase history.

plot(name='phase-plot-name', time_unit='s', legend=None, nrows=2, ncols=2, dpi=200)[source]
plot_species(name, scaling=[1.0, 1.0], title=None, xlabel='Time [s]', ylabel='y', legend='no-legend', filename_tag=None, figsize=[6, 5], dpi=100)[source]

Returns the list of Quantities. The values in each Quantity are synchronized with the Phase data frame.

Return type:list
scale_row(try_time_stamp, value)[source]

Multiplies all of the data in a row (except time stamp) by a scalar value.

set_species_id(name, val)[source]

Sets the flag of a species “name” equal to val.

  • name (str) –
  • val (int) –
set_value(actor, value, try_time_stamp=None)[source]

Returns every single species in the phase history.

Return type:list

Get all time stamps in the index of the data frame.

Return type:list

Returns the time unit of the Phase.

Return type:str

Convert the Phase container into an HTML file.

Parameters:fileName (str) –