Postprocessing
- class ledsa.postprocessing.simulation.SimData(path_simulation: str, read_all=True, remove_duplicates=False, load_config_params=True)[source]
Bases:
object
- get_extco_at_height(channel: int, height: float, window=1) pandas.DataFrame [source]
Retrieves a DataFrame containing smoothed extinction coefficients for a specified layer at given height. This method extracts the extinction coefficients for a given channel and layer, then applies a moving average smoothing over the specified window of time. The result is a DataFrame with experimental time as the index and LED arrays as the columns, providing a time series of extinction coefficients at the specified height.
- Parameters:
channel (int) – The channel index from which to extract extinction coefficients. Each channel represents a different set of measurements or sensor readings.
height (float) – The height for which to extract extinction coefficients.
window (int, optional) – The window size for the moving average smoothing. The default is 1, implying no smoothing. A larger window size will average the data over more time points, smoothing out short-term fluctuations.
- Returns:
A pandas DataFrame with smoothed extinction coefficients. The DataFrame’s index represents experimental time, and its columns represent different LED arrays within the specified height.
- Return type:
pd.DataFrame
- get_extco_at_layer(channel: int, layer: int, window=1) pandas.DataFrame [source]
Retrieves a DataFrame containing smoothed extinction coefficients for a specified layer. This method extracts the extinction coefficients for a given channel and layer, then applies a moving average smoothing over the specified window of time. The result is a DataFrame with experimental time as the index and LED arrays as the columns, providing a time series of extinction coefficients at the specified layer.
- Parameters:
channel (int) – The channel index from which to extract extinction coefficients. Each channel represents a different set of measurements or sensor readings.
layer (int) – The layer number for which to extract extinction coefficients. Layers correspond to different vertical positions or depths in the experimental setup.
window (int, optional) – The window size for the moving average smoothing. The default is 1, implying no smoothing. A larger window size will average the data over more time points, smoothing out short-term fluctuations.
- Returns:
A pandas DataFrame with smoothed extinction coefficients. The DataFrame’s index represents experimental time, and its columns represent different LED arrays within the specified layer.
- Return type:
pd.DataFrame
- get_extco_at_led_array(channel: int, led_array_id: int, yaxis='layer', window=1) pandas.DataFrame [source]
Retrieves a DataFrame containing smoothed extinction coefficients for a specific LED array.
This method extracts the extinction coefficients for a specified channel and LED array, applies a moving average smoothing over time based on the specified window size, and restructures the DataFrame to have experimental time as the index and layers (or heights) as columns. The method first selects the relevant extinction coefficients for the specified channel and LED array. It then applies a moving average smoothing operation across a defined window of time steps. The resulting data is organized such that the experimental time is the index, providing a structured view suitable for analysis or visualization. Depending on the ‘yaxis’ parameter, the columns of the resulting DataFrame are labeled as either layers or converted to heights.
- Parameters:
channel (int) – The channel index from which to extract extinction coefficients.
led_array_id (int) – The ID for which to extract extinction coefficients.
yaxis (str, optional) – Determines whether the DataFrame’s columns should represent ‘layer’ or ‘height’. The default is ‘layer’, which uses the layer numbers as column names. If set to ‘height’, the column names are converted to the corresponding heights based on layer numbers.
window (int, optional) – The window size for the moving average smoothing. The default is 1, which means no smoothing is applied. A window greater than 1 will smooth the data over the specified number of time steps.
- Returns:
A pandas DataFrame with the smoothed extinction coefficients. The index represents the experimental time, and the columns represent either layers or heights, depending on the ‘yaxis’ parameter.
- Return type:
pd.DataFrame
- get_extco_at_time(channel: int, time: int, yaxis='layer', window=1, smooth='ma') pandas.DataFrame [source]
Retrieves a DataFrame containing smoothed extinction coefficients at a specific time.
This method extracts the extinction coefficients for a specified channel and time, applies smoothing over time using either a moving average or median based on the specified window size. It restructures the DataFrame to have layers or heights as indices and LED arrays as columns. The method first selects the extinction coefficients for the specified channel. It then applies the specified smoothing operation across a defined window of timesteps. The resulting data is then pivoted to organize extinction coefficients by LED array and layer or height, depending on the ‘yaxis’ parameter, providing a structured view suitable for analysis or visualization.
- Parameters:
channel (int) – The channel index to extract extinction coefficients for.
time (int) – The time at which to extract extinction coefficients.
yaxis (str, optional) – Determines whether the y-axis of the returned DataFrame should represent ‘layer’ or ‘height’. Defaults to ‘layer’.
window (int, optional) – The window size for the moving average or median smoothing. Defaults to 1.
smooth (str, optional) – The smoothing method to use, either ‘ma’ for moving average or ‘median’ for median. Defaults to ‘ma’.
- Returns:
A pandas DataFrame with the smoothed extinction coefficients. Indices represent either layers or heights, and columns represent LED arrays.
- Return type:
pd.DataFrame
- get_image_name_from_time(time: int)[source]
Retrieves the image name corresponding to a specific times.
- Parameters:
time (int) – The time index.
- Returns:
The name of the image.
- Return type:
str
- get_ledparams_at_led_array(channel: int, led_array_id: int, param='sum_col_val', yaxis='led_id', window=1, n_ref=None) pandas.DataFrame [source]
Retrieves a DataFrame containing normalized LED parameters for a specific LED array, optionally smoothed over time. This method selects LED parameter data for a given channel and LED array. It normalizes the data based on the average of the first n_ref entries (if n_ref is not False), and applies a moving average smoothing over the specified window of time. The result is a DataFrame with experimental time as the index and LED identifiers (or heights) as the columns, depending on the yaxis parameter.
- param channel:
The channel index from which to extract LED parameters. Channels typically represent different sensor readings or experimental conditions.
- type channel:
int
- param led_array_id:
The ID of the LED array for which to extract LED parameters. LED arrays may represent different spatial locations or orientations in the experimental setup.
- type led_array_id:
int
- param param:
The specific LED parameter to extract and analyze, such as ‘sum_col_val’. Defaults to ‘sum_col_val’.
- type param:
str, optional
- param yaxis:
Determines the labeling of the DataFrame’s columns, either ‘led_id’ for LED identifiers or ‘height’ for physical heights. Defaults to ‘led_id’.
- type yaxis:
str, optional
- param window:
The window size for the moving average smoothing. A value of 1 implies no smoothing. A larger window size averages the data over more time points, reducing short-term fluctuations.
- type window:
int, optional
- param n_ref:
The number of initial entries to average for normalization. If set to False, absolute values are returned without normalization. Defaults to 10.
- type n_ref:
int or bool, optional
- return:
A pandas DataFrame with normalized (and optionally smoothed) LED parameters. The index represents experimental time, and columns represent LED identifiers or heights.
- rtype:
pd.DataFrame
- get_ledparams_at_led_id(channel: int, led_id: int, param='sum_col_val', window=1, n_ref=None) pandas.DataFrame [source]
Retrieves a DataFrame containing normalized LED parameters for a specific LED ID, optionally smoothed over time.
This method selects LED parameter data for a given channel and LED ID, normalizes the data based on the average of the first n_ref entries (if n_ref is not False), and applies a moving average smoothing over the specified window of time. The result is a DataFrame with experimental time as the index, providing a time series of the specified LED parameter for the selected LED.
- Parameters:
channel (int) – The channel index from which to extract LED parameters. Channels typically represent different sets of measurements or sensor readings.
led_id (int) – The identifier of the LED for which to extract parameters. This ID is used to select the specific LED’s data from the dataset.
param (str, optional) – The specific LED parameter to extract and analyze, such as ‘sum_col_val’. This parameter determines which aspect of the LED’s data is analyzed. Defaults to ‘sum_col_val’.
window (int, optional) – The window size for the moving average smoothing. A value of 1 implies no smoothing, while a larger window size averages the data over more time points, thereby smoothing out short-term fluctuations.
n_ref (int or bool, optional) – The number of initial entries to average for normalization. If set to False, absolute values are returned without normalization. This parameter allows for the normalization of data to account for initial conditions or baseline measurements. Defaults to 10.
- Returns:
A pandas DataFrame with normalized (and optionally smoothed) LED parameters for the specified LED ID. The DataFrame’s index represents experimental time.
- Return type:
pd.DataFrame
This method enables the analysis of temporal variations in specific LED parameters for an individual LED, facilitating the examination of changes or trends in the LED’s behavior over the course of an experiment. By normalizing and smoothing the data, the method helps reveal underlying patterns that may not be immediately apparent from the raw data.
- get_pixel_cordinates_of_LED(led_id: int)[source]
Returns the pixel coordinates of a specified LED.
- Parameters:
led_id (int) – The identifier for the LED.
- Returns:
A list containing the x and y pixel coordinates of the LED.
- Return type:
list
- get_pixel_values_of_led(led_id: int, channel: int, time: int, radius=None)[source]
Retrieves a cropped numpy array of pixel values around a specified LED, based on its ID, for a given image channel and time.
This method calculates the pixel values in a specified radius around an LED’s position on an image. It first determines the LED’s pixel coordinates, then retrieves the image corresponding to the specified time, and finally extracts a square array of pixel values centered on the LED’s location.
- Parameters:
led_id (int) – The identifier for the LED of interest. This ID is used to look up the LED’s position.
channel (int) – The image channel from which to extract pixel values. Different channels may represent different color channels or sensor readings.
time (int) – The time at which the image was taken. This corresponds to a specific moment in the experimental timeline.
radius (int, optional) – The radius around the LED’s position from which to extract pixel values. If not specified, the search_area_radius from the config file is used. Defaults to None.
- Returns:
A numpy array containing the pixel values in the specified radius around the LED. The array is cropped from the original image, centered on the LED’s position.
- Return type:
numpy.ndarray
- Raises:
ValueError – If path_images is not available when trying to access image files.
- height_from_layer(layer)
- layer_from_height(height)
- read_all()[source]
Read led parameters and extionciton coefficients for all color channels from the simulation path