geoschem / HEMCO

The Harmonized Emissions Component (HEMCO), developed by the GEOS-Chem Support Team.
https://hemco.readthedocs.io
Other
17 stars 32 forks source link

[QUESTION] Converting kgC/m2/s to kg/m2/s #76

Closed drnimbusrain closed 3 years ago

drnimbusrain commented 3 years ago

@msulprizio Hi Melissa,

Sorry to ask a similar question again here (to issue #38), but in latest HEMCOv3, do the same kgC to kg converting rules apply? For example, if I have a HEMCO input emission inventory in kgC/m2/s, but want the output in kg/m2/s, does HEMCO do the conversion by specifying the units as kg/m2/s in the HEMCO_Diagn.rc file?

Example for ACET:

HEMCO Config File:

ExtNr Name sourceFile sourceVar sourceTime C/R/E SrcDim SrcUnit Species ScalIDs Cat Hier
0 NEI2016v1_NONPT_ACET $ROOT/NEI2016v1/v2020-07/$MM/NEI2016v1_0.1x0.1_2016$MM$DD_nonpt.nc ACET 2016/1-12/1-31/$HH C xy kgC/m2/s ACET 1007 5 50

HEMCO Spec File:

ID NAME MW MWEMIS MOLECRATIO K0 CR PKA
31 ACET 58.1 12.0 3.0 0.0 0.0 0.0

HEMCO Diag File:

Name Spec ExtNr Cat Hier Dim Unit
ACET ACET -1 -1 -1 2 kg/m2/s

Also, does simply specifying the SrcUnit as kg/m2/s in the HEMCO config file have the same effect? Such as,

0 NEI2016v1_NONPT_ACET $ROOT/NEI2016v1/v2020-07/$MM/NEI2016v1_0.1x0.1_2016$MM$DD_nonpt.nc ACET 2016/1-12/1-31/$HH C xy kg/m2/s ACET 1007 5 50

Thank you,

Patrick

msulprizio commented 3 years ago

Hi @drnimbusrain. Thanks for writing. HEMCO will no longer handle automatic unit conversions of kgC/m2/s to or from kg/m2/s. All units in HEMCO are assumed to be in kg species/m2/s, but it is up to the user to make sure these conversions are done in a pre-processing step or in HEMCO_Config.rc. For inventories that do carry some species in kgC/m2/s, you can now see in HEMCO_Config.rc that scale factors are applied to convert from units carbon to units species. You should be able to do the same by including the scaleID for the relevant scale factors in your new entries in HEMCO_Config.rc. The existing carbon to species scale factors are:

# Units carbon to species conversions
# Factor = # carbon atoms * MW carbon) / MW species
40 CtoACET MATH:58.09/(3.0*12.0)   - - - xy unitless 1
41 CtoALD2 MATH:44.06/(2.0*12.0)   - - - xy unitless 1
42 CtoALK4 MATH:58.12/(4.3*12.0)   - - - xy unitless 1
43 CtoBENZ MATH:78.12/(6.0*12.0)   - - - xy unitless 1
44 CtoC2H4 MATH:28.05/(2.0*12.0)   - - - xy unitless 1
45 CtoC2H6 MATH:30.08/(2.0*12.0)   - - - xy unitless 1
46 CtoC3H8 MATH:46.08/(3.0*12.0)   - - - xy unitless 1
47 CtoEOH  MATH:46.06/(2.0*12.0)   - - - xy unitless 1
48 CtoMEK  MATH:72.11/(4.0*12.0)   - - - xy unitless 1
49 CtoPRPE MATH:42.09/(3.0*12.0)   - - - xy unitless 1
55 CtoTOLU MATH:92.15/(7.0*12.0)   - - - xy unitless 1
56 CtoXYLE MATH:106.18/(8.0*12.0)  - - - xy unitless 1
59 CtoC2H2 MATH:26.04/(2.0*12.0)   - - - xy unitless 1
61 CtoISOP MATH:68.13/(5.0*12.0)   - - - xy unitless 1
62 CtoMTPA MATH:136.26/(10.0*12.0) - - - xy unitless 1
64 CtoMBOX MATH:86.13/(5.0*12.0)   - - - xy unitless 1
67 CtoSESQ MATH:204.4/(15.0*12.0)  - - - xy unitless 1

The specification of "kgC/m2/s" in the entry in HEMCO_Config.rc does nothing with respect to unit conversions, but depending on the unit tolerance setting at the top of that file, HEMCO may print a warning to HEMCO.log or crash if that string does not match the string in the data file.

The HEMCO diagnostic output will always be in units species, not carbon, regardless of what is specified in HEMCO_Diagn.rc since HEMCO does not handle that unit conversion. It may actually be a good idea for us to put an error trap in HEMCO to stop with a warning if users specify units carbon in the HEMCO_Diagn.rc file to avoid users attempting that.

drnimbusrain commented 3 years ago

@msulprizio Thank you Melissa for your explanation that HEMCO does not do this unit conversion automatically anymore.

So just to clarify, including this conversion information in the HEMCO_sa_Spec.rc for the different species will NOT result in a HEMCO conversion of kgC/m2/s to kg/m2/s?

For example, I am including this information for all species:

ID NAME MW MWEMIS MOLECRATIO K0 CR PKA
31 ACET         58.1  12.0 3.0  0.0 0.0 0.0

In other words, I now have to do the conversion as you specified in the HEMCO_Config.rc, and these entries in the HEMCO_sa_Spec.rc will just be ignored?

Thanks again!

Patrick

msulprizio commented 3 years ago

That is correct, although in the latest versions of HEMCO_sa_Spec.rc the MWEMIS and MOLECRATIO columns should be removed. See https://github.com/geoschem/HEMCO/blob/main/run/HEMCO_sa_Spec.rc. If you include these columns when running with HEMCO 3.0+, the simulation should crash when reading that file (or if not it may lead to an out-of-bounds error).

drnimbusrain commented 3 years ago

@msulprizio Hi Melissa, thank you for the clarification.

Its strange though because I am running latest HEMCO main branch, and including that information in the HEMCO_sa_Spec.rc columns, and I have not seen any error as you describe. Maybe I am not running the latest HEMCO 3.0+?

THANK YOU,

Patrick

msulprizio commented 3 years ago

I thought that might be the case. I think I see the issue in routine Model_GetSpecies as highlighted in these lines of code: https://github.com/geoschem/HEMCO/blob/54f2032a790a42a21db9e032d1e59ac02d642320/src/Interfaces/Standalone/hcoi_standalone_mod.F90#L936-L950

The way it is written, the code can't actually tell the number of columns but instead reads the line, determines the string length, then separates the string by spaces, and assigns the first 6 columns to the fields specified above. This means MWEMIS and MOLECRATIO columns in your file are actually being read into the fields for K0 and CR which are now the 4th and 5th columns.

The best way to resolve this in my opinion is to convert the species file to a YAML file and read the properties in that way (similar to what we're doing in GEOS-Chem). I can create a feature request for that if we all agree. Any thoughts @christophkeller @jimmielin @lizziel @yantosca ?

drnimbusrain commented 3 years ago

Great thank you Melissa! In the meantime, I will just remove the unecessary MWEMIS and MOLECRATIO columns from my species file and do the conversion correctly in the config file for HEMCO3.0+. Look forward to any new feature update on this with YAML etc.

Thanks again,

Patrick

mje1398 commented 3 years ago

Hi All, We (@LukeFakes) got a bit confused by the kgC/m2/s not actually doing anything with the carbon mass. We assumed that as it is there it did the conversation rather than the multiplier at the end. I'm not sure what the best thing is to do here? Having it in there suggests that the multiplication is being done at the unit level whereas it's actually being done by the multiplier at the end? SHould HEMCO fallover if it gets units that it doesn't understand or can't do anything with (e.g. the C in the unit?).

msulprizio commented 3 years ago

Hi @mje1398 @LukeFakes. We plan to overhaul HEMCO_Config.rc, and at that time we hope to rethink the handling of units. I think ideally we would remove the units column from HEMCO_Config.rc since it doesn't actually do anything anymore (i.e. automatic unit conversions have been removed) and instead assume all fluxes are input as kg species/m2/s either directly from the file or via scaling factors. If HEMCO encountered units from file that were not in kg/m2/s, then it would print a warning to the HEMCO.log file asking the user to ensure scaling factors are applied to explicitly do the conversion. I think it would make sense to modify the "Unit tolerance" option at that time to allow for users to tell HEMCO to crash in that case rather than continuing on past the warning.

I've added a new Feature Request here to track our progress and wishlist for overhauling HEMCO_Config.rc. See https://github.com/geoschem/HEMCO/issues/102.

mje1398 commented 3 years ago

Hi @msulprizio, THat sounds great. I think it would be useful if HEMCO Just fell over as the default. I'm not sure how carefully people check the geos.log file? Or the other alternative would be a geos.error file which just stored the warnings to make it clear you were getting warnings?