-
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 #28 from openmethane/allow-directory
Allow custom input directory
- Loading branch information
Showing
12 changed files
with
152 additions
and
86 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
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
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,38 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import dotenv | ||
import pytest | ||
import xarray as xr | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def root_dir(): | ||
return Path(__file__).parent.parent | ||
|
||
|
||
# This fixture will be automatically used by all tests to setup the required env variables | ||
@pytest.fixture(autouse=True) | ||
def env(monkeypatch, root_dir): | ||
initial_env = dict(os.environ) | ||
|
||
# Use the example .env file to drive the tests | ||
dotenv.load_dotenv(dotenv_path=root_dir / ".env.example", override=True) | ||
|
||
yield | ||
|
||
# Reset environment to initial state | ||
os.environ.clear() | ||
os.environ.update(initial_env) | ||
|
||
|
||
@pytest.fixture() | ||
def cro_xr(root_dir, env): | ||
cro_file_path = os.path.join(root_dir, os.environ["CROFILE"]) | ||
return xr.open_dataset(cro_file_path) | ||
|
||
|
||
@pytest.fixture() | ||
def dot_xr(root_dir, env): | ||
dot_file_path = os.path.join(root_dir, os.environ["DOTFILE"]) | ||
return xr.open_dataset(dot_file_path) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,42 @@ | ||
import os | ||
|
||
import pytest | ||
import xarray as xr | ||
from openmethane_prior.omUtils import getenv | ||
from scripts.omCreateDomainInfo import create_domain_info | ||
|
||
|
||
@pytest.fixture() | ||
def geom_xr(root_dir): | ||
geom_file_path = os.path.join(root_dir, getenv("GEO_EM")) | ||
return xr.open_dataset(geom_file_path) | ||
|
||
|
||
@pytest.fixture() | ||
def input_domain_xr(root_dir): | ||
return create_domain_info( | ||
geometry_file=os.path.join(root_dir, getenv("GEO_EM")), | ||
cross_file=os.path.join(root_dir, getenv("CROFILE")), | ||
dot_file=os.path.join(root_dir, getenv("DOTFILE")), | ||
) | ||
|
||
|
||
def test_grid_size_for_geo_files(cro_xr, geom_xr, dot_xr): | ||
expected_cell_size = 10000 | ||
|
||
assert cro_xr.XCELL == expected_cell_size | ||
assert cro_xr.YCELL == expected_cell_size | ||
|
||
assert geom_xr.DX == expected_cell_size | ||
assert geom_xr.DY == expected_cell_size | ||
|
||
assert dot_xr.XCELL == expected_cell_size | ||
assert dot_xr.YCELL == expected_cell_size | ||
|
||
|
||
def test_compare_in_domain_with_cro_dot_files(input_domain_xr, cro_xr, dot_xr): | ||
assert dot_xr.NCOLS == input_domain_xr.COL_D.size | ||
assert dot_xr.NROWS == input_domain_xr.ROW_D.size | ||
|
||
assert cro_xr.NCOLS == input_domain_xr.COL.size | ||
assert cro_xr.NROWS == input_domain_xr.ROW.size |
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