You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Additional request: validate that there are no duplicate observation point names Originally posted by @veenstrajelmer in #459 (comment)
Describe the solution you'd like
A (Pydantic) validator that verifies there are no duplicate names in all read observation points. This should work for a single XYNModel and a single ObservationPointModel.
Open Question (@veenstrajelmer): when reading multiple obs files, actually names must be unique across all of them. Agree?
If so, that would mean we (also) need some root validation in the FMModel.Output class.
Same discussion for PolyFile+ ObservationCrossSectionModel
The text was updated successfully, but these errors were encountered:
Hi Arthur, indeed, this is across all of them. To avoid duplicate names in the output. However, the xy-coordinates are not relevant here. It is also to avoid accidental equal station names called Den in this example:
1.5 2.3 Den Haag
1.2 3.4 Den Helder
What is also important for both polyfiles as obsfiles is that the names are not empty strings, and indeed that they are not duplicated. I think they are also not allowed to start with a number. A small example code shows that hydrolib-core does not validate any of these faulty inputs:
importhydrolib.core.dflowfmashcdfmpolyfile_obj=hcdfm.PolyFile()
foripolinrange(2):
name='duplicate_name'#TODO: not allowed to use identical polyline names in 1 file, but this is not catched by hydrolib-corename=''#TODO: when providing name='' it will result in an invalid plifile, but this is not catched by hydrolib-corename='1'#TODO: starting the name with a number is probably not allowed by FM, but this is not catched by hydrolib-corepointsobj_list= [{'x': -68.35, 'y': 12.2+ipol, 'data': []},
{'x': -68.35, 'y': 12.3+ipol, 'data': []},
{'x': -68.35, 'y': 12.4+ipol, 'data': []},
{'x': -68.35, 'y': 12.5+ipol, 'data': []}]
# TODO: would be convenient of the n_rows and n_columns is derived from the points automaticallypolyobject=hcdfm.PolyObject(metadata={'name':name,'n_rows':4,'n_columns':2}, points=pointsobj_list)
polyfile_obj.objects.append(polyobject)
print('names of polylines in the polyfile')
print([x.metadata.nameforxinpolyfile_obj.objects])
polyfile_obj.save('test_pli.pli')
There might be more demands for the polyline names, like:
not allowed to start with a numeric character
not allowed to contain a dash or other non alphanumeric character. They may contain spaces, so this might also be allowed though. Still good to check.
Furthermore, for PolyObject specifically, it would be great that the n_rows and n_columns are derived from the provided points, but this could be a follow-up issue.
In dfm_tools there is now the function dfm_tools.hydrolib_helpers.validate_polyline_names() that checks duplicate names and starting with a non-alpha character. That function can be removed again after this issue is fixed.
veenstrajelmer
changed the title
Validate no duplicate station names in observation point files (+same for obs crossections)
Validate no duplicate/empty station names in observation point files (+same for obs crossections)
Jul 9, 2024
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
A (Pydantic) validator that verifies there are no duplicate names in all read observation points. This should work for a single
XYNModel
and a singleObservationPointModel
.Open Question (@veenstrajelmer): when reading multiple obs files, actually names must be unique across all of them. Agree?
If so, that would mean we (also) need some root validation in the
FMModel.Output
class.Same discussion for
PolyFile
+ObservationCrossSectionModel
The text was updated successfully, but these errors were encountered: