diff --git a/.gitignore b/.gitignore index a0d0041..eee5077 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,11 @@ cython_debug/ #.idea/ demo.py + +data1/ + +datacube.pickle + +results2/ + +animation1.gif diff --git a/pyproject.toml b/pyproject.toml index 7013150..775ddbc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "satsync" -version = "0.0.3" +version = "0.0.4" description = "A python package to align satellite images." authors = ["Cesar Aybar "] repository = "https://github.com/csaybar/satsync" diff --git a/satsync/main.py b/satsync/main.py index df7b6cd..1d4687a 100644 --- a/satsync/main.py +++ b/satsync/main.py @@ -245,8 +245,8 @@ def run_xarray(self) -> xr.Dataset: for index, img in enumerate(self.datacube.values): # Obtain the warp matrix warped_image, warp_matrix = self.get_warped_image( - reference_image=reference_layer, - moving_image=img.values, + reference_image_feature=reference_layer, + moving_image=img, ) # Save the warp matrix ... copy here makes cv2 happy @@ -261,7 +261,7 @@ def run_xarray(self) -> xr.Dataset: coords=self.datacube.coords, dims=self.datacube.dims, attrs=self.datacube.attrs, - ) + ), warp_matrices def run_numpy(self) -> np.ndarray: """ @@ -277,7 +277,7 @@ def run_numpy(self) -> np.ndarray: for index, img in enumerate(self.datacube): # Obtain the warp matrix warped_image, warp_matrix = self.get_warped_image( - reference_image=reference_layer, moving_image=img + reference_image_feature=reference_layer, moving_image=img ) # Save the warp matrix ... copy here makes cv2 happy @@ -306,7 +306,7 @@ def run_multicore_numpy(self) -> np.ndarray: futures.append( executor.submit( self.get_warped_image, - reference_image=reference_layer, + reference_image_feature=reference_layer, moving_image=img, ) ) @@ -339,8 +339,8 @@ def run_multicore_xarray(self) -> xr.Dataset: futures.append( executor.submit( self.get_warped_image, - reference_image=reference_layer, - moving_image=img.values + reference_image_feature=reference_layer, + moving_image=img ) ) @@ -358,7 +358,7 @@ def run_multicore_xarray(self) -> xr.Dataset: coords=self.datacube.coords, dims=self.datacube.dims, attrs=self.datacube.attrs, - ) + ), warp_matrices def run(self) -> Union[xr.Dataset, np.ndarray]: """ diff --git a/satsync/utils.py b/satsync/utils.py index 7fea83e..1ee80fd 100644 --- a/satsync/utils.py +++ b/satsync/utils.py @@ -10,7 +10,6 @@ import rasterio as rio import xarray as xr - def create_array( path: Union[str, pathlib.Path], outdata: Union[str, pathlib.Path] @@ -173,10 +172,10 @@ def plot_rgb( fig, axs = plt.subplots(1, 2, figsize=(10, 5)) axs[0].imshow(to_display1) - axs[0].set_title(f"Original Cube - {dates[index]}") + axs[0].set_title(f"Original Cube - {str(dates[index])}") axs[0].axis("off") axs[1].imshow(to_display2) - axs[1].set_title(f"Aligned Cube - {dates[index]}") + axs[1].set_title(f"Aligned Cube - {str(dates[index])}") axs[1].axis("off") return fig, axs @@ -216,6 +215,9 @@ def plot_animation1( Returns: pathlib.Path: The path to the gif file. """ + # check if the system has ImageMagick installed + if os.system("convert -version") != 0: + raise ValueError("You need to install ImageMagick to create the gif") # create folder is not exists png_output_folder = pathlib.Path(png_output_folder) @@ -348,6 +350,9 @@ def plot_animation2( gif_delay (int, optional): The delay between the images. Defaults to 20. gif_loop (int, optional): The number of loops. Defaults to 0. """ + # check if the system has ImageMagick installed + if os.system("convert -version") != 0: + raise ValueError("You need to install ImageMagick to create the gif") # create folder is not exists png_output_folder = pathlib.Path(png_output_folder)