Skip to content

[com1;com8;com9;in1;in2;in3] Read from raster#1193

Merged
fso42 merged 9 commits intomasterfrom
readFromRaster
Nov 13, 2025
Merged

[com1;com8;com9;in1;in2;in3] Read from raster#1193
fso42 merged 9 commits intomasterfrom
readFromRaster

Conversation

@awirb
Copy link
Contributor

@awirb awirb commented Oct 9, 2025

Allow reading input data from raster without any additional shapefile

  • release, secondaryRelease, entrainment, resistance and friction parameters
  • for thickness files (release, secondaryRelease, entrainment) - values are directly taken from raster file - where values != 0 thickness is set according to raster values
  • resistance - if values != 0 resistance area if values ==0 no resistance (parameters for resistance are taken from ini file)
  • if file provided as .asc or .tif - reading thickness from ini file does NOT work and thickness variation through ini file not possible

Todos see: #1201

Notes:
When using raster files:

  • relThFromFile is set to "True" (since thickness is read from the file)
  • But the attributes relThId, relThThickness, and relThCi95 don't exist (because
    getThicknessValue returns early for raster files)
  • The old code tried to access these non-existent attributes, causing the KeyError
  • The new code detects raster files first and skips the shapefile-specific attribute handling

Maybe fixes #1110

@awirb awirb requested a review from fso42 October 9, 2025 12:33
@awirb awirb added the featureRequest ideas or functions that would be useful label Oct 9, 2025
@fso42 fso42 added the enhancement New feature or request label Oct 14, 2025
@fso42 fso42 changed the title WIP: Read from raster [BASE] Read from raster Oct 16, 2025
@fso42 fso42 assigned fso42 and unassigned awirb Oct 16, 2025
@fso42 fso42 changed the title [BASE] Read from raster [com1;com8;com9;in1;in2;in3] Read from raster Oct 16, 2025
awirb added 2 commits October 22, 2025 17:25
check that also with remeshed files it works
  - add check for nan and neg values in rater input files
  = add option auto
fso42 added 3 commits November 4, 2025 11:25
Updated variable names in test files and configuration files from `FromShp` to `FromFile` comments to reflect the change.

refactor(com9MoTVoellmy): switch from thFromShp to thFromFile; update tau variable naming

- Updated string delimiters from single to double quotes for consistency.
- Changed `tau0` references to `tauC` throughout for naming consistency.
- Added a new method `setVariableEntrainmentParameters` for handling entrainment parameters dynamically.
- Modified and extended related test cases to reflect updates.
- Updated configuration to set default entrainment to `auto` and clarified `meshCellSize` behavior.
- Updated Linux executable

refactor(motUtils): remove unused `entitydefs` import

refactor(all): update bed strength profile and thickness flag naming

- Changed `Bed strength profile` value from `global` to `constant` in configurations.
- Updated thickness flag naming from `FromShp` to `FromFile`
- Adjusted related configuration and code references to align with these changes.

refactor(com1DFA): remove `relThFromFile` flag and related references

- Removed the `relThFromFile` flag from configurations and test files.
- Adjusted code, comments, and related test cases to align with the removal.
- Introduced new test data `testRel2.asc` and updated file references for consistency.
- Removed unused or redundant lines in test files.

refactor(com9MoTVoellmy): dynamically handle forest parameter files

- Added `setVariableForestParameters` function to manage `nd` and `bhd` parameter files and update configuration accordingly.
- Modified `getInput.py` to check for presence and remeshing status of forest parameter files.
- Updated `com9MoTVoellmy` logic to handle `FOREST_EFFECTS` value dynamically, including `auto`, `yes`, and `no` states.
- Changed default value of `FOREST_EFFECTS` in `com9MoTVoellmyCfg.ini` to `auto`.
- Commented out unused dependencies (`gdal`, `geos`, and `proj`) in `pyproject.toml`.

feat(com9MoTVoellmy): add simulation type override functionality

- Introduced `simType` parameter to `runCom9MoTVoellmy` for overriding simulation type.
- Updated command-line interface to accept `--sim_type` with defined options (`null`, `ent`, `res`, `entres`, `available`).
- Modified `MoTUtils` to set default `Entrainment` to `none` when conditions are not met.
- Improved logging to capture simulation type overrides.
- Refined handling of forest effect parameters to ensure correct field extent.

