Skip to content

Commit

Permalink
- Finished test 'test_observation_points_create'
Browse files Browse the repository at this point in the history
  • Loading branch information
Leynse committed Feb 20, 2025
1 parent f25b5a9 commit b26fe77
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions tests/test_observation_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,42 @@ def test_observation_points_io(model_config, tmp_path):
assert obs0.equals(obs1)


# def test_observation_points_create(model):
# goal: check if obsfile can be made from a geojson
# gdf = model.data_catalog.get_geodataframe(
# os.path.join(TESTDATADIR, "obs.geojson"),
# )
def test_observation_points_create(model_config, tmp_path):
# goal: test if obsfile can be made from an existing geojson
# goal: compare to similar values from existing ascii sfincs.obs file
# goal: check behaviour merge = False and True

# points from sfincs.obs file read in (because .data that initializes, and not ._data)
obs0 = model_config.observation_points.data

# read in related geojson
gdf = model_config.data_catalog.get_geodataframe(
join(TESTMODELDIR, "gis", "obs.geojson")
)

# call create
model_config.observation_points.create(locations=gdf, merge=False)

# check if sizes are the same
obs1 = model_config.observation_points.data
assert obs1.shape == obs0.shape # (3,2) > both 3 points

# check if coordinates are similar (do to rounding in ascii sfincs.obs not exactly the same)
assert np.isclose(obs1.geometry.x.values, obs0.geometry.x.values, rtol=0.001).all()
assert np.isclose(obs1.geometry.y.values, obs0.geometry.y.values, rtol=0.001).all()

# add again with merge = True and should have 6 points now
model_config.observation_points.create(locations=gdf, merge=True)
obs2 = model_config.observation_points.data
assert obs2.size == 12 # (6,2) > now 6 points


# model_config.observation_points.clear() #> does not work?

# def test_observation_points_set(model):
# goal: check if point can be added (one in and one outside of region)
# goal: check if points outside of region are actually clipped

# def test_observation_points_merge(model):
# goal: check behaviour merge = False and True

# def test_observation_points_add_delete_point(model):
# goal: check if single point added/deleted as GUI style works

Expand Down

0 comments on commit b26fe77

Please sign in to comment.