Repository navigation
Add emission and deposition tables to the budget - #457
Behrooz-Roozitalab wants to merge 7 commits into
Conversation
…ons and depositions- for all variables, add a calculation option using annual mean files
justin-richling
left a comment
There was a problem hiding this comment.
This PR is mostly good @Behrooz-Roozitalab, thank you for breaking this up logically! It looks like a lot of suggested changes, but it's really only related to commented out code and some indentation suggestions. I will merge this when you get to these, thanks again!
| @@ -136,7 +153,7 @@ def aerosol_gas_tables(adfobj, trop_val=None, **kwargs): | |||
| # if True, calculate only Tropospheric values | |||
| # if False, all layers | |||
| # tropopause is defiend as either directly or indirectly. Look for tropopause to see the definition | |||
| Tropospheric = bres['Tropospheric'] | |||
| #Tropospheric = bres['Tropospheric'] | |||
There was a problem hiding this comment.
Sorry for the late review on this @Behrooz-Roozitalab! The only question I have is if this is commented out, could we just remove it, or is this something that might get flagged later?
There was a problem hiding this comment.
It should be removed now.
Summary. Adds two new analysis scripts ( Classification: new/modified diagnostic scripts ( Blocking1. 2. try:
spc_chmp = Dic_scn_var_comp[current_var][current_var+'_CHMP']
except:
spc_chml = 0 # <- should be spc_chmp
spc_chmp = np.where(np.isnan(trop), np.nan, spc_chmp) # line 1258Two bugs in three lines: the handler doesn't define 3. subprocess.run(cmd, check=True) # unguarded, runs first
try:
subprocess.run(cmd, check=True, capture_output=True, text=True) # same cmd again
except FileNotFoundError: ...
except subprocess.CalledProcessError as e: ...The first line looks like a leftover. It doubles the cost of the most expensive step in the 4. The This is the §4.2 "missing input files are normal" case, but the required behavior there is warn-and-skip, not warn-and-zero. The script already tracks 5. New scripts are not registered in 6. Non-blocking7. Removing the 8. 9. Duration is inconsistent between the two branches. 10. Docstrings do not follow §6.2. Both new files: no module docstring; the entry-point docstrings are free prose with no 11. 12. YAML formatting and a behavior question. Optional / follow-up (pre-existing, not this PR's job)
Not verified
Findings #1–#3 are mechanical and quick. #4 (the silent zeros) has the real scientific consequence and is the biggest ask. Happy to help with any of these. |
|
Hi Justin, Thanks for reviewing it. And the AI review was helpful. About the AI comment on 'silent zeros', we actually don't report any 0 value and provide a comment. I clarified the comment. |
8e08772 to
3f612b3
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Example config: fix YAML indentation that broke parsing, make the chemistry budget tables opt-in (commented out) and document kwargs - aerosol_gas_tables: fall back on budget_tables:Tropospheric from the variable defaults file when the kwarg is not given Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every handler guards a lookup of a history-file field (ds[...]) or a budget component (Dic_scn_var_comp[...]), which raise KeyError when missing. Fallback behavior is unchanged; other errors and Ctrl-C now propagate instead of being swallowed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eams
With 'Climate: True', the chemistry budget table scripts averaged the history
files with 'ncra' into '{nickname}_ANN.nc' in the plot/table directory, where
it was overwritten on every run and never removed. All three scripts now use
a shared helper, utils.budget_annual_mean_file, controlled by new optional
per-case settings in diag_cam_climo and diag_cam_baseline_climo:
budget_table_save keep the file (default false)
budget_table_overwrite remake it even if it exists (default false)
budget_table_save_loc where it is kept; required only if saving
The file is named $cam_case_name.$hist_str.budget_ANN.YYYY01-YYYY12.nc and
carries global attributes for the case, stream, years and source files. A
matching file in budget_table_save_loc is reused unless overwrite is set; a
file that is not saved is made in a temporary directory and removed. The
settings are checked before any calculations, and are ignored (with a note)
when Climate is False.
emissions_table and depositions_table now pick each case's history stream
with utils.pick_hist_str, as aerosol_gas_tables does, so a case without
cam.h0/cam.h0a/cam.hm no longer shifts later cases onto the wrong stream.
When no history files are found, all three scripts now stop with a clear
error instead of an IndexError.
The example config documents the new settings and shows the Climate kwarg
for emissions_table and depositions_table.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Sorry for the delay @Behrooz-Roozitalab, the ADF has changed recently and just wanted to spend some time getting your PR brought up. Below is what I've pushed, and a few things I'd like your input on before we merge: What I've pushed
The budget_table_save: false # keep the annual mean file (default false)
budget_table_overwrite: false # remake it even if it exists (default false)
budget_table_save_loc: /some/dir # required only if budget_table_save is true
History stream lookup. Missing model output in the tablesYou're right that a completely missing term is never reported as 0:
Are you OK with me making that change? It changes what appears in your tables, so I wanted to check with you first. Questions
Thanks! |
Updates to the budget code including:
Also, two tables are added to this version (could be called in YAML file) to calculate the emissions and depositions for all the variables in the files.