Skip to content

Remove duplicate NETL flow correction method#20

Merged
frankhanna94 merged 1 commit intodevelopmentfrom
elemef
Jan 5, 2026
Merged

Remove duplicate NETL flow correction method#20
frankhanna94 merged 1 commit intodevelopmentfrom
elemef

Conversation

@dt-woods
Copy link

This PR addresses NETL-RIC#260. It removes the duplicate correct_netl_flow_names from natural_gas_upstream.py and updates the method of the same name found in elementaryflows.py. As this method is reference in fix_coal_mining_lci in coal_upstream.py, the results were cross-checked before and after the update

import pandas as pd
from pandas.testing import assert_frame_equal

old_csv = "OLD_ng_lci_2020rev1.csv"  # archived earlier run
new_csv = "ng_lci_2020rev1.csv"
old_df = pd.read_csv(old_csv)
new_df = pd.read_csv(new_csv)

err_msgs = []
idx = 0
while idx < len(new_df) - 1:
    try:
        assert_frame_equal(new_df.loc[idx:,:], old_df.loc[idx:,:], check_dtype=False)
    except Exception as e:
        err_msg = (idx, str(e))
        err_msgs.append(err_msg)
    finally:
        idx += 1

The differences between the two dataframes were only in the 'flow_name' column for five rows:

Index Error Message
70 'Particulate matter, ≤ 2.5μm' != 'Particulate matter, âÂ\x89¤ 2.5Ã\x8e¼m'
146 'Particulate matter, > 2.5μm and ≤ 10μm' != 'Particulate matter, > 2.5Ã\x8e¼m and âÂ\x89¤ 10Ã\x8e¼m'
151 'Particulate matter, > 10μm' != 'Particulate matter, > 10Ã\x8e¼m'
182 'Total Organic Carbon' != 'Nitrogen'
186 'Phenols' != 'Phenols '

These corrections are based on poor encodings (note the Greek letters) and new mappings.

Global variabless in natural_gas_upstream.py were capitalized to conform with standard.
Minor formatting fixes were applied to conform to PEP8.

addresses NETL-RIC#260. Remove duplicate correct_netl_flow_names from natural_gas_upstream.py and update the same method found in elementaryflows.py; cross-check that the data are the same when running fix_coal_mining_lci in coal_upstream.py (PASS); uppercase globals in natural_gas_upstream.py; minor formatting fixes
@dt-woods dt-woods added the enhancement New feature or request label Dec 30, 2025
@frankhanna94 frankhanna94 merged commit 6bf5709 into development Jan 5, 2026
3 checks passed
@frankhanna94 frankhanna94 deleted the elemef branch January 8, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants