Hi all,
I thought I'd contribute a similar version of the read-write script above. My goal was to merge values from two different files, namely copying BOTTOM from a "bathymetry" file to a "previous computation" file (from GAIA) so that sediment information would be preserved, but a new bottom would be applied. I also take the opportunity to reset CUMUL BED EVOL to 0 over the whole domain. If necessary, it would be possible to also use data from the first time step of the "previous computation" file and apply it to the last time step, but I didn't need to do that in this case.
The output file contains the last time step of the "previous computation" file, with the modified variables. This, of course, assumes that the two files have the same number of points. I also modified the script to be
slightly more in keeping with Python best practices; as well, I use it from the command line with the following syntax:
python3 merge_slf.py -p "previous-computation.slf" -b "bathymetry.slf" -o "output.slf"
As in the other script, you will have to modify the path to your pputils install. There is probably a way to add pputils to $PYTHONPATH and have it work automatically, but I couldn't be bothered to figure that out
I hope this can be useful to someone else, even if only as a starting point to your own scripting. Maybe someday, it will be easy to read/write the selafin format without external libraries