Skip to content

E0018 Module

The e0018.py module processes multiple IQ files for Schottky signal analysis. It automates the workflow of reading files, generating spectrograms, saving processed data, and managing logs. The module supports multithreading for efficient processing.

Functions

plot_and_save_spectrogram(xx, yy, zz, filename, span=None)

Generates and saves a spectrogram plot.

Parameters:

  • xx (array): Frequency data.
  • yy (array): Time data.
  • zz (array): Power data.
  • filename (str): Name of the output file.
  • span (float, optional): Frequency span for zoomed plots.

Workflow:

  1. Filters the frequency data based on the span.
  2. Plots the spectrogram using matplotlib.
  3. Saves the plot as a PNG file.

process_loop(syncfile, logfile, lustrepath, queue)

Reads a sync file and enqueues files for processing.

Parameters:

  • syncfile (str): Path to the sync file.
  • logfile (str): Path to the log file.
  • lustrepath (str): Directory containing the files to process.
  • queue (Queue): Queue to store files for processing.

Workflow:

  1. Reads the sync file line by line.
  2. Checks if each file has already been processed.
  3. Enqueues unprocessed files for further processing.

process_each(source_fullfilename, basefilename, outpath, wwwpath, n_avg, lframes, nframes)

Processes a single IQ file.

Parameters:

  • source_fullfilename (str): Full path to the source file.
  • basefilename (str): Base name of the file.
  • outpath (str): Directory to save processed files.
  • wwwpath (str): Directory to copy files for web access.
  • n_avg (int): Number of frames to average.
  • lframes (int): Length of each frame.
  • nframes (int): Number of frames to process.

Workflow:

  1. Reads the IQ file and computes the power spectrogram.
  2. Generates and saves spectrogram plots (full and zoomed).
  3. Saves processed data as .npz files.
  4. Copies files to the specified directories.

put_into_logfile(file, logfilename)

Writes a file entry into the log file.

Parameters:

  • file (str): File name to log.
  • logfilename (str): Path to the log file.

already_processed(currentfilename, logfilename)

Checks if a file has already been processed.

Parameters:

  • currentfilename (str): Name of the file to check.
  • logfilename (str): Path to the log file.

Returns:

  • bool: True if the file is already processed, False otherwise.

worker(queue, outpath, wwwpath, n_avg, lframes, nframes)

Processes files from the queue in a separate thread.

Parameters:

  • queue (Queue): Queue containing files to process.
  • outpath (str): Directory to save processed files.
  • wwwpath (str): Directory to copy files for web access.
  • n_avg (int): Number of frames to average.
  • lframes (int): Length of each frame.
  • nframes (int): Number of frames to process.

main()

Main function to initialize and run the file processing workflow.

Workflow:

  1. Parses command-line arguments to load a TOML configuration file.
  2. Reads configuration settings for paths and processing parameters.
  3. Initializes a queue and starts worker threads for multithreaded processing.
  4. Continuously monitors the sync file for new files to process.
  5. Gracefully stops all threads on user interruption.

Command-Line Interface

The e0018.py module can be executed as a standalone script. It accepts the following command-line arguments:

Arguments:

  • --config (str, required): Path to the TOML configuration file.

Example Usage:

```bash python e0018.py --config config.toml