Sync from remote server: 2025-10-12 18:56:41

This commit is contained in:
2025-10-12 18:56:59 +02:00
commit 7e8ee264aa
553 changed files with 161447 additions and 0 deletions

137
Tilt/MediaDati_IPL.m Executable file
View File

@@ -0,0 +1,137 @@
% Questa routine calcola le medie (giornaliere o per intervalli definiti)
% necessarie per le elaborazioni successive per i TiltLink
% ACCdef contiene le medie per l'intervallo definito delle accelerazioni
% ARRAYdate contiene le date e il tempo per ogni dato (per media
% giornaliera, la data di quel giorno)
function [ACCdef_IPL,MAGdef_IPL,ARRAYdateIPL,ACCdefRis_IPL,MAGdefRis_IPL,TempDef_IPL]...
= MediaDati_IPL(accIPL,magIPL,TimeIPL,ris_acc_IPL,ris_mag_IPL,tempIPL,tolleranzaAcc,...
tolleranzaMag,NdatiMedia,NodoInPlaceLink,MEMS,FileName)
fileID = fopen(FileName,'a');
fmt = '%s \r';
text = 'MediaDati_IPL function started';
fprintf(fileID,fmt,text);
%% Accelerazione o angoli
[r,~] = size(accIPL);
if NdatiMedia > r
NdatiMedia = r;
end
ACCdef_IPL = smoothdata(accIPL,'gaussian',NdatiMedia);
%% Matrice date
ARRAYdateIPL = TimeIPL;
%% Risultante acc
ACCdefRis_IPL = ris_acc_IPL; % Non faccio la media, mi serve il dato come è per applicare i filtri
if MEMS == 1 || MEMS == 2 || strcmp(NodoInPlaceLink(1,4),'g') == 1
% Applico un controllo importante! Se la risultante varia più di 0.01, NON
% faccio la media dei dati attorno, che altrimenti ne sono condizionati!
[r,c] = size(ACCdefRis_IPL); % Nodi in colonna, date in riga
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
cont = 0; % Contatore
cont2 = 0;
for i = 2:r % data
for j = 2:c % nodo
% se il valore assoluto della differenza è maggiore della
% tolleranza, NON faccio la media
if abs(ACCdefRis_IPL(i,j)-ACCdefRis_IPL(i-1,j)) > tolleranzaAcc || ACCdefRis_IPL(i,j) < 0.9 || ACCdefRis_IPL(i,j) > 1.1
Sp = i-Win; % Punto di partenza (date)
if Sp <= 0
Sp = 1;
end
if i+Win > r
Ep = r;
else
Ep = i+Win; % Punto di arrivo (date)
end
Cax = 3*j-2;
Cay = 3*j-1;
Caz = 3*j;
ACCdef_IPL(Sp:Ep,Cax) = accIPL(Sp:Ep,Cax); % ax
ACCdef_IPL(Sp:Ep,Cay) = accIPL(Sp:Ep,Cay); % ay
ACCdef_IPL(Sp:Ep,Caz) = accIPL(Sp:Ep,Caz); % az
cont = cont+1;
end
end
end
text = ['' num2str(cont) ' values of In Place Link accelerometer vector of '...
'gravity not subjected to mean process due to values with excessive variations!'];
fprintf(fileID,fmt,text);
text = ['' num2str(cont2) ' values of In Place Link accelerometer vector of gravity '...
'not subjected to mean process due to not calibrated values!'];
fprintf(fileID,fmt,text);
%% Campi magnetici
MAGdef_IPL = smoothdata(magIPL,'gaussian',NdatiMedia);
% Applico un controllo importante! Se la risultante delle accelerazioni
% varia più di 0.01, NON faccio la media dei dati di campo magnetico attorno,
% che altrimenti ne sono condizionati!
[r,c] = size(ACCdefRis_IPL); % Nodi in colonna, date in riga
Win = NdatiMedia/2; % Individuo la finestra da NON mediare
cont = 0;
cont2 = 0;
for i = 2:r % data
for j = 2:c % nodo
% se il valore assoluto della differenza è maggiore della
% tolleranza, NON faccio la media
if abs(ACCdefRis_IPL(i,j)-ACCdefRis_IPL(i-1,j)) > tolleranzaMag
Sp = i-Win; % Punto di partenza (date)
if Sp <= 0
Sp = 1;
end
if i+Win > r
Ep = r;
else
Ep = i+Win; % Punto di arrivo (date)
end
Cmx = 3*j-2;
Cmy = 3*j-1;
Cmz = 3*j;
MAGdef_IPL(Sp:Ep,Cmx) = magIPL(Sp:Ep,Cmx); % mx
MAGdef_IPL(Sp:Ep,Cmy) = magIPL(Sp:Ep,Cmy); % my
MAGdef_IPL(Sp:Ep,Cmz) = magIPL(Sp:Ep,Cmz); % mz
cont = cont+1;
end
if ACCdefRis_IPL(i,j) < 0.9 || ACCdefRis_IPL(i,j) > 1.1 % Il nodo è fuori taratura!
Sp = i-Win; % Punto di partenza (date)
if Sp <= 0
Sp = 1;
end
if i+Win > r
Ep = r;
else
Ep = i+Win; % Punto di arrivo (date)
end
Cmx = 3*j-2;
Cmy = 3*j-1;
Cmz = 3*j;
MAGdef_IPL(Sp:Ep,Cmx) = magIPL(Sp:Ep,Cmx); % mx
MAGdef_IPL(Sp:Ep,Cmy) = magIPL(Sp:Ep,Cmy); % my
MAGdef_IPL(Sp:Ep,Cmz) = magIPL(Sp:Ep,Cmz); % mz
cont2 = cont2+1;
end
end
end
text = ['' num2str(cont) ' values of In Place Link magnetometer vector not subjected to mean process due to accelerometers values with excessive variations!'];
fprintf(fileID,fmt,text);
text = ['' num2str(cont2) ' values of In Place Link magnetometer vector of gravity not subjected to mean process due to not calibrated accelerometer values!'];
fprintf(fileID,fmt,text);
else
MAGdef_IPL = [];
end
%% Risultante campi magnetici
MAGdefRis_IPL = ris_mag_IPL; % Non faccio la media, mi serve il dato come è per applicare i filtri
%% Temperatura
TempDef_IPL = tempIPL; % Non faccio la media, mi serve il dato come è per applicare i filtri
text = 'Average mean of In Place Link data executed correctly. MediaDati_IPL function ended';
fprintf(fileID,fmt,text);
fclose(fileID);
end