refactor(motUtils): moved forest nd to RES dir

- Updated `pyproject.toml` to restrict Python version to `<3.14`.

feat(com9MoTVoellmy): add functionality to copy timestep directories

- Introduced `copyMoTDirs` function to handle the copying of specific timestep directories (`s`, `h`) from the work directory to the output directory.
- Updated `com9MoTVoellmy` workflow to utilize `copyMoTDirs` for organizing timestep outputs in a structured format under a `timesteps` subfolder.
… exe

refactor(all): Updated Pytest to reflect recent refactoring and handle unsupported `iniStep` scenario gracefully.

- Updated configuration and test files to replace `thFromShp` flag with `thFromFile`.
- Removed redundant code, comments, and unused flags across `com1DFA`, `ana4Stats`, and related test files.
- Added error checks for invalid configurations involving raster inputs and thickness values.
- Disabled unsupported `iniStep=True` and added appropriate error/warning messages in `com1DFA`.
- Standardized string delimiters and improved readability in test functions.

refactor(in1Data, out3Plot, tests): remove redundant checks and imports

- Replaced `!= None` with `is not None` in `getInput.py` and `test_getInput.py` for better readability.
- Removed unused imports from `outCom1DFA.py`,
- Improved minor formatting issues in test assertions.

refactor(pyproject): uncomment Python version restriction to `<3.14`

test(tests): add comprehensive tests for `deriveLineRaster` and `MoTUtils`

- Added unit tests for the `deriveLineRaster` function to handle various scenarios, including invalid raster types, zero raster creation, different file extensions, and inputs from shapefiles or existing rasters.
- Expanded `MoTUtils` tests to cover the copying of files/directories (`copyMoTDirs`) and dynamic setting of friction, entrainment, and forest parameters based on input files and configurations.
- Introduced new test cases for platform-specific behavior and logging in the `com9MoTVoellmy` module.

refactor(all): reformat and improve code readability

- Reformatted long lines across multiple files, including `test_ascUtils.py`, `outPlotAllPeak.py`, `deriveParameterSet.py`, and `test_com9MoTVoellmy.py`, for better readability and adherence to code style guidelines.
- Replaced backslashes in `with` statements with parentheses to align with modern Python practices.
- Removed unnecessary blank lines and optimized formatting in test modules and main scripts.

refactor(tests, in1Data): reformat files and fix wrong pytest data path

- Reformatted long lines and applied parentheses for better readability in `test_ascUtils.py`, `test_com9MoTVoellmy.py`, and `getInput.py`.

feat(data): readd input files for avaSimilarity solution

chore(config): add `*/out3Plot/*` to coverage omit list

test(getInput): add tests for `initializeRelTh` to cover various scenarios

- Added tests to validate `initializeRelTh` functionality:
  - Loading valid release thickness raster files.
  - Handling dimension mismatches between DEM and `relThFile`.
  - Detecting NaN values in `relThFile`.
  - Handling cases with empty configuration for the release thickness file.
- Enhanced test coverage to improve robustness and catch configuration-driven edge cases.

test(getInput/MoTUtils): add pytest

refactor(com9MoTVoellmy): update configuration parameters and default values

 - Values based on a mix of existing rcf examples in the MoTVoellmy repository
@fso42
Copy link
Contributor

fso42 commented Nov 13, 2025

Standardtest ok APART from avaInclinedPlaneEntresTest. Aparently this one got forgotten in the last update of benchmarks (due to res) see #1208

…er from configuration file

Remove `avaHelixChannelWetSnowTest` descriptor JSON file

fix color ordering in aimec plots for relTh from file or from ini

refactor(com1,com9): improve file handling and comments in MoT modules

- Updated comments in `MoTUtils.py`, `com9MoTVoellmy.py`, and `com1DFA.py` for clarity and consistency, particularly regarding file input types (`shapefile`, `raster`).
- Improved configuration files (`com1DFACfg.ini` and `com9MoTVoellmyCfg.ini`) to clarify parameter usage and handle raster inputs.
@fso42 fso42 merged commit 21e4b94 into master Nov 13, 2025
4 of 5 checks passed
@fso42 fso42 deleted the readFromRaster branch November 13, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request featureRequest ideas or functions that would be useful

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reltH read from file

2 participants