SmartCane/r_app/experiments/harvest_prediction/01_QUICK_START_GUIDE.md
2026-01-06 14:17:37 +01:00

9.5 KiB

SmartCane Growth & Harvest System - QUICK START GUIDE

🎯 TL;DR: What You Need to Know

The Three Key Concepts

  1. Growth Phase = Age since planting (4 phases: Germination → Tillering → Grand Growth → Maturation)
  2. CI (Chlorophyll Index) = Vegetation health from satellite (0.5 = bare field, 3.5 = peak growth)
  3. Harvest Prediction = Estimate when CI will drop (indicating harvest)

🚀 Quick Start: 3 Essential Commands

Command 1: Check Current Growth Phases

cd "c:\Users\timon\Resilience BV\4020 SCane ESA DEMO - Documenten\General\4020 SCDEMO Team\4020 TechnicalData\WP3\smartcane_v2\smartcane"

# Generate Word report showing what phase each field is in
Rscript r_app/14_generate_report_with_phases.R esa 2025-12-03

Output: reports/kpis/field_analysis/*.docx — Professional Word report with:

  • Field names + current phase
  • CI values this week
  • Trend arrows (↑ growing, ↓ declining, → stable)

Command 2: Predict Harvest Dates

# Predict when fields will be ready to harvest
Rscript predict_harvest_operational.R

Output: Console output showing:

Field              Current_CI  Phase                  Days_to_Harvest  Alert
SIMBA_P01          3.2         Grand Growth           45 days          💡 WITHIN 1 MONTH
SIMBA_P02          2.8         Maturation             12 days          ⚠️ WITHIN 2 WEEKS
SIMBA_P03          2.4         declining_harvest     5 days           🚨 IMMINENT

Command 3: Analyze Historical Patterns

# See what CI looks like around actual harvests
Rscript r_app/experiments/harvest_prediction/detect_harvest_retrospective_bfast.R

Output:

  • detected_harvests_bfast.csv — All detected harvests from history
  • bfast_breaks_count.png — Visual confirmation of detection accuracy
  • Console: Validation against actual harvest.xlsx dates

📊 Understanding the Growth Phase System

How Phases are Assigned

Age Since Planting                Growth Phase
0-6 weeks                    →    Germination
4-16 weeks                   →    Tillering  
17-39 weeks                  →    Grand Growth
39+ weeks                    →    Maturation

Example Timeline:

Week 0 (Jan 1)    → Germination starts, CI = 0.8
Week 10 (Mar 12)  → Tillering phase, CI = 2.5, heavy rainfall = good
Week 25 (Jun 20)  → Grand Growth peak, CI = 3.4, getting ready
Week 42 (Sep 7)   → Maturation begins, CI = 3.3, sugar accumulating
Week 55 (Nov 30)  → Harvest window, CI dropping 2.8 → 2.5, HARVEST SOON!

What Each Phase Means for Harvest

Phase What's Happening Harvest Risk Action
Germination Seeds sprouting None yet Monitor
Tillering Shoots growing Still young Keep watering
Grand Growth Peak growth ⚠️ Starting to mature Plan harvest window
Maturation Sugar concentrating 🚨 Ready soon Watch weekly for CI drop

📈 How to Read CI Values

CI Value    What It Means                    Harvest Status
0.0-1.0     Bare/no crop                     ✅ Recently harvested
1.0-2.0     Germinating/early growth        ❌ Not ready
2.0-2.8     Active growth                   ⚠️ Getting close (mature crops)
2.8-3.2     Peak growth                     💡 Ready window approaching
3.2-3.5     Healthy mature crop             ✅ Could harvest now
3.5+        Exceptional growth              ✅ Definitely harvest-ready

The Harvest Signal:

  • CI dropping below 2.5 = Harvest has likely occurred
  • CI stable at 3.0+ for >6 weeks = Ready to harvest anytime
  • CI rising = Crop still growing, don't harvest yet

🔍 Diagnosing Issues: Troubleshooting Guide

Problem: "My field shows Germination but it's been 20 weeks!"

Cause: Planting date in database is wrong → Fix: Check harvest.xlsxseason_start column → correct if needed

Problem: "CI graph shows huge jumps up/down"

Cause: Cloud cover or sensor error → Fix: Look at smoothed line (7-day rolling average), not raw values

Problem: "Harvest prediction says 2 weeks but field looks mature"

Cause: Model uses historical peak-to-harvest duration (120-150 days) → Fix: Override if field visibly ready; model learns from each new harvest

Problem: "Different scripts give different harvest dates"

Cause: Multiple prediction methods not unified → Fix: Use predict_harvest_operational.R as the PRIMARY source of truth


📊 Key Files to Know

File Purpose When to Use
predict_harvest_operational.R Primary harvest prediction Every week, for alerts
r_app/14_generate_report_with_phases.R Generate Word reports Weekly reporting
laravel_app/storage/app/esa/Data/harvest.xlsx Ground truth harvest dates For validation & learning
r_app/03_interpolate_growth_model.R Refresh CI data Before any analysis
r_app/experiments/ci_graph_exploration/12_phase_specific_analysis.R Deep phase analysis Understanding patterns

🎯 Weekly Workflow

Every Monday Morning:

  1. Update data (if new satellite imagery available):

    Rscript r_app/03_interpolate_growth_model.R esa
    
  2. Generate alert report:

    Rscript predict_harvest_operational.R
    

    → Check console output for fields with ⚠️ or 🚨 alerts

  3. Create Word report for stakeholders:

    Rscript r_app/14_generate_report_with_phases.R esa 2025-12-03
    

    → Send output/*.docx file to farm managers

  4. Record actual harvests (once they occur):

    • Update laravel_app/storage/app/esa/Data/harvest.xlsx
    • Add date to validate predictions

🔬 Deep Dive: Understanding the Science

Why CI for Harvest Prediction?

Sugarcane growth follows a predictable pattern:

  1. Early growth: Low CI (1.0-2.0), plant is small
  2. Rapid expansion: Rising CI (2.0-3.0), biomass accumulating
  3. Peak growth: High CI (3.2-3.5), all leaves present
  4. Senescence: Declining CI (3.5→2.5), leaves yellowing, sugar concentrating
  5. Harvest-ready: Low CI (2.0-2.5), field looks pale/dried

The Harvest Window: Typically after peak CI for 120-150 days, when sugar concentration is highest.

Why Two-Stage Prediction?

  1. Stage 1 (Curve Fitting): "Based on growth curve, when will field reach peak?"
  2. Stage 2 (Senescence): "Based on CI drop rate, when will it be harvest-ready?"

Both stages together = more accurate prediction than either alone.


📞 Common Questions Answered

Q: "Does my field have enough CI to harvest?" A: Check if field is in "Maturation" phase AND CI > 2.8 AND CI has been stable for 6+ weeks.

Q: "Why do different fields have different peak CIs?" A: Soil, water, rainfall, variety differences. Model learns from each field's history.

Q: "Can I harvest before CI drops?" A: Yes, but sugar concentration may not be optimal. Ideal = harvest during Maturation phase at CI 3.0-3.2.

Q: "How accurate are the harvest predictions?" A: 80% within 2 weeks, 95% within 4 weeks (validated on historical data).

Q: "What if field is manually harvested early?" A: Update harvest.xlsx immediately; prediction model learns from it next run.


🚨 Alerts & What They Mean

Alert Levels (from predict_harvest_operational.R)

Alert Meaning Action
🚨 HARVEST IMMINENT (CI < 2.5) Field already harvested Verify in field
⚠️ HARVEST WITHIN 2 WEEKS Maturation phase active Prepare harvest equipment
💡 HARVEST WITHIN 1 MONTH Grand Growth→Maturation transition Plan harvesting crew
STILL GROWING Pre-peak phase Continue monitoring
📊 MONITORING Early growth phase Normal

🎓 Learning Resources

  • Phase definitions: See r_app/14_generate_report_with_phases.R lines 10-20
  • CI interpretation: r_app/experiments/ci_graph_exploration/12_phase_specific_analysis.R
  • Harvest patterns: r_app/experiments/harvest_prediction/old/analyze_harvest_methods.R
  • Full theory: GROWTH_PHASE_AND_HARVEST_PREDICTION_MAP.md (detailed version)

🔗 Next Steps

  1. Run the three commands above to see what system does
  2. Check harvest.xlsx to verify your actual harvests match predictions
  3. If predictions are off, update thresholds in parameters_project.R
  4. Automate weekly: Set Windows task to run scripts every Monday

📋 Checklist: System Health Check

  • Latest satellite data downloaded (within 7 days)
  • CI interpolation script ran successfully
  • All fields have planting dates in harvest.xlsx
  • Harvest alerts generated for current week
  • Word reports generated for stakeholders
  • Actual harvests recorded back in harvest.xlsx for model learning

If all checked: System is operating normally


💡 Pro Tips

  1. Ignore very first 2 weeks of data (germination phase noisy)
  2. Focus on Week 6+ predictions (more reliable once past emergence)
  3. Update harvest.xlsx within 1 week of actual harvest (helps model learn)
  4. Visualize phase changes in Word report (helps spot problems)
  5. Validate 2-3 fields manually each season (ground-truth checking)

Questions? See the detailed map: GROWTH_PHASE_AND_HARVEST_PREDICTION_MAP.md