Utilities Module#
The utilities module contains helper functions and utilities.
Data selection utilities for electromagnetic field training.
This module provides functionality to select initial training data from the available dataset. Selected data are output to X_train_new.txt.
- class EMFieldML.Utils.DataSelect.DataSelect#
Bases:
objectSelect and manage initial training data for electromagnetic field models.
- static select_init_data(n_total_shapes: int = 372) list[int]#
Select initial training data using a systematic sampling pattern.
Float comparison utilities for electromagnetic field validation.
This module provides a class for comparing lists of floats within a specified precision.
- class EMFieldML.Utils.FloatAssert.FloatAssert(precision: float = 1e-07)#
Bases:
objectFloat comparison utility for electromagnetic field validation.
- __init__(precision: float = 1e-07)#
Initialize the validator with a specified precision.
- Parameters:
precision – The precision threshold for float comparisons.
- read_floats_from_file(file_path: Path) numpy.ndarray#
Read a list of floats from a specified file, assuming space-separated values in each line.
- Parameters:
file_path – Path to the file to read.
- Returns:
A NumPy array of floats read from the file.
- compare_files(file1: Path, file2: Path) bool#
Compare two files containing lists of floats.
- Parameters:
file1 – Path to the first file.
file2 – Path to the second file.
- Returns:
True if the files are equivalent within the specified precision, False otherwise.
- compare_float_arrays(array1: numpy.ndarray, array2: numpy.ndarray) bool#
Compare two arrays of floats within the specified precision.
- Parameters:
array1 – The first array of floats.
array2 – The second array of floats.
- Returns:
True if the arrays are equivalent within the precision, False otherwise.
Custom logger class to add line numbers to log messages with a level of WARNING or higher.
- class EMFieldML.Utils.logger.Logger(level=20, fmt=None, log_file=None, log_dir='log')#
Bases:
objectCustom logger class to add line numbers to log messages with a level of WARNING or higher.
- __init__(level=20, fmt=None, log_file=None, log_dir='log')#
Initialize the CustomLogger class.
- class LineNumberFilter(name='')#
Bases:
FilterCustom filter class to add line numbers.
- filter(record)#
Filter log records to add line number information.
Ferrite shield modeling and parameter generation.
Create parameters for the ferrite shield. 372 types of ferrite shield shapes are created. By preparing 169 positions for these, a total of 62,868 pieces of data are created.