Commit b15ff07c authored by Cresson Remi's avatar Cresson Remi
Browse files

FIX, REFAC: use f-string and os.path.join() for paths concat

1 merge request!6Checkpoints callbacks fixes
Showing with 10 additions and 6 deletions
+10 -6
...@@ -26,6 +26,7 @@ This scripts summarizes the number of samples that we can get from an Acquisitio ...@@ -26,6 +26,7 @@ This scripts summarizes the number of samples that we can get from an Acquisitio
suited for single optical image reconstruction from date SAR/optical pair, for different suited for single optical image reconstruction from date SAR/optical pair, for different
parameters of the AcquisitionsLayout parameters of the AcquisitionsLayout
""" """
import os
import argparse import argparse
import logging import logging
from decloud.acquisitions.sensing_layout import AcquisitionsLayout, S1Acquisition, S2Acquisition from decloud.acquisitions.sensing_layout import AcquisitionsLayout, S1Acquisition, S2Acquisition
...@@ -139,8 +140,8 @@ for max_s1s2_gap_hours in params.maxgaps1s2_list: ...@@ -139,8 +140,8 @@ for max_s1s2_gap_hours in params.maxgaps1s2_list:
np_counts[pos[0], pos[1]] += nb_samples_in_patch np_counts[pos[0], pos[1]] += nb_samples_in_patch
# Export # Export
out_fn = "count_gap{}_range{}-{}_{}.tif".format(max_s1s2_gap_hours, int_radius, ext_radius, tile_name) out_fn = f"count_gap{max_s1s2_gap_hours}_range{int_radius}-{ext_radius}_{tile_name}.tif"
out_fn = system.pathify(params.out_dir) + out_fn out_fn = os.path.join(params.out_dir, out_fn)
logging.info("Saving %s", out_fn) logging.info("Saving %s", out_fn)
raster.save_numpy_array_as_raster(ref_fn=ref_fn, np_arr=np_counts, out_fn=out_fn, scale=scale) raster.save_numpy_array_as_raster(ref_fn=ref_fn, np_arr=np_counts, out_fn=out_fn, scale=scale)
......
...@@ -24,6 +24,7 @@ DEALINGS IN THE SOFTWARE. ...@@ -24,6 +24,7 @@ DEALINGS IN THE SOFTWARE.
""" """
Analyze the S1 and S2 orbits Analyze the S1 and S2 orbits
""" """
import os
import argparse import argparse
import numpy as np import numpy as np
import logging import logging
...@@ -80,5 +81,5 @@ for tile_name, tile_handler in th.items(): ...@@ -80,5 +81,5 @@ for tile_name, tile_handler in th.items():
# Export with pyotb # Export with pyotb
out = np.add(initialized_raster, histo_array) # this is a pyotb object out = np.add(initialized_raster, histo_array) # this is a pyotb object
out_fn = system.pathify(params.out_dir) + "{}_s1s2gap_hist.tif".format(tile_name) out_fn = os.path.join(params.out_dir, f"{tile_name}_s1s2gap_hist.tif")
out.write(out_fn) out.write(out_fn)
...@@ -24,6 +24,7 @@ DEALINGS IN THE SOFTWARE. ...@@ -24,6 +24,7 @@ DEALINGS IN THE SOFTWARE.
""" """
Compute the number of S1 and S2 images used for each patch. Compute the number of S1 and S2 images used for each patch.
""" """
import os
import argparse import argparse
import logging import logging
import numpy as np import numpy as np
...@@ -59,7 +60,7 @@ scale = float(params.patch_size) / float(constants.PATCHSIZE_REF) ...@@ -59,7 +60,7 @@ scale = float(params.patch_size) / float(constants.PATCHSIZE_REF)
for al_bname, al in als: for al_bname, al in als:
for tile_name, tile_handler in th.items(): for tile_name, tile_handler in th.items():
# Output files prefix # Output files prefix
out_prefix = system.pathify(params.out_dir) + tile_name + "_" + al_bname out_prefix = os.join(params.out_dir, tile_name + "_" + al_bname)
# Reference raster grid # Reference raster grid
ref_fn = tile_handler.s2_images[0].clouds_stats_fn ref_fn = tile_handler.s2_images[0].clouds_stats_fn
...@@ -94,6 +95,6 @@ for al_bname, al in als: ...@@ -94,6 +95,6 @@ for al_bname, al in als:
# Export # Export
for key in ["s1", "s2"]: for key in ["s1", "s2"]:
out_fn = "{}_{}_freq.tif".format(out_prefix, key) out_fn = f"{out_prefix}_{key}_freq.tif"
logging.info("Saving %s", out_fn) logging.info("Saving %s", out_fn)
raster.save_numpy_array_as_raster(ref_fn=ref_fn, np_arr=np_counts[key], out_fn=out_fn, scale=scale) raster.save_numpy_array_as_raster(ref_fn=ref_fn, np_arr=np_counts[key], out_fn=out_fn, scale=scale)
...@@ -24,6 +24,7 @@ DEALINGS IN THE SOFTWARE. ...@@ -24,6 +24,7 @@ DEALINGS IN THE SOFTWARE.
""" """
Compute cloud coverage and pixel validity from an input set of tiles Compute cloud coverage and pixel validity from an input set of tiles
""" """
import os
import argparse import argparse
import logging import logging
import numpy as np import numpy as np
...@@ -46,7 +47,7 @@ def compute_stats(tile_name, tile_handler): ...@@ -46,7 +47,7 @@ def compute_stats(tile_name, tile_handler):
:param tile_handler: Tile handler instance :param tile_handler: Tile handler instance
""" """
ref_fn = tile_handler.s2_images[0].clouds_stats_fn ref_fn = tile_handler.s2_images[0].clouds_stats_fn
out_prefix = system.pathify(params.out_dir) + tile_name out_prefix = os.path.join(params.out_dir, tile_name)
# Statistics # Statistics
cloud_cov = np.sum(np.multiply(tile_handler.s2_images_validity, tile_handler.s2_images_cloud_coverage), axis=0) cloud_cov = np.sum(np.multiply(tile_handler.s2_images_validity, tile_handler.s2_images_cloud_coverage), axis=0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment