Deltares / dfm_tools

A Python package for pre- and postprocessing D-Flow FM model input and output files
https://deltares.github.io/dfm_tools/
GNU General Public License v3.0
70 stars 12 forks source link

set local source for tidal forcing #872

Open thopri opened 5 months ago

thopri commented 5 months ago

Hi,

Can I request a way to set a custom tide forcing location? At the moment I need to edit the source code of interpolate_grid2gnd.py as the local forcing location of GTSMv4.1 is hard coded so I can use my own hard coded location! :)

I will probably get round to creating a PR eventually, but having the option to dynamically set a location for the tide forcing would be useful maybe an optional argument in the tide interpolation function below?

dfmt.interpolate_tide_to_bc(tidemodel=tidemodel, file_pli=poly_file, component_list=None)

veenstrajelmer commented 5 months ago

Thanks for this suggestion, this part of the code is still quite hard-coded indeed. Which tide model are you currently using?

thopri commented 5 months ago

I am currently using GTSM but a downloaded version, I had issues with the opendap version that I can't quite recall. We also have our own global tide model that I will want to be able to use (will need to make it compatible). I also use FES2014 a lot, and would probably want to use this (I know this an option in DFM_tools already).

veenstrajelmer commented 5 months ago

Ok, I think in that case for now it would be most convenient for you to use the functions that are used by dfmt.interpolate_tide_to_bc(): https://github.com/Deltares/dfm_tools/blob/03cabed8174f33a857823510aacb536531a7c8df/dfm_tools/interpolate_grid2bnd.py#L116-L120

If you read in your own tidal dataset and interpolate it with dfmt.interp_regularnc_to_plipointsDataset() like is done here: https://github.com/Deltares/dfm_tools/blob/03cabed8174f33a857823510aacb536531a7c8df/dfm_tools/interpolate_grid2bnd.py#L237C19-L238

This gives what you need by using the underlying modules from the dfm_tools code, so it would at least prevent you from having to edit the source code of dfm_tools.