AuxFunctions#
Text
- MAPIT.core.AuxFunctions.calcCovMat(inputAppliedError, inventoryAppliedError, outputAppliedError, processedInputTimes, processedInventoryTimes, processedOutputTimes, ErrorMatrix, MBP, inputTypes, outputTypes, GUIObject=None, doTQDM=True, ispar=False)#
Function to calculate the material balance covariance matrix.
- Parameters:
inputAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of input locations. Each array should be
in shape where is the number of samples. This array should reflect observed quantites (as opposed to ground truths). Inputs are assumed to be flows in units of and will be integrated.processedInputTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of input locations. Each array should be
in shape where is the number of samples. len(processedInputTimes) and the shape of each list entry (ndarray) should be the same as for inputAppliedError. Each entry in the ndarray should correspond to a timestamp indicating when the value was taken.inventoryAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of inventory locations. Each array should be
in shape where is the number of samples. This array should reflect observed quantites. Inventories are assumed to be in units of mass and will not be integrated.processedInventoryTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of inventory locations. Each array should be
in shape where is the number of samples. len(processedInventoryTimes) and shape of each list entry (ndarray) should be the same as for inventoryAppliedError. Each entry in the ndarray should corresond to a timestamp indicating when the value was taken.outputAppliedError (list of ndarrays) – A list of ndarrays that has length equal to the total number of output locations. Each array should be
in shape where is the number of samples. This array should reflect observed quantites. Outputs are assumed to be in flows with units of and will be integrated.processedOutputTimes (list of ndarrays) – A list of ndarrays that has length equal to the total number of output locations. Each array should be
in shape where is the number of samples. len(processedOutputTimes) and shape of each list entry (ndarray) should be the same as for outputAppliedError. Each entry in the ndarray should correspond to a timestamp indicating when the value was taken.ErrorMatrix (ndarray) – mx1 A ndarray shaped
where is the total number of locations across inputs, inventories, and outputs stacked together (in that order) and 2 refers to the relative random and systematic errors. For example with 2 inputs, 2 inventories, and 2 outputs, ErrorMatrix[3,1] would be the relative systematic error of inventory 2. See guide XX for more information.MBP (float) – Defines the material balance period.
inputTypes (list of strings) – Defines the type of input. This should be a list of strings that is the same length as the number of input locations. The strings should be one of the following: ‘discrete’ or ‘continuous’.
outputTypes (list of strings) – Defines the type of output. This should be a list of strings that is the same length as the number of output locations. The strings should be one of the following: ‘discrete’ or ‘continuous’.
GUIObject (object, default=None) – An optional object that carries GUI related references when the API is used inside the MAPIT GUI.
doTQDM (bool, default=True) – Controls the use of TQDM progress bar for command line or notebook operation.
isPar (bool, default=False) – Flag indicating if the function is being run in a parallel context. Only controls output formatting.
- Returns:
SITMUF sequence (ndarray if doSITMUF otherwise None): SITMUF sequence with the shape
where is the length equal to the maximum time based on the number of material balances that could be constructed given the user-provided MBP and number of samples in the input data, and is the number of iterations given as input.GEMUF sequence (ndarray if doGEMUF otherwise None): GEMUF sequence with the shape
where is the length equal to the maximum time based on the number of material balances that could be constructed given the user-provided MBP and number of samples in the input data, and is the number of iterations given as input.
- Return type:
(tuple)
The maximum time of the sequence is based on the minimum of all material balance components (e.g., input, inventories, and outputs) used for the calculation:
import numpy as np time1[-1] = 400 time2[-1] = 300 time3[-1] = 800 j = np.floor( np.min( (time1, time2, time3)))
- MAPIT.core.AuxFunctions.trapSum(relevantIndex, time, data, IT=None, baseline_zero=1e-10)#
Function performs trapezoidal integration on a dataset segment. This is required for bulk facility flows that might need integration before use within statistical tests.
In some cases, flows might be represented as discontinuous pulses of material, in which case, special care is needed to identify the non-zero regions of the dataset to enable proper integration.
This function first identified a list of non-zero pulses of material before performing trapezoidal integration on each non-zero pulse segment. np.trapz is used to perform the integration. See the numpy documentation for more information.
- Parameters:
relevantIndex (ndarray) – An array that expresses the relevant time slice, with boolean values (0 = not relevant, 1 = relevant), with shape
where is the total number of relevant samples and is the total number of iterations.time (ndarray) – An array containing the total number of timestep values under consideration for the analysis. Has shape
where is the total number of samples under consideration and for in relevantIndex and is the total number of iterations.data (ndarray) – An array containing the total number of samples under consideration for the analysis. Should have the same shape as time.
baseline_zero (float) – A float that expresses the threshold below which values are considered zero. Important as datasets often do not represent zero as exactly zero for a variety of reasons.
- Returns:
An array of shape
containing the integrated total for each iteration over the time specified by time[relevantIndex].- Return type:
ndarray