MCPcopy Create free account
hub / github.com/NanoComp/meep / get_dft_array

Method get_dft_array

python/simulation.py:4013–4055  ·  view source on GitHub ↗

Returns the Fourier-transformed fields as a NumPy array. The type is either `numpy.complex64` or `numpy.complex128` depending on the [floating-point precision of the fields](Build_From_Source.md#floating-point-precision-of-the-fields-and-materials-arrays). The DFT fields are centere

(
        self,
        dft_obj: DftObj = None,
        component: int = None,
        num_freq: int = None,
    )

Source from the content-addressed store, hash-verified

4011 return arr
4012
4013 def get_dft_array(
4014 self,
4015 dft_obj: DftObj = None,
4016 component: int = None,
4017 num_freq: int = None,
4018 ):
4019 """
4020 Returns the Fourier-transformed fields as a NumPy array. The type is either `numpy.complex64`
4021 or `numpy.complex128` depending on the [floating-point precision of the fields](Build_From_Source.md#floating-point-precision-of-the-fields-and-materials-arrays). The DFT fields are centered on the Yee-grid voxels using bilinear interpolation of the nearest Yee-grid points.
4022
4023 + **`dft_obj` [ `DftObj` class ]** — A `dft_flux`, `dft_force`, `dft_fields`, or `dft_near2far` object
4024 obtained from calling the appropriate `add` function (e.g., `mp.add_flux`).
4025
4026 + **`component` [ `component` constant ]**— The field component (e.g., `meep.Ez`).
4027
4028 + **`num_freq` [ `int` ]** — The index of the frequency. An integer in the range `0...nfreq-1`,
4029 where `nfreq` is the number of frequencies stored in `dft_obj` as set by the
4030 `nfreq` parameter to `add_dft_fields`, `add_flux`, etc.
4031 """
4032 if not self.dft_objects:
4033 raise RuntimeError(
4034 "DFT monitor dft_obj must be initialized before calling get_dft_array"
4035 )
4036
4037 if hasattr(dft_obj, "swigobj"):
4038 dft_swigobj = dft_obj.swigobj
4039 else:
4040 dft_swigobj = dft_obj
4041
4042 if type(dft_swigobj) is mp.dft_fields:
4043 return mp.get_dft_fields_array(
4044 self.fields, dft_swigobj, component, num_freq
4045 )
4046 elif type(dft_swigobj) is mp.dft_flux:
4047 return mp.get_dft_flux_array(self.fields, dft_swigobj, component, num_freq)
4048 elif type(dft_swigobj) is mp.dft_force:
4049 return mp.get_dft_force_array(self.fields, dft_swigobj, component, num_freq)
4050 elif type(dft_swigobj) is mp.dft_near2far:
4051 return mp.get_dft_near2far_array(
4052 self.fields, dft_swigobj, component, num_freq
4053 )
4054 else:
4055 raise ValueError(f"Invalid type of dft object: {dft_swigobj}")
4056
4057 def get_source(self, component, vol=None, center=None, size=None):
4058 """

Callers 14

test_array_metadataMethod · 0.95
_load_dump_fields_2dMethod · 0.95
_load_dump_fields_3dMethod · 0.95
test_nea2far_periodicMethod · 0.95
gaussian_beamMethod · 0.95
planewave_in_vacuumMethod · 0.95
backwardFunction · 0.95
test_get_dft_arrayMethod · 0.45
cavity-farfield.pyFile · 0.45
solve-cw.pyFile · 0.45
finite_grating.pyFile · 0.45

Calls 1

typeFunction · 0.85