Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-organize coreg.py #329

Merged
merged 56 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
998577f
Add a CRS argument to all coreg.fit functions
adehecq Oct 25, 2022
cbffeb4
Replace old slope/aspect calculation with xdem implementation
adehecq Oct 25, 2022
5851e11
Add a CRS argument to all coreg.fit functions
adehecq Oct 25, 2022
fdbd723
Replace old slope/aspect calculation with xdem implementation
adehecq Oct 25, 2022
165b5d2
Merge branch 'coreg' of github.com:adehecq/xdem into coreg
adehecq Oct 25, 2022
befe474
Replace subsampling with geoutils.spatial_tools implementation
adehecq Oct 25, 2022
0b534c2
Improve testing subsampling for deramp coreg
adehecq Oct 25, 2022
5ca9570
Remove duplicate of deramping
adehecq Oct 25, 2022
c771c3c
Add function to calculate standard ddem stats
adehecq Oct 25, 2022
8eaa010
Fix circular import in previous commit
adehecq Oct 25, 2022
62a98f2
Ensure fit/apply always take transform+crs as input, update tests acc…
adehecq Oct 26, 2022
a51dac8
Fix issue with arg name in overloading. Remove optional type for tran…
adehecq Oct 26, 2022
a6dde03
Raise an error if unproject CRS is used for NuthKaab
adehecq Oct 26, 2022
082f636
Remove unused functions
adehecq Oct 26, 2022
1fa5afc
Move the functions in a more logical order (nothing is changed)
adehecq Oct 26, 2022
60348f6
Remove dilate_mask option of function
adehecq Oct 26, 2022
8c95f0c
Fix bug with option not taken into account in CoregPipeline
adehecq Oct 28, 2022
2782116
Fix bug with resampling option not taken into account in Coregpipeline
adehecq Oct 28, 2022
62ec0bf
Revert to old slope/aspect calculation, more efficient
adehecq Oct 28, 2022
75ef08f
Add a function to create inlier_mask for coreg
adehecq Nov 22, 2022
255c125
Add inout to ignored codespell errors
adehecq Nov 22, 2022
3e51d30
Add tests for create_inlier_mask function
adehecq Nov 22, 2022
8fc9828
Update dem_coregistration function to use create_inlier_mask
adehecq Nov 22, 2022
bc748bd
Fix typo in previous commit and apply linting
adehecq Nov 22, 2022
2dfa703
Fix issue iwth NMAD improperly calculated
adehecq Nov 22, 2022
a60e843
Add a filter to remove pixels with dh above an absolute threshold
adehecq Nov 22, 2022
d49f8d8
Update comment
adehecq Nov 22, 2022
024a2d2
Implement resample=False in dem_coregistration
adehecq Nov 23, 2022
2d690db
Remove the hmode/vmode. Update docstring of dem_coregistration.
adehecq Nov 23, 2022
717543f
Enable input src/ref dem as Raster and not only path to file
adehecq Nov 23, 2022
e13e59f
Implement resample=False for BiasCorr
adehecq Nov 23, 2022
50db29e
Update tests for create_inlier_mask
adehecq Nov 23, 2022
8b99f04
Make sure option resample=False is flagged as not implemented for Blo…
adehecq Nov 23, 2022
3c316c9
Add tests for resample=False option
adehecq Nov 23, 2022
9955743
Linting
adehecq Nov 23, 2022
f2d5086
Update default coreg method and modify outputs of dem_coregistration
adehecq Nov 23, 2022
d09604f
Add test suite for dem_coregistration function
adehecq Nov 24, 2022
2ad914a
Update pre-commit
adehecq Nov 24, 2022
52b7226
Fix mypy issue
adehecq Nov 24, 2022
88391b1
Account for PR comments
rhugonnet Dec 9, 2022
ca28258
Remove NaN forcing
rhugonnet Dec 9, 2022
1a498bf
Merge remote-tracking branch 'upstream/main' into HEAD
rhugonnet Dec 9, 2022
6fb0b0b
Linting
rhugonnet Jan 4, 2023
73fbd47
Remove unnecessary type
adehecq Jan 23, 2023
ada836d
Rename fit_func
adehecq Jan 23, 2023
94c6a07
Improve docstrings
adehecq Jan 23, 2023
bde8967
Simplify if statement
adehecq Jan 23, 2023
7fed61d
Make resampling algo an optional argument for Coreg.apply
adehecq Jan 23, 2023
755ab20
Merge branch 'coreg' of github.com:adehecq/xdem into coreg
adehecq Jan 23, 2023
e7b847b
Fix two bugs and add comment
adehecq Jan 23, 2023
0cb664d
Update NuthKaab shift in tests
adehecq Jan 24, 2023
a7923db
Update tests in examples and coreg
adehecq Jan 24, 2023
ffe7070
Update test_spatialstats values with new coreg that outputs ddem with…
Jan 30, 2023
97c970f
Fix runtime warning in code example
rhugonnet Jan 31, 2023
0fbe1f6
Fix coregistration code snippet
rhugonnet Jan 31, 2023
14d536c
Fix coreg example with new transform and crs argument of Coreg class
rhugonnet Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
hooks:
- id: codespell
args: [
'--ignore-words-list', 'nd,alos',
'--ignore-words-list', 'nd,alos,inout',
'--ignore-regex', '\bhist\b',
'--'
]
Expand Down
6 changes: 3 additions & 3 deletions docs/source/code/coregistration_plot_nuth_kaab.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
inlier_mask = ~outlines_1990.create_mask(dem_2009)

