diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 0cb6ca2..cc80ce8 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -41,7 +41,7 @@ jobs: - uses: "actions/setup-python@v2" with: python-version: "${{ matrix.python }}" - - uses: "actions/cache@v2" + - uses: "actions/cache@v3" id: "cache" with: path: "${{ env.pythonLocation }}" diff --git a/xarray_selafin/Serafin.py b/xarray_selafin/Serafin.py index 616fece..29b77ee 100644 --- a/xarray_selafin/Serafin.py +++ b/xarray_selafin/Serafin.py @@ -120,7 +120,7 @@ class SerafinHeader: - nb_nodes_per_elem : number of nodes per element (= 3 in 2D and 6 in 3D) - nb_nodes_2d : number of 2D nodes (equals to `nb_nodes` in 2D) - - mesh_origin <(float, float)>: x and y shift to apply to written coordinates (set by `set_mesh_origin`) + - mesh_origin <(int, int)>: x and y shift to apply to written coordinates (set by `set_mesh_origin`) - x_stored : east written coordinates [shape = nb_nodes] - y_stored : north written coordinates [shape = nb_nodes] - x : east coordinates [shape = nb_nodes] (set by `_compute_mesh_coordinates`) @@ -177,7 +177,7 @@ def __init__(self, title="", format_type="SERAFIN ", lang=LANG, endian=">"): self.nb_nodes_per_elem = -1 self.nb_nodes_2d = -1 - self.mesh_origin = (0.0, 0.0) + self.mesh_origin = (0, 0) self.x_stored = None self.y_stored = None self.x = None @@ -210,10 +210,10 @@ def _set_file_format_and_precision(self, file_format): If file format is not recognized, the file is expected to be simple precision """ self.file_format = bytes(file_format, SLF_EIT).ljust(8) - if file_format in ("SERAFIND", " D"): + if file_format in ("SERAFIND", "SELAFIND", " D"): self._set_as_double_precision() else: - if file_format not in (" ", "SERAFIN ", "SERAFINS", "SERAPHIN"): + if file_format not in ("SERAFIN ", "SERAFINS", "SELAFIN ", "SERAPHIN"): logger.warning( 'Format "%s" is unknown and is forced to "SERAFIN "' % file_format ) @@ -240,13 +240,13 @@ def build_params(self): 1, 0, self.mesh_origin[0], - self.mesh_origin[0], + self.mesh_origin[1], 0, 0, self.nb_planes, - self.nb_elements, 0, - 1, + 0, + 0 if self.date is None else 1, ) def _build_ikle_2d(self): @@ -803,6 +803,7 @@ def from_triangulation(self, nodes, ikle, ipobo=None): self._compute_mesh_coordinates() self.ikle = ikle.flatten() self._build_ikle_2d() + self.build_params() if ipobo is None: self.build_ipobo() else: @@ -912,6 +913,9 @@ def from_file(self, file, file_size): file.read(4 * self.nb_nodes), dtype=np.dtype(np.int32).newbyteorder(self.endian), ) + # A valid IPOBO should not be equal to zero array + if not np.any(self.ipobo): + logger.warning("The IPOBO array seems corrupted (zeros array). Try to rebuild it with `build_ipobo()`.") file.read(4) # x coordinates