Syntax for editing layered parameters (e.g. soil properties)? #36
Closed
spencercole6-ops
started this conversation in
General
Replies: 1 comment 1 reply
-
|
Hello Spencer, from apsimNGpy.core.apsim import ApsimModel
with ApsimModel("Maize") as model:
ks = model.inspect_model_parameters('Models.Soils.Physical', 'Physical', parameters='KS')
length = ks.shape[0]
# The top two lines of codes here only modify the KS value for the first layer, but the third line updates all values
model.edit_model(model_type='Models.Soils.Physical', model_name='Physical', simulations='Simulation',
KS=[4.752] * length)
ks1 = model.inspect_model_parameters('Models.Soils.Physical', 'Physical', parameters='KS')
print(ks1.KS.tolist())
[4.752, 4.752, 4.752, 4.752, 4.752, 4.752, 4.752]
model.edit_model(model_type='Models.Soils.Physical', model_name='Physical', simulations='Simulation',
KS=[5, 5, 5, 5, 5, 5, 5, ])
ks2 = model.inspect_model_parameters('Models.Soils.Physical', 'Physical', parameters='KS')
print(ks2.KS.tolist())
[5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0]
model.edit_model(model_type='Models.Soils.Physical', model_name='Physical', simulations='Simulation',
KS=[1, 2, 3, 4, 5, 6, 7])
ks3 = model.inspect_model_parameters('Models.Soils.Physical', 'Physical', parameters='KS')
print(ks3.KS.tolist())
[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0] |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Dr. Magala,
Thanks very much for your help solving my installation and path issues. My model has been running fine and I have been successful in testing, including modifying cultivars. However, I have been trying to do some sensitivity analysis with some physical properties which have values based on soil layer and I've ran into some trouble. Below is a minimal example of my code.
# All of this runs fine and produces expected resultsfrom apsimNGpy.core.apsim import ApsimModelimport pandas as pdmodelpath = "path/to/model/file/model.apsimx"model = ApsimModel(model=modelpath)model.run(report_name='Report', verbose=False)results = model.result# The top two lines of codes here only modify the KS value for the first layer, but the third line updates all valuesmodel.edit_model(model_type='Models.Soils.Physical', model_name='Physical', simulations='Simulation', KS=[4.752]*10)model.edit_model(model_type='Models.Soils.Physical', model_name='Physical', simulations='Simulation', KS=[5,5,5,5,5,5,5,5,5,5])model.edit_model(model_type='Models.Soils.Physical', model_name='Physical', simulations='Simulation', KS=[1,2,3,4,5,6,7,8,9,10])I can't seem to update more than the first layer value using the syntax in your published examples online. Oddly, the last line of code above did update the values for all layers as expected, but no other lists I have tried could reproduce this. I thought it could be that it didn't like float values but the other integer list I tried only updated the top layer value as well.
Thank you again in advance,
Spencer
Beta Was this translation helpful? Give feedback.
All reactions