def transfer_function(nu: np.ndarray, center_nu: float, nu_bw: float, nu_offset: float = 0.): """The transfer function of the flat top window. Parameters ---------- nu : The frequency components. :math:`[ps^{-1}]` center_nu : The center frequency. :math:`[ps^{-1}]` nu_bw : The spectral bandwith. :math:`[ps^{-1}]` nu_offset : The offset frequency. :math:`[ps^{-1}]` """ window = FlatTopFilter.amplitude_transfer_function(nu, center_nu, nu_bw, nu_offset) return Field.temporal_power(window)
def transfer_function(time: np.ndarray, v_pi: List[float], v_bias: List[float], v_mod: List[Union[float, Callable]]) -> np.ndarray: v_pi = util.make_list(v_pi, 2) v_bias = util.make_list(v_bias, 2) v_mod = util.make_list(v_mod, 2) v_mod_: List[Callable] = [] for v in v_mod: if (callable(v)): v_mod_.append(v) else: v_mod_.append(lambda t: v) print(v_pi, v_bias, v_mod_) phase_shift = [ lambda t: cst.PI * (v_bias[0] + v_mod_[0](t)) / v_pi[0], lambda t: cst.PI * (v_bias[1] + v_mod_[1](t)) / v_pi[1] ] tf = np.cos((phase_shift[0](time) - phase_shift[1](time)) / 2.) return Field.temporal_power(tf)
def __call__(self, domain: Domain, ports: List[int], fields: List[Field] ) -> Tuple[List[int], List[Field]]: output_fields: List[Field] = [] for field in fields: # Channels for i in range(len(field)): window = np.zeros(field[i].shape, dtype=complex) window = self.window(field.nu[i], self.center_nu, self.nu_bw, self.nu_offset) window_shift = FFT.ifftshift(window) field[i] = FFT.ifft(window_shift * FFT.fft(field[i])) # Noise if (self.NOISE): field.noise *= Field.temporal_power(self.window( domain.noise_nu, self.center_nu, self.nu_bw, self.nu_offset)) output_fields.append(field) return self.output_ports(ports), output_fields
def _calc_power_for_ratio(self, array: np.ndarray): return np.sum(Field.temporal_power(array), axis=1).reshape((-1, 1))
def get_criterion(self, waves_f, waves_b): criterion = np.sum(Field.temporal_power(waves_f)) criterion += np.sum(Field.temporal_power(waves_b)) return criterion
RS=False, XPM=False, ASYM=True, COUP=True, approx_type=1, nlse_method='ssfm_super_sym', steps=steps, ode_method=method, save=True, wait=False, NOISE=True) lt.add_link(pulse[0], coupler[0]) lt.run(pulse) lt.reset() # Plot parameters and get waves x_datas.append(coupler[2][0].time) y_datas.append(Field.temporal_power(coupler[2][0].channels)) plot_groups.append(0) line_labels.extend(ode_methods) plot_titles.extend(["ODE solvers test with n={}".format(str(steps))]) # -------------------- Plotting results ------------------------ plot.plot2d(x_datas, y_datas, plot_groups=plot_groups, plot_titles=plot_titles, x_labels=['t'], y_labels=['P_t'], line_labels=line_labels, line_opacities=[0.1])