Commit graph

262 commits

Author SHA1 Message Date
DimitraVeropoulou 35e474cf5c Add gap score calculation to common utils 2026-02-16 14:46:16 +01:00
DimitraVeropoulou 8e2d796b41 Added aura in client type map 2026-02-16 14:45:00 +01:00
DimitraVeropoulou 3f08326308 removed redudant variable definition 2026-02-16 12:12:16 +01:00
DimitraVeropoulou cea3f9a0e5 changed the path for cane supply too 2026-02-16 12:05:40 +01:00
DimitraVeropoulou 0503a93bcd fixed the path that the excel is being saved to 2026-02-16 11:51:10 +01:00
DimitraVeropoulou 951eb487b8 Refactor KPI export function to excel file that matches cane supply strycture 2026-02-16 11:04:31 +01:00
Timon 8bc151ee4c chore: Remove obsolete .gitignore files from python_app and r_app 2026-02-16 10:28:33 +01:00
DimitraVeropoulou a9840171cb Enhance logging functionality and update report generation scripts
- Improved safe_log function to include timestamps and conditional logging
- Added diagnostic messages for field visualization processing
- Updated CI map rendering parameters for consistency
- Refined raster mapping functions in report_utils for clarity
- Added .png files to .gitignore
2026-02-16 10:21:55 +01:00
Timon d075302efa feat: Add spectral extraction and analysis scripts for SC-161 and SC-162
- Implemented `run_spectral_extraction.py` to batch extract spectral indices (NDVI, BSI, NDWI) from 4-band TIFF files, saving results in a structured CSV format.
- Created `spectral_features.py` for calculating various spectral indices, including NDVI, BSI, NDWI, CI_green, CI_red, GNDVI, SAVI, and EVI2.
- Added Jupyter notebook `02_season_normalization_analysis.ipynb` for analyzing season-length normalization, comparing ESA and Angata spectral indices, and visualizing growth patterns.
- Included functions for computing season age, plotting trajectories, and performing peak and amplitude analysis.
2026-02-16 10:11:43 +01:00
DimitraVeropoulou 684050d459 fixed the "key insights" calculation 2026-02-12 17:27:21 +01:00
DimitraVeropoulou eb1b7772e5 changed the named of the generated excel and rmd back to "kpi_summary_tables_week", as the 90 requests 2026-02-12 17:16:41 +01:00
DimitraVeropoulou 3106871a81 Remove the creation of weekly_tile_max_mosaic folder 2026-02-12 16:55:34 +01:00
DimitraVeropoulou be29e4fcb3 round to 2 decimals the gap score 2026-02-12 15:44:41 +01:00
DimitraVeropoulou 750db99a41 fixed the KPIs calculation for agronomic utils, fixed the path for saving the excel and rds, updated the main file 2026-02-12 15:43:58 +01:00
DimitraVeropoulou 13015f6ec0 Fix the output path so excel, rds and csv are saved in the same folder 2026-02-12 13:50:57 +01:00
DimitraVeropoulou 7eeed342f3 Update the cane supply main and util script (with the 2σ gap score) 2026-02-12 13:47:35 +01:00
Timon d81f1a4e5a Enhance cum_ci_plot function with dynamic max values for x-axis breaks 2026-02-12 08:47:30 +01:00
Timon Weitkamp dbc097e42c
Merge pull request #9 from TimonWeitkamp/review_perField_code
Review per field code
2026-02-11 15:11:13 +01:00
Timon bb23e4eca7 Remove obsolete KPI validation and overview maps aggregation scripts 2026-02-11 14:47:39 +01:00
DimitraVeropoulou 613b35fc59 add missing bracket to gap score function 2026-02-11 14:44:09 +01:00
Timon 4cd62ab82e Enhance report utility functions and add validation scripts
- Updated `create_CI_map` and `create_CI_diff_map` functions to enforce a 1:1 aspect ratio for consistent map sizing.
- Modified `ci_plot` function to adjust widths of arranged maps for better layout.
- Changed raster merging method in `aggregate_per_field_mosaics_to_farm_level` from `mosaic` to `merge` for improved handling of field data.
- Introduced `test_kpi_validation.R` script to validate the structure of KPI RDS files, ensuring expected KPIs are present.
- Added `test_overview_maps_aggregation.R` script to test the aggregation pipeline for overview maps, including loading field mosaics, creating a farm-level mosaic, and generating visualizations.
2026-02-11 14:32:36 +01:00
DimitraVeropoulou 97d1ea33f1 add the 2σ calculate_gap_filling_kpi in common utils + comment out old function 2026-02-11 14:03:58 +01:00
DimitraVeropoulou 4968162bfc Add huss in the client type map 2026-02-11 13:31:56 +01:00
Timon b6fa1956c0 Enhance debugging output and improve date handling in TIFF removal script; update report utility functions for better map layout and historical data handling. 2026-02-11 09:48:07 +01:00
Timon 2d6f062c27 changes again 2026-02-10 22:11:58 +01:00
Timon a40b9c1dfe coderabbit fixes 2026-02-10 22:01:02 +01:00
Timon dd83a9e27f some messy updates to script 90, wil l need to do some cleaning tomorrow... 2026-02-10 21:53:49 +01:00
Timon e5a48ca447 remove file 2026-02-10 19:28:49 +01:00
Timon 8de05ce968 modified: r_app/91_CI_report_with_kpis_cane_supply.Rmd 2026-02-10 19:17:12 +01:00
Timon 5ba610d897 Merge remote-tracking branch 'origin/review_perField_code' into code-improvements 2026-02-10 19:13:20 +01:00
Timon 53bfc20f96 Enhance field boundary loading with success flags and improve dummy point handling in hexbin map generation 2026-02-10 17:57:07 +01:00
DimitraVeropoulou 8db2b641ce updated the name of the 90/91 files 2026-02-10 17:52:15 +01:00
Timon 3d3df151d3 Update .gitignore to include cache files, enhance R Markdown report paths, and improve KPI calculation script for clarity and error handling 2026-02-10 17:50:12 +01:00
DimitraVeropoulou cf7d28e276 added missing bracket and added the total acres var in the reports detail 2026-02-10 17:50:08 +01:00
DimitraVeropoulou 4b862bc016 Issue: two variables were in the same line. 2026-02-10 17:46:28 +01:00
Timon f2da320fb6 Refactor KPI calculation scripts for improved error handling and clarity 2026-02-10 16:12:07 +01:00
Timon b1b96e6c6a gap filling worked to per-field 2026-02-10 16:01:59 +01:00
Timon 054cc85bdb small issues 2026-02-10 15:38:23 +01:00
Timon 0dc46628fd Address CodeRabbit review feedback - [description of changes] 2026-02-10 12:45:41 +01:00
Timon 51d479673d Merge branch 'backward-compat-no-tiling' into code-improvements 2026-02-10 12:23:18 +01:00
Timon ede84679d7 code rabbit review stuff 2026-02-10 11:34:29 +01:00
Timon bfd56ccd16 seperate scripts work for angata, except for the word doc. 2026-02-09 20:34:11 +01:00
Timon 3ee3f9e31c shaving off some more details... 2026-02-09 10:40:01 +01:00
DimitraVeropoulou 58d3e655ab
Merge pull request #6 from TimonWeitkamp/SC-119
Sc 119
2026-02-05 14:51:02 +01:00
DimitraVeropoulou 5be79bcc87 Implemented the changed for ISO numbering to 90 script (generated the simple word file) 2026-02-05 12:11:33 +01:00
DimitraVeropoulou cc38d25a54 Changed the week and year numbering to use ISO in the kpi_utils. Update the 80 script to call the function. 2026-02-05 10:54:55 +01:00
Timon Weitkamp db4e8c68e5
Merge pull request #5 from TimonWeitkamp/new_gap_calculation
New gap calculation
2026-02-04 16:41:35 +01:00
DimitraVeropoulou 9f217df98a Changed the generated doc to match the one in Linear (SC-20) BUT i cannot run the coded parts. 2026-02-04 16:24:56 +01:00
Timon e16677eb78 aura until word creation works. word cration itself needs more work. 2026-02-04 12:24:02 +01:00
Timon 5c29c9b549 sc 114 library formatting and cleaning 2026-02-04 09:44:08 +01:00
Timon 85d2f11ed6 issue 113 done, added propper yaml to all files 2026-02-03 17:31:02 +01:00
Timon 8d560ff155 SC-112 Phase 2 Complete: Restructure Script 80 utilities by client type
- Consolidate 80_kpi_utils.R, 80_weekly_stats_utils.R, 80_report_building_utils.R into three client-aware files:
  - 80_utils_common.R (50+ functions): Shared utilities, constants, and helpers
  - 80_utils_agronomic_support.R: AURA-specific KPI calculations (6 KPIs)
  - 80_utils_cane_supply.R: ANGATA placeholder for future expansion
