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

Incompatible TimeStep and TimeSpan in TTLEM raise Error instead of Warning + Adjustment #47

Open
lengri opened this issue Oct 22, 2024 · 0 comments

Comments

@lengri
Copy link

lengri commented Oct 22, 2024

Hi! When providing TTLEM with a time span (TimeSpan) and a time step size (TimeStep) that are non-compatible, meaning TimeSpan/TimeStep is not a natural number, TTLEM breaks instead of adjusting the TimeSpan. Here is a MWE

clc, clear, close

DEM = GRIDobj('srtm_bigtujunga30m_utm11.tif');
p = ttlemset;
p.TimeSpan = 100;
p.TimeStep = 11;
U = DEM;
U.Z(:) = 0;
U.Z(2:end-1,2:end-1) = 1e-3;

p.TimeStep
p.TimeSpan

ttlem(DEM,U,p)

produces

Unrecognized field name "ts".

Error in ttlem (line 108)
        'to be a multiple of the time step'],p.ts,tspan);

Error in test (line 14)
ttlem(DEM,U,p)

I think this is pretty straightforward to fix: In the conditional block in ttlem.m starting in line 104, a warning message referencing p.ts is called before the new time span is saved to p.ts. Swapping the statement and the assignment of p.ts should do the trick.
This error is of course easy to avoid, as you just need to use a run time that is a whole-number multiple of the step size.

On a side note: If you call help ttlemset, you get told that p.TimeStep_outer = <your value> will adjust the size of the time step, but in reality it should be p.TimeStep = <your value>. Not a big deal, but I did wonder for a bit why my assigned step size did not match the step size I was seeing in the model until I checked the code itself.

Cheers,
Lennart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant