Skip to content

Commit

Permalink
Add OilGasAsset (#347)
Browse files Browse the repository at this point in the history
* Add OilGasAsset

Signed-off-by: Joe Moorhouse <[email protected]>

* Update to geopandas needed (fiona clash); requires 3.9 minimum.

Signed-off-by: Joe Moorhouse <[email protected]>

* Use 3.9 in tox

Signed-off-by: Joe Moorhouse <[email protected]>

* Relax test slightly (small differences from numerical libraries).

Signed-off-by: Joe Moorhouse <[email protected]>

---------

Signed-off-by: Joe Moorhouse <[email protected]>
  • Loading branch information
joemoorhouse authored Sep 5, 2024
1 parent b037118 commit a8fb879
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

env:
python-version: "3.8"
python-version: "3.9"

jobs:
ci:
Expand Down
146 changes: 39 additions & 107 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "OS-Climate Physical Risk Library"
authors = [
{name = "Joe Moorhouse",email = "[email protected]"},
]
requires-python = ">=3.8,<3.11"
requires-python = ">=3.9,<3.11"
readme = "README.md"
license = {file = "LICENSE"}
keywords = ["Physical", "Climate", "Risk", "Finance"]
Expand Down Expand Up @@ -46,7 +46,7 @@ dependencies = [
"shapely>=2.0.1",
"s3fs>=2022.1.0",
"zarr>=2.10.3",
"geopandas>=0.13.2",
"geopandas>=0.14.4",
"h3>=3.7.7",
"lmdbm>=0.0.6",
]
Expand Down
17 changes: 16 additions & 1 deletion src/physrisk/kernel/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ def __init__(
self.type = type


class OilGasAsset(Asset):
def __init__(
self,
latitude: float,
longitude: float,
*,
location: Optional[str] = None,
type: Optional[str] = None,
**kwargs,
):
super().__init__(latitude, longitude, **kwargs)
self.location = location
self.type = type


class PowerGeneratingAsset(Asset):
def __init__(
self,
Expand All @@ -164,9 +179,9 @@ def __init__(
self.type: Optional[str] = type
self.location: Optional[str] = location
self.capacity: Optional[float] = capacity
self.primary_fuel: Optional[FuelKind] = None

if type is not None:
self.primary_fuel: Optional[FuelKind] = None
archetypes = type.split("/")
if 0 < len(archetypes):
self.primary_fuel = FuelKind[archetypes[0]]
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/chronic_asset_impact_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@ def test_chronic_vulnerability_model(self):
]
)
value_diff = np.sum(np.abs(value_test - value_exp))
self.assertAlmostEqual(value_diff, 0.0, places=8)
self.assertAlmostEqual(value_diff, 0.0, places=6)
2 changes: 1 addition & 1 deletion tests/vulnerability_models/wbgt_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,4 @@ def test_wbgt_vulnerability(self):
0.00000000000,
]
)
np.testing.assert_almost_equal(value_test, value_exp, decimal=8)
np.testing.assert_almost_equal(value_test, value_exp, decimal=6)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38, static
envlist = py39, static

[testenv]
deps =
Expand Down

0 comments on commit a8fb879

Please sign in to comment.