Api Reference#

pseudobatch.data_correction.accumulated_dilution_factor(after_sample_reactor_volume: ndarray[Any, dtype[_ScalarType_co]], sample_volume: ndarray[Any, dtype[_ScalarType_co]]) ndarray[Any, dtype[_ScalarType_co]][source]#

Calculates the accumulated dilution factor.

Parameters:
  • after_sample_reactor_volume (NDArray) – The volume of the bioreactor. At the sampling time points, this has to be the volume AFTER the sample was taken.

  • sample_volume (NDArray) – The volume of the sample taken at each time point.

Returns:

The accumulated dilution factor for each timepoint. The first value is always 1.

Return type:

NDArray

pseudobatch.data_correction.convert_volumetric_rates_from_pseudo_to_real(pseudo_volumetric_rates: Series | ndarray[Any, dtype[_ScalarType_co]], reactor_volume: Series | ndarray[Any, dtype[_ScalarType_co]], sample_volume: Series | ndarray[Any, dtype[_ScalarType_co]]) Series | ndarray[Any, dtype[_ScalarType_co]][source]#

Convert pseudo concentration to real concentration.

Parameters:
  • pseudo_concentration (Union[pd.Series, NDArray]) – Pseudo volumetric rates to be converted.

  • reactor_volume (Union[pd.Series, NDArray]) – Reactor volume, this must be the BEFORE sampling volume.

  • sample_volume (Union[pd.Series, NDArray]) – Sample volume.

Returns:

Real volumetric rates.

Return type:

Union[pd.Series, NDArray]

pseudobatch.data_correction.hypothetical_concentration(metabolised_amount: ndarray, reactor_volume: ndarray, sample_volume: ndarray) ndarray[source]#

Preprocess the gaseous/volatile species data to prepare it for the pseudo batch transformation. The functions calculates the hypothetical liquid concentration of the gaseous species if the gas species did not evaporate. This is done by first calculating the hypothetical concentration of evaporated species including losses due to sampling. Then the function adds the hypothetical concentration of evaporated species to the measured concentration of the gaseous species to get the preprocessed concentration data.

Parameters:
  • metabolised_amount (np.ndarray) – Net accumulated result of metabolism at each time point. Thus, if the species is consumed, the values are negative, if the species is produced, the values are positive.

  • reactor_volume (np.ndarray) – Reactor volume BEFORE sampling.

  • sample_volume (np.ndarray) – Sample volume.

Returns:

Hypothetical liquid concentration of gaseous species if the gas species did not evaporate.

Return type:

np.ndarray

Notes

For highly volatile species, such as CO2 and O2, the measured concentration in the liquid phase can be assumed to be zero.

pseudobatch.data_correction.metabolised_amount(off_gas_amount: ndarray[Any, dtype[_ScalarType_co]], dissolved_amount_after_sampling: ndarray[Any, dtype[_ScalarType_co]], inlet_gas_amount: ndarray[Any, dtype[_ScalarType_co]], sampled_amount: ndarray[Any, dtype[_ScalarType_co]], inlet_liquid_amount: ndarray[Any, dtype[_ScalarType_co]] | None = None)[source]#

Calulated the amount of metabolised species at a given time. Essentially, solving the mass balance equation for the metabolised species.

Parameters:
  • off_gas_amount (NDArray) – Accumulated amount of the species exiting the reactor.

  • dissolved_amount_after_sampling (NDArray) – Amount of the species in the reactor after sampling.

  • inlet_gas_amount (NDArray) – Accumulated amount of the species entering the reactor through the gas inlet.

  • sampled_amount (NDArray) – Accumulated amount of the species removed from the reactor through sampling.

  • inlet_liquid_amount (NDArray, optional) – Accumulated amount of the species entering the reactor through the liquid inlet. If not given, it is assumed that no mass of the species entering the reactor through the liquid inlet.

pseudobatch.data_correction.pseudobatch_transform(measured_concentration: ndarray[Any, dtype[_ScalarType_co]], reactor_volume: ndarray[Any, dtype[_ScalarType_co]], accumulated_feed: ndarray[Any, dtype[_ScalarType_co]], concentration_in_feed: ndarray[Any, dtype[_ScalarType_co]] | float, sample_volume: ndarray[Any, dtype[_ScalarType_co]]) ndarray[Any, dtype[_ScalarType_co]][source]#

