-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from fema-ffrd/feature/stac-funcs
Feature/stac funcs
- Loading branch information
Showing
6 changed files
with
306 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,78 @@ | ||
from .geom import RasGeomHdf | ||
|
||
from typing import Dict | ||
from geopandas import GeoDataFrame | ||
|
||
|
||
class RasPlanHdf(RasGeomHdf): | ||
PLAN_INFO_PATH = "Plan Data/Plan Information" | ||
PLAN_PARAMS_PATH = "Plan Data/Plan Parameters" | ||
PRECIP_PATH = "Event Conditions/Meteorology/Precipitation" | ||
RESULTS_UNSTEADY_PATH = "Results/Unsteady" | ||
RESULTS_UNSTEADY_SUMMARY_PATH = f"{RESULTS_UNSTEADY_PATH}/Summary" | ||
VOLUME_ACCOUNTING_PATH = f"{RESULTS_UNSTEADY_PATH}/Volume Accounting" | ||
|
||
def __init__(self, name: str, **kwargs): | ||
super().__init__(name, **kwargs) | ||
|
||
def get_plan_info_attrs(self) -> Dict: | ||
"""Returns plan information attributes from a HEC-RAS HDF plan file. | ||
Returns | ||
------- | ||
dict | ||
Dictionary filled with plan information attributes. | ||
""" | ||
return self.get_attrs(self.PLAN_INFO_PATH) | ||
|
||
def get_plan_param_attrs(self) -> Dict: | ||
"""Returns plan parameter attributes from a HEC-RAS HDF plan file. | ||
Returns | ||
------- | ||
dict | ||
Dictionary filled with plan parameter attributes. | ||
""" | ||
return self.get_attrs(self.PLAN_PARAMS_PATH) | ||
|
||
def get_meteorology_precip_attrs(self) -> Dict: | ||
"""Returns precipitation attributes from a HEC-RAS HDF plan file. | ||
Returns | ||
------- | ||
dict | ||
Dictionary filled with precipitation attributes. | ||
""" | ||
return self.get_attrs(self.PRECIP_PATH) | ||
|
||
def get_results_unsteady_attrs(self) -> Dict: | ||
"""Returns unsteady attributes from a HEC-RAS HDF plan file. | ||
Returns | ||
------- | ||
dict | ||
Dictionary filled with unsteady attributes. | ||
""" | ||
return self.get_attrs(self.RESULTS_UNSTEADY_PATH) | ||
|
||
def get_results_unsteady_summary_attrs(self) -> Dict: | ||
"""Returns results unsteady summary attributes from a HEC-RAS HDF plan file. | ||
Returns | ||
------- | ||
dict | ||
Dictionary filled with results summary attributes. | ||
""" | ||
return self.get_attrs(self.RESULTS_UNSTEADY_SUMMARY_PATH) | ||
|
||
def get_results_volume_accounting_attrs(self) -> Dict: | ||
"""Returns volume accounting attributes from a HEC-RAS HDF plan file. | ||
Returns | ||
------- | ||
dict | ||
Dictionary filled with volume accounting attributes. | ||
""" | ||
return self.get_attrs(self.VOLUME_ACCOUNTING_PATH) | ||
|
||
def enroachment_points(self) -> GeoDataFrame: | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from src.rashdf import RasPlanHdf | ||
|
||
import h5py | ||
|
||
attrs_to_set = {"test_attribute1": "test_str1", "test_attribute2": 500} | ||
|
||
|
||
def test_get_plan_info_attrs(tmp_path): | ||
with h5py.File(tmp_path / "test.hdf", "w") as f: | ||
group = f.create_group(RasPlanHdf.PLAN_INFO_PATH) | ||
for key, value in attrs_to_set.items(): | ||
group.attrs[key] = value | ||
|
||
ras_plan_hdf = RasPlanHdf(tmp_path / "test.hdf") | ||
|
||
assert ras_plan_hdf.get_plan_info_attrs() == attrs_to_set | ||
|
||
|
||
def test_get_plan_param_attrs(tmp_path): | ||
with h5py.File(tmp_path / "test.hdf", "w") as f: | ||
group = f.create_group(RasPlanHdf.PLAN_PARAMS_PATH) | ||
for key, value in attrs_to_set.items(): | ||
group.attrs[key] = value | ||
|
||
ras_plan_hdf = RasPlanHdf(tmp_path / "test.hdf") | ||
|
||
assert ras_plan_hdf.get_plan_param_attrs() == attrs_to_set | ||
|
||
|
||
def test_get_meteorology_precip_attrs(tmp_path): | ||
with h5py.File(tmp_path / "test.hdf", "w") as f: | ||
group = f.create_group(RasPlanHdf.PRECIP_PATH) | ||
for key, value in attrs_to_set.items(): | ||
group.attrs[key] = value | ||
|
||
ras_plan_hdf = RasPlanHdf(tmp_path / "test.hdf") | ||
|
||
assert ras_plan_hdf.get_meteorology_precip_attrs() == attrs_to_set | ||
|
||
|
||
def test_get_results_unsteady_attrs(tmp_path): | ||
with h5py.File(tmp_path / "test.hdf", "w") as f: | ||
group = f.create_group(RasPlanHdf.RESULTS_UNSTEADY_PATH) | ||
for key, value in attrs_to_set.items(): | ||
group.attrs[key] = value | ||
|
||
ras_plan_hdf = RasPlanHdf(tmp_path / "test.hdf") | ||
|
||
assert ras_plan_hdf.get_results_unsteady_attrs() == attrs_to_set | ||
|
||
|
||
def test_get_results_unsteady_summary_attrs(tmp_path): | ||
with h5py.File(tmp_path / "test.hdf", "w") as f: | ||
group = f.create_group(RasPlanHdf.RESULTS_UNSTEADY_SUMMARY_PATH) | ||
for key, value in attrs_to_set.items(): | ||
group.attrs[key] = value | ||
|
||
ras_plan_hdf = RasPlanHdf(tmp_path / "test.hdf") | ||
|
||
assert ras_plan_hdf.get_results_unsteady_summary_attrs() == attrs_to_set | ||
|
||
|
||
def test_get_results_volume_accounting_attrs(tmp_path): | ||
with h5py.File(tmp_path / "test.hdf", "w") as f: | ||
group = f.create_group(RasPlanHdf.VOLUME_ACCOUNTING_PATH) | ||
for key, value in attrs_to_set.items(): | ||
group.attrs[key] = value | ||
|
||
ras_plan_hdf = RasPlanHdf(tmp_path / "test.hdf") | ||
|
||
assert ras_plan_hdf.get_results_volume_accounting_attrs() == attrs_to_set |