rsoft_cad.utils.rsoft_file_io package
Submodules
rsoft_cad.utils.rsoft_file_io.filesystem module
Filesystem module for RSoft CAD utilities
- rsoft_cad.utils.rsoft_file_io.filesystem.copy_files_to_destination(file_list, destination_folder)[source]
Copy a list of files to a destination folder.
Parameters: file_list (list): List of file paths to copy destination_folder (str): Path to the folder where files will be copied
Returns: list: List of paths of copied files
- rsoft_cad.utils.rsoft_file_io.filesystem.get_next_run_folder(folder_path, prefix)[source]
Find all folders with the given prefix in the specified path, identify the maximum run number, and return the next run folder name.
- rsoft_cad.utils.rsoft_file_io.filesystem.copy_files_by_extension(expt_dir, extension, include_subfolders=True)[source]
Finds files with a specific extension in a source folder and copies them to a destination folder.
rsoft_cad.utils.rsoft_file_io.finders module
Finders module for RSoft CAD utilities
- rsoft_cad.utils.rsoft_file_io.finders.find_fld_files(folder_path, include_subfolders=False)[source]
Find all files with .fld extension in the specified folder.
Parameters: folder_path (str): Path to the folder to search in include_subfolders (bool): If True, search in subfolders as well (recursive search)
Returns: list: List of .fld filenames found
- rsoft_cad.utils.rsoft_file_io.finders.find_mon_files(folder_path, include_subfolders=False)[source]
Find all files with .mon extension in the specified folder. Parameters: folder_path (str): Path to the folder to search in include_subfolders (bool): If True, search in subfolders as well (recursive search) Returns: list: List of .mon filenames found
- rsoft_cad.utils.rsoft_file_io.finders.find_files_by_extension(folder_path, extension, include_subfolders=False)[source]
Find all files with the specified extension in the given folder.
Parameters: folder_path (str): Path to the folder to search in extension (str): File extension to search for (e.g., “.nef”, “.mon”)
Can be provided with or without the leading dot
include_subfolders (bool): If True, search in subfolders as well (recursive search)
Returns: list: List of filenames with the specified extension
rsoft_cad.utils.rsoft_file_io.readers module
Readers module for RSoft CAD utilities
- rsoft_cad.utils.rsoft_file_io.readers.read_mon_file(file_path)[source]
Read a .mon file into a pandas DataFrame.
Parameters: file_path (str): Path to the .mon file
Returns: tuple: (header_info, data_df) where:
header_info is a dictionary containing monitor metadata
data_df is a pandas DataFrame with z-axis as the first column and monitor readings as other columns
- rsoft_cad.utils.rsoft_file_io.readers.read_nef_file(file_path)[source]
Read and parse a .nef file containing effective refractive index data.
Parameters: file_path (str): Path to the .nef file
Returns: dict: Dictionary containing parsed data with the following keys:
‘indices’: Array of index values (first column)
‘n_eff_real’: Array of real parts of effective refractive index (second column)
‘n_eff_imag’: Array of imaginary parts of effective refractive index (third column)
‘n_eff_complex’: Array of complex numbers (real + j*imag)
- rsoft_cad.utils.rsoft_file_io.readers.read_field_data(filename)[source]
Read complex data from a 2D uniform grid file format and return as a dictionary.
The file format follows this syntax: /rn,a,b/nx0 /rn,qa,qb Nx X0 Xn Zpos Output_Type Optional_Data Ny Y0 Yn Data(X0,Y0) … Data(X0,Yn) … … … Data(Xn,Y0) … Data(Xn,Yn)
Returns a dictionary with parsed data and metadata.
rsoft_cad.utils.rsoft_file_io.write_lp_modes_to_rsoft module
- rsoft_cad.utils.rsoft_file_io.write_lp_modes_to_rsoft.generate_and_write_lp_modes(mode_field_diam: float = 25, highest_mode: str = 'LP02', num_grid_x: int = 250, num_grid_y: int = 250, output_dir: str = './sandbox/ideal_modes', ref_prefix: str = 'ref_LP') None[source]
Generate and write linearly polarized (LP) optical fiber mode fields to files.
This function generates various LP modes up to the specified highest mode (e.g., “LP02”), calculates their field distributions based on the provided parameters, and writes the field data to files in the specified output directory.
- Parameters:
mode_field_diam (float, default=25) – Mode field diameter, determining the spatial extent of the optical mode.
highest_mode (str, default="LP02") – The highest LP mode to generate, in format “LPmn” where: - m is the azimuthal mode number - n is the radial mode number
num_grid_x (int, default=250) – Number of grid points in the x-direction.
num_grid_y (int, default=250) – Number of grid points in the y-direction.
output_dir (str, default="./sandbox/ideal_modes") – Directory where the field data files will be saved. Will be created if it doesn’t exist.
- Returns:
The function writes files to disk but does not return any values.
- Return type:
None
Notes
For modes with azimuthal number > 0, both ‘a’ and ‘b’ variants are generated, each with both Vertical (V) and Horizontal (H) polarizations. For modes with azimuthal number = 0, only ‘a’ variants are generated with both V and H polarizations.
rsoft_cad.utils.rsoft_file_io.writers module
- rsoft_cad.utils.rsoft_file_io.writers.write_femsim_field_data(filename, complex_data, xmin, xmax, ymin, ymax, z_pos=0, output_type='OUTPUT_REAL_IMAG_3D', effective_index=1.0, wavelength=1.55, format_suffix='/ls1')[source]
Write complex field data to a 2D uniform grid file in RSoft format.
Parameters:
- filenamestr
Path to the output file
- complex_datanumpy.ndarray
2D numpy array of complex values with shape (nx, ny)
- xmin, xmaxfloat
X-axis range
- ymin, ymaxfloat
Y-axis range
- z_posfloat, optional
Z position of the field data. Default is 0.
- output_typestr, optional
Type of output data. Default is “OUTPUT_REAL_IMAG_3D”.
- effective_indexfloat, optional
Effective index value. Default is 1.0.
- wavelengthfloat, optional
Wavelength value in μm. Default is 1.55.
- format_suffixstr, optional
Suffix for the format line. Default is “/ls1”.
Returns:
None