APSIMInitiative / ApsimX

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

How to correctly add cultivar commands to modify simulated phenology and yield? #8514

Open iMarang opened 6 months ago

iMarang commented 6 months ago

What is your question?

Question: how to modify cultivar commands correctly in Apsim next gen?

I'm testing an optimisation routine whereby APSIM simulation results (yield, LAI, soil moisture) are checked against observations (yield, LAI, soil moisture) to modify run parameters to improve model fit. I've implemented this successfully in previous versions of Apsim next gen (pre-2021), but am struggling with the 2023.9.7308.0 version I'm using currently.

A bunch of apsimx files are attached, each with a Replacement node containing all simulation details including a cultivar 'Gregory' with commands spelling out the phenology parameter updates for optimising the run. Also attached is the weather file. test_updateCultParams.zip

For example: [Phenology].Phyllochron.BasePhyllochron.FixedValue = 140 [Phenology].CAMP.EnvData.VrnTreatDuration = 112 [Phenology].CAMP.EnvData.VrnTreatTemp = 21.0 [Phenology].CAMP.FLNparams.MinLN = 16 [Phenology].CAMP.FLNparams.PpLN = 16 [Phenology].CAMP.FLNparams.VrnLN = 14 [Phenology].CAMP.FLNparams.VxPLN = -3 [Phenology].HeadEmergenceLongDayBase.FixedValue = 140 [Phenology].HeadEmergencePpSensitivity.FixedValue = 1 [Phenology].PhyllochronPpSensitivity.FixedValue = 1.12

and [Phenology].Phyllochron.BasePhyllochron.FixedValue = 50 [Phenology].CAMP.EnvData.VrnTreatDuration = 40 [Phenology].CAMP.EnvData.VrnTreatTemp = 7.5 [Phenology].CAMP.FLNparams.MinLN = 6 [Phenology].CAMP.FLNparams.PpLN = 6 [Phenology].CAMP.FLNparams.VrnLN = 5 [Phenology].CAMP.FLNparams.VxPLN = -3 [Phenology].HeadEmergenceLongDayBase.FixedValue = 50 [Phenology].HeadEmergencePpSensitivity.FixedValue = 1 [Phenology].PhyllochronPpSensitivity.FixedValue = 0.4

Return precisely the same results (same yield, LAI and soil moisture) for all dates and params (e.g., yield of 564.680 g/m2 on 11/11/2016). Note, I'm not setting these based on realistic thresholds, I'm just testing the APSIM response preparatory to assessing realism.

ric394 commented 5 months ago

I've created a simple file that shows how to do this by adding the cultivars to a wheat model in replacements. The cultivars will then be available in your "Sowing using a variable rule". test_Narr91_updatePhyllochron_setup_example.zip

When I ran the two simulations I got differing values once it's setup in this manner as seen below:

image
iMarang commented 5 months ago

Thanks Julian, that looks to be precisely what I'm going for in terms of impact on modelled yield. Only issue is I can't open the .apsimx on my installed version to interrogate the structure as your set up is from a later version of Apsim. Could you add a screenshot of the simulation from that file?

I'm using APSIM 2023.9.7308 and wish to retain the same version on both my local machine and VM to avoid coding errors. While I'd prefer to use the latest version in most cases, during the build process it's easier to keep the same JSON pathing. Once I have the prototype up and running, I'll look to build a version control pipeline to allow upgrading the model version.

Also, Happy New Year. Hope your 2024 is glorious.

On Thu, Jan 11, 2024 at 11:23 AM Julian Rich @.***> wrote:

I've created a simple file that shows how to do this by adding the cultivars to a wheat model in replacements. The cultivars will then be available in your "Sowing using a variable rule". test_Narr91_updatePhyllochron_setup_example.zip https://github.com/APSIMInitiative/ApsimX/files/13895769/test_Narr91_updatePhyllochron_setup_example.zip

When I ran the two simulations I got differing values once it's setup in this manner as seen below: image.png (view on web) https://github.com/APSIMInitiative/ApsimX/assets/123442863/77ed5312-6a66-4f2e-8265-3605f3ee52ef

— Reply to this email directly, view it on GitHub https://github.com/APSIMInitiative/ApsimX/issues/8514#issuecomment-1885975288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFN7AJCTJ4M35VN27HU2XVDYN4WI7AVCNFSM6AAAAABA35WEBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVHE3TKMRYHA . You are receiving this because you authored the thread.Message ID: @.***>

ric394 commented 5 months ago

Sure thing. This replacements folder sits under Simulations, I couldn't show it in the screenshot but this should be enough structure to do what you need.

I hope this helps.

