diff --git a/src/openeo_processes/cubes.py b/src/openeo_processes/cubes.py index be532686..8a8e1481 100644 --- a/src/openeo_processes/cubes.py +++ b/src/openeo_processes/cubes.py @@ -677,7 +677,7 @@ def refactor_data(data: xr.DataArray) -> List[xr.Dataset]: def create_output_filepath(output_filepath: str, idx: int = 0, ext: str = "nc") -> str: """Create the output filepath.""" root, _ = splitext(output_filepath) - return f'{root}_{idx}.{ext}' + return f'{root}_{str(idx).zfill(5)}.{ext}' # start workaround # https://github.com/opendatacube/datacube-core/issues/972 diff --git a/tests/test_cubes.py b/tests/test_cubes.py index 1e4a34eb..999582de 100644 --- a/tests/test_cubes.py +++ b/tests/test_cubes.py @@ -56,8 +56,8 @@ def test_save_result(self): # TODO improve file check # xarray tests out_filename = "out.tif" - out_filename_0 = "out_0.tif" - out_filename_1 = "out_1.tif" + out_filename_0 = "out_00000.tif" + out_filename_1 = "out_00001.tif" out_product = "product.yml" oeop.save_result(self.test_data.xr_odc_data_3d, out_filename) assert os.path.exists(out_filename_0) @@ -74,8 +74,8 @@ def test_save_result(self): os.remove(out_product) out_filename = "out.nc" - out_filename_0 = "out_0.nc" - out_filename_1 = "out_1.nc" + out_filename_0 = "out_00000.nc" + out_filename_1 = "out_00001.nc" oeop.save_result(self.test_data.xr_data_extra_dim, out_filename, format='netCDF', write_prod=False) assert os.path.exists(out_filename_0) @@ -107,14 +107,14 @@ def test_save_result_from_file(self): ref_ds_0 = ref_ds.loc[dict(time="2016-01-13T12:00:00.000000000")] data_array = ref_ds.to_array(dim="bands") oeop.save_result(data_array, format='netCDF') - actual_ds_0 = xr.load_dataset("out_0.nc") + actual_ds_0 = xr.load_dataset("out_00000.nc") assert ref_ds_0.dims == actual_ds_0.dims assert ref_ds_0.coords == actual_ds_0.coords assert ref_ds_0.variables == actual_ds_0.variables assert ref_ds_0.geobox == actual_ds_0.geobox assert ref_ds_0.extent == actual_ds_0.extent for i in range(10): - os.remove(f"out_{i}.nc") + os.remove(f"out_{str(i).zfill(5)}.nc") os.remove("product.yml") def test_fit_curve(self):