Skip to content

Commit

Permalink
Merge pull request #79 from climate-resource/mid-yr-handling
Browse files Browse the repository at this point in the history
Update western handling
  • Loading branch information
znichollscr authored Dec 3, 2024
2 parents 17741f8 + 5a8faf3 commit ab5313f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/79.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed handling of Western data to account for the fact that the raw data is January-centred.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@
# %%
clean = raw.rename({"Year": "year", **western_variable_normalisation_map}, axis="columns")
clean = clean.set_index("year")
clean

# %%
# Western data from this file is start of year, yet we want mid-year values, hence do the below
tmp = ((clean.iloc[:-1, :].values + clean.iloc[1:, :].values) / 2.0).copy()
clean = clean.iloc[:-1, :]
clean.iloc[:, :] = tmp
clean

# %%
clean.columns.name = "gas"
clean = clean.stack().to_frame("value").reset_index() # type: ignore
clean["unit"] = assumed_unit
Expand Down

0 comments on commit ab5313f

Please sign in to comment.