Skip to content

Commit

Permalink
fix for different formats of text files depending on the year
Browse files Browse the repository at this point in the history
  • Loading branch information
kalebphipps committed Aug 29, 2024
1 parent 885f1f9 commit 25d5d5b
Showing 1 changed file with 48 additions and 13 deletions.
61 changes: 48 additions & 13 deletions paint/data/juelich_weather_convertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,56 @@ def concatenate_weather(self) -> pd.DataFrame:
)
# Remove NaN
df = df[~df.index.isna()]
# Convert Date and Time
df["DateTime"] = pd.to_datetime(
df.index + " " + df["Date"], format="%d.%m.%Y %H:%M:%S"
)
df["DateTime"] = (
df["DateTime"].dt.tz_localize("Europe/Berlin").dt.tz_convert("UTC")
)
if df.index.name != "Date":
# Convert Date and Time
df["DateTime"] = pd.to_datetime(
df.index + " " + df["Date"], format="%d.%m.%Y %H:%M:%S"
)
df["DateTime"] = (
df["DateTime"].dt.tz_localize("Europe/Berlin").dt.tz_convert("UTC")
)
else:
# Convert Date and Time
df["DateTime"] = pd.to_datetime(
df.index + " " + df["Time"], format="%d.%m.%Y %H:%M:%S"
)
df["DateTime"] = (
df["DateTime"].dt.tz_localize("Europe/Berlin").dt.tz_convert("UTC")
)

# Clean Data frame
df = df.drop(columns=["Date", "Time"])
df = df.drop(
columns=[
"Date",
"Time",
"TriggerBarometer",
"Fuse1",
"Fuse2",
"Fuse3",
"Fuse4",
"Fuse5",
"Fuse6",
"Fuse7",
"Fuse9",
"UPS",
"OvervoltageProtection",
"Lnet",
"Tb",
"Ld",
"Direktunnormiert",
"Globalunnormiert",
"Diffusunnormiert",
"Direkttempfaktor",
"Globaltempfaktor",
"Diffustempfaktor",
"Gloabalwinkelfaktor",
"Diffuswinkelfaktor",
"Azimuth",
"Elevation",
"DNI Korr Norm",
],
errors="ignore",
)
df.index = df["DateTime"].dt.strftime(mappings.TIME_FORMAT)
df = df.drop(columns="DateTime")
df_list.append(df)
Expand All @@ -137,11 +177,6 @@ def merge_and_save_to_hdf5(self) -> pd.Series:
}
)

# Drop columns not containing weather data
full_weather_df = full_weather_df.drop(columns=juelich_mappings.drop_columns)

# Rename columns

# create HDF5 file
with h5py.File(self.output_path / self.file_name, "w") as file:
# Save the time data
Expand Down

0 comments on commit 25d5d5b

Please sign in to comment.