Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obsfile path with spaces is not supported #564

Open
veenstrajelmer opened this issue Oct 10, 2023 · 0 comments
Open

Obsfile path with spaces is not supported #564

veenstrajelmer opened this issue Oct 10, 2023 · 0 comments
Labels
priority: high type: bug Something isn't working type: compatibility Changes needed to be compatible with the computational core

Comments

@veenstrajelmer
Copy link
Collaborator

Describe the bug
When there is a space in an obsfile path, HYDROLIB-core raises a ValidationError since it only reads the path up to the space:

ValidationError: 4 validation errors for Output
obsfile -> 0
  File: `C:\DATA\dfm_tools\dfm_tools\Vietnam_model_forissue\Vietnam` not found, skipped parsing. (type=value_error)
obsfile -> 0

The path of the obsfile is C:\DATA\dfm_tools\tests\examples_workinprogress\Vietnam _model_forissue\Vietnam_obs.xyn

To Reproduce

# import packages
import os
import hydrolib.core.dflowfm as hcdfm
import pandas as pd
import numpy as np

# user input
model_name = 'Vietnam'
dir_output = os.path.abspath(f'./{model_name} _model_forissue') #TODO: space in path will raise ValidationError
os.makedirs(dir_output, exist_ok=True)

# generate obspoints
xpts = np.array([106.52500191, 105.87500194, 106.52500192, 106.47500189])
ypts = np.array([18.09475411, 18.46123843, 18.23233872, 17.9569871])
npts = np.array(['x106p53_y18p09', 'x105p88_y18p46', 'x106p53_y18p23', 'x106p48_y17p96'])
obs_pd = pd.DataFrame(dict(x=xpts,y=ypts,name=npts))

# save obsfile
file_obs = os.path.join(dir_output, f'{model_name}_obs.xyn')
obs_pd.to_csv(file_obs, sep=' ', header=False, index=False, float_format='%.6f')

# initialize mdu file and update settings
mdu = hcdfm.FMModel()
mdu.output.obsfile = file_obs

Expected behavior
If a space is included, it will still work. Just like for files like ext files and such, since it works here.

Version info (please complete the following information):

  • OS: Windows
  • Version: 0.5.2
@priscavdsluis priscavdsluis added type: bug Something isn't working type: compatibility Changes needed to be compatible with the computational core priority: high labels Apr 9, 2024
@rhutten rhutten added this to To do in HYDROLIB-core via automation Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high type: bug Something isn't working type: compatibility Changes needed to be compatible with the computational core
Projects
HYDROLIB-core
  
To do
Development

No branches or pull requests

2 participants