ajwdewit / pcse

Repository for the Python Crop Simulation Environment
Other
191 stars 127 forks source link

In one wofost model, the'apply_npk' event and the 'irrigate' event do not work. #38

Closed agnaru closed 4 years ago

agnaru commented 4 years ago

I'm trying to modify agromanagement file for wofost model and change apply_npk values and irrigation like this:

agro = '''
- 1988-01-01:
    CropCalendar:
        crop_name: wheat
        variety_name: winter-wheat
        crop_start_date: 1988-01-01
        crop_start_type: emergence
        crop_end_date:
        crop_end_type: maturity
        max_duration: 300
    TimedEvents:
    -   event_signal: irrigate
        name: Irrigation application table
        comment: All irrigation amounts in cm
        events_table:
        - 1988-03-05: {amount: 10, efficiency: 0.7}
        - 1988-03-20: {amount: 10, efficiency: 0.7}
        - 1988-04-01: {amount: 10, efficiency: 0.7}
        - 1988-04-10: {amount: 10, efficiency: 0.7}
        - 1988-05-10: {amount: 10, efficiency: 0.7}
    -   event_signal: apply_npk
        name:  Timed N/P/K application table
        comment: All fertilizer amounts in kg/ha
        events_table:
        - 1988-04-29: {N_amount: 0., P_amount: 40., K_amount: 20., N_recovery: 0.7, P_recovery: 0.7, K_recovery: 0.7}
        - 1988-06-16: {N_amount: 0., P_amount: 10., K_amount: 20., N_recovery: 0.7, P_recovery: 0.7, K_recovery: 0.7}
    StateEvents: null
'''
agro = yaml.safe_load(agro)

Wofost71_WLP_FD doesn't respond to apply_NPK events. (only respond to irrigate events)

Howerver, when i use wofost = Engine(params, weather, agro, config="Wofost71_NPK.conf"), it doesn't respond to irrigate events, but respond to apply_NPK events

Wofost71_PP model doesn't react to both events.

my question is, is there a wofost model that responds to both events? Or is it not implemented yet? Or is it a bug?

S-lac commented 4 years ago

Have you edited the configuration ? If I recall correctly the 'Wofost71_NPK.conf' if you haven't changed it uses the SOIL = WaterbalancePP which is (from the code) :

"""Fake waterbalance for simulation under potential production.

Keeps the soil moisture content at field capacity and only accumulates crop transpiration
and soil evaporation rates through the course of the simulation
"""

If you want it to respond to irrigation, maybe just switch it to SOIL = WaterbalanceFD ?

agnaru commented 4 years ago

@S-lac Oh my, I didn't read the soil file properly.

Thanks! Now, Wofost71_NPK responds to irrigation event by just switching SOIL = WaterbalancePP to SOIL = WaterbalanceFD

S-lac commented 4 years ago

No worries ! For the others, obviously I forgot to mention that you need to import the right module beforehands : from pcse.soil.classic_waterbalance import WaterbalanceFD . Have nice simulations !

mishagrol commented 3 years ago

@jjanggu1993 Hello! Can you share your config="Wofost71_NPK.conf file ? I met the same problem

I use SOIL = WaterbalanceFD and CROP = WofostNPK

but model doesn't respond to irrigation events, thanks!

# Copyright (c) 2004-2014 Alterra, Wageningen-UR
# Allard de Wit (allard.dewit@wur.nl), April 2014
"""PCSE configuration file for WOFOST Water-limited Production simulation
in PCSE identical to the FORTRAN WOFOST 7.1

This configuration file defines the soil and crop components that
should be used for water-limited production simulation for
freely draining soils.
"""

from pcse.soil.classic_waterbalance import WaterbalanceFD
#from pcse.soil.classic_waterbalance import WaterbalancePP
from pcse.crop.wofost_npk import WofostNPK
from pcse.agromanagement import AgroManagementSingleCrop
from pcse.agromanager import AgroManager

# Module to be used for water balance
SOIL = WaterbalanceFD

# Module to be used for the crop simulation itself
CROP = WofostNPK

# Module to use for AgroManagement actions
AGROMANAGEMENT = AgroManagementSingleCrop

# variables to save at OUTPUT signals
# Set to an empty list if you do not want any OUTPUT
OUTPUT_VARS = ["DVS","LAI","TAGP", "TWSO", "TWLV", "TWST",
               "TWRT", "TRA", "RD", "SM", "WWLOW", "NNI",
                "KNI", "PNI", "NPKI","NSOIL","PSOIL","KSOIL",
                "NAVAIL", "PAVAIL","KAVAIL",
                "NDEMLV", "NDEMRT","NDEMSO","NDEMST",
                "PDEMLV", "PDEMRT","PDEMSO","PDEMST",
                "KDEMLV", "KDEMRT","KDEMSO","KDEMST",
                "RNUPTAKE", "RPUPTAKE", "RKUPTAKE", "RNFIX",
                "NTRANSLOCATABLE", "PTRANSLOCATABLE", "KTRANSLOCATABLE"]
# interval for OUTPUT signals, either "daily"|"dekadal"|"monthly"
# For daily output you change the number of days between successive
# outputs using OUTPUT_INTERVAL_DAYS. For dekadal and monthly
# output this is ignored.
OUTPUT_INTERVAL = "daily"
OUTPUT_INTERVAL_DAYS = 1
# Weekday: Monday is 0 and Sunday is 6
OUTPUT_WEEKDAY = 0

# Summary variables to save at CROP_FINISH signals
# Set to an empty list if you do not want any SUMMARY_OUTPUT
SUMMARY_OUTPUT_VARS = ["DVS","LAIMAX","TAGP", "TWSO", "TWLV", "TWST",
                       "TWRT", "CTRAT", "RD", "DOS", "DOE", "DOA",
                       "DOM", "DOH", "DOV"]

# Summary variables to save at TERMINATE signals
# Set to an empty list if you do not want any TERMINAL_OUTPUT
TERMINAL_OUTPUT_VARS = ["WTRAT", "EVST", "EVWT", "TSR", "RAINT", "TOTINF",
                        "TOTIRR", "PERCT", "LOSST"]
agnaru commented 3 years ago

@mishagrol I'm sorry to check late. this is my Wofost71_NPK.conf file.

# -*- coding: utf-8 -*-
# Copyright (c) 2004-2014 Alterra, Wageningen-UR
# Allard de Wit (allard.dewit@wur.nl), April 2014
"""PCSE configuration file for WOFOST Water-limited Production simulation
in PCSE identical to the FORTRAN WOFOST 7.1

This configuration file defines the soil and crop components that
should be used for water-limited production simulation for
freely draining soils.
"""

from pcse.soil.classic_waterbalance import WaterbalancePP
from pcse.soil.classic_waterbalance import WaterbalanceFD
from pcse.crop.wofost_npk import WofostNPK
from pcse.agromanager import AgroManager

# Module to be used for water balance
SOIL = WaterbalanceFD

# Module to be used for the crop simulation itself
CROP = WofostNPK

# Module to use for AgroManagement actions
AGROMANAGEMENT = AgroManager

# variables to save at OUTPUT signals
# Set to an empty list if you do not want any OUTPUT
OUTPUT_VARS = ["DVS","LAI","TAGP", "TWSO", "TWLV", "TWST",
               "TWRT", "TRA", "RD", "SM", "WWLOW", "NNI",
                "KNI", "PNI", "NPKI","NSOIL","PSOIL","KSOIL",
                "NAVAIL", "PAVAIL","KAVAIL",
                "NDEMLV", "NDEMRT","NDEMSO","NDEMST",
                "PDEMLV", "PDEMRT","PDEMSO","PDEMST",
                "KDEMLV", "KDEMRT","KDEMSO","KDEMST",
                "RNUPTAKE", "RPUPTAKE", "RKUPTAKE", "RNFIX",
                "NTRANSLOCATABLE", "PTRANSLOCATABLE", "KTRANSLOCATABLE"]
# interval for OUTPUT signals, either "daily"|"dekadal"|"monthly"
# For daily output you change the number of days between successive
# outputs using OUTPUT_INTERVAL_DAYS. For dekadal and monthly
# output this is ignored.
OUTPUT_INTERVAL = "daily"
OUTPUT_INTERVAL_DAYS = 1
# Weekday: Monday is 0 and Sunday is 6
OUTPUT_WEEKDAY = 0

# Summary variables to save at CROP_FINISH signals
# Set to an empty list if you do not want any SUMMARY_OUTPUT
SUMMARY_OUTPUT_VARS = ["DVS","LAIMAX","TAGP", "TWSO", "TWLV", "TWST",
                       "TWRT", "CTRAT", "RD", "DOS", "DOE", "DOA",
                       "DOM", "DOH", "DOV"]

# Summary variables to save at TERMINATE signals
# Set to an empty list if you do not want any TERMINAL_OUTPUT
TERMINAL_OUTPUT_VARS = ["WTRAT", "EVST", "EVWT", "TSR", "RAINT", "TOTINF",
                        "TOTIRR", "PERCT", "LOSST"]