Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ downloaded_data/
rivretrieve/data

**/*.pyc
**/*.png
**/*.png
**/*.env
22 changes: 13 additions & 9 deletions examples/test_brazil_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,27 @@
logging.basicConfig(level=logging.INFO)

gauge_ids = [
"12650000",
"15400000",
]
variable = constants.DISCHARGE
variable = constants.STAGE_DAILY_MEAN
start_date = "2023-01-01"
end_date = "2024-12-31"

plt.figure(figsize=(12, 6))

# Initialize fetcher (credentials are loaded from .env by default)
fetcher = BrazilFetcher()

for gauge_id in gauge_ids:
print(f"Fetching data for {gauge_id}...")
data = fetcher.get_data(gauge_id=gauge_id, variable=variable)
print(f"Fetching {variable} for {gauge_id} from {start_date} to {end_date}...")
data = fetcher.get_data(gauge_id=gauge_id, variable=variable, start_date=start_date, end_date=end_date)
if not data.empty:
print(f"Data for {gauge_id}:")
print(data.head())
print(f"Time series from {data[constants.TIME_INDEX].min()} to {data[constants.TIME_INDEX].max()}")
print(f"Time series from {data.index.min()} to {data.index.max()}")
plt.plot(
data[constants.TIME_INDEX],
data[constants.DISCHARGE],
data.index,
data[variable],
label=gauge_id,
marker=".",
linestyle="-",
Expand All @@ -33,8 +37,8 @@

if "data" in locals() and not data.empty:
plt.xlabel(constants.TIME_INDEX)
plt.ylabel(f"{constants.DISCHARGE} (m3/s)")
plt.title(f"Brazil River Discharge ({gauge_ids[0]} - Full Time Series)")
plt.ylabel(f"{variable} (m3/s)")
plt.title(f"Brazil River Discharge ({gauge_ids[0]} - {start_date} to {end_date})")
plt.legend()
plt.grid(True)
plt.tight_layout()
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ dataretrieval>=1.0.0
openpyxl>=3.0.0
xarray
parameterized
python-dotenv
ruff
tqdm
zarr>=3.0.7
Loading