Sync from remote server: 2025-10-12 18:56:41
This commit is contained in:
379
Tilt/report_IPLHR.m
Executable file
379
Tilt/report_IPLHR.m
Executable file
@@ -0,0 +1,379 @@
|
||||
function [GI_MaxDispMESE,GI_DateIPLHR,GI_MaxDispProf,ATTIVA,FIG,FIG_ENG] = report_IPLHR(...
|
||||
rIPLHR,m,NodoInPlaceLinkHR,toolrif,unitrif,datarif,firstdata_num,Font_caption,...
|
||||
Font_tools,siteID,toolrifID,DT,DT_ENG,FIG,FIG_ENG,br,colonna2,colonna2bis,status,...
|
||||
ATTIVA,activeEN,conn,FileName)
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'report_IPLHR function started';
|
||||
fprintf(fileID,fmt,text);
|
||||
|
||||
import mlreportgen.dom.*
|
||||
import mlreportgen.report.*
|
||||
|
||||
% Make sure DOM is compilable
|
||||
makeDOMCompilable()
|
||||
|
||||
GI_MaxDispMESE = [];
|
||||
GI_DateIPLHR = [];
|
||||
GI_MaxDispProf = [];
|
||||
check = 0;
|
||||
NODATA(m,1) = 0;
|
||||
while check == 0
|
||||
if status(m,1) == 1
|
||||
if ATTIVA == 1
|
||||
testo = Paragraph('Catena non ancora installata o inattiva.');
|
||||
ATTIVA = 0;
|
||||
add(DT,testo);
|
||||
if activeEN == 1
|
||||
testo = Paragraph('Array not installed or inactive.');
|
||||
add(DT_ENG,testo);
|
||||
end
|
||||
end
|
||||
check = 1;
|
||||
elseif status(m,1) == 3
|
||||
if ATTIVA == 1
|
||||
testo = Paragraph(['Monitoraggio completato. Invitiamo a visitare la '...
|
||||
'piattaforma web per la visione dei dati storici.']);
|
||||
ATTIVA = 0;
|
||||
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
|
||||
check = 1;
|
||||
else
|
||||
for n = 1:rIPLHR(m,1)
|
||||
NodeNum = num2str(NodoInPlaceLinkHR(n,m));
|
||||
comando = ['select EventDate, EventTime, HShift_local, HShift, NodeDepth, '...
|
||||
'XShift, YShift, X, Y 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
|
||||
if n == 1 % Il primo lo scrivo e creo la variabile di controllo
|
||||
else
|
||||
[rS,~] = size(Spost_local);
|
||||
if rD ~= rS
|
||||
NODATA(m,1) = 2;
|
||||
check = 0;
|
||||
break
|
||||
else
|
||||
check = 1;
|
||||
end
|
||||
end
|
||||
% dall'inizio
|
||||
Spost_local(:,n) = cell2mat((Dati(:,3)))*1000; % Loc 2D
|
||||
Spost(:,n) = (cell2mat(Dati(:,4)))*1000; % Cum 2D
|
||||
Prof(:,n) = -(cell2mat(Dati(1,5))); % Profondità
|
||||
% Locali ultimo mese
|
||||
Spost_Local_MeseX(:,n) = cell2mat(Dati(:,6)); % Loc X ultimo mese
|
||||
Spost_Local_MeseY(:,n) = cell2mat(Dati(:,7)); % Loc Y ultimo mese
|
||||
diffMeseX_Local(1,n) = Spost_Local_MeseX(end,n)-Spost_Local_MeseX(1,n);
|
||||
diffMeseY_Local(1,n) = Spost_Local_MeseY(end,n)-Spost_Local_MeseY(1,n);
|
||||
DispMese_Local(1,n) = sqrt(diffMeseX_Local(1,n)^2 + diffMeseY_Local(1,n)^2)*1000;
|
||||
% Cumulati ultimo mese
|
||||
Spost_MeseX(:,n) = cell2mat(Dati(:,8)); % Cum X ultimo mese
|
||||
Spost_MeseY(:,n) = cell2mat(Dati(:,9)); % Cum Y ultimo mese
|
||||
diffMeseX(1,n) = Spost_MeseX(end,n)-Spost_MeseX(1,n);
|
||||
diffMeseY(1,n) = Spost_MeseY(end,n)-Spost_MeseY(1,n);
|
||||
DispMese(1,n) = sqrt(diffMeseX(1,n)^2 + diffMeseY(1,n)^2)*1000;
|
||||
else
|
||||
NODATA(m,1) = 1;
|
||||
check = 1;
|
||||
end
|
||||
end
|
||||
if NODATA(m,1) == 0
|
||||
if strcmp(colonna2bis(m+1,1),colonna2(m+1,1)) == 0 % data zero = data riferimento
|
||||
clear Spost;
|
||||
clear Spost_local;
|
||||
clear Azimuth;
|
||||
datarifNEW = datestr(firstdata_num{m+1,1},'yyyy-mm-dd'); % data riferimento definita sul sito
|
||||
for nw = 1:rIPLHR(m,1)
|
||||
NodeNum = num2str(NodoInPlaceLinkHR(nw,m));
|
||||
comando = ['select EventDate, EventTime, HShift_local, HShift, NodeDepth, XShift, YShift, X, Y '...
|
||||
'from ElabDataView where EventDate = ''' datarifNEW ''' and ToolNameID = ''' char(toolrif) ...
|
||||
''' and UnitName = ''' char(unitrif) ''' and NodeNum = ''' NodeNum ''' '];
|
||||
curs = exec(conn,comando);
|
||||
curs = fetch(curs);
|
||||
DatiNEW = curs.Data; % dati registrati alla data di riferimento
|
||||
[~,rC] = size(DatiNEW);
|
||||
if rC ~= 1
|
||||
% dalla data di riferimento
|
||||
Spost_Local_X_RIF(:,nw) = cell2mat(DatiNEW(:,6)); %Loc X data rif
|
||||
Spost_Local_Y_RIF(:,nw) = cell2mat(DatiNEW(:,7)); %Loc Y data rif
|
||||
diffX_Local_RIF(1,nw) = Spost_Local_MeseX(end,nw)-Spost_Local_X_RIF(1,nw);
|
||||
diffY_Local_RIF(1,nw) = Spost_Local_MeseY(end,nw)-Spost_Local_Y_RIF(1,nw);
|
||||
Spost_local(1,nw) = sqrt(diffX_Local_RIF(1,nw)^2 + diffY_Local_RIF(1,nw)^2)*1000;
|
||||
|
||||
Spost_X_RIF(:,nw) =cell2mat(DatiNEW(:,8)); % Cum X data rif
|
||||
Spost_Y_RIF(:,nw) =cell2mat(DatiNEW(:,9)); % Cum Y data rif
|
||||
diffX_RIF(1,nw) = Spost_MeseX(end,nw)-Spost_X_RIF(1,nw);
|
||||
diffY_RIF(1,nw) = Spost_MeseY(end,nw)-Spost_Y_RIF(1,nw);
|
||||
Spost(1,nw) = sqrt(diffX_RIF(1,nw)^2 + diffY_RIF(1,nw)^2)*1000;
|
||||
else
|
||||
NODATA(m,1) = 1;
|
||||
end
|
||||
end
|
||||
% Approssimo gli spostamenti al decimo di millimetro
|
||||
conv = Spost*10;
|
||||
conv = round(conv);
|
||||
Spost = conv/10;
|
||||
end
|
||||
|
||||
MaxDisp = max(Spost_local(end,:));
|
||||
Index = find(Spost_local(end,:) == MaxDisp);
|
||||
MaxDispProf = Prof(1,Index(1));
|
||||
|
||||
MaxDispMESE = max(DispMese_Local(end,:));
|
||||
IndexMESE = find(DispMese_Local(end,:) == MaxDispMESE);
|
||||
MaxDispProfMESE = Prof(1,IndexMESE(1));
|
||||
|
||||
% aggiungo ancora
|
||||
comando = ['select nodetype_id, depth, num from nodes where tool_id = ''' num2str(cell2mat(toolrifID)) ...
|
||||
''' and nodetype_id = 9 order by num'];
|
||||
Anc = fetch(conn,comando);
|
||||
ProfAnc = -(cell2mat((Anc(:,2))));
|
||||
Prof = [ProfAnc Prof];
|
||||
[rt,~] = size(Spost_local);
|
||||
ancoraTL = zeros(rt,1);
|
||||
Spost_local = [ancoraTL Spost_local];
|
||||
Spost = [ancoraTL Spost];
|
||||
DispMese_Local = [0 DispMese_Local];
|
||||
DispMese = [0 DispMese];
|
||||
|
||||
% per grafici integrati
|
||||
GI_MaxDispMESE_x = Spost_Local_MeseX(:,IndexMESE(1)); % x del nodo a maggior spostamento
|
||||
GI_diff_x = GI_MaxDispMESE_x(:,:)- GI_MaxDispMESE_x(1,1); % differenza
|
||||
GI_MaxDispMESE_y = Spost_Local_MeseY(:,IndexMESE(1));% y del nodo a maggior spostamento
|
||||
GI_diff_y = GI_MaxDispMESE_y(:,:)- GI_MaxDispMESE_y(1,1); % differenza
|
||||
GI_MaxDispMESE = sqrt((GI_diff_x).^2 + (GI_diff_y).^2)*1000; % risultante
|
||||
GI_DateIPLHR = Date;
|
||||
GI_MaxDispProf = MaxDispProfMESE;
|
||||
|
||||
% --- grafico locali-profondità DALL'INIZIO ---
|
||||
figure(1)
|
||||
subplot(1,2,1);
|
||||
plot(DispMese_Local,Prof);
|
||||
hold on
|
||||
plot(Spost_local(end,:),Prof);
|
||||
title('Spostamenti Locali 2D');
|
||||
xlabel('Spostamento [mm]');
|
||||
ylabel(['Profondit' char(224) ' [m]']);
|
||||
h = gca;
|
||||
h.XAxis.MinorTick = 'on';
|
||||
if MaxDisp < 10 % mm
|
||||
xlim([-inf 10]);
|
||||
end
|
||||
grid on
|
||||
grid minor
|
||||
lgd = legend('Periodo di riferimento','Intero periodo','Location','southeast');
|
||||
lgd.FontSize = 6;
|
||||
|
||||
% Grafico Cumulati
|
||||
subplot(1,2,2);
|
||||
plot(DispMese,Prof);
|
||||
hold on
|
||||
DispCum = plot(Spost(end,:),Prof);
|
||||
title('Spostamenti Cumulati 2D');
|
||||
xlabel('Spostamento [mm]');
|
||||
ylabel(['Profondit' char(224) ' [m]']);
|
||||
h = gca;
|
||||
h.XAxis.MinorTick = 'on';
|
||||
if max(Spost(end,:)) < 10
|
||||
xlim([-inf 10]);
|
||||
end
|
||||
grid on
|
||||
grid minor
|
||||
% legend('Periodo di riferimento','Intero periodo','Location','southeast','FontSize',8);
|
||||
% lgd.FontSize = 6;
|
||||
%
|
||||
TempName = char(strcat('Report',siteID,'-', char(toolrif),'DispIPL.png'));
|
||||
saveas(DispCum,TempName);
|
||||
Chart = Image(TempName);
|
||||
if m > 1
|
||||
for C = 1:m-1
|
||||
if status(C,1) == 3 || status(C,1) == 1
|
||||
Chart.Style = {Height('10cm'),HAlign('center')};
|
||||
break
|
||||
else
|
||||
Chart.Style = {ScaleToFit};
|
||||
end
|
||||
end
|
||||
else
|
||||
Chart.Style = {ScaleToFit};
|
||||
end
|
||||
Chart.Style = {ScaleToFit};
|
||||
Chart_capM = Paragraph(['Fig. ' num2str(FIG) ' - Spostamenti differenziali locali e cumulati in '...
|
||||
'direzione di massima pendenza registrati dalla catena '...
|
||||
'durante il periodo temporale di riferimento e a partire '...
|
||||
'dalla data di riferimento riportata in Tabella 1']);
|
||||
FIG = FIG+1;
|
||||
Chart_capM.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
close(figure(1))
|
||||
|
||||
SE = Section();
|
||||
sezTilt = Heading3('In Place Link HR');
|
||||
sezTilt.Style = {OuterMargin('0in','0in','0.15in','0in'),FontSize(Font_tools),Bold(1),Italic(1)};
|
||||
SE.Title = sezTilt;
|
||||
|
||||
% ENG
|
||||
if activeEN == 1
|
||||
figure(1)
|
||||
subplot(1,2,1);
|
||||
plot(DispMese_Local,Prof);
|
||||
hold on
|
||||
plot(Spost_local(end,:),Prof);
|
||||
title('2D Local Displacements');
|
||||
xlabel('Displacement [mm]');
|
||||
ylabel('Depth [m]');
|
||||
h = gca;
|
||||
h.XAxis.MinorTick = 'on';
|
||||
if MaxDisp < 10 % mm
|
||||
xlim([-inf 10]);
|
||||
end
|
||||
grid on
|
||||
grid minor
|
||||
|
||||
subplot(1,2,2);
|
||||
plot(DispMese,Prof);
|
||||
hold on
|
||||
DispCum = plot(Spost(end,:),Prof);
|
||||
title('2D Cumulative Displacements');
|
||||
xlabel('Displacements [mm]');
|
||||
ylabel('Depth [m]');
|
||||
h = gca;
|
||||
h.XAxis.MinorTick = 'on';
|
||||
if max(Spost(end,:)) < 10
|
||||
xlim([-inf 10]);
|
||||
end
|
||||
grid on
|
||||
grid minor
|
||||
lgd = legend('Last period','Entire period','Location','southeast');
|
||||
lgd.FontSize = 6;
|
||||
|
||||
TempName = char(strcat('Report',siteID,'-', char(toolrif),'Disp_ENG.png'));
|
||||
saveas(DispCum,TempName);
|
||||
Chart = Image(TempName);
|
||||
if m > 1
|
||||
for C = 1:m-1
|
||||
if status(C,1) == 3 || status(C,1) == 1
|
||||
Chart.Style = {Height('10cm'),HAlign('center')};
|
||||
break
|
||||
else
|
||||
Chart.Style = {ScaleToFit};
|
||||
end
|
||||
end
|
||||
else
|
||||
Chart.Style = {ScaleToFit};
|
||||
end
|
||||
Chart.Style = {ScaleToFit};
|
||||
Chart_capM = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Local and cumulative '...
|
||||
'differential displacements along maximum grade direction, '...
|
||||
'recorded during the monitoring reference period and starting from the '...
|
||||
'reported in Tab. 1']);
|
||||
FIG_ENG = FIG_ENG+1;
|
||||
Chart_capM.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
|
||||
close(figure(1))
|
||||
|
||||
SE_ENG = Section();
|
||||
sezTilt_ENG = Heading3('In Place Link HR');
|
||||
sezTilt_ENG.Style = {OuterMargin('0in','0in','0.15in','0in'),FontSize(Font_tools),Bold(1),Italic(1)};
|
||||
SE_ENG.Title = sezTilt;
|
||||
end
|
||||
|
||||
testo = Paragraph(['I grafici seguenti riportano i valori di spostamento differenziale locale e cumulato '...
|
||||
'misurati dal sensore elettrolitico 2D lungo la direzione di massima pendenza, '...
|
||||
'registrati durante il periodo temporale di riferimento e calcolati a partire dalla lettura di '...
|
||||
'riferimento riportata in Tabella 1. ']);
|
||||
testo2 = Paragraph(['In particolare, il massimo spostamento differenziale locale registrato durante il periodo '...
|
||||
'temporale di riferimento ' char(232) ' pari a ' num2str((MaxDispMESE), '%0.1f') ' mm alla profondit' char(224) ...
|
||||
' di ' num2str(MaxDispProfMESE) ' metri. Lo spostamento cumulato in testa risulta pari a ' num2str(DispMese(end,end),'%0.1f') ' mm.']);
|
||||
testo3 = Paragraph(['Gli stessi dati relativi all''intero periodo di monitoraggio rilevano un massimo spostamento '...
|
||||
'differenziale locale pari a ' num2str((MaxDisp), '%0.1f') ' mm, in corrispondenza di una profondit' char(224) ...
|
||||
' di ' num2str(MaxDispProf) ' metri. Lo spostamento cumulato in testa risulta pari a ' num2str(Spost(end,end)) ' mm.']);
|
||||
testo.HAlign = 'justify';
|
||||
testo2.HAlign = 'justify';
|
||||
testo3.HAlign = 'justify';
|
||||
add(DT,sezTilt);
|
||||
add(DT,testo);
|
||||
add(DT,testo2);
|
||||
add(DT,testo3);
|
||||
add(DT,Chart);
|
||||
add(DT,Chart_capM);
|
||||
add(DT,br);
|
||||
% ENG
|
||||
if activeEN == 1
|
||||
testo = Paragraph(['The following graphs shows the local and differential cumulative displacements '...
|
||||
'recorded by 3D MEMS sensor along the maximum grade direction during the reference monitoring period '...
|
||||
'and starting from the reference date reported in Tab. 1. The maximum local differential displacement '...
|
||||
'recorded during the reference time period equals ' num2str((MaxDispMESE),'%0.1f') ' mm at a depth of '...
|
||||
num2str(abs(MaxDispProfMESE)) ' m. The cumulative displacements at the ground level is '...
|
||||
num2str(DispMese(end,end),'%0.1f') ' mm.']);
|
||||
testo2 = Paragraph(['The same analysis related to the whole monitoring period highlights a maximum local '...
|
||||
'differential displacement of ' num2str((MaxDisp), '%0.1f') ' mm, at a depth of ' num2str(abs(MaxDispProf)) ...
|
||||
' m. The cumulative displacement equals ' num2str(Spost(end,end)) ' mm.']);
|
||||
testo.HAlign = 'justify';
|
||||
testo2.HAlign = 'justify';
|
||||
add(DT_ENG,sezTilt);
|
||||
add(DT_ENG,testo);
|
||||
add(DT_ENG,testo2);
|
||||
add(DT_ENG,Chart);
|
||||
add(DT_ENG,Chart_capM);
|
||||
add(DT_ENG,br);
|
||||
end
|
||||
%pulisco variabili da riutilizzare per catena successiva
|
||||
clear Spost;
|
||||
clear Spost_local;
|
||||
clear Spost_mese;
|
||||
clear Spost_local_mese;
|
||||
clear Prof;
|
||||
clear Azim;
|
||||
clear DirAzim;
|
||||
clear Spost_Local_MeseX;
|
||||
clear Spost_Local_MeseY;
|
||||
clear diffMeseX_Local;
|
||||
clear diffMeseY_Local;
|
||||
clear DispMese_Local;
|
||||
clear Spost_MeseX;
|
||||
clear Spost_MeseY;
|
||||
clear diffMeseX;
|
||||
clear diffMeseY;
|
||||
clear DispMese;
|
||||
clear GI_MaxDispMESE_x;
|
||||
clear GI_diff_x;
|
||||
clear GI_MaxDispMESE_y;
|
||||
clear GI_diff_y;
|
||||
else
|
||||
if ATTIVA == 1
|
||||
testo = Paragraph('Non sono presenti dati relativi al periodo temporale considerato.');
|
||||
ATTIVA = 0;
|
||||
add(DT,testo);
|
||||
check = 1;
|
||||
if activeEN == 1
|
||||
testo = Paragraph('No data available for the reference time period.');
|
||||
add(DT_ENG,testo);
|
||||
if m == 1
|
||||
add(DT_ENG,br);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fileID = fopen(FileName,'a');
|
||||
fmt = '%s \r';
|
||||
text = 'report_IPLHR function executed correctly';
|
||||
fprintf(fileID,fmt,text);
|
||||
fclose(fileID);
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user