APSIMInitiative / ApsimX

ApsimX is the next generation of APSIM
http://www.apsim.info
Other
138 stars 167 forks source link

error: NaN (not a number) found when getting variable: [Leaf].Fw #7947

Closed markosdask closed 1 year ago

markosdask commented 1 year ago

Hi, could anyone explain the reason for the below error?

Unable to evaluate linear interpolation function .Vineyard.Row.Grapevine.Leaf.CohortParameters.ExpansionStress --> NaN (not a number) found when getting variable: [Leaf].Fw

I am just trying to see if the grapevine works with data from Greece and this error constantly comes up, even if I try the weather data with other simulations (e.g. barley, wheat) in order to check if I have appropriately created my weather data in excel format. the details of the error are below. Thanks

ERROR in file: C:\Users\marko\OneDrive\Documents\14_climate_change\testing_learning\grapevine_new_markos_drama_testing.apsimx Simulation name: Vineyard Models.Core.SimulationException ---> System.Exception: Unable to evaluate linear interpolation function .Vineyard.Row.Grapevine.Leaf.CohortParameters.ExpansionStress ---> System.Exception: NaN (not a number) found when getting variable: [Leaf].Fw at Models.Functions.VariableReference.Value(Int32 arrayIndex) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Functions\VariableReference.cs:line 49 at Models.Functions.LinearInterpolationFunction.Value(Int32 arrayIndex) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Functions\LinearInterpolationFunction.cs:line 101 --- End of inner exception stack trace --- at Models.Functions.LinearInterpolationFunction.Value(Int32 arrayIndex) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Functions\LinearInterpolationFunction.cs:line 101 at Models.PMF.Organs.Leaf.OnDoPotentialPlantGrowth(Object sender, EventArgs e) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\PMF\Organs\Leaf.cs:line 1257 at Models.Clock.OnDoCommence(Object sender, CommenceArgs e) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Clock.cs:line 377 at Models.Core.Simulation.Run(CancellationTokenSource cancelToken) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Core\Simulation.cs:line 290 --- End of inner exception stack trace --- at Models.Core.Simulation.Run(CancellationTokenSource cancelToken) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Core\Simulation.cs:line 299 at Models.Core.Run.SimulationDescription.Run(CancellationTokenSource cancelToken) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Core\Run\SimulationDescription.cs:line 133 at APSIM.Shared.JobRunning.JobRunner.RunActualJob(IRunnable job, IJobManager jobManager) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\APSIM.Shared\JobRunning\JobRunner.cs:line 213

par456 commented 1 year ago

Is it possible for you upload a copy of your weather file so we can take a look? We might also need your apsimx file if you've already modified parts of it from, otherwise I'll just check it against the example grapevine.

markosdask commented 1 year ago

Hi Andrew, The excel has the weather data. test-clima-drama_HISTORY_DATA_for_bug_survey.xlsx

The APSIMX grapevine has nothing changed except the "tree initialisation" in soil adjusted to the first date of the weather data (1/1/1951). Nothing else has been changed as I was looking into only to check that it runs and then start changing some factors. I uploaded in zip file the .apsimX, .bak and .db file . If I am not correct please let me know.

grapevine_test_drama_markos_with error.apsimx.zip thanks, Markos.

par456 commented 1 year ago

Just tried out your files and they ran on my end without any problems. I note you're still on version 159, so try updating apsimx to the newest version, that should hopefully fix the problem.

markosdask commented 1 year ago

Hi again, updated to latest version. same main error again: Unable to evaluate linear interpolation function .Vineyard.Row.Grapevine.Leaf.CohortParameters.ExpansionStress --> NaN (not a number) found when getting variable: [Leaf].Fw the "more information" has changed a little bit , i think in the lines that the error is shown (?) the only thing I have changed is Reset date, from "10-Jan" to "10 Jul" in both row and soil in order to be in northern hemisphere (i suppose) In the weather data window, the "Qmax" has the "minus infinite" symbol in many lines. Is there a chance, this to be the problem? besides that I do not understand what the Qmax is... the new file attached: grapevine_test_drama_markos_upd_apsimX_still_same_error.zip

