Question about the ats_input_spec

38 views
Skip to first unread message

Chuyang Liu

unread,
Sep 15, 2025, 4:50:57 PMSep 15
to Amanzi-ATS Users
Hi there,

Many thanks for the well-documented notebooks provided for the ATS Short Course 2025. They have been extremely helpful in understanding the major updates in the new version.

While going through the notebooks at https://github.com/amanzi/ats-short-course/blob/ats-short-course-20250908/05_model_setup/,
I encountered an error on my end while running 4-coweeta_ats_input_file.ipynb, as shown below.Snipaste_2025-09-15_13-50-02.png


Any hints or suggestions would be greatly appreciated!



--------------------------------------------------------------------------- KeyError Traceback (most recent call last) File ~/miniforge3/envs/ww2_0/lib/python3.12/site-packages/ats_input_spec/public.py:550, in add_soil_type.<locals>.add_entry(key, value, tensor) 549 try: --> 550 fe = main['state']['evaluators'][key] 551 except KeyError: File ~/miniforge3/envs/ww2_0/lib/python3.12/site-packages/ats_input_spec/specs.py:185, in ParameterCollection.__getitem__(self, k) 184 def __getitem__(self, k): --> 185 return self._pars[k].get() KeyError: 'base_porosity' During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) Cell In[17], line 1 ----> 1 write_spinup_steadystate(name, precip_mean) 2 write_transient(name, True) 3 write_transient(name, False) Cell In[15], line 3 1 def write_spinup_steadystate(name, precip_mean, **kwargs): 2 # create the main list ----> 3 main = get_main() 5 # set precip to 0.6 * the mean precip value 6 precip = main['state']['evaluators'].append_empty('surface-precipitation') Cell In[13], line 19 16 add_land_cover(main_list) 18 # add soil properties ---> 19 add_soil_properties(main_list) 21 # add observations for each subcatchment 22 if steadystate: Cell In[12], line 16 13 else: 14 smoothing_interval = 0.0 ---> 16 ats_input_spec.public.add_soil_type(main_list, set_name, ats_id, output_filenames['mesh'], 17 float(props['porosity [-]']), 18 float(props['permeability [m^2]']), 1.e-7, 19 float(props['van Genuchten alpha [Pa^-1]']), 20 float(props['van Genuchten n [-]']), 21 float(props['residual saturation [-]']), 22 float(smoothing_interval)) File ~/miniforge3/envs/ww2_0/lib/python3.12/site-packages/ats_input_spec/public.py:567, in add_soil_type(main, region_name, label, filename, porosity, permeability, compressibility, van_genuchten_alpha, van_genuchten_n, residual_sat, smoothing_interval, porosity_key, permeability_key, compressibility_key, wrm_key) 565 # add porosity & permeability 566 if porosity is not None: --> 567 add_entry('base_porosity', porosity) 568 if permeability is not None: 569 add_entry('permeability', permeability, True) File ~/miniforge3/envs/ww2_0/lib/python3.12/site-packages/ats_input_spec/public.py:557, in add_soil_type.<locals>.add_entry(key, value, tensor) 555 fe['tensor type'] = 'scalar' 556 else: --> 557 fe.set_type('independent variable', known_specs['evaluator-independent-variable-spec']) 558 fe['constant in time'] = True 559 sublist = fe['function'].append_empty(region_name) File ~/miniforge3/envs/ww2_0/lib/python3.12/site-packages/ats_input_spec/specs.py:735, in SpecDict.__getitem__(self, key) 733 result = TypedSpec(contained_name, policy='sublistdash', others=others) 734 else: --> 735 result = self._store[key].copy() 737 # add in included specs, recursively 738 if hasattr(result, 'includes'): KeyError: 'evaluator-independent-variable-spec'
---------------------------


Thanks,
Chuyang

Bo Gao

unread,
Sep 16, 2025, 1:11:31 AMSep 16
to Chuyang Liu, Amanzi-ATS Users
Hi Chuyang,

This error says that ats_input_spec cannot find the header file that includes "evaluator-independent-variable-spec", which should be in $AMANZI_SRC_DIR. Can you check whether $AMANZI_SRC_DIR is added to your environment variables?

Best,
Bo Gao

--
You received this message because you are subscribed to the Google Groups "Amanzi-ATS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ats-users/312107bb-07c1-4f13-8874-5b026e1dde2fn%40googlegroups.com.
Message has been deleted
Message has been deleted

Chuyang Liu

unread,
Sep 16, 2025, 6:14:06 PMSep 16
to Amanzi-ATS Users
Thanks, Bo. The problem has been fixed. The problem was caused by the old $AMANZI_SRC_DIR in my environment, and it had not been fully updated when I used VSCODE to restart the engine.

Best,
Chuyang

Bo Gao

unread,
Sep 16, 2025, 6:16:39 PMSep 16
to Chuyang Liu, Amanzi-ATS Users
This issue has been solved offline. It is because of a mismatch of "AMANZI_SRC_DIR" path shown in Chuyang's PATH and os.environ. The "AMANZI_SRC_DIR" path was not updated in os.environ, so the newer version of ats_input_spec used an older version of amanzi code, in which some key names have been changed.

Most of such KeyError problems in ats_input_spec should be caused by that the corresponding header files including those keys were not found, either because the header files are not in path or because those keys have been renamed with code version updating.

Best,
Bo Gao

Reply all
Reply to author
Forward
0 new messages