- Move all internal helpers (calculate_cv, calculate_change_percentages, calculate_spatial_autocorrelation, extract_ci_values, etc.) to common
- Add MORAN_THRESHOLD_* constants to common
- Fix parameters_project.R field boundaries path (removed extra 'Data' directory)
- Update 80_calculate_kpis.R with conditional client-type sourcing logic
- Validate both ANGATA (cane_supply) and AURA (agronomic_support) workflows with comprehensive testing
- All 96+ functions accounted for; ready for production use
2026-02-03 17:21:35 +01:00
DimitraVeropoulou f94a6317bd feat: Integrate 2σ gap filling KPI into weekly field analysis
- Changed gap calculation from Q25 to 2σ below median method (kpi_utils.R)
- Integrated gap filling into script 80 with tile-based processing
- Added Gap_score column to field analysis output (Excel/CSV/RDS)
- Fixed memory issues by processing 25 tiles individually instead of merging
- Fixed Field_id matching to ensure gap scores populate correctly

Gap scores now calculate for all 1185 fields with range 0-11.25%
Works with tile-based mosaics (Angata 5x5 grid) without memory errors
2026-02-03 16:41:04 +01:00
Timon 20e3d5b4a3 worked on sc 110 making a 10 utils file and making general log files. 2026-02-03 16:34:49 +01:00
Timon c313f87959 fixed issue 110 moving stuff to 00 common 2026-02-03 16:14:10 +01:00
Timon c4ef10f44f changing paths CS-109 2026-02-03 15:13:21 +01:00
Timon 6efa6b6b05 "wip" 2026-02-03 14:56:04 +01:00
Timon 9e0534cb70 add readme 2026-02-02 15:42:55 +01:00
Timon 86460aa189 table width to page instead of content 2026-02-02 15:37:57 +01:00
Timon 3fe1cf8638 removed emoticons 2026-02-02 15:35:36 +01:00
DimitraVeropoulou 19986706b9 changed the gap_score calculation from using the lower 25% of CI values to excluding pixels eith values 2σ lower than the median. 2026-02-02 13:30:06 +01:00
Timon 14300f6832 updating inbetween stuff, not finished yet 2026-02-02 12:07:10 +01:00
DimitraVeropoulou 39536ab72a testing 2026-02-02 11:49:04 +01:00
Timon 1c08070965 script 40 per-field weekly mosaics - tested with aura 2026-01-29 21:49:15 +01:00
Timon 9b8c971902 script 30 refactored to per field 2026-01-29 21:36:47 +01:00
Timon 4d6bba828f refactored 10 20 2026-01-29 21:10:24 +01:00
Timon d1f352f21c updated sc-91 2026-01-29 17:26:03 +01:00
Timon 4445f72e6f works for angata and aura 2026-01-29 16:04:04 +01:00
Timon dd915f9b9e adjusting scripts to work for all projects 2026-01-29 09:04:46 +01:00
Timon b2de819fc4 Fix backward compatibility: Support non-tiled (single-file) mosaic projects
- Script 80: Add fallback logic to detect and handle single-file mosaics
- Weekly stats utils: Support both tile-based and single-file mosaic detection
- Pipeline runner: Auto-detect mosaic mode (tiled vs single-file)
- Flexible grid size detection for tile-based projects (5x5, 10x10, etc)

