-
Notifications
You must be signed in to change notification settings - Fork 29
read and write inputfiles in gui updated. #282
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
base: main
Are you sure you want to change the base?
Conversation
…ed, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/main.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/output_2d.py Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Rename visualizers folder to gui_tabs and update all imports Co-authored-by: Sierd <[email protected]> * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]>
* Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * Carcans files added for Olivier * bugfixes with domain overview * Gui v0.2 added (#264) * add wind plotting functionality * Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/main.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/output_2d.py Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Rename visualizers folder to gui_tabs and update all imports Co-authored-by: Sierd <[email protected]> * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> * testcommit * reverse commit * removed Carcans from Main * Refactor GUI: Complete modular architecture with all GUI tabs extract… (#268) * Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/main.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/output_2d.py Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Rename visualizers folder to gui_tabs and update all imports Co-authored-by: Sierd <[email protected]> * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> * Delete ADDITIONAL_IMPROVEMENTS.md * deleted md files --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> * Update Python version requirement to <3.14 (#270) crash reported when newest python version is used. Numba not compatible yet. * Fix ustarn calculation: initialization and FFT shear formula bugs (#265) * Initial plan * Fix ustars0 and ustarn0 initialization bug in wind.py Fixed bug where ustars0 and ustarn0 were incorrectly set to ustar magnitude instead of their respective directional components ustars and ustarn. Co-authored-by: Sierd <[email protected]> * input files for debugging * Fix missing division in dtauy FFT shear calculation The dtauy_t formula in the FFT shear method was missing the division by sc_kv(0., 2.*sqrt(2.)*sigma), causing incorrect y-direction shear stress perturbations. This resulted in non-zero ustarn values even when the bed had no y-direction variability. The formula now matches the structure of dtaux_t calculation. Co-authored-by: Sierd <[email protected]> * Fix frequency array alignment in FFT shear calculation The kx and ky frequency arrays were misaligned with the FFT output. The code was creating frequency arrays with fftfreq(n+1)[1:] which skips the DC component, but the FFT includes all frequencies. This caused incorrect mapping between frequencies and FFT coefficients, leading to wrong shear perturbations. Fixed by using fftfreq(n) which properly matches the FFT output dimensions and includes the DC component at the correct index. Co-authored-by: Sierd <[email protected]> * Handle division by zero at DC component in FFT shear The previous fix included the DC component (kx=0, ky=0) in the frequency arrays, which caused division by zero errors in the shear calculations. Fixed by: - Using safe division with np.where to replace zeros with 1.0 temporarily - Explicitly setting DC component of perturbations to 0 after calculation - Applying same fix to filter_highfrequencies function The DC component represents the mean value and doesn't contribute to perturbations, so setting it to zero is physically correct. Co-authored-by: Sierd <[email protected]> * Use masked computation to avoid invalid values in FFT shear The previous fix still allowed invalid values when kx=0 (but ky≠0) because sigma depends on kx. When kx=0, sigma=0 which causes issues in Bessel function ratios. New approach: - Create a mask for valid computations: (k > 0) & (abs(kx) > 0) - Initialize perturbation arrays with zeros - Only compute perturbations for valid frequency combinations - All invalid combinations (kx=0 or k=0) automatically get zero perturbation This is physically correct: perturbations at kx=0 (pure y-direction frequencies) should be zero for the x-direction flow formulation. Co-authored-by: Sierd <[email protected]> * Simplify FFT shear edge case handling Simplified the masked computation approach to a cleaner implementation: - Use np.where for safe division (replace zeros with 1.0 temporarily) - Compute formulas normally with safe arrays - Apply invalid_mask at the end to zero out problematic regions This achieves the same result with much simpler, more readable code. Co-authored-by: Sierd <[email protected]> * Update shear.py reverted the suggested division in dtauy_t calculation * deleted wind tests * shear patch --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> * new work on padding (#278) --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: OlivierBurvingt <[email protected]>
* Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * Carcans files added for Olivier * bugfixes with domain overview * Gui v0.2 added (#264) * add wind plotting functionality * Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/main.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/output_2d.py Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Rename visualizers folder to gui_tabs and update all imports Co-authored-by: Sierd <[email protected]> * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> * testcommit * reverse commit * removed Carcans from Main * Refactor GUI: Complete modular architecture with all GUI tabs extract… (#268) * Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/main.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/output_2d.py Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Rename visualizers folder to gui_tabs and update all imports Co-authored-by: Sierd <[email protected]> * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> * Delete ADDITIONAL_IMPROVEMENTS.md * deleted md files --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> * Update Python version requirement to <3.14 (#270) crash reported when newest python version is used. Numba not compatible yet. * Fix ustarn calculation: initialization and FFT shear formula bugs (#265) * Initial plan * Fix ustars0 and ustarn0 initialization bug in wind.py Fixed bug where ustars0 and ustarn0 were incorrectly set to ustar magnitude instead of their respective directional components ustars and ustarn. Co-authored-by: Sierd <[email protected]> * input files for debugging * Fix missing division in dtauy FFT shear calculation The dtauy_t formula in the FFT shear method was missing the division by sc_kv(0., 2.*sqrt(2.)*sigma), causing incorrect y-direction shear stress perturbations. This resulted in non-zero ustarn values even when the bed had no y-direction variability. The formula now matches the structure of dtaux_t calculation. Co-authored-by: Sierd <[email protected]> * Fix frequency array alignment in FFT shear calculation The kx and ky frequency arrays were misaligned with the FFT output. The code was creating frequency arrays with fftfreq(n+1)[1:] which skips the DC component, but the FFT includes all frequencies. This caused incorrect mapping between frequencies and FFT coefficients, leading to wrong shear perturbations. Fixed by using fftfreq(n) which properly matches the FFT output dimensions and includes the DC component at the correct index. Co-authored-by: Sierd <[email protected]> * Handle division by zero at DC component in FFT shear The previous fix included the DC component (kx=0, ky=0) in the frequency arrays, which caused division by zero errors in the shear calculations. Fixed by: - Using safe division with np.where to replace zeros with 1.0 temporarily - Explicitly setting DC component of perturbations to 0 after calculation - Applying same fix to filter_highfrequencies function The DC component represents the mean value and doesn't contribute to perturbations, so setting it to zero is physically correct. Co-authored-by: Sierd <[email protected]> * Use masked computation to avoid invalid values in FFT shear The previous fix still allowed invalid values when kx=0 (but ky≠0) because sigma depends on kx. When kx=0, sigma=0 which causes issues in Bessel function ratios. New approach: - Create a mask for valid computations: (k > 0) & (abs(kx) > 0) - Initialize perturbation arrays with zeros - Only compute perturbations for valid frequency combinations - All invalid combinations (kx=0 or k=0) automatically get zero perturbation This is physically correct: perturbations at kx=0 (pure y-direction frequencies) should be zero for the x-direction flow formulation. Co-authored-by: Sierd <[email protected]> * Simplify FFT shear edge case handling Simplified the masked computation approach to a cleaner implementation: - Use np.where for safe division (replace zeros with 1.0 temporarily) - Compute formulas normally with safe arrays - Apply invalid_mask at the end to zero out problematic regions This achieves the same result with much simpler, more readable code. Co-authored-by: Sierd <[email protected]> * Update shear.py reverted the suggested division in dtauy_t calculation * deleted wind tests * shear patch --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> * new work on padding (#278) --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: OlivierBurvingt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the functionality for reading and writing input files in the GUI, with a major refactoring of the configuration file writing logic to preserve structure and organization from the DEFAULT_CONFIG. The changes also reorganize the DEFAULT_CONFIG dictionary in constants.py with better sectioning and add support for handling empty strings and datetime patterns.
Changes:
- Refactored
write_configfileto parse constants.py and preserve section structure with comments - Reorganized DEFAULT_CONFIG into logical sections with descriptive headers
- Added empty string handling in utils and GUI for better input validation
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| aeolis/utils.py | Added empty string check to print_value function to treat empty strings like None |
| aeolis/inout.py | Complete rewrite of write_configfile to preserve section structure; added datetime pattern detection in parse_value |
| aeolis/hydro.py | Added empty check for external_vars before checking membership to prevent errors |
| aeolis/gui/application.py | Convert empty/whitespace-only strings to None when saving config |
| aeolis/constants.py | Major reorganization of DEFAULT_CONFIG with new section headers and logical grouping |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aeolis/inout.py
Outdated
| value = p[key] | ||
|
|
||
| # Skip this key if its value matches the default | ||
| if key in DEFAULT_CONFIG and np.all(value == DEFAULT_CONFIG[key]) : |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary trailing space before the colon in the if statement. Remove the space between 'key])' and ':' for consistency with Python style guidelines.
| if key in DEFAULT_CONFIG and np.all(value == DEFAULT_CONFIG[key]) : | |
| if key in DEFAULT_CONFIG and np.all(value == DEFAULT_CONFIG[key]): |
| 'output_vars' : ['zb', 'zs', | ||
| 'Ct', 'Cu', | ||
| 'uw', 'udir', | ||
| 'uth', 'mass' |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comma after 'mass' on line 206. This list should have commas separating all elements. The missing comma will cause a syntax error when Python tries to parse this configuration dictionary.
| 'uth', 'mass' | |
| 'uth', 'mass', |
| 'alpha_lift' : 0.2, # [-] Vegetation-induced upward lift (0-1) of transport-layer centroid | ||
|
|
||
| # --- Grass vegetation model (new vegetation framework) --- # | ||
| 'method_vegetation' : 'duran', # ['duran' | 'grass'] Vegetation formulation |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate key 'method_vegetation' defined. This parameter is first defined on line 352 under the 'Vegetation (OLD)' section and then redefined on line 387 under the 'Grass vegetation model (new vegetation framework)' section. In Python dictionaries, duplicate keys cause the second value to overwrite the first, making line 352 ineffective. Consider removing the duplicate or using different key names if both are needed.
| 'method_vegetation' : 'duran', # ['duran' | 'grass'] Vegetation formulation | |
| 'method_vegetation_new' : 'duran', # ['duran' | 'grass'] Vegetation formulation |
aeolis/hydro.py
Outdated
| # Check if SWL or zs are not provided by some external model | ||
| # In that case, skip initialization | ||
| if ('zs' not in p['external_vars']) : | ||
| if not p['external_vars'] or('zs' not in p['external_vars']) : |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space between 'or' and the opening parenthesis. The condition should be written as 'or (' instead of 'or('. While Python will still parse this correctly, it violates PEP 8 style guidelines for spacing around operators.
| if not p['external_vars'] or('zs' not in p['external_vars']) : | |
| if not p['external_vars'] or ('zs' not in p['external_vars']) : |
| # In that case, skip initialization | ||
| if ('zs' not in p['external_vars']) : | ||
| if not p['external_vars'] or('zs' not in p['external_vars']) : | ||
|
|
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 71 contains only whitespace with inconsistent indentation. This appears to be an unnecessary blank line within the if statement block. Remove this line or ensure consistent indentation.
| 'Cl_gw' : 0.7, # [m] Groundwater overheight due to runup | ||
| 'in_gw' : 0, # [m] Initial groundwater level | ||
| 'GW_stat' : 1, # [m] Landward static groundwater boundary (if static boundary is defined) | ||
| 'max_moist' : 10., # NEWCH # [%] Moisture content (volumetric in percent) above which the threshold shear velocity is set to infinity (no transport, default value Delgado-Fernandez, 2010) |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate key 'max_moist' defined. Line 337 has a comment marker 'NEWCH' suggesting it may be leftover from development. In Python dictionaries, duplicate keys will result in the second value overwriting the first, making line 337 have no effect. Remove the duplicate on line 337.
| 'max_moist' : 10., # NEWCH # [%] Moisture content (volumetric in percent) above which the threshold shear velocity is set to infinity (no transport, default value Delgado-Fernandez, 2010) |
| 'm_veg' : [0.4], # [-] Shear non-uniformity correction factor | ||
| 'c1_okin' : [0.48], # [-] Downwind decay coefficient in Okin shear reduction | ||
|
|
||
| 'veg_sigma' : 0., # [-] Sigma in gaussian distrubtion of vegetation cover filter |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate key 'veg_sigma' defined. This parameter is first defined on line 361 under the 'Vegetation (OLD)' section and then redefined on line 426 under the 'Grass vegetation model (new vegetation framework)' section. In Python dictionaries, duplicate keys cause the second value to overwrite the first. Consider removing the duplicate or using different key names if both are needed.
| 'veg_sigma' : 0., # [-] Sigma in gaussian distrubtion of vegetation cover filter | |
| 'veg_sigma_grass' : 0., # [-] Sigma in gaussian distribution of vegetation cover filter (grass model) |
| 'germinate' : 0., # [1/year] Possibility of germination per year | ||
| 'lateral' : 0., # [1/year] Posibility of lateral expension per year | ||
| 'veg_gamma' : 1., # [-] Constant on influence of sediment burial | ||
| 'veg_sigma' : 0., # [-] Sigma in gaussian distrubtion of vegetation cover filter |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: 'distrubtion' should be 'distribution'. This typo appears in the comment describing the veg_sigma parameter.
| 'veg_sigma' : 0., # [-] Sigma in gaussian distrubtion of vegetation cover filter | |
| 'veg_sigma' : 0., # [-] Sigma in gaussian distribution of vegetation cover filter |
aeolis/inout.py
Outdated
| if key in DEFAULT_CONFIG and np.all(value == DEFAULT_CONFIG[key]) : | ||
| continue |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using np.all for comparison may fail when value is None or a non-array type (e.g., string, bool, int). The code attempts to compare all values in the configuration, including None types, which will cause np.all to raise an error. Consider adding a type check or using a safer comparison method that handles scalars, None, and arrays appropriately.
aeolis/inout.py
Outdated
| if key in DEFAULT_CONFIG and np.all(value == DEFAULT_CONFIG[key]): | ||
| continue |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using np.all for comparison may fail when value is None or a non-array type (e.g., string, bool, int). The code attempts to compare all values in the configuration, including None types, which will cause np.all to raise an error. Consider adding a type check or using a safer comparison method that handles scalars, None, and arrays appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
|
|
||
| comment = comments.get(key, '') | ||
| formatted_value = print_value(value, fill='None') | ||
| fp.write('{:<{width}} = {:<20} %% {}\n'.format( |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent use of '%' vs '%%' in the format string. Line 271 uses a single '%' while line 291 uses '%%'. Both should use the same format to maintain consistency in the output file format. Since line 271 is inside sections and line 291 is for additional parameters, they should likely both use single '%' to match the section header format on line 254.
| fp.write('{:<{width}} = {:<20} %% {}\n'.format( | |
| fp.write('{:<{width}} = {:<20} % {}\n'.format( |
| # In that case, skip initialization | ||
| if ('zs' not in p['external_vars']) : | ||
| if not p['external_vars'] or ('zs' not in p['external_vars']) : | ||
|
|
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty line added after the condition check serves no functional purpose and reduces code readability. Consider removing this blank line.
| 'wind_file' : None, # Filename of ASCII file with time series of wind velocity and direction | ||
| 'tide_file' : None, # Filename of ASCII file with time series of water levels | ||
| 'wave_file' : None, # Filename of ASCII file with time series of wave heights | ||
| 'meteo_file' : None, # Filename of ASCII file with time series of meteorlogical conditions |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: 'meteorlogical' should be 'meteorological' in the comment.
| 'meteo_file' : None, # Filename of ASCII file with time series of meteorlogical conditions | |
| 'meteo_file' : None, # Filename of ASCII file with time series of meteorological conditions |
| 'm_veg' : [0.4], # [-] Shear non-uniformity correction factor | ||
| 'c1_okin' : [0.48], # [-] Downwind decay coefficient in Okin shear reduction | ||
|
|
||
| 'veg_sigma' : 0., # [-] Sigma in gaussian distrubtion of vegetation cover filter |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error: 'distrubtion' should be 'distribution' in the comment.
| 'veg_sigma' : 0., # [-] Sigma in gaussian distrubtion of vegetation cover filter | |
| 'veg_sigma' : 0., # [-] Sigma in gaussian distribution of vegetation cover filter |
| 'in_gw' : 0, # [m] Initial groundwater level | ||
| 'GW_stat' : 1, # [m] Landward static groundwater boundary (if static boundary is defined) | ||
| 'max_moist' : 10., # NEWCH # [%] Moisture content (volumetric in percent) above which the threshold shear velocity is set to infinity (no transport, default value Delgado-Fernandez, 2010) | ||
| 'max_moist' : 10., # [%] Moisture content (volumetric in percent) above which the threshold shear velocity is set to infinity (no transport, default value Delgado-Fernandez, 2010) |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate key 'max_moist' defined twice with the same value. The second definition on line 338 will override the first definition on line 337. One of these entries should be removed.
| 'max_moist' : 10., # [%] Moisture content (volumetric in percent) above which the threshold shear velocity is set to infinity (no transport, default value Delgado-Fernandez, 2010) |
| 'alpha_lift' : 0.2, # [-] Vegetation-induced upward lift (0-1) of transport-layer centroid | ||
|
|
||
| # --- Grass vegetation model (new vegetation framework) --- # | ||
| 'method_vegetation' : 'duran', # ['duran' | 'grass'] Vegetation formulation |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate key 'method_vegetation' defined twice with the same value. The second definition on line 387 will override the first definition on line 352. One of these entries should be removed to avoid confusion.
| 'method_vegetation' : 'duran', # ['duran' | 'grass'] Vegetation formulation |
| # Parse constants.py to extract section headers, order, and comments | ||
| import aeolis.constants | ||
| constants_file = aeolis.constants.__file__ | ||
|
|
||
| section_headers = [] | ||
| section_order = {} | ||
| comments = {} | ||
|
|
||
| with open(constants_file, 'r', encoding='utf-8') as f: | ||
| lines = f.readlines() | ||
|
|
||
| # Find DEFAULT_CONFIG definition | ||
| in_default_config = False | ||
| current_section = None | ||
| current_keys = [] | ||
|
|
||
| for line in lines: | ||
| # Check if we're entering DEFAULT_CONFIG | ||
| if 'DEFAULT_CONFIG' in line and '=' in line and '{' in line: | ||
| in_default_config = True | ||
| continue | ||
|
|
||
| # Check if we're exiting DEFAULT_CONFIG | ||
| if in_default_config and line.strip().startswith('}'): | ||
| # Save last section | ||
| if current_section and current_keys: | ||
| section_order[current_section] = current_keys | ||
| break | ||
|
|
||
| if in_default_config: | ||
| # Check for section header (starts with # ---) | ||
| if line.strip().startswith('# ---') and len(line.strip()) > 10: | ||
| # Save previous section | ||
| if current_section and current_keys: | ||
| section_order[current_section] = current_keys | ||
| current_keys = [] | ||
|
|
||
| # Extract new section name (between # --- and ---) | ||
| text = line.strip()[5:].strip().rstrip('- #') | ||
| current_section = text | ||
| section_headers.append(current_section) | ||
|
|
||
| # Check for parameter definition (contains ':' and not a comment-only line) | ||
| elif ':' in line and "'" in line and not line.strip().startswith('#'): | ||
| # Extract parameter name | ||
| param_match = re.search(r"'([^']+)'", line) | ||
| if param_match: | ||
| param_name = param_match.group(1) | ||
| current_keys.append(param_name) | ||
|
|
||
| # Extract comment (after #) | ||
| if '#' in line.split(':')[1]: | ||
| comment_part = line.split('#')[1].strip() | ||
| comments[param_name] = comment_part | ||
|
|
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing the entire constants.py source file on every call to write_configfile is a performance concern, especially if this function is called frequently. Consider caching the parsed section headers, order, and comments as module-level variables or computing them once during module initialization.
| except Exception: | ||
| try: | ||
| return value == default | ||
| except Exception: |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using bare Exception catches in the _is_default_value helper function is too broad and may hide legitimate errors. Consider catching specific exception types (e.g., ValueError, TypeError) or at minimum logging the exceptions for debugging purposes.
| except Exception: | |
| try: | |
| return value == default | |
| except Exception: | |
| except (TypeError, ValueError) as exc: | |
| logger.debug( | |
| "Array comparison failed for key %r with value %r and default %r: %s", | |
| key, | |
| value, | |
| default, | |
| exc, | |
| ) | |
| try: | |
| return value == default | |
| except (TypeError, ValueError) as exc: | |
| logger.debug( | |
| "Equality comparison failed for key %r with value %r and default %r: %s", | |
| key, | |
| value, | |
| default, | |
| exc, | |
| ) |
| # fp.write('%% %s\n' % ('-' * 70)) | ||
|
|
||
| # Write each key in this section | ||
| for key in section_keys: | ||
| value = p[key] | ||
|
|
||
| # Skip this key if its value matches the default and skipping is allowed | ||
| if not include_defaults and _is_default_value(key, value): | ||
| continue | ||
|
|
||
| comment = comments.get(key, '') | ||
|
|
||
| # Format the value | ||
| formatted_value = print_value(value, fill='None') | ||
|
|
||
| # Write the line with proper formatting | ||
| fp.write('{:<{width}} = {:<20} % {}\n'.format( | ||
| key, formatted_value, comment, width=max_key_len | ||
| )) | ||
|
|
||
| fp.write('\n') # Blank line between sections | ||
|
|
||
| # Write any remaining keys not in the section order | ||
| remaining_keys = [k for k in p.keys() if k not in sum(section_order.values(), [])] | ||
| if remaining_keys: | ||
| fp.write('%% %s %s\n' % ('-' * 15, 'Additional Parameters')) | ||
| # fp.write('%% %s\n' % ('-' * 70)) |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented-out code should be removed rather than left in the codebase. The commented lines on 255, 281 serve no functional purpose and reduce code readability. If this code is needed for future reference, it should be documented in version control history instead.
No description provided.