function [GI_LivelloFaldaPL,GI_ProfPL,GI_DatePL,PL_A,PL_D,ATTIVA,FIG,FIG_ENG] = report_PL(... rPL,rTL,rIPL,m,NodoPiezoLink,PL_A,PL_D,toolrif,unitrif,datarif,Font_caption,Font_tools,toolrifID,... siteID,DT,DT_ENG,FIG,FIG_ENG,br,status,ATTIVA,activeEN,conn,FileName) fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'report_PL function started'; fprintf(fileID,fmt,text); import mlreportgen.dom.* import mlreportgen.report.* % Make sure DOM is compilable makeDOMCompilable() GI_LivelloFaldaPL = []; GI_ProfPL = []; GI_DatePL = []; titolo = 1; 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 misuraPL = cell(1,3); for p = 1:rPL(m,1) NodeNum = num2str(NodoPiezoLink(p,m)); comando = ['select num, depth, measurment from nodes where tool_id = ''' num2str(cell2mat(toolrifID))... ''' and num = ''' NodeNum ''' and nodetype_id = 2 ']; curs = exec(conn,comando); curs = fetch(curs); Leggo = curs.Data; misuraPL(1,p) = Leggo(1,3); % unità di misura del piezometro % pressione assoluta vs relativa PL_A(p) = 0; PL_D(p) = 0; if strcmp(misuraPL(1,p),'VW kPa') == 1 || strcmp(misuraPL(1,p),'VW kg/cm2') == 1 PL_A(p) = PL_A(p)+1; else PL_D(p) = PL_D(p)+1; end 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 for p = 1:rPL(m,1) NodeNum = num2str(NodoPiezoLink(p,m)); comando = ['select num, depth, measurment from nodes where tool_id = ''' num2str(cell2mat(toolrifID))... ''' and num = ''' NodeNum ''' and nodetype_id = 2 ']; curs = exec(conn,comando); curs = fetch(curs); Leggo = curs.Data; misuraPL(1,p) = Leggo(1,3); % unità di misura del piezometro % pressione assoluta vs relativa PL_A(p) = 0; PL_D(p) = 0; if strcmp(misuraPL(1,p),'VW kPa') == 1 || strcmp(misuraPL(1,p),'VW kg/cm2') == 1 PL_A(p) = PL_A(p)+1; else PL_D(p) = PL_D(p)+1; end end end check = 1; else SE = Section(); if activeEN == 1 SE_ENG = Section(); end for p = 1:rPL(m,1) NodeNum = num2str(NodoPiezoLink(p,m)); comando = ['select EventDate, EventTime, water_level, pressure 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; comando = ['select num, depth, measurment from nodes where tool_id = ''' num2str(cell2mat(toolrifID))... ''' and num = ''' NodeNum ''' and nodetype_id = 2 ']; curs = exec(conn,comando); curs = fetch(curs); Leggo = curs.Data; % Modifico il formato di data e ora [rD,rC] = size(Dati); [~,PZc] = size(Leggo); if rC ~= 1 && PZc > 1 T = [cell2mat(Dati(:,1)) repmat(' ', [rD,1]) cell2mat(Dati(:,2))]; Date = datenum(T); % Data if p == 1 % Il primo lo scrivo e creo la variabile di controllo check = 1; else [rS,~] = size(waterlevel); if rD ~= rS NODATA(m,1) = 2; check = 0; break else check = 1; end end waterlevel(:,p) = cell2mat(Dati(:,3)); % altezza falda pressure(:,p) = cell2mat(Dati(:,4)); % pressione comando = ['select depth from nodes where tool_id = ''' num2str(cell2mat(toolrifID))... ''' and num = ''' NodeNum ''' and nodetype_ID = 2 ']; curs = exec(conn,comando); curs = fetch(curs); ProfPL(1,p) = curs.Data; % profondità piezometro misuraPL(1,p) = Leggo(1,3); % unità di misura del piezometro % pressione assoluta vs relativa tipopressione = 'assoluta '; if activeEN == 1 tipopressione = 'absolute '; end PL_A(p) = 0; PL_D(p) = 0; if strcmp(misuraPL(1,p),'VW kPa') == 1 || strcmp(misuraPL(1,p),'VW kg/cm2') == 1 tipopressione = 'relativa '; if activeEN == 1 tipopressione = 'relative '; end PL_A(p) = PL_A(p)+1; else PL_D(p) = PL_D(p)+1; end else NODATA(m,1) = 1; check = 1; end if NODATA(m,1) == 0 % grafico livello falda e pressione interstiziale NELL'ULTIMO MESE figure(3) plot(Date,waterlevel(:,p),'LineWidth',1.5); yyaxis left ylabel(['Profondit' char(224) ' [m da p.c.]']); var = max(abs(waterlevel(:,p)-waterlevel(1,p))); media = mean(waterlevel(:,p)); if var < 0.7 ylim([media-0.5 media+0.5]); end title(['Livello idrico e pressione ' tipopressione ' - Sensore a ' num2str(cell2mat(ProfPL(1,p))) ' m da p.c.']); xlabel('Data [gg/mm/aaaa]'); hold on yyaxis right porepress = plot(Date,pressure(:,p),'--'); ylabel(['Pressione ' tipopressione ' [Pa]']); xlim([Date(1)-1 Date(end)+1]); h = gca; h.XAxis.MinorTick = 'on'; datetick('x','dd/mm/yyyy','keepticks','keeplimits'); xtickangle(20); grid on grid minor TempName = char(strcat('Report',siteID,'-', char(toolrif),'-Piezo',num2str(cell2mat(ProfPL(1,p))), '.png')); saveas(porepress,TempName); ChartPL = Image(TempName); if rPL(p,1) == 1 ChartPL.Style = {Height('8cm'),HAlign('center')}; elseif rPL(p,1) == 2 ChartPL.Style = {Height('7.5cm'),HAlign('center')}; else ChartPL.Style = {Height('8cm'),HAlign('center')}; end if rPL(p,1) == 2 ChartPL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Livello idrico e pressione ' tipopressione... ' registrati dal piezometro posto alla profondit' ... char(224) ' di ' num2str(cell2mat(ProfPL(1,p))) ' metri']); ChartPL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; else ChartPL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Livello idrico e pressione ' tipopressione... ' registrati durante il periodo temporale di riferimento dal piezometro posto alla profondit' ... char(224) ' di ' num2str(cell2mat(ProfPL(1,p))) ' metri']); ChartPL_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; end FIG = FIG+1; if titolo == 1 sezPiezo = Heading3('Piezo Link'); sezPiezo.Style = {OuterMargin('0in','0in','0.15in','0in'),FontSize(Font_tools),Bold(1),Italic(1)}; SE.Title = sezPiezo; add(DT,sezPiezo); titolo = 0; end escludi2 = 0; if rPL(p,1) == 2 if p == 1 testo = Paragraph(['I grafici seguenti riportano i valori di livello idrico e pressione ' tipopressione... ' misurati nel corso del periodo di riferimento dai piezometri presenti nella catena. '... 'Il sensore situato a una profondit' char(224) ' di ' ... num2str(cell2mat(ProfPL(1,p))) ' m da p.c. ha rilevato un''altezza '... 'di falda massima pari a ' num2str(round(max(waterlevel(:,p)),2), '%0.2f') ' m ed un valore minimo pari a '... num2str(round(min(waterlevel(:,p)),2), '%0.2f') ' m, per una variazione massima di '... num2str(round(max(waterlevel(:,p)),2)-round(min(waterlevel(:,p)),2),'%0.2f') ' m.']); testo.HAlign = 'justify'; escludi2 = 1; add(DT,testo); elseif p == 2 testo = Paragraph(['Il sensore situato a una profondit' char(224) ' di ' ... num2str(cell2mat(ProfPL(1,p))) ' m da p.c. ha rilevato un''altezza '... 'di falda massima pari a ' num2str(round(max(waterlevel(:,p)),2), '%0.2f') ' m ed un valore minimo pari a '... num2str(round(min(waterlevel(:,p)),2), '%0.2f') ' m, per una variazione massima di '... num2str(round(max(waterlevel(:,p)),2)-round(min(waterlevel(:,p)),2),'%0.2f') ' m.']); testo.HAlign = 'justify'; escludi2 = 1; add(DT,testo); end elseif p == 1 testo = Paragraph(['I grafici seguenti riportano i valori di livello idrico e pressione ' tipopressione... ' misurati nel corso del periodo di riferimento dai piezometri presenti nella catena.']); testo.HAlign = 'justify'; add(DT,testo); end if escludi2 == 0 testo2 = Paragraph(['Il sensore situato a una profondit' char(224) ' di ' ... num2str(cell2mat(ProfPL(1,p))) ' m da p.c. ha rilevato un''altezza '... 'di falda massima pari a ' num2str(round(max(waterlevel(:,p)),2), '%0.2f') ' m ed un valore minimo pari a '... num2str(round(min(waterlevel(:,p)),2), '%0.2f') ' m, per una variazione massima di '... num2str(round(max(waterlevel(:,p)),2)-round(min(waterlevel(:,p)),2),'%0.2f') ' m.']); testo2.HAlign = 'justify'; add(DT,testo2); end add(DT,ChartPL); add(DT,ChartPL_cap); if p == rPL(m,1) || p == 1 && rPL(m,1) > 2 || rTL(m,1) == 0 && p == 1 && rIPL(m,1) == 0 && p == 1 add(DT,br); end close(figure(3)); % Inglese if activeEN == 1 % grafico livello falda e pressione interstiziale NELL'ULTIMO MESE figure(3) plot(Date,waterlevel(:,p),'LineWidth',1.5); yyaxis left ylabel('Depth [m b.g.l.]'); if var < 1 ylim([media-0.5 media+0.5]); end title(['Water level and ' tipopressione ' pressure - Sensor at ' ... num2str(cell2mat(ProfPL(1,p))) ' m of depth']); xlabel('Date [dd/mm/yyyy]'); hold on yyaxis right porepress = plot(Date,pressure(:,p),'--'); ylabel([tipopressione ' pressure [Pa]']); xlim([Date(1)-1 Date(end)+1]); h = gca; h.XAxis.MinorTick = 'on'; datetick('x','dd/mm/yyyy','keepticks','keeplimits'); xtickangle(20); grid on grid minor TempName = char(strcat('Report',siteID,'-', char(toolrif),'-Piezo',num2str(cell2mat(ProfPL(1,p))), '_ENG.png')); saveas(porepress,TempName); ChartPL = Image(TempName); if rPL(p,1) == 1 ChartPL.Style = {Height('8cm'),HAlign('center')}; elseif rPL(p,1) == 2 ChartPL.Style = {Height('7.5cm'),HAlign('center')}; else ChartPL.Style = {Height('8cm'),HAlign('center')}; end if rPL(p,1) == 2 ChartPL_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Water level and ' tipopressione... ' pressure recorded by the piezometer at a depth of ' num2str(cell2mat(ProfPL(1,p))) ' m']); ChartPL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; else ChartPL_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Water level and ' tipopressione... ' pressure recorded during the reference time period by the sensor placed at a depth of ' ... num2str(cell2mat(ProfPL(1,p))) ' m']); ChartPL_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')}; end FIG_ENG = FIG_ENG+1; if titolo == 1 SE_ENG.Title = sezPiezo; add(DT_ENG,sezPiezo); titolo = 0; end escludi2 = 0; if rPL(p,1) == 2 if p == 1 testo = Paragraph(['The following graphs shows the water level and ' tipopressione... ' pressure values recorded during the reference time period by the piezometers placed on site. '... 'Sensor at a depth of ' num2str(cell2mat(ProfPL(1,p))) ' m b.g.l. registered a maximum water level '... 'that equals ' num2str(round(max(waterlevel(:,p)),2), '%0.2f') ' m. The minimum value is '... num2str(round(min(waterlevel(:,p)),2), '%0.2f') ' m, while the maximum variation is '... num2str(round(max(waterlevel(:,p)),2)-round(min(waterlevel(:,p)),2),'%0.2f') ' m.']); testo.HAlign = 'justify'; escludi2 = 1; add(DT_ENG,testo); elseif p == 2 testo = Paragraph(['Sensor at a depth of ' num2str(cell2mat(ProfPL(1,p))) ' m b.g.l. registered a maximum water level '... 'that equals ' num2str(round(max(waterlevel(:,p)),2), '%0.2f') ' m. The minimum value is '... num2str(round(min(waterlevel(:,p)),2), '%0.2f') ' m, while the maximum variation is '... num2str(round(max(waterlevel(:,p)),2)-round(min(waterlevel(:,p)),2),'%0.2f') ' m.']); testo.HAlign = 'justify'; escludi2 = 1; add(DT_ENG,testo); end elseif p == 1 testo = Paragraph(['The following graphs shows the water level and ' tipopressione... ' pressure values recorded during the reference time period by the piezometers placed on the Array. ']); testo.HAlign = 'justify'; add(DT_ENG,testo); end if escludi2 == 0 testo2 = Paragraph(['Sensor at a depth of ' num2str(cell2mat(ProfPL(1,p))) ' m b.g.l. registered a maximum water level '... 'that equals ' num2str(round(max(waterlevel(:,p)),2), '%0.2f') ' m. The minimum value is '... num2str(round(min(waterlevel(:,p)),2), '%0.2f') ' m, while the maximum variation is '... num2str(round(max(waterlevel(:,p)),2)-round(min(waterlevel(:,p)),2),'%0.2f') ' m.']); testo2.HAlign = 'justify'; add(DT_ENG,testo2); end add(DT_ENG,ChartPL); add(DT_ENG,ChartPL_cap); if p == rPL(m,1) || p == 1 && rPL(m,1) > 2 || rTL(m,1) == 0 && p == 1 && rIPL(m,1) == 0 && p == 1 add(DT_ENG,br); end close(figure(3)); end % per grafici integrati diffP = waterlevel-waterlevel(1,:); maxP = max(diffP); MAX = max(maxP); ind = find(maxP==MAX); GI_LivelloFaldaPL = diffP(:,ind); GI_ProfPL = cell2mat(ProfPL(1,ind)); GI_DatePL = Date; 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 check = 1; end end end end end text = 'report_PL function executed correctly'; fprintf(fileID,fmt,text); fclose(fileID); end