Fixes:
- Script 80 now checks weekly_tile_max/{grid_size} first, falls back to weekly_mosaic
- calculate_field_statistics handles both tile patterns and single-file patterns
- run_full_pipeline detects project mode automatically
- All verification checks are now flexible and don't assume fixed paths

Projects like 'aura' (small ROI < 10km) will use single-file approach automatically
Projects like 'angata' (large ROI >= 10km) will use tile-based approach automatically
2026-01-28 11:19:07 +01:00
Timon 9a55d2fcf8 Refactor full pipeline script to include intelligent checking of existing outputs and dynamic execution of scripts. Added new Python scripts for RGB validation and evaluation template creation. Enhanced error handling and logging throughout the pipeline. 2026-01-27 08:58:06 +01:00
Timon 4143bdf4d7 updateing csv file 2026-01-20 12:06:45 +01:00
Timon c11b10a73f working on visualisation, not working too well... 2026-01-18 11:25:31 +01:00
Timon 9f312131d7 integration lstm 31 and 80 complete - angata kpi file now dynamic 2026-01-18 10:14:08 +01:00
Timon 1f5add7485 refactored script 80 2026-01-18 09:27:16 +01:00
Timon 7975f8ad06 8 week data working now 2026-01-18 07:39:30 +01:00
Timon 3e4430b3be added last columns of trends, only harvest imminent and age left to do 2026-01-16 09:10:39 +01:00
Timon 8d84c8cab5 phase 2 cv trend implemented 2026-01-16 08:30:47 +01:00
Timon 6e88acef25 added some more stats and functions calculate and export csv and rds file for future ref 2026-01-16 08:04:45 +01:00
Timon 4e94a9a78b expanding csv table 2026-01-15 15:35:16 +01:00
Timon fabbf3214d Enhance harvest detection logic and testing framework
- Updated `detect_mosaic_mode` function to check for grid-size subdirectories in addition to tile-named files.
- Added comprehensive tests for DOY reset logic in `test_doy_logic.py`.
- Implemented feature extraction tests in `test_feature_extraction.py`.
- Created tests for growing window method in `test_growing_window_only.py`.
- Developed a complete model inference test in `test_model_inference.py`.
- Added a debug script for testing two-step refinement logic in `test_script22_debug.py`.
2026-01-15 14:30:54 +01:00
Timon d6448b8703 Refactor: Update system architecture documentation to reflect Python integration and add complete pipeline overview 2026-01-15 10:25:38 +01:00
Timon 458b8247be Cleanup: Fix CI formula, reorganize shell scripts and test files
- Fixed CI calculation: changed from NDVI (NIR-Red)/(NIR+Red) to correct NIR/Green-1 formula in:
  * process_single_tile() function
  * create_ci_band() utility function
  * Updated create_mask_and_crop() documentation