[cid:b51f61b8-85a7-452a-bb9f-d57038c2ecf3]

Julian Rich

Software Developer | CSIRO

@.**@.> | 0423 428 566


From: iMarang @.> Sent: Friday, January 12, 2024 02:25 To: APSIMInitiative/ApsimX @.> Cc: Rich, Julian (A&F, Toowoomba) @.>; State change @.> Subject: Re: [APSIMInitiative/ApsimX] How to correctly add cultivar commands to modify simulated phenology and yield? (Issue #8514)

Thanks Julian, that looks to be precisely what I'm going for in terms of impact on modelled yield. Only issue is I can't open the .apsimx on my installed version to interrogate the structure as your set up is from a later version of Apsim. Could you add a screenshot of the simulation from that file?

I'm using APSIM 2023.9.7308 and wish to retain the same version on both my local machine and VM to avoid coding errors. While I'd prefer to use the latest version in most cases, during the build process it's easier to keep the same JSON pathing. Once I have the prototype up and running, I'll look to build a version control pipeline to allow upgrading the model version.

Also, Happy New Year. Hope your 2024 is glorious.

On Thu, Jan 11, 2024 at 11:23 AM Julian Rich @.***> wrote:

I've created a simple file that shows how to do this by adding the cultivars to a wheat model in replacements. The cultivars will then be available in your "Sowing using a variable rule". test_Narr91_updatePhyllochron_setup_example.zip https://github.com/APSIMInitiative/ApsimX/files/13895769/test_Narr91_updatePhyllochron_setup_example.zip

When I ran the two simulations I got differing values once it's setup in this manner as seen below: image.png (view on web) https://github.com/APSIMInitiative/ApsimX/assets/123442863/77ed5312-6a66-4f2e-8265-3605f3ee52ef

— Reply to this email directly, view it on GitHub https://github.com/APSIMInitiative/ApsimX/issues/8514#issuecomment-1885975288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFN7AJCTJ4M35VN27HU2XVDYN4WI7AVCNFSM6AAAAABA35WEBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVHE3TKMRYHA . You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHubhttps://github.com/APSIMInitiative/ApsimX/issues/8514#issuecomment-1887522420, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5NZNL3RK5TD5TSECTQ4JLDYOAHAVAVCNFSM6AAAAABA35WEBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBXGUZDENBSGA. You are receiving this because you modified the open/close state.Message ID: @.***>

iMarang commented 5 months ago

Sorry Julian, I'm not sure I follow. I had a look into your .apsimx example a bit more closely and it looks like you have both cultivars in the one simulation, along with two sets of Sow with variable rule, and I couldn't see where/how the value of the BasePhyllochron parameter was updated? The layout from one of the previously supplied runfiles is below.

image

My objective is to have a single generic cultivar instance in the apsimx file that gets updated iteratively between runs to shift model performance closer to observations. We're not phenotyping or testing cultivar differences since this is all with uncalibrated runs.

ric394 commented 5 months ago

@iMarang I've created an apsimx file in the same version of apsimx (7308) you're using. Let me know if this works for your needs. ExampleVariableCultivarSim.zip

iMarang commented 5 months ago

Thank you very much, that's great. I've been able to generate variation from cultivar commands, and it's also streamlined my .apsimx structure, dropping a redundant 'Simulations' node. I'll get cracking re-pathing my code, but this is little tweaks and much easier to parse.

Only question I had was when clicking through the nodes ('Field', 'Soil' etc) I get an Object reference not set to an instance of an object message, but it doesn't stop it from running. Details below:

System.NullReferenceException: Object reference not set to an instance of an object. at UserInterface.Views.EditorView.set_Text(String value) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\ApsimNG\Views\EditorView.cs:line 115 at UserInterface.Views.EditorView.set_Lines(String[] value) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\ApsimNG\Views\EditorView.cs:line 160 at UserInterface.Presenters.EditorPresenter.OnModelChanged(Object changedModel) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\ApsimNG\Presenters\EditorPresenter.cs:line 108 at UserInterface.CommandHistory.InvokeModelChanged(Object model) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\ApsimNG\CommandHistory.cs:line 119 at UserInterface.Commands.ChangeProperty.Do(ITreeView tree, Action`1 modelChanged) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\ApsimNG\Commands\ChangeProperty.cs:line 70 at UserInterface.Presenters.EditorPresenter.OnCommandsChanged(Object sender, EventArgs e) in C:\Users\ContainerAdministrator\AppData\Local\Temp\ApsimX\ApsimNG\Presenters\EditorPresenter.cs:line 73

Just confirming is this ok to ignore?

stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had any activity in the last 30 days. It will be closed in one week if no further activity occurs. Thank you for your contributions.