Skip to content

Commit

Permalink
Add lowercase option
Browse files Browse the repository at this point in the history
  • Loading branch information
vegardkv committed Oct 11, 2022
1 parent 1bb253b commit 0fc0526
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/xtgeoapp_grd3dmaps/aggregate/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class MapSettings:
@dataclass
class Output:
mapfolder: str
lowercase: bool = True
plotfolder: Optional[str] = None
use_plotly: bool = False
aggregation_tag: bool = True
Expand Down
11 changes: 10 additions & 1 deletion src/xtgeoapp_grd3dmaps/aggregate/grid3d_aggregate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def generate_maps(
xn,
yn,
p_maps,
output.lowercase,
)
_write_surfaces(surfs, output.mapfolder, output.plotfolder, output.use_plotly)

Expand All @@ -132,6 +133,7 @@ def _ndarray_to_regsurfs(
x_nodes: np.ndarray,
y_nodes: np.ndarray,
maps: List[List[np.ndarray]],
lowercase: bool,
) -> List[xtgeo.RegularSurface]:
return [
xtgeo.RegularSurface(
Expand All @@ -142,13 +144,20 @@ def _ndarray_to_regsurfs(
xori=x_nodes[0],
yori=y_nodes[0],
values=np.ma.array(map_, mask=np.isnan(map_)),
name=f"{fn}--{prop}"
name=_deduce_surface_name(fn, prop, lowercase),
)
for fn, inner in zip(filter_names, maps)
for prop, map_ in zip(prop_names, inner)
]


def _deduce_surface_name(filter_name, property_name, lowercase):
name = f"{filter_name}--{property_name}"
if lowercase:
name = name.lower()
return name


def _write_surfaces(
surfaces: List[xtgeo.RegularSurface],
map_folder: str,
Expand Down
32 changes: 16 additions & 16 deletions tests/test_scripts/test_grid3d_aggregate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_aggregated_map1_add2docs(datatree):
str(result),
]
)
swat = xtgeo.surface_from_file(result / "all--max_SWAT--20030101.gri")
swat = xtgeo.surface_from_file(result / "all--max_swat--20030101.gri")
assert swat.values.min() == pytest.approx(0.14292679727077484, abs=1e-8)
_copy2docs(cfg)

Expand All @@ -46,7 +46,7 @@ def test_aggregated_map2_add2docs(datatree):
str(result),
]
)
swat = xtgeo.surface_from_file(result / "all--min_SWAT--20030101.gri")
swat = xtgeo.surface_from_file(result / "all--min_swat--20030101.gri")
assert swat.values.mean() == pytest.approx(0.7908786104444353, abs=1e-8)
_copy2docs(cfg)

Expand All @@ -65,7 +65,7 @@ def test_aggregated_map3_add2docs(datatree):
str(result),
]
)
poro = xtgeo.surface_from_file(result / "all--mean_PORO.gri")
poro = xtgeo.surface_from_file(result / "all--mean_poro.gri")
assert poro.values.mean() == pytest.approx(0.1677586422488292, abs=1e-8)
_copy2docs(cfg)

Expand All @@ -84,11 +84,11 @@ def test_aggregated_map4_add2docs(datatree):
str(result),
]
)
swat = xtgeo.surface_from_file(result / "zone1--max_SWAT--20030101.gri")
swat = xtgeo.surface_from_file(result / "zone1--max_swat--20030101.gri")
assert swat.values.max() == pytest.approx(1.0000962018966675, abs=1e-8)
assert (result / "all--max_SWAT--20030101.gri").is_file()
assert (result / "zone2--max_SWAT--20030101.gri").is_file()
assert (result / "zone3--max_SWAT--20030101.gri").is_file()
assert (result / "all--max_swat--20030101.gri").is_file()
assert (result / "zone2--max_swat--20030101.gri").is_file()
assert (result / "zone3--max_swat--20030101.gri").is_file()
_copy2docs(yml)


Expand All @@ -106,7 +106,7 @@ def test_aggregated_map5_add2docs(datatree):
str(result),
]
)
poro = xtgeo.surface_from_file(result / "all--mean_PORO.gri")
poro = xtgeo.surface_from_file(result / "all--mean_poro.gri")
assert poro.values.mean() == pytest.approx(0.1648792893163274, abs=1e-8)
_copy2docs(cfg)

Expand All @@ -127,13 +127,13 @@ def test_aggregated_map6_add2docs(datatree):
)
gri_files = [p.stem for p in Path(result).glob("*.gri")]
assert sorted(gri_files) == sorted([
"all--max_SWAT--19991201",
"all--max_SWAT--20030101",
"FirstZone--max_SWAT--19991201",
"FirstZone--max_SWAT--20030101",
"SecondZone--max_SWAT--19991201",
"SecondZone--max_SWAT--20030101",
"ThirdZone--max_SWAT--19991201",
"ThirdZone--max_SWAT--20030101",
"all--max_swat--19991201",
"all--max_swat--20030101",
"firstzone--max_swat--19991201",
"firstzone--max_swat--20030101",
"secondzone--max_swat--19991201",
"secondzone--max_swat--20030101",
"thirdzone--max_swat--19991201",
"thirdzone--max_swat--20030101",
])
_copy2docs(cfg)
6 changes: 3 additions & 3 deletions tests/test_scripts/test_grid3d_migration_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_migration_time1(datatree):
str(result),
]
)
swat = xtgeo.surface_from_file(result / "all--MigrationTime.gri")
swat = xtgeo.surface_from_file(result / "all--migrationtime.gri")
assert swat.values.max() == pytest.approx(3.08767, abs=0.001)


Expand All @@ -30,5 +30,5 @@ def test_migration_time2(datatree):
str(result),
]
)
assert (result / "lower_zone--MigrationTime.gri").is_file()
assert not (result / "all--MigrationTime.gri").is_file()
assert (result / "lower_zone--migrationtime.gri").is_file()
assert not (result / "all--migrationtime.gri").is_file()

0 comments on commit 0fc0526

Please sign in to comment.