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

Make the coregistration approaches more modular. #24

Closed
erikmannerfelt opened this issue Mar 3, 2021 · 3 comments · Fixed by #71
Closed

Make the coregistration approaches more modular. #24

erikmannerfelt opened this issue Mar 3, 2021 · 3 comments · Fixed by #71
Assignees
Labels
enhancement Feature improvement or request

Comments

@erikmannerfelt
Copy link
Contributor

There is no consensus on the optimal coregistration pipeline, so adding modularity would help explore this.

A structure suggestion

It could be done in scikit-learn's fashion for regression models:

from sklearn.linear_model import LinearRegressor, RANSACRegressor
import numpy as np

X = np.linspace(0, 1, num=50).reshape(-1, 1)
y = np.linspace(0, 2, num=50)

for regressor in LinearRegressor, RANSACRegressor:
    model = regressor()
    model.fit(X, y)
    print(model.score(X, y))

The point of the above example is to show how interchangeable the different regression models are.

The function sklearn.pipeline.make_pipeline() allows for custom regression pipelines to be created. If for example the samples should be normalized before, this could easily be done:

from sklearn.linear_model import LinearRegressor
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import make_pipeline

model = make_pipeline([StandardScaler(), LinearRegressor(fit_intercept=True)])

model.fit(X,y)
# etc...

A similar approach could be done for coreg.py:

from xdem import coreg

reference_dem = ....
dem_to_be_aligned = ....
other_dem = ....

model = coreg.AmauryCoreg()
model.fit(reference_dem, dem_to_be_aligned)

print(model.nmad)

model.transform(other_dem)

... or something similar.
If a custom pipeline is sought:

model = coreg.make_pipeline([coreg.BiasCorr(), coreg.OutlierRemoval(), coreg.ICPCoreg()])

model.fit(reference_dem, dem_to_be_aligned)

Basically, all coreg approaches should be subclasses of a BaseCoreg class or similar, and all should have the methods .fit() and .transform() (or similar terminology). The make_pipeline() could be adapted from the equivalent in scikit-learn.

@erikmannerfelt erikmannerfelt added the enhancement Feature improvement or request label Mar 3, 2021
@adehecq
Copy link
Member

adehecq commented Mar 3, 2021

I like it!

@rhugonnet
Copy link
Contributor

Yes, this looks really great!! I'd be curious of what @fmaussion thinks about this. How is the modular approach of OGGM conceived? I'm not familiar with it myself.

@adehecq
Copy link
Member

adehecq commented Mar 9, 2021

Assuming we have the worse DEM possible, with gaps, noise and with a very large transformation, it would be good to have the following steps:

  • remove a vertical shift, or possibly a ramp
  • calculate residuals to a reference elevation and remove large outliers
  • calculate a rigid (or possibly non rigid) transformation
  • refine with Nuth & Kaab which is always more accurate on subpixel shifts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature improvement or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants