atomica.excel.TimeDependentConnections

class atomica.excel.TimeDependentConnections(code_name, full_name, tvec, from_pops, to_pops, interpop_type, ts=None, from_pop_type=None, to_pop_type=None)[source]

Bases: object

Structure for reading/writing interactions

A TimeDependentConnections object is suitable when there are time dependent interactions between two quantities This class is used for both transfers and interactions. The content that it writes consists of

  • A connection matrix table that has Y/N selection of which interactions are present between two things

  • A set of pairwise connections specifying to, from, units, assumption, and time

Interactions can have a diagonal, whereas transfers cannot (e.g. a population can infect itself but cannot transfer to itself).

In Excel, a TimeDependentConnections maps to three tables

  1. A table to enter the code name and full name

  2. An interactions matrix with Y/N indicating whether an interaction between two populations exists

  3. A set of rows for entering time varying data for each pair of populations

Parameters
  • code_name (str) – the code name of this quantity e.g. ‘aging’

  • full_name (str) – the full name of this quantity e.g. ‘Aging’

  • tvec (array) – time values for the time-dependent rows

  • pops – list of strings to use as the rows and columns - these are typically lists of population code names

  • type – ‘transfer’ or ‘interaction’. A transfer cannot have diagonal entries, and can have Number or Probability formats. An Interaction can have diagonal entries and only has N.A. formats

  • ts (Optional[dict]) – Optionally specify a dict containing all of the non-empty TimeSeries objects used. The format is {(from_pop, to_pop):TimeSeries}. An interaction can only be Y/N for clarity, if it is Y then a row is displayed for the TimeSeries. Actually, the Y/N can be decided in the first instance based on the provided TimeSeries i.e. if a TimeSeries is provided for an interaction, then the interaction must have been marked with Y

  • pop_type – Specify pop_type, which is used by ProjectData.add_pop() to determine which TDCs to add new populations to

Attributes

attributes

Attributes associated with the table

ts_attributes

Attributes associated with each TimeSeries row

assumption_heading

Heading to use for assumption column

write_units

Write a column for units (if None, units will be written if any of the TimeSeries have units)

write_uncertainty

Write a column for units (if None, units will be written if any of the TimeSeries have uncertainty)

write_assumption

Write a column for units (if None, units will be written if any of the TimeSeries have an assumption)

Methods

from_tables

Instantiate based on list of tables

write

Write to cells in a worksheet

assumption_heading

Heading to use for assumption column

attributes

Attributes associated with the table

static from_tables(tables, interaction_type)[source]

Instantiate based on list of tables

This method instantiates and initializes a new TimeDependentConnections object from tables that have been read in using read_tables(). Note that the parent object such as ProjectData is responsible for extracting the tables and passing them to this function. For instance, the transfers sheet might contain more than one set of tables, so it is the calling function’s responsibility to split those tables up into the groups of three expected by this method.

Parameters
  • tables (list) – A list of tables. A table here is a list of rows, and a row is a list of cells.

  • interaction_type – A string identifying the interaction type - either ‘transfer’ or ‘interaction’

Returns

A new TimeDependentConnections instance

ts_attributes

Attributes associated with each TimeSeries row

write(worksheet, start_row, formats, references=None, widths=None)[source]

Write to cells in a worksheet

Parameters
  • worksheet – An xlsxwriter worksheet instance

  • start_row – The first row in which to write values

  • formats – Format dict for the opened workbook - typically the return value of standard_formats() when the workbook was opened

  • references (Optional[dict]) – References dict containing cell references for strings in the current workbook

  • widths (Optional[dict]) – dict storing column widths

Return type

int

Returns

The row index for the next available row for writing in the spreadsheet

write_assumption

Write a column for units (if None, units will be written if any of the TimeSeries have an assumption)

write_uncertainty

Write a column for units (if None, units will be written if any of the TimeSeries have uncertainty)

write_units

Write a column for units (if None, units will be written if any of the TimeSeries have units)