Skip to content

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

@lengri

Description

@lengri

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions