diff --git a/gprMax/cython/geometry_outputs.pyx b/gprMax/cython/geometry_outputs.pyx index f93c58d4..df074aee 100644 --- a/gprMax/cython/geometry_outputs.pyx +++ b/gprMax/cython/geometry_outputs.pyx @@ -45,7 +45,7 @@ cpdef get_line_properties( material IDs for each line. """ cdef np.ndarray material_data = np.zeros(number_of_lines, dtype=np.uint32) - cdef np.ndarray connectivity = np.zeros(2 * number_of_lines, dtype=np.intc) + cdef np.ndarray connectivity = np.zeros(2 * number_of_lines, dtype=np.int32) cdef int line_index = 0 cdef int connectivity_index = 0 cdef int point_id = 0 diff --git a/gprMax/geometry_outputs.py b/gprMax/geometry_outputs.py index 3416e8cb..9f971568 100644 --- a/gprMax/geometry_outputs.py +++ b/gprMax/geometry_outputs.py @@ -101,9 +101,9 @@ class GeometryView(ABC): grid: FDTDGrid class describing a grid in a model. """ - self.start = np.array([xs, ys, zs], dtype=np.intc) - self.stop = np.array([xf, yf, zf], dtype=np.intc) - self.step = np.array([dx, dy, dz], dtype=np.intc) + self.start = np.array([xs, ys, zs], dtype=np.int32) + self.stop = np.array([xf, yf, zf], dtype=np.int32) + self.step = np.array([dx, dy, dz], dtype=np.int32) self.size = (self.stop - self.start) // self.step self.filename = Path(filename) @@ -224,7 +224,7 @@ class GeometryViewLines(GeometryView): n_lines = 3 * self.nx * self.ny * self.nz self.cell_types = np.full(n_lines, VtkCellType.LINE) - self.cell_offsets = np.arange(0, 2 * n_lines + 2, 2, dtype=np.intc) + self.cell_offsets = np.arange(0, 2 * n_lines + 2, 2, dtype=np.int32) self.connectivity, self.material_data = get_line_properties( n_lines, self.nx, self.ny, self.nz, ID @@ -330,7 +330,7 @@ class Metadata: self.gprmax_version = __version__ self.dx_dy_dz = self.grid.dl - self.nx_ny_nz = np.array([self.grid.nx, self.grid.ny, self.grid.nz], dtype=np.intc) + self.nx_ny_nz = np.array([self.grid.nx, self.grid.ny, self.grid.nz], dtype=np.int32) self.materials = self.materials_comment() @@ -427,8 +427,8 @@ class Metadata: def dx_dy_dz_comment(self) -> npt.NDArray[np.float64]: return self.grid.dl - def nx_ny_nz_comment(self) -> npt.NDArray[np.intc]: - return np.array([self.grid.nx, self.grid.ny, self.grid.nz], dtype=np.intc) + def nx_ny_nz_comment(self) -> npt.NDArray[np.int32]: + return np.array([self.grid.nx, self.grid.ny, self.grid.nz], dtype=np.int32) def materials_comment(self) -> List[str]: if not self.averaged_materials: diff --git a/gprMax/grid/mpi_grid.py b/gprMax/grid/mpi_grid.py index 88797a22..c3e3d1a8 100644 --- a/gprMax/grid/mpi_grid.py +++ b/gprMax/grid/mpi_grid.py @@ -57,7 +57,7 @@ class MPIGrid(FDTDGrid): COORDINATOR_RANK = 0 def __init__(self, comm: MPI.Cartcomm): - self.size = np.zeros(3, dtype=np.intc) + self.size = np.zeros(3, dtype=np.int32) self.comm = comm self.x_comm = comm.Sub([False, True, True]) @@ -65,12 +65,12 @@ class MPIGrid(FDTDGrid): self.z_comm = comm.Sub([True, True, False]) self.pml_comm = MPI.COMM_NULL - self.mpi_tasks = np.array(self.comm.dims, dtype=np.intc) + self.mpi_tasks = np.array(self.comm.dims, dtype=np.int32) - self.lower_extent = np.zeros(3, dtype=np.intc) - self.upper_extent = np.zeros(3, dtype=np.intc) + self.lower_extent = np.zeros(3, dtype=np.int32) + self.upper_extent = np.zeros(3, dtype=np.int32) self.negative_halo_offset = np.zeros(3, dtype=np.bool_) - self.global_size = np.zeros(3, dtype=np.intc) + self.global_size = np.zeros(3, dtype=np.int32) self.neighbours = np.full((3, 2), -1, dtype=int) self.neighbours[Dim.X] = self.comm.Shift(direction=Dim.X, disp=1) @@ -164,7 +164,7 @@ class MPIGrid(FDTDGrid): """ return self.rank == self.COORDINATOR_RANK - def get_grid_coord_from_coordinate(self, coord: npt.NDArray[np.intc]) -> npt.NDArray[np.intc]: + def get_grid_coord_from_coordinate(self, coord: npt.NDArray[np.int32]) -> npt.NDArray[np.int32]: """Get the MPI grid coordinate for a global grid coordinate. Args: @@ -224,8 +224,8 @@ class MPIGrid(FDTDGrid): return [coord_to_rank(coord) for coord in np.ndindex(*(stop - start))] def global_to_local_coordinate( - self, global_coord: npt.NDArray[np.intc] - ) -> npt.NDArray[np.intc]: + self, global_coord: npt.NDArray[np.int32] + ) -> npt.NDArray[np.int32]: """Convert a global grid coordinate to a local grid coordinate. The returned coordinate will be relative to the current MPI @@ -240,7 +240,9 @@ class MPIGrid(FDTDGrid): """ return global_coord - self.lower_extent - def local_to_global_coordinate(self, local_coord: npt.NDArray[np.intc]) -> npt.NDArray[np.intc]: + def local_to_global_coordinate( + self, local_coord: npt.NDArray[np.int32] + ) -> npt.NDArray[np.int32]: """Convert a local grid coordinate to a global grid coordinate. Args: @@ -252,7 +254,7 @@ class MPIGrid(FDTDGrid): return local_coord + self.lower_extent def global_coord_inside_grid( - self, global_coord: npt.NDArray[np.intc], allow_inside_halo: bool = False + self, global_coord: npt.NDArray[np.int32], allow_inside_halo: bool = False ) -> bool: """Check if a global coordinate falls with in the local grid. @@ -277,7 +279,7 @@ class MPIGrid(FDTDGrid): return all(global_coord >= lower_bound) and all(global_coord <= upper_bound) def global_bounds_overlap_local_grid( - self, start: npt.NDArray[np.intc], stop: npt.NDArray[np.intc] + self, start: npt.NDArray[np.int32], stop: npt.NDArray[np.int32] ) -> bool: local_start = self.global_to_local_coordinate(start) local_stop = self.global_to_local_coordinate(stop) @@ -285,10 +287,10 @@ class MPIGrid(FDTDGrid): def limit_global_bounds_to_within_local_grid( self, - start: npt.NDArray[np.intc], - stop: npt.NDArray[np.intc], - step: npt.NDArray[np.intc] = np.ones(3, dtype=np.intc), - ) -> Tuple[npt.NDArray[np.intc], npt.NDArray[np.intc], npt.NDArray[np.intc]]: + start: npt.NDArray[np.int32], + stop: npt.NDArray[np.int32], + step: npt.NDArray[np.int32] = np.ones(3, dtype=np.int32), + ) -> Tuple[npt.NDArray[np.int32], npt.NDArray[np.int32], npt.NDArray[np.int32]]: local_start = self.global_to_local_coordinate(start) # Bring start into the local grid (and not in the negative halo) @@ -801,7 +803,7 @@ class MPIGrid(FDTDGrid): if p[2] < 0 or p[2] > self.gz: raise ValueError("z") - local_point = self.global_to_local_coordinate(np.array(p, dtype=np.intc)) + local_point = self.global_to_local_coordinate(np.array(p, dtype=np.int32)) return all(local_point >= self.negative_halo_offset) and all(local_point <= self.size) diff --git a/gprMax/mpi_model.py b/gprMax/mpi_model.py index 72aee350..73da3c28 100644 --- a/gprMax/mpi_model.py +++ b/gprMax/mpi_model.py @@ -74,8 +74,8 @@ class MPIModel(Model): self.geometryobjects = [] for go in objects: - start = np.array([go.xs, go.ys, go.zs], dtype=np.intc) - stop = np.array([go.xf, go.yf, go.zf], dtype=np.intc) + start = np.array([go.xs, go.ys, go.zs], dtype=np.int32) + stop = np.array([go.xf, go.yf, go.zf], dtype=np.int32) if self.G.global_bounds_overlap_local_grid(start, stop): comm = self.comm.Split() assert isinstance(comm, MPI.Intracomm) @@ -83,7 +83,7 @@ class MPIModel(Model): stop_grid_coord = self.G.get_grid_coord_from_coordinate(stop) + 1 go.comm = comm.Create_cart((stop_grid_coord - start_grid_coord).tolist()) - go.global_size = np.array([go.nx, go.ny, go.nz], dtype=np.intc) + go.global_size = np.array([go.nx, go.ny, go.nz], dtype=np.int32) start, stop, offset = self.G.limit_global_bounds_to_within_local_grid(start, stop) go.size = stop - start go.start = start diff --git a/gprMax/receivers.py b/gprMax/receivers.py index 467f94fa..f27dae23 100644 --- a/gprMax/receivers.py +++ b/gprMax/receivers.py @@ -31,8 +31,8 @@ class Rx: def __init__(self): self.ID: str self.outputs = {} - self.coord = np.zeros(3, dtype=np.intc) - self.coordorigin = np.zeros(3, dtype=np.intc) + self.coord = np.zeros(3, dtype=np.int32) + self.coordorigin = np.zeros(3, dtype=np.int32) @property def xcoord(self) -> int: diff --git a/gprMax/snapshots.py b/gprMax/snapshots.py index 48e93770..976f2eec 100644 --- a/gprMax/snapshots.py +++ b/gprMax/snapshots.py @@ -130,10 +130,10 @@ class Snapshot: self.grid_dl = grid_dl self.grid_dt = grid_dt - self.start = np.array([xs, ys, zs], dtype=np.intc) - self.stop = np.array([xf, yf, zf], dtype=np.intc) - self.step = np.array([dx, dy, dz], dtype=np.intc) - self.size = np.ceil((self.stop - self.start) / self.step).astype(np.intc) + self.start = np.array([xs, ys, zs], dtype=np.int32) + self.stop = np.array([xf, yf, zf], dtype=np.int32) + self.step = np.array([dx, dy, dz], dtype=np.int32) + self.size = np.ceil((self.stop - self.start) / self.step).astype(np.int32) self.slice: list[slice] = list(map(slice, self.start, self.stop + self.step, self.step)) self.nbytes = 0 @@ -365,14 +365,14 @@ class MPISnapshot(Snapshot): xs, ys, zs, xf, yf, zf, dx, dy, dz, time, filename, fileext, outputs, grid_dl, grid_dt ) - self.offset = np.zeros(3, dtype=np.intc) + self.offset = np.zeros(3, dtype=np.int32) self.global_size = self.size.copy() self.comm: MPI.Cartcomm = None # type: ignore def initialise_snapfields(self): # Start and stop may have changed since initialisation - self.size = np.ceil((self.stop - self.start) / self.step).astype(np.intc) + self.size = np.ceil((self.stop - self.start) / self.step).astype(np.int32) return super().initialise_snapfields() def has_neighbour(self, dimension: Dim, direction: Dir) -> bool: diff --git a/gprMax/sources.py b/gprMax/sources.py index 9a55017d..1ed6782d 100644 --- a/gprMax/sources.py +++ b/gprMax/sources.py @@ -33,8 +33,8 @@ class Source: def __init__(self): self.ID: str self.polarisation = None - self.coord = np.zeros(3, dtype=np.intc) - self.coordorigin = np.zeros(3, dtype=np.intc) + self.coord = np.zeros(3, dtype=np.int32) + self.coordorigin = np.zeros(3, dtype=np.int32) self.start = 0.0 self.stop = 0.0 self.waveform: Waveform diff --git a/gprMax/vtkhdf_filehandlers/vtk_image_data.py b/gprMax/vtkhdf_filehandlers/vtk_image_data.py index 9cc44622..0d2b3137 100644 --- a/gprMax/vtkhdf_filehandlers/vtk_image_data.py +++ b/gprMax/vtkhdf_filehandlers/vtk_image_data.py @@ -29,7 +29,7 @@ class VtkImageData(VtkHdfFile): def __init__( self, filename: Union[str, PathLike], - shape: npt.NDArray[np.intc], + shape: npt.NDArray[np.int32], origin: Optional[npt.NDArray[np.float32]] = None, spacing: Optional[npt.NDArray[np.float32]] = None, direction: Optional[npt.NDArray[np.float32]] = None, @@ -68,11 +68,11 @@ class VtkImageData(VtkHdfFile): if len(shape) > self.DIMENSIONS: raise ValueError(f"Shape must not have more than {self.DIMENSIONS} dimensions.") elif len(shape) < self.DIMENSIONS: - shape = np.concatenate((shape, np.ones(self.DIMENSIONS - len(shape), dtype=np.intc))) + shape = np.concatenate((shape, np.ones(self.DIMENSIONS - len(shape), dtype=np.int32))) self.shape = shape - whole_extent = np.zeros(2 * self.DIMENSIONS, dtype=np.intc) + whole_extent = np.zeros(2 * self.DIMENSIONS, dtype=np.int32) whole_extent[1::2] = self.shape self._set_root_attribute(self.WHOLE_EXTENT_ATTR, whole_extent) @@ -89,7 +89,7 @@ class VtkImageData(VtkHdfFile): self.set_direction(direction) @property - def whole_extent(self) -> npt.NDArray[np.intc]: + def whole_extent(self) -> npt.NDArray[np.int32]: return self._get_root_attribute(self.WHOLE_EXTENT_ATTR) @property @@ -141,7 +141,7 @@ class VtkImageData(VtkHdfFile): self._set_root_attribute(self.DIRECTION_ATTR, direction) def add_point_data( - self, name: str, data: npt.NDArray, offset: Optional[npt.NDArray[np.intc]] = None + self, name: str, data: npt.NDArray, offset: Optional[npt.NDArray[np.int32]] = None ): """Add point data to the VTKHDF file. @@ -163,7 +163,7 @@ class VtkImageData(VtkHdfFile): return super().add_point_data(name, data, points_shape, offset) def add_cell_data( - self, name: str, data: npt.NDArray, offset: Optional[npt.NDArray[np.intc]] = None + self, name: str, data: npt.NDArray, offset: Optional[npt.NDArray[np.int32]] = None ): """Add cell data to the VTKHDF file. diff --git a/gprMax/vtkhdf_filehandlers/vtk_unstructured_grid.py b/gprMax/vtkhdf_filehandlers/vtk_unstructured_grid.py index 095bd1b1..fa4a687e 100644 --- a/gprMax/vtkhdf_filehandlers/vtk_unstructured_grid.py +++ b/gprMax/vtkhdf_filehandlers/vtk_unstructured_grid.py @@ -101,20 +101,20 @@ class VtkUnstructuredGrid(VtkHdfFile): @property def number_of_cells(self) -> int: number_of_cells = self._get_root_dataset(self.Dataset.NUMBER_OF_CELLS) - return np.sum(number_of_cells, dtype=np.intc) + return np.sum(number_of_cells, dtype=np.int32) @property def number_of_connectivity_ids(self) -> int: number_of_connectivity_ids = self._get_root_dataset(self.Dataset.NUMBER_OF_CONNECTIVITY_IDS) - return np.sum(number_of_connectivity_ids, dtype=np.intc) + return np.sum(number_of_connectivity_ids, dtype=np.int32) @property def number_of_points(self) -> int: number_of_points = self._get_root_dataset(self.Dataset.NUMBER_OF_POINTS) - return np.sum(number_of_points, dtype=np.intc) + return np.sum(number_of_points, dtype=np.int32) def add_point_data( - self, name: str, data: npt.NDArray, offset: Optional[npt.NDArray[np.intc]] = None + self, name: str, data: npt.NDArray, offset: Optional[npt.NDArray[np.int32]] = None ): """Add point data to the VTKHDF file. @@ -143,7 +143,7 @@ class VtkUnstructuredGrid(VtkHdfFile): return super().add_point_data(name, data, shape, offset) def add_cell_data( - self, name: str, data: npt.NDArray, offset: Optional[npt.NDArray[np.intc]] = None + self, name: str, data: npt.NDArray, offset: Optional[npt.NDArray[np.int32]] = None ): """Add cell data to the VTKHDF file. diff --git a/gprMax/vtkhdf_filehandlers/vtkhdf.py b/gprMax/vtkhdf_filehandlers/vtkhdf.py index dab3f676..1c29da83 100644 --- a/gprMax/vtkhdf_filehandlers/vtkhdf.py +++ b/gprMax/vtkhdf_filehandlers/vtkhdf.py @@ -185,8 +185,8 @@ class VtkHdfFile(AbstractContextManager): self, name: "VtkHdfFile.Dataset", data: npt.ArrayLike, - shape: Optional[npt.NDArray[np.intc]] = None, - offset: Optional[npt.NDArray[np.intc]] = None, + shape: Optional[npt.NDArray[np.int32]] = None, + offset: Optional[npt.NDArray[np.int32]] = None, xyz_data_ordering=True, ): """Write specified dataset to the root group of the VTKHDF file. @@ -211,8 +211,8 @@ class VtkHdfFile(AbstractContextManager): self, path: str, data: npt.ArrayLike, - shape: Optional[npt.NDArray[np.intc]] = None, - offset: Optional[npt.NDArray[np.intc]] = None, + shape: Optional[npt.NDArray[np.int32]] = None, + offset: Optional[npt.NDArray[np.int32]] = None, dtype: Optional[npt.DTypeLike] = None, xyz_data_ordering=True, ): @@ -301,8 +301,8 @@ class VtkHdfFile(AbstractContextManager): self, name: str, data: npt.NDArray, - shape: Optional[npt.NDArray[np.intc]] = None, - offset: Optional[npt.NDArray[np.intc]] = None, + shape: Optional[npt.NDArray[np.int32]] = None, + offset: Optional[npt.NDArray[np.int32]] = None, ): """Add point data to the VTKHDF file. @@ -321,8 +321,8 @@ class VtkHdfFile(AbstractContextManager): self, name: str, data: npt.NDArray, - shape: Optional[npt.NDArray[np.intc]] = None, - offset: Optional[npt.NDArray[np.intc]] = None, + shape: Optional[npt.NDArray[np.int32]] = None, + offset: Optional[npt.NDArray[np.int32]] = None, ): """Add cell data to the VTKHDF file. @@ -341,8 +341,8 @@ class VtkHdfFile(AbstractContextManager): self, name: str, data: npt.ArrayLike, - shape: Optional[npt.NDArray[np.intc]] = None, - offset: Optional[npt.NDArray[np.intc]] = None, + shape: Optional[npt.NDArray[np.int32]] = None, + offset: Optional[npt.NDArray[np.int32]] = None, dtype: Optional[npt.DTypeLike] = None, ): """Add field data to the VTKHDF file.