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

Method handle_cvector_dataset

python/mpb_data.py:133–227  ·  view source on GitHub ↗
(self, in_arr, multiply_bloch_phase)

Source from the content-addressed store, hash-verified

131 return np.reshape(out_arr_re, out_dims[:rank])
132
133 def handle_cvector_dataset(self, in_arr, multiply_bloch_phase):
134 in_x_re = np.real(in_arr[:, :, :, 0]).ravel()
135 in_x_im = np.imag(in_arr[:, :, :, 0]).ravel()
136 in_y_re = np.real(in_arr[:, :, :, 1]).ravel()
137 in_y_im = np.imag(in_arr[:, :, :, 1]).ravel()
138 in_z_re = np.real(in_arr[:, :, :, 2]).ravel()
139 in_z_im = np.imag(in_arr[:, :, :, 2]).ravel()
140
141 d_in = [[in_x_re, in_x_im], [in_y_re, in_y_im], [in_z_re, in_z_im]]
142 in_dims = [in_arr.shape[0], in_arr.shape[1], 1]
143 if self.verbose:
144 print("Found complex vector dataset...")
145
146 if self.verbose:
147 fmt = "Input data is rank {}, size {}x{}x{}."
148 rank = 2
149
150 print(fmt.format(rank, in_dims[0], in_dims[1], in_dims[2]))
151
152 # rotate vector field according to cart_map
153 if self.verbose:
154 fmt1 = "Rotating vectors by matrix [ {:.10g}, {:.10g}, {:.10g}"
155 fmt2 = " {:.10g}, {:.10g}, {:.10g}"
156 fmt3 = " {:.10g}, {:.10g}, {:.10g} ]"
157 print(
158 fmt1.format(self.cart_map.c1.x, self.cart_map.c2.x, self.cart_map.c3.x)
159 )
160 print(
161 fmt2.format(self.cart_map.c1.y, self.cart_map.c2.y, self.cart_map.c3.y)
162 )
163 print(
164 fmt3.format(self.cart_map.c1.z, self.cart_map.c2.z, self.cart_map.c3.z)
165 )
166
167 N = in_dims[0] * in_dims[1]
168 for ri in range(2):
169 for i in range(N):
170 v = mp.Vector3(d_in[0][ri][i], d_in[1][ri][i], d_in[2][ri][i])
171 v = self.cart_map * v
172 d_in[0][ri][i] = v.x
173 d_in[1][ri][i] = v.y
174 d_in[2][ri][i] = v.z
175
176 out_dims = [1, 1, 1]
177
178 if self.resolution > 0:
179 out_dims[0] = self.Rout.c1.norm() * self.resolution + 0.5
180 out_dims[1] = self.Rout.c2.norm() * self.resolution + 0.5
181 out_dims[2] = self.Rout.c3.norm() * self.resolution + 0.5
182 else:
183 for i in range(3):
184 out_dims[i] = in_dims[i] * self.multiply_size[i]
185
186 out_dims[2] = 1
187
188 N = 1
189 for i in range(3):
190 out_dims[i] = int(max(out_dims[i], 1))

Callers 1

convertMethod · 0.95

Calls 3

map_dataFunction · 0.85
normMethod · 0.80
maxFunction · 0.50

Tested by

no test coverage detected