ERROR in file: C:\Users\marko\OneDrive\Documents\14_climate_change\testing_learning\grapevine_new_markos_dramatesting.apsimx Simulation name: Vineyard Models.Core.SimulationException ---> System.Exception: Unable to evaluate linear interpolation function .Vineyard.Row.Grapevine.Leaf.CohortParameters.ExpansionStress ---> System.Exception: NaN (not a number) found when getting variable: [Leaf].Fw at Models.Functions.VariableReference.Value(Int32 arrayIndex) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Functions\VariableReference.cs:line 49 at Models.Functions.LinearInterpolationFunction.Value(Int32 arrayIndex) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Functions\LinearInterpolationFunction.cs:line 101 --- End of inner exception stack trace --- at Models.Functions.LinearInterpolationFunction.Value(Int32 arrayIndex) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Functions\LinearInterpolationFunction.cs:line 101 at Models.PMF.Organs.Leaf.OnDoPotentialPlantGrowth(Object sender, EventArgs e) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\PMF\Organs\Leaf.cs:line 1257 at Models.Clock.OnDoCommence(Object , CommenceArgs e) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Clock.cs:line 380 at Models.Core.Simulation.Run(CancellationTokenSource cancelToken) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Core\Simulation.cs:line 292 --- End of inner exception stack trace --- at Models.Core.Simulation.Run(CancellationTokenSource cancelToken) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Core\Simulation.cs:line 301 at Models.Core.Run.SimulationDescription.Run(CancellationTokenSource cancelToken) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\Models\Core\Run\SimulationDescription.cs:line 132 at APSIM.Shared.JobRunning.JobRunner.RunActualJob(IRunnable job, IJobManager jobManager) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\APSIM.Shared\JobRunning\JobRunner.cs:line 213

markosdask commented 1 year ago

@par456 is there any chance you may video your run with the data so that I can view them and check what I am doing wrong, or perhaps telco somehow (don't mind about my time difference!) thanks.

par456 commented 1 year ago

It still worked on my end, but I think you've got it right, I don't have any minus infinity lines in the weather data when I import it. That certainly could cause NaN errors within the program if its happening on your end.

I've attached the sim I just ran with all the files it would need, give that a go on your end and if it's still out, then we might needed to have video chat and see what's gone wrong.

grapevine_test_drama_running.zip

markosdask commented 1 year ago

Good morning, I runned it, same error. if you do not see Qmax values with "minus infinite" then there might be a problem because i see them again in your apsimx file that i opened to run it. below are the printscreens: error_NaN Qmax_minus_infinite

let me know if you want to telco. thanks.

zur003 commented 1 year ago

I see that @markosdask has comma as the decimal separator. Any chance that this could be a locale issue?

markosdask commented 1 year ago

@zur003 from the apsimX original weather files, I copied the MetData excel file as a template to create mine. I just checked it again and all have commas (lincoln, Dalby, etc).

par456 commented 1 year ago

I think Eric is onto something there, if it's importing the numbers with commas instead of periods for the decimals, apsim might be having a problem. My calculated QMax values are also different from yours which does suggest it's having trouble reading something in.

I've converted your excel file to a .met file to see if that is being caused by importing from excel. Try that out and if that still doesn't work, try using the Kingaroy.met weather in .\APSIM2023\Examples\WeatherFiles and see if that works. If all those fail, then at least it rules out any formatting problems in the weather files and I can start digging for another solution.

test-clima-drama_with_met_file.zip

markosdask commented 1 year ago

@par456 the file you sent me, it run! Thank you. Kingaroy.met file also run! Sorry @zur003 I did not understand that actually the commas shown might be periods in the actual file. So how should I proceed?

par456 commented 1 year ago

Glad that it worked, I know what the issue you have is now. I'll probably have a look at it tomorrow because it seems like an easy fix on our end.