Skip to content

Commit

Permalink
Adding profiling (poetry and new test)
Browse files Browse the repository at this point in the history
I've not included the data file that the test uses. Will confer and consider best way of handling large file in the context of a cloud-based CI test
  • Loading branch information
a-smith-github committed Aug 18, 2023
1 parent 2dea564 commit 1553622
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Binary file added .pyproject.toml.swp
Binary file not shown.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ scipy = "^1.7.3"
Bottleneck = "^1.3.5"
tabulate = "^0.8.10"
dacite = "^1.6.0"
pytest-profiling = "^1.7.0"

[tool.poetry.group.types.dependencies]
types-tabulate = "^0.9.0.0"
Expand Down
36 changes: 36 additions & 0 deletions tests/pmodel/test_profiling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pytest

def test_profiling_example():

from importlib import resources
import xarray
import numpy as np
from pyrealm.pmodel import PModel, PModelEnvironment

# Loading the dataset:
dpath = resources.files("pyrealm_build_data") / "inputs_data_24.25.nc"

ds = xarray.load_dataset(dpath)

# Variable set up
# Air temperature in Kelvin
tc = (ds["temp"]).to_numpy()
# Atmospheric pressure in Pascals
patm = ds["patm"].to_numpy()
# Obtain VPD and remove negative values
vpd = ds["vpd"].to_numpy()
vpd = np.clip(vpd, 0, np.inf)
# Extract fAPAR (unitless)
fapar = ds["fapar"].to_numpy()
# Gather PPFD µmole/m2/s1
ppfd = ds["ppfd"].to_numpy()
# Define atmospheric CO2 concentration (ppm)
co2 = np.ones_like(tc) * 400

# Generate and check the PModelEnvironment
pm_env = PModelEnvironment(tc=tc, patm=patm, vpd=vpd, co2=co2)

# Standard PModel
pmod = PModel(env=pm_env, kphio=1 / 8)
pmod.estimate_productivity(fapar=fapar, ppfd=ppfd)
pmod.summarize()

0 comments on commit 1553622

Please sign in to comment.