openclimatedata / globalwarmingpotentials

Global Warming Potentials as assessed by the IPCC in CSV format, and as Python and Node modules
Creative Commons Zero v1.0 Universal
22 stars 8 forks source link

Fix CFC-11 and CFC-12 values from AR6 #18

Closed rgieseke closed 2 years ago

rgieseke commented 2 years ago

Closes #16

I used the following script to update

import pandas as pd

df = pd.read_csv("https://raw.githubusercontent.com/chrisroadmap/ar6/main/data_output/7sm/metrics_supplement_cleaned.csv")

df.index = df["Acronym"].fillna(df["Formula"])

df = df.rename(index={
  "Carbon tetrachloride": "CCl4",
  "Methyl bromide": "CH3Br",
  "Methyl chloroform": "CH3CCl3",
  "PFC-14": "CF4",
  "PFC-116": "C2F6",
  "PFC-218": "C3F8",
  "PFC-31-10": "C4F10",
  "PFC-41-12": "C5F12",
  "PFC-51-14": "C6F14",
  "PFC-61-16": "C7F16",
  "PFC-71-18": "C8F18",
  "PFC-91-18": "C10F18",
  "PFC-C-318": "cC4F8",
  "Chloroform": "CHCl3",
  "Methylene chloride": "CH2Cl2",
  "Methyl chloride": "CH3Cl"
  })

df.index = df.index.str.replace("-", "")

df.index.name = "Index"

gwp = pd.read_csv("globalwarmingpotentials.csv", comment="#")

# Not matched
for item in gwp.Species:
     if item in df.index:
        continue
        #print(item)
     else:
        print("MISSING: ", item)

gwp = gwp.drop(["AR6GWP100", "AR6GWP20"], axis=1)
gwp = gwp.set_index("Species")

for key, vals in gwp.iterrows():
    if key in df.index:
        gwp.at[key, "AR6GWP100"] = df.loc[key]["GWP100"]
        gwp.at[key, "AR6GWP20"] = df.loc[key]["GWP20"]

for col in gwp.columns:
    try:
        gwp[col] = gwp[col].astype("Int64")
    except TypeError:
        pass

gwp.to_csv("globalwarmingpotentials.csv", index=True)
rgieseke commented 2 years ago

Thanks again @chrisroadmap!

@mikapfl I can wait with merging and releasing until the conda release process (#17) is ready, so this would be a test whether everything works for conda, too.

mikapfl commented 2 years ago

If you want to, you can do that, but in general

so I don't know if you want to wait

rgieseke commented 2 years ago

Ok, then i'll merge and release :-) Not sure if you need to update the version number!