- Renamed numbered shell scripts for clarity (matching R script numbering):
  * 01_run_planet_download -> 10_planet_download.sh
  * 02_run_ci_extraction -> 20_ci_extraction.sh
  * 03_run_growth_model -> 30_growth_model.sh
  * 04_run_mosaic_creation -> 40_mosaic_creation.sh
  * 09_run_calculate_kpis -> 80_calculate_kpis.sh
  * 10_run_kpi_report -> 90_kpi_report.sh

- Archived obsolete shell scripts to old_sh/:
  * build_mosaic.sh, build_report.sh, interpolate_growth_model.sh
  * 05_run_dashboard_report.sh, 06_run_crop_messaging.sh
  * 11_run_yield_prediction.sh/ps1
  * runcane.sh, runpython.sh, smartcane.sh, update_RDS.sh

- Deleted test/debug files and temporary outputs:
  * analyze_*.R, benchmark_gpu_vs_cpu.py, convert_angata_harvest.py
  * debug_mosaic.R, examine_kpi_results.R, generate_sar_report.R
  * inspect_8band_structure.R, inspect_tif_bands.R
  * old_working_utils.R, predict_harvest_operational.R
  * run_kpi_calculation.R, run_report.R, simple_sar_test.R
  * data_validation_tool/, harvest_ci_pattern_analysis.png, kpi_debug.out

- Enhanced harvest prediction: Added threshold tuning (0.40-0.45) and field type handling

- Enhanced mosaic creation: Improved tile detection and routing logic
2026-01-14 16:58:51 +01:00
Timon d365b5838b Move: archive old KPI scripts (09, 09b, 09c, 20) to old_scripts/ for testing 2026-01-14 11:37:13 +01:00
Timon 04e1641a18 Create 80_calculate_kpis.R: unified KPI calculation (per-field SC-64 + farm-level metrics) 2026-01-14 11:36:06 +01:00
Timon 62106eeb3b Update: source() calls to reference renamed util files (20_, 30_, 40_) 2026-01-14 11:24:27 +01:00
Timon b7ef583efa Rename: number utils to match their main scripts 2026-01-14 11:16:23 +01:00
Timon 5aa456fbf5 Rename: 01_ to 10_ for stage consistency 2026-01-14 11:12:11 +01:00
Timon e69a7c5465 Rename: align stage numbering with Bitbucket structure 2026-01-14 11:10:28 +01:00
Timon 252b4049b3 Rename: align stage numbering with Bitbucket structure 2026-01-14 11:08:33 +01:00
Timon ef29cb5c2c Move experimental files to r_app/experiments 2026-01-14 11:07:40 +01:00
Timon 6d5509dd1b Remove: cleanup test/draft files not in Bitbucket 2026-01-14 11:05:57 +01:00
Timon dfa0aa900d updated website and small things 2026-01-14 11:02:45 +01:00
Timon fc7e5f1ee0 Enhance download progress feedback and optimize tile overlap checks
- Added a progress bar to the tile download process for better user feedback.
- Simplified the tile overlap checking logic in the R script to improve performance and readability.
2026-01-13 11:30:38 +01:00
Timon 03f269302a SC-58: Implement grid filtering and per-date tiling
- Filter master grid to only overlapping tiles based on GeoJSON field boundaries
- Implement per-date tiling for resumable processing (can stop/restart anytime)
- Add grid-size versioning (subfolder structure: daily_tiles_split/5x5/, etc)
- Skip already-processed dates for idempotent execution
- Upfront extent checking (one-time), per-date processing (resumable)
- Reduce storage by excluding empty tiles outside field boundaries
2026-01-13 09:35:51 +01:00
Timon cb63cf00b8 updated code to fit in workflow better 2026-01-12 16:33:23 +01:00
Timon 182d13d593 wip 2026-01-12 14:55:25 +01:00
Timon dc7c346854 updated whole workflow and architercutre md 2026-01-12 09:34:13 +01:00
Timon d22dc2f96e commit all stuff 2026-01-06 14:17:37 +01:00
Timon d5fd4bb463 Add KPI reporting system and deployment documentation
Major Changes:
- NEW: Scripts 09 & 10 for KPI calculation and enhanced reporting
- NEW: Shell script wrappers (01-10) for easier execution
- NEW: R packages flextable and officer for enhanced Word reports
- NEW: DEPLOYMENT_README.md with complete deployment guide
- RENAMED: Numbered R scripts (02, 03, 04) for clarity
- REMOVED: Old package management scripts (using renv only)
- UPDATED: Workflow now uses scripts 09->10 instead of 05

Files Changed: 90+ files
New Packages: flextable, officer
New Scripts: 09_run_calculate_kpis.sh, 10_run_kpi_report.sh
Documentation: DEPLOYMENT_README.md, EMAIL_TO_ADMIN.txt

See DEPLOYMENT_README.md for full deployment instructions.
2025-10-14 11:49:30 +02:00