From f3b27af3e884b3c8d6cf284b8f0416505d67c2ef Mon Sep 17 00:00:00 2001 From: Manuel Klarmann Date: Thu, 4 Jun 2026 13:48:45 +0200 Subject: [PATCH] Fix c_month() ignoring its input (always returned all-zeros) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c_month() initialised m_month to np.zeros and then tested m_month[i] (the zeros it had just created) instead of the input months, so no branch ever fired and the function returned an all-zeros array regardless of its argument — silently disabling the tillage month-correction. Seed m_month from in_month so the Dec/Jan -> February remapping operates on the real event months. Fixes #3 --- SALCAnitrate/SALCAnitrate_field.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SALCAnitrate/SALCAnitrate_field.py b/SALCAnitrate/SALCAnitrate_field.py index 94b6bec..a849f86 100644 --- a/SALCAnitrate/SALCAnitrate_field.py +++ b/SALCAnitrate/SALCAnitrate_field.py @@ -71,8 +71,10 @@ def c_month(in_month): ''' # import the numpy module again for the SALCAfuture environment import numpy as np - # generate an array with zeros the length of the input - m_month = list(np.zeros(len(in_month))) + # copy the input so the month remapping below operates on the real event + # months (previously this was np.zeros, so the loop tested zeros and the + # function always returned an all-zeros array regardless of its input) + m_month = list(in_month) # for each month in the input list for i in range(len(in_month)): # returns 0 for no event