Skip to content

Commit

Permalink
0.0.4
Browse files Browse the repository at this point in the history
bug in xr.DataArray fixed!
  • Loading branch information
csaybar committed May 6, 2024
1 parent 70af5a9 commit 4c93d7a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,11 @@ cython_debug/
#.idea/

demo.py

data1/

datacube.pickle

results2/

animation1.gif
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
repository = "https://github.com/csaybar/satsync"
Expand Down
16 changes: 8 additions & 8 deletions satsync/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
"""
Expand All @@ -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
Expand Down Expand Up @@ -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,
)
)
Expand Down Expand Up @@ -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
)
)

Expand All @@ -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]:
"""
Expand Down
11 changes: 8 additions & 3 deletions satsync/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4c93d7a

Please sign in to comment.