Single Facet Data Process
Module for processing and analyzing SOFAST data for a single facet mirror.
This script performs the following steps:
Load saved single facet SOFAST collection data from an HDF5 file.
Save projected sinusoidal fringe images to PNG format.
Save captured sinusoidal fringe images and mask images to PNG format.
Process data with SOFAST and save processed data to HDF5.
Generate a suite of plots and save image files.
Examples
To run the script, simply execute it as a standalone program:
>>> python example_process_single_facet.py
This will perform the processing steps and save the results to the data/output/single_facet directory with the following subfolders:
B1_projected_fringes - The patterns sent to the display during the SOFAST measurement of the optic. B2_captured_fringes - The captured images of the displayed patterns as seen by the SOFAST camera. B3_diagnostics - Output reporting the progress of SOFAST. B4_analysis - The processed data from SOFAST. B5_plots - The output figure suite from a SOFAST characterization.
- example.sofast_fringe.single_facet.example_process_single_facet.example_process_single_facet_driver(arg_settings_dir_body_ext: str | None = None, verbose_param=None)
Sets up and runs the example_process_single_facet() routine.
- Parameters:
arg_settings_dir_body_ext (str) – Full path and filename for settings file, containing inputand output directories, plot control settings, etc. Optional. If not provided, internal defaults are used. See code for options sought within file.
verbose (bool) – If true, output detailed progress and calculation output.
- example.sofast_fringe.single_facet.example_process_single_facet.process_single_facet(verbose: bool, file_camera: str, file_display: str, file_orientation: str, file_facet: str, file_calibration: str, file_measurement: str, dir_save: str, measurement_id: str, post_process_id: str, fit_initial_focal_length_x: float, fit_initial_focal_length_y: float, fit_robust_least_squares: bool, fit_downsample: int, measured_interpolation_type: str, reference_mirror_surface_type: str, reference_mirror_focal_length_x: float, reference_mirror_focal_length_y: float, output_fringe_images: bool, plots: StandardPlotOutput)
Performs processing of previously collected SOFAST data of single facet mirror.
Load saved single facet SOFAST collection data from HDF5 file
Save projected sinusoidal fringe images to PNG format
Save captured sinusoidal fringe images and mask images to PNG format
Processes data with SOFAST and save processed data to HDF5
Generate plot suite and save image files
Facet Ensemble Data Process
Module for processing and analyzing SOFAST data for an ensemble of mirrors.
This script performs the following steps:
Load saved facet ensemble SOFAST collection data from an HDF5 file.
Save projected sinusoidal fringe images to PNG format.
Save captured sinusoidal fringe images and mask images to PNG format.
Process data with SOFAST and save processed data to HDF5.
Generate a suite of plots and save image files.
Examples
To run the script, simply execute it as a standalone program:
>>> python example_process_facet_ensemble.py
This will perform the processing steps and save the results to the data/output/single_facet directory with the following subfolders:
1_images_fringes_projected - The patterns sent to the display during the SOFAST measurement of the optic. 2_images_captured - The captured images of the displayed patterns as seen by the SOFAST camera 3_processed_data - The processed data from SOFAST. 4_processed_output_figures - The output figure suite from a SOFAST characterization.
Notes
The script assumes that the input data files are located in the specified directories.
Chat GPT 4o assisted with the generation of some docstrings in this file.
- example.sofast_fringe.example_process_facet_ensemble.example_process_facet_ensemble()
Performs processing of previously collected SOFAST data of facet ensemble.
Load saved facet ensemble Sofast collection data
Save projected sinusoidal fringe images to PNG format
Save captured sinusoidal fringe images and mask images to PNG format
Processes data with SOFAST and save processed data to HDF5
Generate plot suite and save images files
Undefined Facet Data Process
Module for processing and analyzing SOFAST data for a single facet mirror of unknown shape.
This script performs the following steps: 1. Load saved single facet SOFAST collection data from an HDF5 file. 2. Save projected sinusoidal fringe images to PNG format. 3. Save captured sinusoidal fringe images and mask images to PNG format. 4. Process data with SOFAST and save processed data to HDF5. 5. Generate a suite of plots and save image files.
Examples
To run the script, simply execute it as a standalone program:
>>> python example_process_undefined_shape.py
This will perform the processing steps and save the results to the data/output/single_facet directory with the following subfolders: 1_images_fringes_projected - The patterns sent to the display during the SOFAST measurement of the optic. 2_images_captured - The captured images of the displayed patterns as seen by the SOFAST camera 3_processed_data - The processed data from SOFAST. 4_processed_output_figures - The output figure suite from a SOFAST characterization.
Notes
The script assumes that the input data files are located in the specified directories.
Chat GPT 40 assisted with the generation of some docstrings in this file.
- example.sofast_fringe.example_process_undefined_shape.example_process_undefined_shape_facet()
Performs processing of previously collected SOFAST data of single facet mirror with an unknown shape.
Load saved single facet SOFAST collection data from HDF5 file
Save projected sinusoidal fringe images to PNG format
Save captured sinusoidal fringe images and mask images to PNG format
Processes data with SOFAST and save processed data to HDF5
Generate plot suite and save images files
Generating Standard Mirror Output Plots
- example.sofast_fringe.example_standard_mirror_plot_output.example_single_facet() None
Loads and visualizes CSP facet from saved Sofast HDF file containing measured data of an NSTTF Facet.
Load Sofast measurement data
Define viewing/illumination geometry
- Create standard output plots:
Perform ray trace of facet
Plot orthorectified slope maps
Plot orthorectified slope error map
Plot facet in 3d
Plot sun images on receiver
Plot ensquared energy curve
Running SOFAST in Debug Mode
Processes SOFAST data with debug mode enabled.
This module provides a function to process optical measurements using the SOFAST framework while enabling debug mode. The function performs the following tasks: loading necessary data files, calibrating fringe images, and processing the measurements. If an error occurs during processing, debug figures are saved for further analysis.
- Usage:
To execute the processing with debug mode, run the module directly. The output figures and log files will be saved in a specified directory structure.
Generate Rectangular Screen Definition
Generates a rectangular SOFAST screen shape definition file.
This module defines a function to create and save a rectangular screen shape definition for use in SOFAST applications. The screen dimensions, name, and output filename are specified within the function. The generated definition file can be utilized in optical simulations and analyses involving the SOFAST framework.
- Usage:
To execute the script and generate the screen definition file, run the module directly. The output file will be saved in the current working directory.
- example.sofast_fringe.example_make_rectangular_screen_definition.example_make_rectangular_screen_definition()
Creates and saves a rectangular screen shape definition for SOFAST.
This function defines the dimensions of a rectangular screen and creates a corresponding DisplayShape object. The screen’s width and height are specified in meters, along with a name for the display. The resulting screen shape definition is saved as an HDF5 file in the current working directory.
Notes
The screen dimensions are hardcoded in the function. Edit the USER INPUT section of the code to make a new definition file:
Width (screen_x): 0.3 meters
Height (screen_y): 0.2 meters
Display name: ‘LCD monitor laptop’
Output filename: ‘display_LCD_monitor.h5’
The generated HDF5 file can be used in subsequent SOFAST analyses to represent the specified screen shape.
Example
To generate the screen definition file, simply call the function:
>>> example_make_rectangular_screen_definition()
The output file will be saved in the current working directory.
Process SOFAST Temperature Experiment Data
Python script that provides an example of how to process SOFAST data of the Sandia temperature chamber experiment. In this experiment, a CSP mirror was placed in a large temerature chamber. An installation of SOFAST was set up outside of the temperature chamber so that when the chamber doors were opened, SOFAST could immediately take a measurement. This was done for a range of temperatures from +5C to -50C. This example will walk a user through how to automatically process such data, how to automatically plot slope maps, and how to generate slope difference plots to show the change in slope from a reference temerature.
To run, the base directory containing the calibration and measurement data
must be defined and passed in as the first argument:
`
python sofast_temperature_analysis.py "path/to/base/dir"
`
- example.sofast_fringe.sofast_temperature_analysis.example_run_temperature_analysis(dir_working: str, dir_save: str) None
Runs a temperature analysis example using SOFAST. This function processes multiple SOFAST measurements of the same mirror at different temperatures by utilizing calibration data and measurement files organized in a specified directory structure.
- Parameters:
dir_working (str) –
The path to the working directory that contains the required subdirectories:
calibration/ Should contain calibration files including:
camera.h5
facet_definition.json
image_projection.h5
screen_shape.h5
spatial_orientation.h5
measurements/ Should contain measurement files named in the format measurement_XXC.h5, where XX represents the analysis temperature.
dir_save (str) – The directory where all output figures will be saved. This directory will be created if it does not already exist.
Notes
The function performs the following steps:
Checks for the existence of the input and output directories.
Loads all calibration files necessary for processing the measurements.
Characterizes all measurement files by calibrating fringe images and processing them with the SOFAST algorithm.
Calculates the slope deviation of the mirrors from a reference temperature of 20°C and generates visualizations of the slope magnitude and differences, saving them as PNG files in the specified output directory.
The expected directory structure is as follows:
` dir_working/ ├── calibration/ │ ├── camera.h5 │ ├── facet_definition.json │ ├── image_projection.h5 │ ├── screen_shape.h5 │ └── spatial_orientation.h5 ├── measurements/ │ ├── measurement_05C.h5 │ ├── measurement_10C.h5 │ ├── measurement_20C.h5 │ ├── measurement_30C.h5 │ ├── measurement_40C.h5 │ └── measurement_50C.h5 └── output/ `This function is intended for use in scientific research and analysis involving temperature-dependent measurements of optical surfaces.
Running SOFAST with Command Line Tool
Command-line tool for processing optical measurements using SOFAST.
This module provides a command-line interface for processing optical measurements using the SOFAST framework. It sets up the necessary components for image acquisition, image projection, and SOFAST processing, allowing users to run measurements and generate results based on the provided calibration and configuration files.
Note
To run this example, you will need a full physical SOFAST setup. This includes a camera, display (LCD screen or projector), and a mirror to test.
The calibration files required to run this example are not included in the OpenCSP repository. You will need to generate your own for your own system.
Usage:
To run the command-line tool, provide the paths to the calibration directory and the directory where results should be saved as command-line arguments.
For example:
`
python sofast_command_line_tool.py path/to/calibration/files path/to/save/outputs
`
- example.sofast_fringe.sofast_command_line_tool.example_sofast_command_line_tool(dir_cal: str, dir_save: str) None
Processes optical measurements using SOFAST via command-line interface.
This function performs the following steps:
Sets up logging for the processing session.
Configures image acquisition settings for the camera.
Loads image projection data from an HDF5 file.
Initializes the SOFAST interface and fringe system.
Loads necessary processing data, including facet definitions, camera data, spatial orientation, display shape, and dot locations.
Configures plotting options and save paths for output files.
Executes the SOFAST processing routine.
- Parameters:
dir_cal (str) – The directory path containing calibration files required for processing, including image projection, facet definitions, camera data, and spatial orientation data.
dir_save (str) – The directory path where the output results and figures will be saved.
Example
To run the SOFAST command-line tool, execute the script with the required directories as arguments:
>>> python script_name.py /path/to/calibration /path/to/save/results
The results will be saved in the specified directory.