| 314 | self.cart_map = cart_map |
| 315 | |
| 316 | def convert(self, arr, kpoint=None): |
| 317 | if isinstance(arr, MPBArray): |
| 318 | self.lattice = arr.lattice |
| 319 | self.kpoint = arr.kpoint |
| 320 | |
| 321 | if self.lattice is None: |
| 322 | err = ( |
| 323 | "Couldn't find 'lattice.' You must do one of the following:\n" |
| 324 | + " 1. Pass the ModeSolver lattice to the MPBData constructor\n" |
| 325 | + " i.e., MPBData(lattice=ms.get_lattice())\n" |
| 326 | + " 2. Create an MPBArray to pass to MPBData.convert()\n" |
| 327 | + " i.e., mpb_arr = MPBArray(arr, ms.get_lattice(), ... ); mpb_data.convert(mpb_arr))" |
| 328 | ) |
| 329 | raise ValueError(err) |
| 330 | |
| 331 | if kpoint: |
| 332 | self.kpoint = kpoint |
| 333 | |
| 334 | self.init_output_lattice() |
| 335 | |
| 336 | if len(arr.shape) == 4: |
| 337 | return self.handle_cvector_dataset(arr, not arr.bloch_phase) |
| 338 | else: |
| 339 | return self.handle_dataset(arr) |