Lambda functions have been introduced into Scilab 2025.0.0. Did you used them with timeseries/table?
Here are some examples of uses:
dt = datetime(2025, 1, 1:31)';
temp_max = [9; 10; 4; 2; 11; 12; 7; 8; 11; 4; 4; 6; 4; 5; 6; 7; 5; 6; 6; 6; 7; 10; 9; 11; 11; 8; 10; 10; 8; 8; 5];
temp_min = [4; 2; 0; 0; 8; 6; 4; 4; 2; 1; 0; 0; -1; -1; 1; 1; 0; 0; 0; 1; 1; 3; 4; 8; 5; 2; 7; 7; 6; 3; 2];
precip = [0; 7.8; 0; 1.4; 3.1; 0.4; 0.4; 6.3; 2; 4.6; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 2.3; 0.1; 1.5; 0.2; 0; 3; 0.7; 0.7; 0.9; 1.3];
sunrise = duration(8, [44; 44; 44; 44; 43; 43; 43; 42; 42; 41; 41; 40; 40; 39; 38; 38; 37; 36; 35; 34; 33; 32; 31; 30; 29; 28; 27; 25; 24; 23; 22], 0);
sunset = duration(17, [5; 6; 7; 8; 9; 10; 12; 13; 14; 15; 17; 18; 19; 20; 22; 24; 25; 27; 28; 30; 31; 33; 34; 36; 37; 39; 41; 42; 44; 45; 47], 0);
varnames = ["Date", "Temp_max", "Temp_min", "Precip", "Sunrise", "Sunset"];
ts = timeseries(dt, temp_max, temp_min, precip, sunrise, sunset, "VariableNames", varnames);
head(ts, 5)
ans = [5x5 timeseries]
Date Temp_max Temp_min Precip Sunrise Sunset
__________ ________ ________ ______ ________ ________
2025-01-01 9 4 0 08:44:00 17:05:00
2025-01-02 10 2 7.8 08:44:00 17:06:00
2025-01-03 4 0 0 08:44:00 17:07:00
2025-01-04 2 0 1.4 08:44:00 17:08:00
2025-01-05 11 8 3.1 08:43:00 17:09:00
We want to obtain the accumulated precipitation and sun hours per day:
f = #(precip, sunrise, sunset) -> (varargout = list(cumsum(precip), sunset - sunrise))
r = rowfun(f, ts, "InputVariables", ["Precip", "Sunrise", "Sunset"], "OutputVariableNames", ["Cumul_Precip", "Sunhour"])
blue = color(39, 115, 191);
orange = color(209, 81, 4);
// Precipitation bar
b = bar(ts.Precip);
b.background = blue;
b.foreground = blue;
gca().tight_limits = "on";
xlabel("days");
y = ylabel("Precipitation [mm]");
y.foreground = blue;
// New axes for accumulated precipitation
a = newaxes();
a.filled = "off";
plot(r.Cumul_Precip, "color", "#D15104", "thickness", 2);
a.tight_limits = "on";
a.axes_visible(1) = "off";
a.y_location = "right";
a.box = "off";
a.foreground = orange;
a.font_color = orange;
y = ylabel("Accumulated Precipitation [mm]");
y.foreground = orange;
And the accumulated precipitation and average temperature per week:
f = #(precip) -> (sum(precip));
tempmean = #(tempmax, tempmin) -> (msprintf("%.1f", mean([tempmax, tempmin])))
r = retime(ts(:, "Precip"), "regular", f, "TimeStep", caldays(7))
r = [5x1 timeseries]
Date Precip
__________ ______
2025-01-01 13.1
2025-01-08 12.9
2025-01-15 0
2025-01-22 7.8
2025-01-29 2.9
g = groupsummary(ts, "Date", caldays(7), tempmean, {"Temp_max", "Temp_min"})
g = [5x3 table]
Date GroupCount fun_Temp_max_Temp_min
__________________________ __________ _____________________
[ 2025-01-01, 2025-01-08 ) 7 5.6
[ 2025-01-08, 2025-01-15 ) 7 3.4
[ 2025-01-15, 2025-01-22 ) 7 3.4
[ 2025-01-22, 2025-01-29 ) 7 7.5
[ 2025-01-29, 2025-02-05 ] 3 5.3
Data downloaded from https://www.historique-meteo.net/france/ile-de-france/paris/2025/01/
Enjoy your ride with Scilab!