GeoscienceAustralia / ga_sar_workflow

InSAR processing workflow used by Geoscience Australia
Apache License 2.0
3 stars 1 forks source link

Refactoring the OOP/class-based processing modules into function based like the rest of the code base #334

Closed mwheeler closed 2 years ago

mwheeler commented 2 years ago

This is the final mega PR / the last of the big refactoring and cleanup effort from the last month!

This PR addresses #330 - by refactoring the processing module logic out of classes and into free standing functions like all the other processing code.

This PR intentionally does 'not' clean up some poor code design issues in these modules (eg: offset_calc in coregister_dem.py does way too much for one function), it's simply a class -> no class translation.

The main change besides the removal of classes is obviously some changes in where the state (previously held by the classes) lives... which unsurprisingly is mostly paths, and thus is in all the insar.paths.* modules that have been developed over the past few PRs. The rest of the state held by the old classes was mostly settings / intermediate variables, and as such is now taken as function parameters and/or live as local variables where they're used.

The diffs for the 3 files listed below... in this PR are going to be basically useles:

This is because they're basically "rewrites" from a classic diff perspective (from all the whitespace changes / one less indentation level) - a better diff program like Meld might help.

This PR also implements BackscatterPaths (the last path class that wasn't implemented in the prior PRs) - as the cleaned up/refactored code touched by this PR was the code responsible for creating these paths previously.

Addendum: I've also been running tests on Gadi and confirm all is good (and even diff'd the file structure before all these refactoring PRs and after, and confirmed not only are things good - we actually fixed a bug where duplicate _gamma0 and .gammaa0 files were being created prior to the unification/standardisation of path definitions - due to two inconsistent pieces of code using mismatching file paths in it's processing)