Skip to content

Commit

Permalink
Merge remote-tracking branch 'downstream/dev' into dev -- use tzfpy
Browse files Browse the repository at this point in the history
  • Loading branch information
OuyangWenyu committed Feb 20, 2024
2 parents 6b75e87 + cb624c1 commit 524527b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
3 changes: 1 addition & 2 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ dependencies:
- pint
- pint-pandas
- pint-xarray

- tzfpy
- pip
- pip:
- timezonefinder[numba]
- codetiming
- hydroutils
12 changes: 6 additions & 6 deletions hydrodataset/caravan.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from urllib.request import urlopen
import pandas as pd
import numpy as np
from timezonefinder import TimezoneFinder
from tzfpy import get_tz
from hydroutils import hydro_file
from hydrodataset import CACHE_DIR, HydroDataset

Expand Down Expand Up @@ -532,9 +532,9 @@ def cache_attributes_xrdataset(self):

# for attrs not from hydroatlas in caravan, we directly set pint unit
units_dict["area"] = "km^2"
units_dict[
"area_fraction_used_for_aggregation"
] = "dimensionless" # this one is from atlas but not specified in the document
units_dict["area_fraction_used_for_aggregation"] = (
"dimensionless" # this one is from atlas but not specified in the document
)
units_dict["aridity"] = "dimensionless"
units_dict["country"] = "dimensionless"
units_dict["frac_snow"] = "dimensionless"
Expand Down Expand Up @@ -748,7 +748,7 @@ def _check_data(self, regions):
_data.set_index(["date"])
)
the_ncfile_data.attrs = attrs
tf = TimezoneFinder()
# tf = TimezoneFinder()
site_meta_file = os.path.join(
self.data_source_description["ATTR_DIR"],
region,
Expand All @@ -763,7 +763,7 @@ def _check_data(self, regions):
lon = df_metadata.loc[
df_metadata.index == gage_id, "gauge_lon"
].values[0]
the_ncfile_data.attrs["Timezone"] = tf.timezone_at(lat=lat, lng=lon)
the_ncfile_data.attrs["Timezone"] = get_tz(lat=lat, lng=lon)
the_ncfile = os.path.join(
os.path.dirname(file_path), f"{gage_id}.nc"
)
Expand Down
10 changes: 7 additions & 3 deletions hydrodataset/hydro_dataset.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
"""
Author: Wenyu Ouyang
Date: 2022-09-05 23:20:24
LastEditTime: 2023-07-27 21:44:01
LastEditTime: 2024-02-20 19:33:43
LastEditors: Wenyu Ouyang
Description: main modules for hydrodataset
FilePath: \hydrodataset\hydrodataset\hydro_dataset.py
Copyright (c) 2021-2022 Wenyu Ouyang. All rights reserved.
"""
from pathlib import Path

from abc import ABC
from pathlib import Path
from typing import Union

import numpy as np

from hydrodataset import ROOT_DIR


Expand Down Expand Up @@ -63,7 +66,8 @@ def read_other_cols(
self, object_ids=None, other_cols: dict = None, **kwargs
) -> dict:
"""some data which cannot be easily treated as constant vars or time-series with same length as relevant vars
CONVENTION: other_cols is a dict, where each item is also a dict with all params in it"""
CONVENTION: other_cols is a dict, where each item is also a dict with all params in it
"""
raise NotImplementedError

def get_constant_cols(self) -> np.array:
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ scipy
pint
pint-pandas
pint-xarray
timezonefinder[numba]
tzfpy
codetiming

hydroutils
hydroutils
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ scipy
pint
pint-pandas
pint-xarray
timezonefinder[numba]
tzfpy
codetiming

hydroutils

0 comments on commit 524527b

Please sign in to comment.