@@ -103,8 +103,6 @@ def _mode_voltage_coefficients(self, mode_data: ModeData) -> FreqModeDataArray:
103103 to the total port voltage.
104104 """
105105 flux_sign = 1 if self .direction == "+" else - 1
106-
107- mode_data = mode_data ._isel (mode_index = [self .mode_index ])
108106 if self .voltage_integral is None :
109107 flux_sign = 1 if mode_data .monitor .store_fields_direction == "+" else - 1
110108 current_coeffs = self .current_integral .compute_current (mode_data )
@@ -118,7 +116,6 @@ def _mode_current_coefficients(self, mode_data: ModeData) -> FreqModeDataArray:
118116 to the total port current.
119117 """
120118 flux_sign = 1 if self .direction == "+" else - 1
121- mode_data = mode_data ._isel (mode_index = [self .mode_index ])
122119 if self .current_integral is None :
123120 flux_sign = 1 if mode_data .monitor .store_fields_direction == "+" else - 1
124121 voltage_coeffs = self .voltage_integral .compute_voltage (mode_data )
@@ -221,20 +218,20 @@ def to_absorber(
221218
222219 def compute_voltage (self , sim_data : SimulationData ) -> FreqDataArray :
223220 """Helper to compute voltage across the port."""
224- mode_data = sim_data [self ._mode_monitor_name ]
221+ mode_data = sim_data [self ._mode_monitor_name ]. _isel ( mode_index = [ self . mode_index ])
225222 voltage_coeffs = self ._mode_voltage_coefficients (mode_data )
226223 amps = mode_data .amps
227- fwd_amps = amps .sel (direction = "+" ).squeeze ()
228- bwd_amps = amps .sel (direction = "-" ).squeeze ()
224+ fwd_amps = amps .sel (direction = "+" , mode_index = self . mode_index ).squeeze ()
225+ bwd_amps = amps .sel (direction = "-" , mode_index = self . mode_index ).squeeze ()
229226 return voltage_coeffs * (fwd_amps + bwd_amps )
230227
231228 def compute_current (self , sim_data : SimulationData ) -> FreqDataArray :
232229 """Helper to compute current flowing through the port."""
233- mode_data = sim_data [self ._mode_monitor_name ]
230+ mode_data = sim_data [self ._mode_monitor_name ]. _isel ( mode_index = [ self . mode_index ])
234231 current_coeffs = self ._mode_current_coefficients (mode_data )
235232 amps = mode_data .amps
236- fwd_amps = amps .sel (direction = "+" ).squeeze ()
237- bwd_amps = amps .sel (direction = "-" ).squeeze ()
233+ fwd_amps = amps .sel (direction = "+" , mode_index = self . mode_index ).squeeze ()
234+ bwd_amps = amps .sel (direction = "-" , mode_index = self . mode_index ).squeeze ()
238235 # In ModeData, fwd_amps and bwd_amps are not relative to
239236 # the direction fields are stored
240237 sign = 1.0
0 commit comments