Add emission and deposition tables to the budget - #457
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?
| raise AdfError(errmsg) | ||
|
|
||
| # Initialize nicknames dictionary | ||
| #nicknames = {} |
There was a problem hiding this comment.
Can we remove this if it is not being used?
| # Calculated duration of time period in seconds? | ||
| #durations[case] = (end_period-start_period).days*86400 #+365*86400 | ||
|
|
||
|
|
||
| # Get number of years for calculations | ||
| #num_yrs[case] = (int(end_year)-int(start_year)) #+1 |
There was a problem hiding this comment.
Can we also remove these commented out lines?
| except subprocess.CalledProcessError as e: | ||
| print(f"NCO Error (Exit Code {e.returncode}): {e.stderr}") | ||
|
|
||
| #os.sys(f"ncra {Files} {output_location}/{case}_ANN.nc") |
There was a problem hiding this comment.
Is this also safe to remove?
|
|
||
| # Gather dictionary data for current case | ||
| # NOTE: The calculations can take a long time... | ||
| #Dic_scn_var_comp[case] = make_Dic_scn_var_comp_2D(adfobj, VARIABLES, data_dir, dic_SE, Files, ext1_SE, AEROSOLS) |
There was a problem hiding this comment.
Can we also remove this and line 273, #inside = Inside_SE_region(current_lat,current_lon,dir_shapefile)?
| needed_vars = [] | ||
| Dic_all_data={} | ||
|
|
||
| # all_data=[] |
There was a problem hiding this comment.
Can we remove this line?
| if file == 0: | ||
| Dic_all_data[var]=[] | ||
|
|
||
| # Star gathering of variable data |
There was a problem hiding this comment.
Let's indent this to match the formatting and fix typo to # Start gathering ...
| data=data*delP | ||
| else: | ||
| data=data | ||
| # End if |
There was a problem hiding this comment.
Looks like this is also off on the formatting, could you indent/move it to the correct spot?
| nickname = case | ||
|
|
||
| # Collect row data in a list of dictionaries | ||
| #durations[case] |
There was a problem hiding this comment.
Remove this commented out line.
| @@ -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'] | |||
|
|
|||
| ### NOT WORKING FOR NOW | |||
There was a problem hiding this comment.
Is this still not currently working, or can we remove this line too?
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. |
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.