Output the field function `func` to an HDF5 file in the datasets named `name*.r` and `name*.i` for the real and imaginary parts. Similar to `integrate_field_function`, `func` is a function of position (a `Vector3`) and the field components corresponding to `cs`: a li
(self, name, cs, func, real_only=False, h5file=None)
| 4324 | ) |
| 4325 | |
| 4326 | def output_field_function(self, name, cs, func, real_only=False, h5file=None): |
| 4327 | """ |
| 4328 | Output the field function `func` to an HDF5 file in the datasets named `name*.r` |
| 4329 | and `name*.i` for the real and imaginary parts. Similar to |
| 4330 | `integrate_field_function`, `func` is a function of position (a `Vector3`) and the |
| 4331 | field components corresponding to `cs`: a list of `component` constants. If |
| 4332 | `real_only` is True, only outputs the real part of `func`. |
| 4333 | """ |
| 4334 | if self.fields is None: |
| 4335 | raise RuntimeError( |
| 4336 | "Fields must be initialized before calling output_field_function" |
| 4337 | ) |
| 4338 | |
| 4339 | ov = self.output_volume if self.output_volume else self.fields.total_volume() |
| 4340 | h5 = self.output_append_h5 if h5file is None else h5file |
| 4341 | append = h5file is None and self.output_append_h5 is not None |
| 4342 | |
| 4343 | self.fields.output_hdf5( |
| 4344 | name, |
| 4345 | [cs, func], |
| 4346 | ov, |
| 4347 | h5, |
| 4348 | append, |
| 4349 | self.output_single_precision, |
| 4350 | self.get_filename_prefix(), |
| 4351 | real_only, |
| 4352 | ) |
| 4353 | if h5file is None: |
| 4354 | self.output_h5_hook( |
| 4355 | self.fields.h5file_name(name, self.get_filename_prefix(), True) |
| 4356 | ) |
| 4357 | |
| 4358 | def _get_field_function_volume(self, where=None, center=None, size=None): |
| 4359 | try: |