Documentation for all functions exposed by tema-analyzer in temafunctions.py

temafunctions.calculateVelocity(dataframe, column)

Calculated the velocity of a particle based on the x, y and absolute positions. Returns a new Pandas DataFrame where the velocity of the same type (i.e. x, y, abs) as the input position is added as a column to the DataFrame. If the column called does not have units or is already a velocity, the function will return the result as a rate. Function uses central difference velocity calculations

Parameters:
  • dataframe (DataFrame) – Pandas DataFrame that contains the position or input data.

  • column (str) – The name of the column that you wish to take the velocity or rate of.

Returns:

newDataFrame, a Pandas DataFrame containing the position or input data as well as the calculated velocity or rate data as an added column.

Return type:

DataFrame

temafunctions.changeColUnit(dataframe, newUnit, columns, scaleFactor=1, inPlace=True)

Changes the units of a Pandas DataFrame to be anything other than the standard s, m, radians. Returns a Pandas DataFrame of the TEMA data where the units of the columns have been changed to a user specified input and the data has been scaled accordingly.

Parameters:
  • dataframe (DataFrame) – Pandas DataFrame that contains the cleaned and reorderd data.

  • columns (list) – List of column names. Including this will result in a subset of the columns having their units stripped. You must include the columns.

  • newUnit (str) – The new unit as a string that goes in the square brakets of the column label (i.e. [us]).

  • scaleFactor (float) – The number you multiply the current column values by to get the new, converted values.

  • inPlace (bool) – Determines whether the column values are updated or if you make a new column. Default value is True so the values are updated in place.

Returns:

newDataFrame, a Pandas DataFrame of the TEMA data rescaled and relabeled to use the desired units.

Return type:

DataFrame

temafunctions.cleanImportTemaData(filename)

Returns the cleaned, more intuitively labeled TEMA data file as a Pandas dataframe using default parameters. This file has standardized units.

Parameters:

filename (str) – The name of the TEMA .txt file you wish to import. Note that the imported file should be a tab delineated text file.

Returns:

newDataFrame, a pandas Data Frame that contains the cleaned content of the input.

Return type:

DataFrame

temafunctions.exportTemaData(filename, dataframe, columns=None, includeNaN=False)

Returns a csv of the TEMA data where the columns have been relabeled and reorderd, and the data has been scaled to standard units.

Parameters:
  • filename (str) – The name you would like the exported output file to have.

  • dataframe (DataFrame) – Pandas DataFrame that contains the cleaned and reorderd data.

  • columns (list) – List of column names. Including this will result in a subset of the columns being included in the csv file. Default is None.

  • includeNAN (bool) – Boolean value that determines whether NAN values are included in the exported file. If true, NAN values are included in the exported csv. If false, the corresponding csv rows and columns will be stripped from the export. Default setting is false.

Returns:

None. Saves the cleaned TEMA data as a csv file.

temafunctions.getConversion(unit)

Returns the cleaned, more intuitively labeled TEMA data file as a Pandas dataframe. This file has standardized units.

Parameters:

unit (str) – The unit prefix for a particular column extracted from the input file.

Returns:

A tuple containing a scalar multiplier that will convert the data in the DataFrame from the original unit to the standard unit and the string abbreviation of the standard unit we are converting to.

Return type:

(float,unit)

temafunctions.importTemaData(filename)

Returns raw TEMA input data as a Pandas dataframe.

Parameters:

filename (str) – The unit prefix for a particular column extracted from the input file.

Returns:

newDataFrame, a pandas Data Frame that contains the uncleaned content of the input.

Return type:

DataFrame

temafunctions.scalePxToDist(dataframe, scaleFactor, columns=None, metersPerPixel=False, inPlace=True)

Returns a Pandas DataFrame of the TEMA data where the data has been scaled based on a pixels to meters conversion.

Parameters:
  • dataframe (DataFrame) – Pandas DataFrame that contains the cleaned and reorderd data.

  • scaleFactor (float) – The number you need to multiply each value in the column by to convert it to meters from pixels. Note that scaleFactor should be in terms of pixels/meter

  • columns (list) – List of column names. Including this will result in a subset of the columns having their units scaled by the pixel to meter conversion. Default is None.

  • metersPerPixel (bool) – Determines whether you are converting from pixels to meters or meters to pixel. Default value is false, so you are converting using pixels per meter.

  • inPlace (bool) – Determines whether the column values are updated or if you make a new column. Default value is True so the values are updated in place.

Returns:

newDataFrame, a Pandas DataFrame containing the original data scaled by the user-inputted pixel to meter conversion.

Return type:

DataFrame

temafunctions.standardizeColFormat(dataframe)

Returns the intuitively labeled TEMA data file as a Pandas dataframe

Parameters:

dataframe (DataFrame) – The name of the Pandas DataFrame you wish to import. At this stage, the DF should be converted to standard units and its units relabeled.

Returns:

newDataFrame, a pandas DataFrame where the column names have been restructured so that they are more intuitive. They should show the expression being shown (position, velocity, etc), component of that expression (x,y), particle number, and unit.

Return type:

DataFrame

temafunctions.standardizeColOrder(dataframe, renumber=False)

Returns the cleaned, more intuitively labeled TEMA data file as a Pandas dataframe where the columns are reordered to put position first, followed by velocities, and etc.

Parameters:
  • dataframe (DataFrame) – The Pandas DataFrame containing the relabled, rescaled data.

  • renumber (bool) – Parameter that allows you to renumber the default particle numbers to be in numerical order from 1. False as default. If false, particle numbers will appear exactly as generated in TEMA (i.e. numbers will be associated to particle number labels in TEMA and may skip integers like 1, 2, 4, 7, etc).

Returns:

newDataFrame, a Pandas DataFrame that contains the TEMA data that is rescaled with the columns re-labeled and re-ordered.

Return type:

DataFrame

temafunctions.standardizeUnits(dataframe)

Takes datafram with unknown, and variable units and converts data to standard units of m, s, radians.

Parameters:

dataframe (DataFrame) – A Pandas DataFrame containing the original, unaltered and unscaled TEMA data.

Returns:

newDataFrame, a pandas DataFrame where the data has been converted to units of s, radians, and m, and the unit names are converted to SI base units.

temafunctions.stripColUnit(dataframe, columns=None)

Returns a Pandas DataFrame of the TEMA data where the units of the columns have been removed. This function needs to be run on the data before it can be plotted using Altair.

Parameters:
  • dataframe (DataFrame) – Pandas DataFrame that contains cleaned and ordered data.

  • columns (list) – List of column names. Including this will result in a subset of the columns having their units stripped. Default is None.

Returns:

newDataFrame, the cleaned TEMA data with the units removed from the column names.

Return type:

DataFrame