ajwdewit / pcse

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

KeyError: 'DVS' with WOFOST8? #59

Closed Han-Su22 closed 2 years ago

Han-Su22 commented 2 years ago

Dear all,

I am learning to use PCSE and WOFOST8. I used the pcse_notebooks. When I replaced the WOFOST7 with WOFOST8 (Wofost80_NWLP_FD_beta, WOFOST80SiteDataProvider) in the #7 notebook, 'Running crop rotations', I got an error:

KeyError: 'DVS'

It seems that, when using WOFOST8, 'DVS' is not registered during the initialization stage. Since 'DVS' is used in the NPK soil module of WOFOST8, it raised this error. Do you have any idea how to deal with it?

Best, Han

Han-Su22 commented 2 years ago

When using the WOFOST7, the 'DVS' is NAN in this case. Is that the reason? Does it mean we should consider 'DVS' is NAN in the NPK soil module?

Han-Su22 commented 2 years ago

I added an if condition in the function calc_rates() of npk_soil_dynamics.py:

if "DVS" in k.keys() and "RFTRA" in k.keys():

Only calculate the rate when crops grow to solve the issue. Please correct me if I am wrong.

ajwdewit commented 2 years ago

Dear Han,

Can you try the latest version on the 'develop' branch. I think it should be solved in develop. There was indeed a problem with the npk_soil_dynamics which occurred with the model was started before crop emergence and some crop states were not available yet.

with best regards,

Allard

Han-Su22 commented 2 years ago

Dear Allard,

Thanks for your update. This problem is solved in develop.

Best, Han