Closed yantosca closed 1 month ago
@yantosca, thanks for putting this together. I have a few questions about the output.
Why is number of entries in FJX_j2j.dat
equal to the number of photo reactions in fullchem.eqn
? There are cases where a photolyzing species in FJX_j2j.dat
has one entry in that file but two equations in fullchem.eqn
, e.g. PIP. There are also photolysis equations in fullchem.eqn
that reuse J-values for a different species and are not in FJX_j2j.dat
. I would think this would make "Number of entries in FJX_j2j.dat" not equal to "Number of photo rxns in fullchem.eqn" except by coincidence.
Why are species that are not in FJX_j2j.dat
included as Is_Photolysis=True
. For example, R7P and ALK4P below are not in FJX_j2j.dat
as shown by their reuse of R4P's J-values.
R4P uses PHOTOL(83 ) and has Is_Photolysis=True
R7P uses PHOTOL(83 ) and has Is_Photolysis=True
ALK4P uses PHOTOL(83 ) and has Is_Photolysis=True
Any species that have Is_Photolysis=True
but are not in FJX_j2j.dat
will have output J-value diagnostics that are all zero.
I thought we were going to remove Is_Photolysis
from the species database since it is redundant information with FJX_j2j.dat. We could read the dat-file upon initialization and extract the unique number of species.
- Why is number of entries in
FJX_j2j.dat
equal to the number of photo reactions infullchem.eqn
? There are cases where a photolyzing species inFJX_j2j.dat
has one entry in that file but two equations infullchem.eqn
, e.g. PIP. There are also photolysis equations infullchem.eqn
that reuse J-values for a different species and are not inFJX_j2j.dat
. I would think this would make "Number of entries in FJX_j2j.dat" not equal to "Number of photo rxns in fullchem.eqn" except by coincidence.
I will double check this. Like you said, it may just be coinicidence.
- Why are species that are not in
FJX_j2j.dat
included asIs_Photolysis=True
. For example, R7P and ALK4P below are not inFJX_j2j.dat
as shown by their reuse of R4P's J-values.R4P uses PHOTOL(83 ) and has Is_Photolysis=True R7P uses PHOTOL(83 ) and has Is_Photolysis=True ALK4P uses PHOTOL(83 ) and has Is_Photolysis=True
Any species that have
Is_Photolysis=True
but are not inFJX_j2j.dat
will have output J-value diagnostics that are all zero.
You are correct. We should remove those.
- I thought we were going to remove
Is_Photolysis
from the species database since it is redundant information with FJX_j2j.dat. We could read the dat-file upon initialization and extract the unique number of species.
We will but this is a temporary solution for now.
I made changes in GEOS-Chem to fix the J-value diagnostics resulting from mismatches in the files. I wrote my own script to figure out the mismatches to keep it simple. My approach is more command line style, amenable to notebooks. I wonder if we are going to put an example for this whether we should do that as well, so it is easier to read and do data analysis with.
import numpy as np
import yaml
# Get content of FJX_j2j.dat files (both fullchem and Hg)
with open('FJX_j2j.dat') as file_object:
data_j2j_fullchem = file_object.readlines()
with open('FJX_j2j.Hg.dat') as file_object:
data_j2j_hg = file_object.readlines()
data_j2j = data_j2j_fullchem + data_j2j_hg
# Get unique species names across both files
data_j2j_allcaps =[x.upper() for x in data_j2j]
j2j_species = [i.split()[1] for i in data_j2j_allcaps if "PHOTON" in i]
j2j_unique_species = np.unique(j2j_species)
print('\nNumber of unique species in FJX_j2j.dat (fullchem and Hg):',len(j2j_unique_species))
# Get species in species_data.yml with Is_Photolysis equal to True
with open('species_database.yml', 'r') as stream:
data_db = yaml.safe_load(stream)
db_is_photol = [key for key, value in data_db.items() if value.get('Is_Photolysis') is True]
db_is_photol_allcaps = [x.upper() for x in db_is_photol]
# Store as sets
j2j_unique_species_set = set(j2j_unique_species)
db_is_photol_set = set(db_is_photol_allcaps)
# Print FJX_j2j.dat species not is_photolysis=true in species_database.yml.
in_j2j_but_not_db = j2j_unique_species_set.difference(db_is_photol_set)
print('\nThe following species are in FJX_j2j.dat but do not have Is_Photolysis=True in species_database.yml. J-value diagn\ ostics will not be created for them. Check that these species are not photolyzed in the KPP equation file fullchem.eqn and other *.eqn files. If they are not then consider removing them from `FJX_j2j.dat`. If they are then `Is_Photolysis=True` must be added to the species database to output J-value diagnostics for them.')
for i in in_j2j_but_not_db:
print(i)
# Print species that have is_photolysis=true but are not in FJX_j2j.dat.
in_db_but_not_j2j = db_is_photol_set.difference(j2j_unique_species_set)
print('\nThe following species are Is_Photolysis=True in species_database.yml but are not species in FJX_j2j.dat for Hg or
fullchem. J-value diagnostics will be created for them but will be filled with all zeros. The species database should be updated to remove Is_Photolysis for these species.')
for i in in_db_but_not_j2j:
print(i)
# Ideas for further checks:
# More checks: Open fullchem.eqn and check that:
# - every index in FJX_j2j.dat is used as index in PHOTOL array
# - every index in fullchem.eqn PHOTOL array is in FJX_j2j.dat
# - Make a printout of each FJX_j2j.dat equation and which equation(s) in
# fullchem.eqn use it.
The output looks like this:
Number of unique species in FJX_j2j.dat (fullchem and Hg): 175
The following species are in FJX_j2j.dat but do not have Is_Photolysis=True in species_database.yml.
J-value diagnostics will not be created for them. Check that these species are not photolyzed in the
KPP equation file fullchem.eqn and other *.eqn files. If they are not then consider removing them from
`FJX_j2j.dat`. If they are then `Is_Photolysis=True` must be added to the species database to output
J-value diagnostics for them.
H2O
SO2
HO2
CF3I
H12O2
The following species are Is_Photolysis=True in species_database.yml but are not species in
FJX_j2j.dat for Hg or fullchem. J-value diagnostics will be created for them but will be filled
with all zeros. The species database should be updated to remove Is_Photolysis for these species.
HGCL
R7N2
O3ATBL
O3MT
R7P
ACR
O3USA
O3INIT
HG_OTHER_PROP
O3ASBL
O3_PROP
O3AFBL
O3NABL
APAN
ALK4N2
O3UT
AROMCHO
RNO3
O3STRAT
ALK4P
O3PCBL
O3EUBL
O3ROW
Thanks @lizziel. If you want I can close this PR and have you add a new PR with your script.
Okay, I am going to let the dust settle on the J-values diagnostics and species database before adding any example scripts to GCPy. We are still figuring out what changes will be made for the diagnostic and whatever is done will affect the checks needed. GCST can use local scripts to check and I don't think we need to share the scripts on GCPy just yet.
Name and Institution (Required)
Name: Bob Yantosca Institution: Harvard + GCST
Describe the update
This PR adds a new script
gcpy/examples/geoschem/check_photolysis.py
, which validates the GEOS-Chem photolysis mechanism by checking thespecies_database.yml
,FJX_j2j.dat
, andfullchem.eqn
(orcustom.eqn
) files.Expected changes
When calling the script with:
The following output is generated:
Output such as this denotes a succesfully-configured photolysis mechanism. All of the photo species should have
Is_Photolysis: true
in thespecies_database.yml
file. Mismatches of species will generate an error message.