Pseudo batch transformation function for a single species. This function transforms the measured concentrations to the pseudo concentrations.

Parameters:
  • measured_concentration (NDArray) – a NDArray with the measured concentration of the species that should be transformed, e.g. biomass or compound

  • reactor_volume (NDArray) – a NDArray of bioreator volume. The volume MUST be the volumes just BEFORE sampling.

  • accumulated_feed (NDArray) – a NDArray of the accumulated volumen of feed added at this timepoint.

  • concentration_in_feed (Union[NDArray, float]) – a NDArray OR a float of the concentration of the species in the feed, for biomass and products this is 0

  • sample_volume (NDArray) – a NDArray of the sample volumes at given time points. The array should

  • taken (contain 0 at timepoints where no samples was)

Returns:

A NDArray with the pseudo concentrations of the species.

Return type:

NDArray

pseudobatch.data_correction.pseudobatch_transform_multiple(measured_concentrations: ndarray[Any, dtype[_ScalarType_co]], reactor_volume: ndarray[Any, dtype[_ScalarType_co]], accumulated_feed: ndarray[Any, dtype[_ScalarType_co]], concentration_in_feed: Iterable | ndarray[Any, dtype[_ScalarType_co]], sample_volume: ndarray[Any, dtype[_ScalarType_co]]) ndarray[Any, dtype[_ScalarType_co]][source]#

Perform the pseudo batch transformation on multiple species at once. This function simply wraps the pseudobatch_transform() function.

Parameters:
  • measured_concentrations (NDArray) – a NDArray with the measured concentration of the species that should be transformed, e.g. biomass or compound. Each column should be a different species and the reach row a time point.

  • reactor_volume (NDArray) – a NDArray of bioreator volume. The volume MUST be the volumes just BEFORE sampling.

  • feed_in_interval (NDArray) – a NDArray of the feed volumen in the interval since last timepoint.

  • concentration_in_feed (Iterable or NDArray) – the concentration of each species in the feed medium. This can be an iterable of the same length as the number of columns in the measured_concentrations array. Alternatively an NDArray which contain the concetration for each individual time step. Again the order of the columns has to match in order in measured_concentration.

  • sample_volume (NDArray) – a NDArray of the sample volumes at given time points. The array should contain 0 at timepoints where no samples was taken

Returns:

A NDArray of the same shape as the measured_concentration argument with the pseudo concentrations of the species. The columns correspond to the columns in measured_concentration.

Return type:

NDArray

pseudobatch.data_correction.pseudobatch_transform_pandas(df: DataFrame, measured_concentration_colnames: str | Iterable[str], reactor_volume_colname: str, accumulated_feed_colname: str | Iterable[str], concentration_in_feed: Iterable[float | int] | Iterable[Iterable[float | int]], sample_volume_colname: str, pseudo_col_postfix: str = '_pseudo') DataFrame[source]#

Apply pseudo batch transformation for several species from a dataframe.

The function outputs a dataframe containing the pseudo batch transformed data a species for each column.

Parameters:
  • df (pd.DataFrame) – a pandas dataframe containing the data to be transformed

  • measured_concentration_colnames (Union[str, Iterable[str]]) – a string or list of strings with the column names of the measured concentration of the species that should be transformed, e.g. biomass or glucose

  • reactor_volume_colname (str) – a string with the column name of the reactor volume

  • accumulated_feed_colname (Union[str, Iterable[str]]) – a string or list of strings with the column names of the accumulated feed

  • concentration_in_feed (Union[Iterable[float], Iterable[Iterable[float]]]) – a list of floats or list of lists of floats with the concentrations of the species in the feed. The order has to match the order of the species given in measured_concentration_colnames. If multiple feed streams are given, the concentration_in_feed should be a list of lists. E.g. [[conc_Glc_feed1, conc_Glc_feed2], [conc_Biomass_feed1, conc_Biomass_feed2]]. Thus, the outer list iterates over the species and the inner list iterates over the feed streams. The order has to match the order of the species, and accumulated feeds given in measured_concentration_colnames and accumulated_feed_colname.

  • sample_volume_colname (str) – a string with the column name of the sample volume

  • pseudo_col_postfix (str, optional) – a string with the postfix to be added to the column names of the pseudo batch transformed data, by default “_pseudo”

Returns:

a pandas dataframe containing the pseudo batch transformed data a species for each column.

Return type:

pd.DataFrame