Skip to content

Add GIS-to-model table population and CFSR WGN nearest-station lookup for write_config_files#2

Draft
Copilot wants to merge 131 commits intomainfrom
copilot/create-r-package-for-project-structure
Draft

Add GIS-to-model table population and CFSR WGN nearest-station lookup for write_config_files#2
Copilot wants to merge 131 commits intomainfrom
copilot/create-r-package-for-project-structure

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 26, 2026

  • Analyzed the bug: R's .gis_insert_connections() doesn't handle daq (deep aquifer) as a sinkcat when building rout_unit_con_out
  • Split aqu_map into shallow (aqu_map) and deep (daq_map) by name prefix to mirror Python's separate gis_to_aqu_ids/gis_to_deep_aqu_ids dicts
  • Added daq = daq_map to cat_to_map, daq = "aqu" to cat_to_typ, and "daq" to supported list

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

…e writing support

Agent-Logs-Url: https://github.com/limnotrack/swatplus-editor/sessions/29227b2e-c432-40c3-8f56-9d0993473269

Co-authored-by: tadhg-moore <23136262+tadhg-moore@users.noreply.github.com>
Copilot AI changed the title [WIP] Add R package to handle project object structure Add swatplusEditoR R package for SWAT+ project database management Mar 26, 2026
Copilot AI requested a review from tadhg-moore March 26, 2026 21:35
Complete R-native implementation guided by Python fileio modules:
- New fileio.R: SWAT+ formatting utilities (padding, meta lines, generic table writer)
- Rewritten write_files.R: writes all 50+ SWAT+ file types directly from SQLite DB
  - simulation: time.sim, print.prt, object.prt, object.cnt, constituents.cs
  - climate: weather-sta.cli, weather-wgn.cli, atmo.cli
  - connect: hru.con, channel.con, reservoir.con, etc. (13 files)
  - channel, reservoir, routing_unit, hru, dr, aquifer, water_rights
  - basin, hydrology, exco, recall, structural, hru_parm_db
  - ops, lum, chg, init, soils, decision_table, regions
  - file.cio: database-driven with proper condition flags
  - weather file copying support
- No longer requires Python executable or API server
- Editor exe and API server retained as optional fallbacks
- All existing tests pass plus new formatting tests added

Agent-Logs-Url: https://github.com/limnotrack/swatplus-editor/sessions/ec3ca7fb-4be7-4293-8518-76aeca74be15

Co-authored-by: tadhg-moore <23136262+tadhg-moore@users.noreply.github.com>
Copilot AI changed the title Add swatplusEditoR R package for SWAT+ project database management Rewrite write_config_files to produce all SWAT+ input files natively in R Mar 27, 2026
Copilot AI and others added 3 commits March 27, 2026 01:27
…ting

Creates all ~100 SWAT+ tables with sensible defaults before
write_config_files() runs, mirroring Python setup.py initialization.
Critical tables (time_sim, print_prt, codes_bsn, parameters_bsn,
file_cio_classification, file_cio, etc.) are populated with defaults
from the SWAT+ datasets database. Existing data is never overwritten.

Agent-Logs-Url: https://github.com/limnotrack/swatplus-editor/sessions/aba36dbc-6fb1-48e8-810b-306ba54b5f24

Co-authored-by: tadhg-moore <23136262+tadhg-moore@users.noreply.github.com>
Copilot AI changed the title Rewrite write_config_files to produce all SWAT+ input files natively in R Ensure all SWAT+ database tables exist before write_config_files executes Mar 27, 2026
…s and comprehensive write_config_files tests

Bug fix: swat_write_table now uses sequential row numbers (1,2,3...) for the
id column instead of actual database IDs that may have gaps. This mirrors the
Python bug fix in hru.py and reservoir.py (Wetland_wet).

New tests:
- ERA5 climate data files exist in package
- Add weather stations with ERA5-style climate file references
- set_weather_dir works with ERA5 data directory
- set_weather_dir rejects non-existent directory
- swat_write_table uses sequential row numbers for id column
- write_config_files produces all necessary files for SWAT+ simulation
- write_config_files with weather_dir copies ERA5 climate files

Agent-Logs-Url: https://github.com/limnotrack/swatplus-editor/sessions/aed436ee-4ac7-4759-9b4e-05a5cebb567b

Co-authored-by: tadhg-moore <23136262+tadhg-moore@users.noreply.github.com>
Copilot AI and others added 30 commits April 8, 2026 02:38
…land_wet table, fix soil_plant_ini nutrients_id

Agent-Logs-Url: https://github.com/limnotrack/swatplus-editor/sessions/a5dda0ed-b8b7-4874-8fd6-08be4a5438aa

Co-authored-by: tadhg-moore <23136262+tadhg-moore@users.noreply.github.com>
…supplementary_tables()

Tables added include: connection tables (channel, outlet, delratio, exco,
aquifer2d, modflow + conditionally-created recall/reservoir/hru), climate
tables (atmo_cli, weather_file, weather_sta_cli_scale), recall data tables,
reservoir parameter tables, channel LTE tables, initialization tables
(pest/path/hmet/salt), calibration tables, region/cataloging tables,
exchange/delivery-ratio tables, link tables, print/output tables, scenario
feature tracking tables, salt module tables, and water allocation tables.

Agent-Logs-Url: https://github.com/limnotrack/swatplus-editor/sessions/948fcff2-7b10-4f6a-b0eb-bd44d169186d

Co-authored-by: tadhg-moore <23136262+tadhg-moore@users.noreply.github.com>
…to, add missing columns

Agent-Logs-Url: https://github.com/limnotrack/swatplus-editor/sessions/2faa99b0-785d-4e3f-b4ca-9054ccb0ab24

Co-authored-by: tadhg-moore <23136262+tadhg-moore@users.noreply.github.com>
…ild_con_out()

Agent-Logs-Url: https://github.com/limnotrack/swatplus-editor/sessions/21680076-16a1-4abf-8276-50cb82683aff

Co-authored-by: tadhg-moore <23136262+tadhg-moore@users.noreply.github.com>
…ection building

Agent-Logs-Url: https://github.com/limnotrack/swatplus-editor/sessions/3d8e99fc-a4a7-4ea8-81da-90e3dff1b259

Co-authored-by: tadhg-moore <23136262+tadhg-moore@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants