gicait / PyAEZ

PyAEZ is a python package consisted of many algorithms related to Agro-ecalogical zoning (AEZ) framework.
MIT License
74 stars 51 forks source link

3 fixes to ClimateRegime.py #100

Closed kerriegeil closed 6 months ago

kerriegeil commented 6 months ago

Hey guys. I've been working on a sped up version of module 1 and comparing it's outputs to the outputs of the repo model version. During this process I've found a few bugs in the repo version of pyaez. They are in ClimateRegime.py:

1) in getLGP. The initialization of Sb_old and Wb_old to zero for each grid cell needs to be moved inside the spatial loops for the zero initialization to work as intended. Otherwise, the Sb_old and Wb_old will initialize to the new bucket values for the previous grid cell.

2) in AEZClassification. This is a weird one, but there are two conditional statements in this function that aren't working as intended and python will not throw an error in this case. The problem arises when using 'variable[row,col] in [val1,val2,val3,val4]' in an 'elif' conditional statement. This part of the condition needs to be enclosed in parentheses or the statement won't work as intended.

3) in getMultiCroppingZones. The order of the inputs in the function does not match the order of the inputs in the notebook. I've updated the order in the .py file instead of the notebook. It's the last two inputs that are the offenders ts_t0 and ts_t10.

kerriegeil commented 6 months ago

one more bug I forgot about... the last part of the huge if-elif-elif-elif-else-block in EtaCalc is missing the sbx equation. I'm guessing that sbx=sb_old-snm is what's missing based on the previous sections of the if-block. I'm not sure why this doesn't error because for pixels that fall under the 'else' part of this block, the function returns Sb365 without having computed it.