nuth_kaab = xdem.coreg.NuthKaab()
nuth_kaab.fit(dem_2009.data, dem_1990.data, transform=dem_2009.transform, inlier_mask=inlier_mask)
dem_coreg = nuth_kaab.apply(dem_1990.data, transform=dem_1990.transform)
nuth_kaab.fit(dem_2009, dem_1990, inlier_mask=inlier_mask)
dem_coreg = nuth_kaab.apply(dem_1990)

ddem_pre = (dem_2009.data - dem_1990.data).filled(np.nan).squeeze()
ddem_post = (dem_2009.data - dem_coreg).filled(np.nan).squeeze()
ddem_post = (dem_2009.data - dem_coreg.data).filled(np.nan).squeeze()

nmad_pre = xdem.spatialstats.nmad(ddem_pre[inlier_mask.squeeze()])
nmad_post = xdem.spatialstats.nmad(ddem_post[inlier_mask.squeeze()])
Expand Down
463 changes: 411 additions & 52 deletions tests/test_coreg.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def test_array_content(self, rst_and_truevals: tuple[Raster, NDArrayf]) -> None:

assert values == pytest.approx(truevals)

@pytest.mark.parametrize("rst_and_truenodata", [(ref_dem, 0), (tba_dem, 0), (ddem, 2316)]) # type: ignore
# Note: Following PR #329, no gaps on DEM edges after coregistration
@pytest.mark.parametrize("rst_and_truenodata", [(ref_dem, 0), (tba_dem, 0), (ddem, 0)]) # type: ignore
def test_array_nodata(self, rst_and_truenodata: tuple[Raster, int]) -> None:
"""Let's also check that the data arrays have always the same number of not finite values"""

Expand Down
6 changes: 3 additions & 3 deletions tests/test_spatialstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ def test_sample_multirange_variogram_default(self) -> None:

# Check the variogram output is consistent for a random state
df = xdem.spatialstats.sample_empirical_variogram(values=self.diff, subsample=10, random_state=42)
assert df["exp"][15] == pytest.approx(23.517837524414062, abs=1e-3)
assert df["exp"][15] == pytest.approx(5.087792205810548, abs=1e-3)
assert df["lags"][15] == pytest.approx(5120)
assert df["count"][15] == 2
assert df["count"][15] == 5
# With a single run, no error can be estimated
assert all(np.isnan(df.err_exp.values))

Expand Down Expand Up @@ -1180,7 +1180,7 @@ def test_patches_method_loop_quadrant(self) -> None:
assert all(df.columns == ["nmad", "nb_indep_patches", "exact_areas", "areas"])

# Check the sampling is fixed for a random state
assert df["nmad"][0] == pytest.approx(1.8663623135417342, abs=1e-3)
assert df["nmad"][0] == pytest.approx(1.8392861049330378, abs=1e-3)
assert df["nb_indep_patches"][0] == 100
assert df["exact_areas"][0] == pytest.approx(df["areas"][0], rel=0.2)

Expand Down
Loading