@@ -23,12 +23,18 @@ class GermanyBerlinFetcher(base.RiverDataFetcher):
2323 - constants.STAGE_DAILY_MEAN (m)
2424 - constants.DISCHARGE_DAILY_MEAN (m³/s)
2525 - constants.WATER_TEMPERATURE_DAILY_MEAN (°C)
26+ - constants.STAGE_INSTANT (m)
27+ - constants.DISCHARGE_INSTANT (m³/s)
28+
29+ Frequency handling:
30+ - Daily mean variables: sreihe=tw
31+ - Instantaneous variables: sreihe=ew
2632 """
2733
2834 METADATA_URL = "https://wasserportal.berlin.de/start.php?anzeige=tabelle_ow&messanzeige=ms_all"
2935 BASE_URL = (
3036 "https://wasserportal.berlin.de/station.php"
31- "?anzeige=d&station={id}&thema={thema}&sreihe=tw &smode=c&sdatum={start_date}"
37+ "?anzeige=d&station={id}&thema={thema}&sreihe={frequency} &smode=c&sdatum={start_date}"
3238 )
3339
3440 @staticmethod
@@ -90,13 +96,17 @@ def get_metadata(self) -> pd.DataFrame:
9096 except Exception as e :
9197 logger .error (f"Failed to fetch metadata: { e } " )
9298 return pd .DataFrame (columns = keep_cols ).set_index (constants .GAUGE_ID )
99+
93100 @staticmethod
94101 def get_available_variables () -> tuple [str , ...]:
95102 return (
96103 constants .STAGE_DAILY_MEAN ,
97104 constants .DISCHARGE_DAILY_MEAN ,
98105 constants .WATER_TEMPERATURE_DAILY_MEAN ,
106+ constants .STAGE_INSTANT ,
107+ constants .DISCHARGE_INSTANT
99108 )
109+
100110 def _download_data (
101111 self ,
102112 gauge_id : str ,
@@ -106,16 +116,24 @@ def _download_data(
106116 ) -> pd .DataFrame :
107117 """Downloads CSV data for a gauge and variable."""
108118 thema_map = {
109- constants .STAGE_DAILY_MEAN : "ows" , # Wasserstand (cm)
110- constants .DISCHARGE_DAILY_MEAN : "odf" , # Durchfluss (m³/s)
111- constants .WATER_TEMPERATURE_DAILY_MEAN : "owt" , # Wassertemperatur (°C)
119+ # Daily
120+ constants .STAGE_DAILY_MEAN : ("ows" , "tw" ), # Wasserstand (cm)
121+ constants .DISCHARGE_DAILY_MEAN : ("odf" , "tw" ), # Durchfluss (m³/s)
122+ constants .WATER_TEMPERATURE_DAILY_MEAN : ("owt" , "tw" ), # Wassertemperatur (°C)
123+
124+ # Instantaneous
125+ constants .STAGE_INSTANT : ("ows" , "ew" ),
126+ constants .DISCHARGE_INSTANT : ("odf" , "ew" ),
127+
112128 }
113129
114130 if variable not in thema_map :
115131 raise ValueError (f"Unsupported variable: { variable } " )
116-
132+
133+ thema , frequency = thema_map [variable ]
117134 start_date_fmt = pd .to_datetime (start_date ).strftime ("%d.%m.%Y" )
118- url = self .BASE_URL .format (id = gauge_id , thema = thema_map [variable ], start_date = start_date_fmt )
135+ url = self .BASE_URL .format (id = gauge_id , thema = thema , frequency = frequency , start_date = start_date_fmt )
136+
119137
120138 logger .info (f"Fetching { variable } for { gauge_id } from { url } " )
121139 r = requests .get (url , timeout = 20 )
@@ -132,6 +150,7 @@ def _download_data(
132150 except Exception as e :
133151 logger .error (f"Error parsing CSV for { gauge_id } : { e } " )
134152 return pd .DataFrame ()
153+
135154 def _parse_data (self , gauge_id : str , raw_data : pd .DataFrame , variable : str ) -> pd .DataFrame :
136155 """Parses Wasserportal CSV to standardized DataFrame."""
137156 if raw_data .empty :
@@ -154,6 +173,7 @@ def _parse_data(self, gauge_id: str, raw_data: pd.DataFrame, variable: str) -> p
154173 .set_index (constants .TIME_INDEX )
155174 )
156175 return df
176+
157177 def get_data (
158178 self ,
159179 gauge_id : str ,
0 commit comments