atomica.excel.TimeDependentValuesEntry¶
- class atomica.excel.TimeDependentValuesEntry(name, tvec=None, ts=None, allowed_units=None, comment=None, pop_type=None)[source]¶
Bases:
object
Table for time-dependent data entry
This class is Databooks and Program books to enter potentially time-varying data. Conceptually, it maps a set of TimeSeries object to a single name and table in the spreadsheet. For example, a Characteristic might contain a TimeSeries for each population, and the resulting TimeDependentValuesEntry (TDVE) table would have a name matching the population, and TimeSeries for each population.
The TDVE class optionally allows the specification of units, assumptions, and uncertainty, which each map to properties on the underlying TimeSeries objects. It also contains a time vector corresponding to the time values that appear or will appear in the spreadsheet.
Note that the units are stored within the TimeSeries objects, which means that they can are able to differ across rows.
- Parameters:
name – The name/title for this table
tvec (
array
) – Specify the time values for this table. All TimeSeries in the ts dict should have corresponding time valuests – Optionally specify an odict() of TimeSeries objects populating the rows. Could be populated after
allowed_units (
list
) – Optionally specify a list of allowed units that will appear as a dropdowncomment (
str
) – Optionally specify descriptive text that will be added as a comment to the name cell
Attributes
Check whether all time series have data entered
Name for th quantity printed in Excel
A comment that will be added in Excel
time axis (e.g. np.arange(2000,2019)) - all TimeSeries time values must exactly match one of the values here.
Dictionary containing extra attributes to write along with each TimeSeries object.
Heading to use for assumption column
Write a column for units (if None, units will be written if any of the TimeSeries have units)
Write a column for uncertainty (if None, uncertainty will be written if any of the TimeSeries have uncertainty)
Write a column for assumption/constant (if None, assumption will be written if any of the TimeSeries have an assumption)
Methods
Create new instance from Excel rows
Write to cells in a worksheet
- assumption_heading¶
Heading to use for assumption column
- comment¶
A comment that will be added in Excel
- classmethod from_rows(rows)[source]¶
Create new instance from Excel rows
Given a set of openpyxl rows, instantiate a
TimeDependentValuesEntry
object That is, the parent object e.g.ProjectData
is responsible for finding where the TDVE table is, and reading all of the rows associated with it (skipping#ignored
rows) and then passing those rows, unparsed, to this functionHeadings for ‘units’, ‘uncertainty’, and ‘assumption’/’constant’ are optional and will be read in if they are present in the spreadsheet.
- Parameters:
rows (
list
) – A list of rows- Returns:
A new
TimeDependentValuesEntry
instance
- property has_data: bool¶
Check whether all time series have data entered
- Returns:
True if all of the TimeSeries objects stored in the TDVE have data
- name¶
Name for th quantity printed in Excel
- ts_attributes¶
Dictionary containing extra attributes to write along with each TimeSeries object.
- tvec¶
time axis (e.g. np.arange(2000,2019)) - all TimeSeries time values must exactly match one of the values here
- write(worksheet, start_row, formats, references=None, widths=None)[source]¶
Write to cells in a worksheet
Note that the year columns are drawn from the
tvec
attribute. To suppress the year columns (e.g. for the user to enter only an assumption) then settvec
to an empty array/list.- 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 openedreferences (
dict
) – References dict containing cell references for strings in the current workbookwidths (
dict
) –dict
storing column widths
- Return type:
- Returns:
The row index for the next available row for writing in the spreadsheet
- write_assumption¶
Write a column for assumption/constant (if None, assumption will be written if any of the TimeSeries have an assumption)
- write_uncertainty¶
Write a column for uncertainty (if None, uncertainty 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)