Skip to content

Commit

Permalink
remove yearisdate
Browse files Browse the repository at this point in the history
  • Loading branch information
veronikasamborska1994 committed Feb 17, 2025
1 parent fb254ff commit 7a75c98
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 34 deletions.
7 changes: 0 additions & 7 deletions etl/steps/data/garden/climate/2025-02-12/sst_annual.meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,4 @@ tables:
unit: ""
description_processing: |-
Annual anomalies of the Oceanic Niño Index (ONI) are calculated by taking the average of the monthly ONI values for a given year.
annual_nino_classification:
title: Annual El Niño or La Niña classification
unit: ""
description_processing: |-
The annual classification of the El Niño-Southern Oscillation (ENSO) state based on the Oceanic Niño Index (ONI) is determined by the majority of the monthly ONI values for a given year.
17 changes: 0 additions & 17 deletions etl/steps/data/garden/climate/2025-02-12/sst_annual.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,7 @@ def run(dest_dir: str) -> None:
#
# Calculate the annual average for the dataset
tb_annual = tb.groupby(["country", "year"]).mean().reset_index()

# Classify the year based on nino_classification
def classify_year(group):
if (group["nino_classification"] == 1).sum() > 6:
return 1
elif (group["nino_classification"] == 2).sum() > 6:
return 2
else:
return 0

tb_annual["annual_nino_classification"] = (
tb.groupby(["country", "year"]).apply(classify_year).reset_index(drop=True)
)
tb_annual = tb_annual.rename(columns={"oni_anomaly": "annual_oni_anomaly"})
tb_annual["annual_nino_classification"] = tb_annual["annual_nino_classification"].copy_metadata(
tb["nino_classification"]
)

tb_annual = tb_annual.drop(columns={"month", "nino_classification"})

tb_annual = tb_annual.format(["country", "year"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ definitions:
presentation:
topic_tags:
- Climate Change
display:
yearIsDay: true
zeroDay: "1949-01-01"
processing_level: minor

# Learn more about the available fields:
Expand Down
9 changes: 2 additions & 7 deletions etl/steps/data/grapher/climate/2025-02-12/sst_by_month.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def run(dest_dir: str) -> None:
# Combine month and year into a single column
tb["date"] = pd.to_datetime(tb["year"].astype(str) + "-" + tb["month"].astype(str) + "-01")
tb["date"] = tb["date"] + pd.offsets.Day(14)
tb["days_since_1941"] = (tb["date"] - pd.to_datetime("1949-01-01")).dt.days

# Create colour_date column based on decades
def year_to_decade(year):
Expand All @@ -43,13 +42,9 @@ def year_to_decade(year):
# Create date_as_country column (keep uncommented but might use in the future)
# tb["date_as_country"] = tb["date"].dt.strftime("%B %Y")

# Drop the original year and month columns
tb = tb.drop(columns=["year", "month", "date"])
tb = tb.drop(columns=["year", "month"])

# Rename the date column to year for grapher purposes
tb = tb.rename(columns={"days_since_1941": "year"})

tb = tb.format(["year", "country"])
tb = tb.format(["date", "country"])
#
# Save outputs.
#
Expand Down

0 comments on commit 7a75c98

Please sign in to comment.