-
Notifications
You must be signed in to change notification settings - Fork 22
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
Flextopo #194
Flextopo #194
Conversation
After our discussion on 12 January 2022, I did make the following changes to the code:
[input.vertical]
imax.value = [2.0, 2.0, 3.0]
[[csv.column]]
header = "imax_H"
map = "sub_S06"
parameter = "vertical.imax"
reducer = "mean"
index_dim = 1 # class "H" |
great! thanks @verseve !!
does this mean that we can only assign values to imax? and is it also possible to read in parameters from staticmaps with a classes dimension? |
No, you can also assign values through a NetCDF variable. Note that the NetCDF variable should have dimension Scale and offset should also work.
Yes, see answer above. |
ok, nice that reading in parameters with classes dimension also works, I guess this is what you mean with:
and about:
what would be the syntax to apply a scale and offset on a map in the staticmaps?
|
Yep, this works fine.
Yes, except that this is not working with A = read_standardized(nc, var, dim_sel) .* mod.scale .+ mod.offset |
is it possible to implement scale and offset with the |
Sure, this is possible. Probably good to support multiple indexing then, I guess there is also the use case to modify more than one index during calibration? |
yes good suggestion, this would imply that if |
And what if you want to change multiple indices at once, for example index 1 and 3 in the example below. Is this useful? [input.vertical.imax]
index_dim = [1,3]
netcdf.variable.name = "map_in_staticmaps"
scale = [2.0, 0.5]
offset = [0.0, 0.0] |
yes this sounds useful aswell, and about the "map_in_staticmaps", can this be a map without a "classes" dimension? |
Yes, this is definitely possible, then it is a parameter without an extra dimension like |
Just to check @verseve, you mention the classes are specified in the TOML like And with this:
Would that be and index into the list of classes in the TOML, or the netCDF? Do you think it might be a good idea to instead specify the label?
|
And @verseve, now that you dug into the code more, do you wish to proceed with the SVector approach? I still have to check the code, but is it correct that we run per class, but then have to recreate each SVector nclass times (with setindex)? Do we already have an idea about performance compared to Python? @laurenebouaziz if you still have the alternate design we discussed in your notes, could you post it in the thread, even if we won't end up using it? |
Yes, this must match the NetCDF dimension exactly (order and size).
The |
I think it is fine to proceed with the SVector approach. I haven't checked the update functions/performance yet, my impression is that if we run in the same way as the |
here is a copy of the notes we took for the other setup we had discussed:
about:
Agree, it could also prevent user errors about starting with index 0 or 1 (i.e. i believe the c parameters has dim values [0,1,2,3] in staticmaps.nc but in julia the index would be 1,2,3,4 right?) |
I tested the following things which all work nicely:
I also changed the names of the variables to longer more explicit names without capital letters to make it more consistent with the other concepts in Wflow. I still need to:
What remains of things we had discussed before is:
Is it still possible for you to have a look at this @verseve (no rush)? (I added a new version of the toml file with the new names in you postbox in case you need it.) And thanks for all the changes so far :) !! |
Did you check the test in |
And @laurenebouaziz, for running
|
Thanks @verseve for checking how it would work in FEWS for flextopo. For scalar netcdf at point locations, I don't think it is a problem to separate the output for the different classes with separate names and import them separately in fews. However, for outmaps and outstates, I don't think there is also a way to split the output for each class in the toml? And would the states still correctly be picked up in a fews warm states run? I guess for outmaps and outstates, it would probably then be better to misuse the z coordinate for the classes, what do you think? |
Update:
[input.vertical.imax]
netcdf.variable.name = "map_in_staticmaps"
scale = 2.0
offset = 0.0
class = "H" |
I finally had some time to test the model and compare it with the python runs and I was able to reproduce the results :)
I think it is a good idead and I implemented this option for parameter multiplication over several classes in commit c5d5c91 I think how it was now, parameter multiplication only worked for a single class and it seemed to me that there were no possibilities to change the parameters over multiple classes at the same time, as for example the code below does not work :
Line 450 in c5d5c91
expects a vector of Float64 while the classes are a vector of strings, so if I replace this line with:
|
I think this should fix this: |
Thanks for spotting this @laurenebouaziz , indeed for FEWS the classes should be [1.0,2.0,3.0] and not 3. |
thanks @verseve ! both are fixed now. |
I did briefly check the code and agree that modifying multiple indices at once is useful. I did notice it is only implemented for dim |
Would be good to increase codecov for this PR, @laurenebouaziz? |
Indeed that would be good, currently:
(although these numbers are a bit inflated due to unrelated I see you did quite some checks offline, but the best would be to add (some of) these checks to the tests such that we know we won't break it in the future. |
yes good point, what kind of tests do you recommend me to add? |
The codecoverage output may help to identify some functions or features that are currently not covered by tests: https://app.codecov.io/gh/Deltares/Wflow.jl/compare/194/diff#D6L531 Try to see what new functionality is not currently being run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a few comments that would be good to address before merging, but overall this seems pretty close to being finished, nice job.
I think it would be good to add to the docs a bit more info on changing/setting input parameters with an extra dimension:
[input.vertical]
c.value = [10.0, 12.0, 9.0, 8.5]
I will add some info on this to |
extend test modifying parameters, apply scale and offset at multiple indices.
Thanks @verseve for completing the docs on param mult with extra dimension! |
Thanks for addressing the comments. Indeed the code coverage looks good now. Shall we remove the extra config argument? |
Yes, I agree to remove the extra |
implementation of flextopo model with flexible number of classes and modular options for the equations/presence of the different storages.
in the toml file the classes are indicated in [model] with:
classes = ["H", "P", "W"]
selection of storage functions for each class is then indicated for the different storages with:
selectSi = ["interception_no_storage", "interception_overflow", "interception_overflow"]
the snow storage and the glacier module are common for all the classes.
interception, hortonponding, hortonrunoff, root-zone, fast storage are class specific (and modular, can be included or excluded for a class through the choice of the function)
the slow reservoir is a common reservoir for the different classes.
to do (things discussed with Willem and Martijn on 12 jan 2022):
[[csv.column]]
header = "Sh_H"
map = "sub_S06"
parameter = "vertical.Sh[1]"
reducer = "mean"
or
[[csv.column]]
header = "Sh_H"
map = "sub_S06"
parameter = "vertical.Sh"
reducer = "mean"
dim = 'H'
changes made in utils.jl slipped in during testing but probably just need to be reverted / removed.
note:
I tested writing explicitly vertical.Sw, vertical.Sww before the function:
vertical.Sw, vertical.Sww = lateral_snow_transport!(
vertical.Sw,
vertical.Sww,
lateral.land.sl,
network.land,
)
but this gives the error: does not work LoadError: setfield!: immutable struct of type FLEXTOPO cannot be changed
same is true if implemented in SBM though. not sure what this means for the update of the snow and snowwater?