rsoft_cad.utils package

RSoft CAD Utilities

This package provides utilities for working with RSoft CAD files, creating and manipulating photonic lantern layouts, and visualizing data.

Subpackages

Submodules

rsoft_cad.utils.fiber_utils module

rsoft_cad.utils.fiber_utils.get_fiber_type_list_by_indices(smf_df: DataFrame, indices: List[int]) List[str][source]

Return a list of fiber types based on DataFrame row indices.

Parameters:
  • smf_df – DataFrame containing fiber specifications

  • indices – List of row indices in the DataFrame

Returns:

List of fiber type strings corresponding to the indices

rsoft_cad.utils.fiber_utils.print_dict(dict_obj: Dict[str, Any], width: int = 80, indent: int = 4) None[source]

Print a dictionary with indented values.

Parameters:
  • dict_obj – Dictionary to print

  • width – Width of the separator line

  • indent – Number of spaces to use for indentation

rsoft_cad.utils.fiber_utils.fiber_assignment(core_map: Dict[str, Any], fiber_type_list: List[str], smf_df: DataFrame, columns_to_include: List[str] | None = None) Dict[str, Dict[str, Any]][source]

Assign fiber properties to each core in the core map for all or selected columns.

Parameters:
  • core_map – Dictionary mapping LP modes to their properties

  • fiber_type_list – List of fiber types to assign to cores

  • smf_df – DataFrame containing fiber specifications

  • columns_to_include – If provided, only process these columns. If None, process all columns.

Returns:

  • Keys are column names from the DataFrame

  • Values are dictionaries mapping LP modes to their respective property values

Return type:

Dictionary where

rsoft_cad.utils.lp_modes module

rsoft_cad.utils.lp_modes.generate_lp_mode(l, p, orientation, mfd, xmin, xmax, ymin, ymax, num_grid_x, num_grid_y)[source]

Generate LP mode with specified parameters and orientation Parameters: l: azimuthal mode index p: radial mode index (p-1 gives the number of radial nodes) orientation: ‘a’ (even/cosine), ‘b’ (odd/sine), or ‘both’ (combined with arbitrary phase) mfd: Mode Field Diameter (μm) xmin, xmax: x-axis range (μm) ymin, ymax: y-axis range (μm) num_grid_x: Number of grid points in x direction num_grid_y: Number of grid points in y direction

rsoft_cad.utils.lp_modes.plot_lp_mode(X, Y, field, l, p, orientation, mfd)[source]

rsoft_cad.utils.mode_utils module

Utility functions for working with optical modes in the RSoft CAD package.

rsoft_cad.utils.mode_utils.get_modes_below_cutoff(input_mode, lp_mode_cutoffs_freq)[source]

Return all modes with cutoff frequencies less than or equal to the cutoff frequency of the input mode.

Parameters:
  • input_mode (str) – The mode string (e.g., “LP21”)

  • lp_mode_cutoffs_freq (dict) – Dictionary mapping mode strings to cutoff frequencies

Returns:

List of mode strings with cutoff frequencies <= the input mode’s cutoff

Return type:

list

rsoft_cad.utils.mode_utils.group_modes_by_radial_number(supported_modes)[source]

Group LP modes by their radial number.

For LP modes in format “LPml”, where: - m is the azimuthal number (first digit) - l is the radial number (second digit)

Parameters:

supported_modes (list) – List of LP mode strings (e.g., [“LP01”, “LP11”, “LP21”])

Returns:

Dictionary mapping radial numbers to lists of modes

Return type:

dict

rsoft_cad.utils.mode_utils.find_segment_by_comp_name(segments, comp_name)[source]

Find a segment by its component name.

Parameters:
  • segments (list) – List of segment strings

  • comp_name (str) – Component name to search for

Returns:

Segment number if found

Return type:

str

Raises:

ValueError – If component is not found in any segment

rsoft_cad.utils.mode_utils.interpolate_taper_value(model, key, z_pos, mode_name=None)[source]

Interpolate a value from the taper model at a specific z-position.

Parameters:

modeldict

The taper model dictionary containing the data

keystr

The key in the model dictionary to interpolate. Must be one of: “fiber_diameters”, “core_diameters”, “fiber_positions”, “capillary_inner_diameter”, “capillary_outer_diameter”, “mode_positions”, or “mode_core_diameters”

z_posfloat

The z-position at which to interpolate

mode_namestr, optional

For mode-related keys (“mode_positions”, “mode_core_diameters”), the LP mode name to interpolate. Required for these keys.

Returns:

float

The interpolated value at the specified z-position