Skip to content

Commit

Permalink
don't wrap src / ref filenames in Path
Browse files Browse the repository at this point in the history
  • Loading branch information
dugalh committed Sep 30, 2024
1 parent 68c018d commit 08b0f6c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/case_studies/drone_mosaic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ While the corrected and reference colours are similar, improvement in surface re
Evaluation
----------

The source and corrected drone images were compared with a second, Landsat-8 reference to evaluate the change in surface reflectance accuracy. The scatter plots below show an improvement in correlation with the reference after correction.
The source and corrected drone images were compared with a second, Landsat-8 reference to evaluate the change in surface reflectance accuracy. The scatter plots below show a meaningful improvement in correlation with the reference after correction.

.. figure:: drone_mosaic-eval.png
:align: center
Expand Down
2 changes: 2 additions & 0 deletions homonim/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def _param_file_cb(ctx: click.Context, param: click.Argument, value):

# define click options and arguments common to more than one command
# use cloup's argument to auto print argument help on command line
# TODO: rasterio 1.4 does not accept Path wrapped URLs
ref_file_arg = cloup.argument(
'ref-file', nargs=1, metavar='REFERENCE', type=click.Path(exists=False, dir_okay=False, path_type=pathlib.Path),
help='Path or URL of a reference image.'
Expand Down Expand Up @@ -327,6 +328,7 @@ def cli(verbose: int, quiet: int):
'-o', '--overwrite', is_flag=True, type=click.BOOL, default=False, show_default=True,
help='Overwrite existing output file(s).'
),
# TODO: does this work in front of an argument? or should it be handles like oty rpc's --gcp-refine?
click.option(
'-cmp', '--compare', 'cmp_file', metavar='FILE',
type=click.Path(exists=False, dir_okay=False, path_type=pathlib.Path), is_flag=False, flag_value='ref',
Expand Down
5 changes: 3 additions & 2 deletions homonim/fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ def _set_metadata(self, im: DatasetWriter, **kwargs):
raise IoError(f'The raster dataset is closed: {im.name}')

kwargs_meta_dict = {f'FUSE_{k.upper()}': v.name if hasattr(v, 'name') else v for k, v in kwargs.items()}
src_name = Path(self._src_filename).name
ref_name = Path(self._ref_filename).name
meta_dict = dict(
FUSE_SRC_FILE=self._src_filename.name, FUSE_REF_FILE=self._ref_filename.name,
FUSE_PROC_CRS=self.proc_crs.name, **kwargs_meta_dict,
FUSE_SRC_FILE=src_name, FUSE_REF_FILE=ref_name, FUSE_PROC_CRS=self.proc_crs.name, **kwargs_meta_dict,
)
im.update_tags(**meta_dict)

Expand Down
8 changes: 5 additions & 3 deletions homonim/raster_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def __init__(
grid to use for processing. For most use cases, it can be left as the default of
:attr:`~homonim.enums.ProcCrs.auto` i.e. the lowest resolution of the source and reference image CRS's.
"""
self._src_filename = Path(src_filename)
self._ref_filename = Path(ref_filename)
self._src_filename = src_filename
self._ref_filename = ref_filename

with rio.open(self._src_filename, 'r') as src_im, rio.open(self._ref_filename, 'r') as ref_im:
self._validate_pair_format(src_im, ref_im)
Expand Down Expand Up @@ -271,8 +271,10 @@ def _auto_block_shape(self, max_block_mem: float = np.inf) -> Tuple[int, int]:
def _assert_open(self):
""" Raise an IoError if the source and reference images are not open. """
if self.closed:
src_name = Path(self._src_filename).name
ref_name = Path(self._ref_filename).name
raise errors.IoError(
f'The raster pair has not been opened: {self._src_filename.name} and {self._ref_filename.name}'
f'The raster pair has not been opened: {src_name} and {ref_name}'
)

def open(self):
Expand Down

0 comments on commit 08b0f6c

Please sign in to comment.