Skip to content

GeoEPIC Single Site Tutorial

This tutorial provides step-by-step guidance on setting up and running a single site simulation in GeoEPIC.

  1. Set Up Environment: This initial step involves configuring your local machine and installing the necessary geoEpic components. For detailed instructions on downloading and running the setup script (epic_setup.bat), please refer to the Installation Page. Completing this step ensures your system is ready to use geoEpic functionalities.

  2. Prepare Input Files: This step involves gathering or creating the four essential input files required by the EPIC model: Site File (.SIT), Soil File (.SOL), Weather File (.DLY), and Operation Schedule File (.OPC). These files contain the specific environmental data and management practices for your simulation site.

    • For detailed guidance on creating/downloading the Site (.SIT) file, refer to the Site File Section in the getting started menu. Example using geoEpic:
      from geoEpic.io import SIT
      sit_file = SIT.load('./umstead.SIT')
      sit_file.area = 1.5
      sit_file.save('umstead_new.SIT')
      
    • For detailed guidance on creating/downloading the Soil (.SOL) file, refer to the Soil File Section in the getting started menu. Example using geoEpic:
      from geoEpic.io import SOL
      from geoEpic.utils import Wicket
      lat, lon = 35.890, -78.750
      wicket = Wicket.from_wkt(f"POINT({lon} {lat})")
      soil_file = SOL.from_sda(wicket)
      soil_file.save('./soil/files/umstead.SOL')
      
    • For detailed guidance on creating/downloading the Weather (.DLY) file, refer to the Weather File Section in the getting started menu. Example using geoEpic:
      from geoEpic.weather import get_daymet_data
      from geoEpic.io import DLY
      lat, lon = 35.890, -78.750
      start_date, end_date = '2015-01-01', '2019-12-31'
      df = get_daymet_data(lat, lon, start_date, end_date)
      DLY(df).save('./weather/NCRDU.DLY')
      
    • For detailed guidance on creating the Operation Schedule (.OPC) file, including using the generate_opc command, refer to the Operation Schedule File Section in the getting started menu. Example command:
      geo_epic generate_opc -c crop_data.csv -t crop_templates -o ./files
      
      Successfully preparing these files provides the model with all necessary inputs for the specific site simulation.
  3. Run Simulation: Once the input files are ready, this step involves configuring the simulation parameters (like start date, duration, desired outputs) and executing the EPIC model for your site. For detailed instructions on using the Site and EPICModel classes, setting parameters, and calling the model.run(site) method, please refer to the Running Simulations Guide. This step performs the core simulation process based on the prepared inputs.

  4. Process Outputs: After the simulation completes, this step involves reading, analyzing, and visualizing the results generated by the EPIC model. The output files contain valuable information about crop yields, soil conditions, water balance, and other environmental metrics.

    • Reading Output Files: EPIC generates various output files. Key ones include ACY (Annual Crop Yield) and DGN (Daily General). Use geoEpic.io classes to read them:

      from geoEpic.io import ACY, DGN
      import pandas as pd
      
      # Assuming 'site' object exists and model has run
      # site.outputs dictionary holds paths to output files.
      
      # Access Annual Crop Yield data
      yields = ACY(site.outputs['ACY']).get_var('YLDG')
      print(yields)
      
      Example output:
        index    YR   CPNM    YLDG
      0      0  2015   CORN   7.175
      1      1  2016   CORN   4.735
      2      2  2017   CORN   9.072
      3      3  2018   CORN   7.829
      4      4  2019   CORN   5.434
      

    • Visualizing Results: Create plots to understand trends. Example: Plotting annual yields:

      import matplotlib.pyplot as plt
      
      plt.figure(figsize=(10, 6))
      plt.bar(yields['YR'], yields['YLDG'], color='green')
      plt.title('Annual Corn Yield (2015-2019)')
      plt.xlabel('Year')
      plt.ylabel('Yield (t/ha)')
      plt.grid(axis='y', linestyle='--', alpha=0.7)
      plt.xticks(yields['YR'])
      plt.tight_layout()
      plt.show()
      
      Example: Plotting daily Leaf Area Index (LAI):
      # Access daily LAI data
      lai = DGN(site.outputs['DGN']).get_var('LAI')
      
      plt.figure(figsize=(12, 6))
      plt.plot(lai['Date'], lai['LAI'], color='darkgreen', linewidth=2)
      plt.title('Leaf Area Index (LAI) Over Time')
      plt.xlabel('Date')
      plt.ylabel('LAI')
      plt.grid(True, alpha=0.3)
      plt.tight_layout()
      plt.show()
      

    • Advanced Analysis: Combine different output variables for deeper insights. Example: Merging precipitation and soil water:

      # Extract precipitation and soil moisture
      dgn_data = DGN(site.outputs['DGN'])
      precip = dgn_data.get_var('PRCP')
      soil_water = dgn_data.get_var('SW') # Example variable code
      
      # Merge data
      merged_data = pd.merge(precip, soil_water, on='Date')
      
      # Add your analysis code here...
      print(merged_data.head())
      

    • Exporting Results: Save your processed data for reports or further use:

      # Export annual yields to CSV
      yields.to_csv('corn_yields_2015_2019.csv', index=False)
      
      # Export daily data to Excel
      with pd.ExcelWriter('simulation_results.xlsx') as writer:
         yields.to_excel(writer, sheet_name='Annual_Yields', index=False)
         lai.to_excel(writer, sheet_name='Daily_LAI', index=False)
         # merged_data.to_excel(writer, sheet_name='Daily_Weather_Soil', index=False)
      
      This final step allows you to interpret the simulation outcomes and draw conclusions about the site's behavior under the simulated conditions.