Sync from remote server: 2025-10-12 18:56:41
This commit is contained in:
213
ATD/report_RL.m
Executable file
213
ATD/report_RL.m
Executable file
@@ -0,0 +1,213 @@
|
||||
function [GI_rainloc,GI_DateRL,ATTIVA,FIG,FIG_ENG] = report_RL(rRL,m,NodoRainLink,toolrif,...
|
||||
unitrif,datarif,Font_caption,Font_tools,siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,...
|
||||
activeEN,conn,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'report_RL function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
import mlreportgen.dom.*
|
||||
import mlreportgen.report.*
|
||||
|
||||
% Make sure DOM is compilable
|
||||
makeDOMCompilable()
|
||||
|
||||
titolo = 1;
|
||||
GI_rainloc = [];
|
||||
GI_DateRL = [];
|
||||
|
||||
if status(m,1) == 1
|
||||
if ATTIVA == 1
|
||||
ATTIVA = 0;
|
||||
testo = Paragraph('Catena non ancora installata o inattiva.');
|
||||
add(DT,testo);
|
||||
if activeEN == 1
|
||||
testo = Paragraph('Array not installed or inactive.');
|
||||
add(DT_ENG,testo);
|
||||
end
|
||||
end
|
||||
elseif status(m,1) == 3
|
||||
if ATTIVA == 1
|
||||
ATTIVA = 0;
|
||||
testo = Paragraph(['Monitoraggio completato. Invitiamo a visitare la '...
|
||||
'piattaforma web per la visione dei dati storici.']);
|
||||
add(DT,testo);
|
||||
if activeEN == 1
|
||||
testo = Paragraph(['Monitoring completed. Please log into the web-based platform '...
|
||||
'to access the complete dataset.']);
|
||||
add(DT_ENG,testo);
|
||||
end
|
||||
end
|
||||
else
|
||||
for r = 1:rRL(m,1)
|
||||
NodeNum = num2str(NodoRainLink(r,m));
|
||||
comando = ['select EventDate, EventTime, Z, ZShift from ElabDataView where EventDate >= ''' ...
|
||||
datarif ''' and ToolNameID = ''' char(toolrif) ''' and UnitName = ''' char(unitrif) ...
|
||||
''' and NodeNum = ''' NodeNum ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
Dati = curs.Data;
|
||||
% Modifico il formato di data e ora
|
||||
[rD,rC] = size(Dati);
|
||||
if rC ~= 1
|
||||
T = [cell2mat(Dati(:,1)) repmat(' ', [rD,1]) cell2mat(Dati(:,2))];
|
||||
Date = datenum(T); % Data
|
||||
pioggiatot = cell2mat(Dati(:,3)); % altezza di pioggia cumulata
|
||||
pioggialoc = cell2mat(Dati(:,4)); % altezza di pioggia locale
|
||||
pioggiatot_diff = pioggiatot - pioggiatot(1);
|
||||
|
||||
% per grafici integrati
|
||||
GI_rainloc = pioggialoc;
|
||||
GI_DateRL = Date;
|
||||
|
||||
% grafico piogge locali e totali
|
||||
figure(6)
|
||||
rain = bar(Date,pioggialoc,65);
|
||||
title('Precipitazioni');
|
||||
yyaxis left
|
||||
ylabel('Altezza di pioggia [mm]');
|
||||
xlabel('Data [gg/mm/aaaa]');
|
||||
xlim([Date(1)-1 Date(end)+1]);
|
||||
ylim([0 max(pioggialoc(:,1))+1]);
|
||||
|
||||
hold on
|
||||
yyaxis right
|
||||
raintot = plot(Date,pioggiatot_diff);
|
||||
ylabel('Altezza di pioggia cumulata [mm]');
|
||||
set(gca,'YColor','k');
|
||||
if min(pioggiatot_diff(:,1))-2 > 0
|
||||
ylim([min(pioggiatot_diff(:,1))-2 max(pioggiatot_diff(:,1))+1]);
|
||||
else
|
||||
ylim([0 max(pioggiatot_diff(:,1))+1]);
|
||||
end
|
||||
|
||||
h = gca;
|
||||
h.XAxis.MinorTick = 'on';
|
||||
datetick('x','dd/mm/yyyy','keepticks','keeplimits');
|
||||
xtickangle(25);
|
||||
str(1,1) = cellstr('Precipitazioni');
|
||||
str(2,1) = cellstr('Precipitazioni cumulate');
|
||||
legend(str,'Location','best');
|
||||
grid on
|
||||
grid minor
|
||||
|
||||
TempName = char(strcat('Report',siteID,'-', char(toolrif),'-RainLink', NodeNum, '.png'));
|
||||
saveas(raintot,TempName);
|
||||
ChartRL = Image(TempName);
|
||||
ChartRL.Style = {ScaleToFit};
|
||||
ChartRL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Andamento nel tempo delle precipitazioni misurate dal pluviometro']);
|
||||
FIG = FIG+1;
|
||||
ChartRL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
|
||||
testo = Paragraph(['Il grafico seguente riporta i dati di precipitazione '...
|
||||
'locale e cumulata registrati nel periodo temporale di riferimento. '...
|
||||
'In particolare, l''altezza di pioggia totale registrata '...
|
||||
'dal pluviometro in riferimento al solo periodo di riferimento ' char(232) ' pari a ' num2str(sum(pioggiatot_diff(end)))...
|
||||
' mm, mentre il valore di pioggia cumulata '...
|
||||
'a partire dall''inizio dell''attivit' char(224) ' di monitoraggio ' char(232) ' di ' num2str(pioggiatot(end))...
|
||||
' mm (dato aggiornato al ' datestr(Date(end), 'dd/mm/yyyy HH:MM') ').']);
|
||||
testo.HAlign = 'justify';
|
||||
|
||||
if titolo == 1
|
||||
sezRain = Paragraph('Rain Link');
|
||||
sezRain.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
|
||||
RR = Section();
|
||||
RR.Title = sezRain;
|
||||
add(DT,sezRain);
|
||||
if activeEN == 1
|
||||
sezRain_ENG = Paragraph('Rain Link');
|
||||
sezRain_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
|
||||
RR_ENG = Section();
|
||||
RR_ENG.Title = sezRain;
|
||||
add(DT_ENG,sezRain_ENG);
|
||||
end
|
||||
titolo = 0;
|
||||
end
|
||||
|
||||
add(DT,testo);
|
||||
add(DT,ChartRL);
|
||||
add(DT,ChartRL_cap);
|
||||
add(DT,br);
|
||||
close(figure(6));
|
||||
|
||||
%--ENG--
|
||||
if activeEN == 1
|
||||
% grafico piogge locali e totali
|
||||
figure(16)
|
||||
rain = bar(Date,pioggialoc,25);
|
||||
title('Rainfall');
|
||||
yyaxis left
|
||||
ylabel('Rainfall [mm]');
|
||||
xlabel('Date [dd/mm/yyyy]');
|
||||
xlim([Date(1)-1 Date(end)+1]);
|
||||
ylim([0 max(pioggialoc(:,1))+1]);
|
||||
|
||||
hold on
|
||||
yyaxis right
|
||||
raintot = plot(Date,pioggiatot_diff);
|
||||
ylabel('Cumulative rainfall [mm]');
|
||||
set(gca,'YColor','k');
|
||||
if min(pioggiatot_diff(:,1))-2 > 0
|
||||
ylim([min(pioggiatot_diff(:,1))-2 max(pioggiatot_diff(:,1))+1]);
|
||||
else
|
||||
ylim([0 max(pioggiatot_diff(:,1))+1]);
|
||||
end
|
||||
|
||||
h = gca;
|
||||
h.XAxis.MinorTick = 'on';
|
||||
datetick('x','dd/mm/yyyy','keepticks','keeplimits');
|
||||
xtickangle(25);
|
||||
str(1,1) = cellstr('Rainfall');
|
||||
str(2,1) = cellstr('Cumulative rainfall');
|
||||
legend(str,'Location','best');
|
||||
grid on
|
||||
grid minor
|
||||
|
||||
|
||||
TempName = char(strcat('Report',siteID,'-', char(toolrif),'-RainLink', NodeNum, '_ENG.png'));
|
||||
saveas(raintot,TempName);
|
||||
ChartRL_ENG = Image(TempName);
|
||||
ChartRL_ENG.Style = {ScaleToFit};
|
||||
ChartRL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Rainfall trend recorded by the rain gauge during the reference time period']);
|
||||
FIG_ENG = FIG_ENG+1;
|
||||
ChartRL_ENG_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
|
||||
testo = Paragraph(['The following graph shows precipitation data recorded by the rain gauge during the '...
|
||||
'reference time period. In particular, the sensor recorded a total rainfall of '...
|
||||
' ' num2str(sum(pioggiatot_diff(end)))...
|
||||
' mm during the reference time period, while the cumulative rainfall measured since the '...
|
||||
'beginning of the monitoring activity amounts to ' num2str(pioggiatot(end))...
|
||||
' mm (updated to: ' datestr(Date(end), 'dd/mm/yyyy HH:MM') ').']);
|
||||
testo.HAlign = 'justify';
|
||||
|
||||
add(DT_ENG,testo);
|
||||
add(DT_ENG,ChartRL_ENG);
|
||||
add(DT_ENG,ChartRL_ENG_cap);
|
||||
add(DT_ENG,br);
|
||||
close(figure(16));
|
||||
end
|
||||
|
||||
% pulisco variabili da riutilizzare per catena successiva
|
||||
clear pioggiatot;
|
||||
clear pioggialoc;
|
||||
|
||||
else
|
||||
if ATTIVA == 1
|
||||
testo = Paragraph('Non sono presenti dati relativi al periodo temporale considerato.');
|
||||
ATTIVA = 0;
|
||||
add(DT,testo);
|
||||
if activeEN == 1
|
||||
testo = Paragraph('No data available for the reference time period.');
|
||||
add(DT_ENG,testo);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
text = 'report_RL function executed correctly. report_RL function closed';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user