Commit fa2bba67 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 4 additions and 3 deletions
+4 -3
...@@ -22,6 +22,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ...@@ -22,6 +22,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
""" """
"""Pre-process one Sentinel-1 image""" """Pre-process one Sentinel-1 image"""
import os
import logging import logging
import argparse import argparse
import otbApplication import otbApplication
...@@ -79,7 +80,7 @@ def main(args): ...@@ -79,7 +80,7 @@ def main(args):
constants.PATCHSIZE_REF) constants.PATCHSIZE_REF)
# Calibration + concatenation + tiling/compression # Calibration + concatenation + tiling/compression
out_fn = system.pathify(params.out_s1_dir) + out_fn out_fn = os.path.join(params.out_s1_dir, out_fn)
if system.is_complete(out_fn): if system.is_complete(out_fn):
logging.info("File %s already exists. Skipping.", system.remove_ext_filename(out_fn)) logging.info("File %s already exists. Skipping.", system.remove_ext_filename(out_fn))
else: else:
......
...@@ -43,7 +43,7 @@ def fconc(il, suffix, tilesize, out_tile_dir, pixel_type=otbApplication.ImagePix ...@@ -43,7 +43,7 @@ def fconc(il, suffix, tilesize, out_tile_dir, pixel_type=otbApplication.ImagePix
logging.info("Concatenate + Tile + Compress GeoTiff for files: %s", "".join(il)) logging.info("Concatenate + Tile + Compress GeoTiff for files: %s", "".join(il))
out_fn = system.basename(il[0]) out_fn = system.basename(il[0])
out_fn = out_fn[:out_fn.rfind("_")] out_fn = out_fn[:out_fn.rfind("_")]
out_fn = out_tile_dir + out_fn + "_" + suffix out_fn = os.path.join(out_tile_dir, out_fn + "_" + suffix)
out_fn += ".tif?&gdal:co:COMPRESS=DEFLATE" out_fn += ".tif?&gdal:co:COMPRESS=DEFLATE"
out_fn += "&streaming:type=tiled&streaming:sizemode=height&streaming:sizevalue={}".format(4 * tilesize) out_fn += "&streaming:type=tiled&streaming:sizemode=height&streaming:sizevalue={}".format(4 * tilesize)
out_fn += "&gdal:co:TILED=YES&gdal:co:BLOCKXSIZE={ts}&gdal:co:BLOCKYSIZE={ts}".format(ts=tilesize) out_fn += "&gdal:co:TILED=YES&gdal:co:BLOCKXSIZE={ts}&gdal:co:BLOCKYSIZE={ts}".format(ts=tilesize)
...@@ -130,7 +130,7 @@ def main(args): ...@@ -130,7 +130,7 @@ def main(args):
logging.info("Product name is %s", product_name) logging.info("Product name is %s", product_name)
# Out directory # Out directory
out_tile_dir = system.pathify(params.out_s2_dir) + tile_name + "/" + product_name + "/" out_tile_dir = os.path.join(params.out_s2_dir, tile_name, product_name)
logging.info("Create or use the following output directory: %s", out_tile_dir) logging.info("Create or use the following output directory: %s", out_tile_dir)
system.mkdir(out_tile_dir) system.mkdir(out_tile_dir)
......
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