@@ -112,12 +112,17 @@ def plot_interactive_spectra(
112112 A list of spectra, where each spectrum is a list of lists of float values, each
113113 corresponding to the transmission of a single wavelength.
114114 wavelengths : list of float
115- A list of wavelength values corresponding to the x-axis of the plot, in nm .
115+ A list of wavelength values corresponding to the x-axis of the plot, in um .
116116 vlines : list of float, optional
117- A list of x-values where vertical lines should be drawn, in nm . Defaults to an empty list.
117+ A list of x-values where vertical lines should be drawn, in um . Defaults to an empty list.
118118 hlines : list of float, optional
119119 A list of y-values where horizontal lines should be drawn. Defaults to an empty list.
120120 """
121+
122+ # Convert wavelengths to nm
123+ wavelengths = [wl * 1e3 for wl in wavelengths ]
124+ vlines = [wl * 1e3 for wl in vlines ]
125+
121126 if isinstance (spectra , dict ):
122127 port_keys = []
123128 for key in spectra :
@@ -460,23 +465,25 @@ def print_statements(
460465
461466
462467def _str_units_to_float (str_units : str ) -> Optional [float ]:
468+ """Returns the numeric value of a string with units in micrometers, e.g. '1550 nm' -> 1.55"""
469+ """Return None if the string is not a valid unit."""
463470 unit_conversions = {
464- "nm" : 1 ,
465- "um" : 1e3 ,
466- "mm" : 1e6 ,
467- "m" : 1e9 ,
471+ "nm" : 1e-3 ,
472+ "um" : 1 ,
473+ "mm" : 1e3 ,
474+ "m" : 1e6 ,
468475 }
469476 match = re .match (r"([\d\.]+)\s*([a-zA-Z]+)" , str_units )
470477 numeric_value = float (match .group (1 )) if match else None
471478 unit = match .group (2 ) if match else None
472479 return float (numeric_value * unit_conversions [unit ]) if unit in unit_conversions and numeric_value is not None else None
473480
474481
475- def get_wavelengths_to_plot (statements : StatementDictionary , num_samples : int = 100 ) -> Tuple [List [float ], List [float ]]:
482+ def get_wavelengths_to_plot (statements : StatementDictionary , num_samples : int = 1000 ) -> Tuple [List [float ], List [float ]]:
476483 """
477484 Get the wavelengths to plot based on the statements.
478485
479- Returns a list of wavelengths to plot the spectra and a list of vertical lines to plot on top the spectra, in nm .
486+ Returns a list of wavelengths to plot the spectra and a list of vertical lines to plot on top the spectra, in um .
480487 """
481488
482489 min_wl = float ("inf" )
0 commit comments