flowdata = readtable("flodata.txt");
pressureIN = flowdata.pressureAtPipeStart_bars_;
pressureOUT= flowdata.pressureAtPipeEnd_10kmFromStart__bars_;
aNoiseIN=flowdata.acousticNoiseAtStart_standardDeviation_;
aNoiseOUT=flowdata.acousticNoiseAtPipeEnd_standardDeviation_;
flowrate = flowdata.flowRate_m3_hour_;
[samples,channels] = size(flowdata);
PHeadLoss = pressureIN-pressureOUT;
t = linspace(0, samples*sample_distance, samples)/86400;
plot(flowrate, PHeadLoss, '.')
densityplot(flowrate, PHeadLoss, [50, 50])
plot(t, pressureIN, '-g',t, pressureOUT, '-r',t, flowrate, '-b');
title(' Input , Output Pressure , FR vs time BEFORE EVERY CLEANING');
legend('Input Pressure','Output Pressure','Flow Rate');
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
rawData = [pressureIN pressureOUT flowrate];
idx_nan = any(isnan(rawData), 2);
cleanData(idx_nan, :) = [];
[samples,channels] = size(cleanData);
t = linspace(0, samples*sample_distance, samples)/86400;
pressureIN = cleanData(:,1);
pressureOUT= cleanData(:,2);
flowrate = cleanData(:,3);
PHeadLoss = pressureIN - pressureOUT;
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
densityplot(flowrate, PHeadLoss, [50,50]);
idx_neg = any(cleanData < 0, 2);
cleanData(idx_neg, :) = [];
[samples,channels] = size(cleanData);
t = linspace(0, samples*sample_distance, samples)/86400;
pressureIN = cleanData(:,1);
pressureOUT= cleanData(:,2);
flowrate = cleanData(:,3);
PHeadLoss = pressureIN - pressureOUT;
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
densityplot(flowrate, PHeadLoss, [50,50]);
[samples,channels] = size(cleanData);
t = linspace(0, samples*sample_distance, samples)/86400;
plot(t, pressureIN, '-g',t, pressureOUT, '-r',t, flowrate, '-b');
title(' Input , Output Pressure , FR vs time');
legend('Input Pressure','Output Pressure','Flow Rate');
pressureIN = pressureIN(ind);
pressureOUT = pressureOUT(ind);
flowrate = flowrate(ind);
PHeadLoss = pressureIN-pressureOUT;
plot(t, pressureIN, '-g',t, pressureOUT, '-r',t, flowrate, '-b');
title(' Input , Output Pressure , FR vs time');
legend('Input Pressure','Output Pressure','Flow Rate');
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
densityplot(flowrate, PHeadLoss, [50,50]);
pressureIN_grad = abs(gradient(pressureIN));
pressureOUT_grad = abs(gradient(pressureOUT));
flowrate_grad = abs(gradient(flowrate));
ind1 = pressureIN_grad<threshold*max(pressureIN_grad);
ind2 = pressureOUT_grad<threshold*max(pressureOUT_grad);
ind3 = flowrate_grad<threshold*max(flowrate_grad);
ind = ind1 & ind2 & ind3 & ind4;
pressureIN = pressureIN(ind);
pressureOUT = pressureOUT(ind);
flowrate = flowrate(ind);
plot(t, pressureIN, '.g',t, pressureOUT, '.r',t, flowrate, '.b');
title(' Input , Output Pressure , FR vs time');
legend('Input Pressure','Output Pressure','Flow Rate');
PHeadLoss = pressureIN - pressureOUT;
densityplot(flowrate, PHeadLoss, [50,50])
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
densityplot(flowrate, PHeadLoss, [50,50]);
PHeadLoss = pressureIN - pressureOUT;
pressureIN = pressureIN(ind);
pressureOUT = pressureOUT(ind);
flowrate = flowrate(ind);
PHeadLoss = pressureIN - pressureOUT;
densityplot(flowrate, PHeadLoss, [50,50])
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
densityplot(flowrate, PHeadLoss, [50,50]);
plot(flowrate, PHeadLoss, '*k')
x2 = 0:0.01:max(flowrate);
y2 = 0.00294150.*x2.^2+45;
[xy,distance_abs,t_a ]= distance2curve([x2' y2'], [flowrate PHeadLoss]);
plot(xy(:,1), xy(:,2), '.r')
dx = dx/prctile(abs(dx), 95);
dy = dy/prctile(abs(dy), 95);
scatter(dx, dy, 'filled')
densityplot(dx, dy, [50,50])
eva=evalclusters([bond.x' bond.y'],'gmdistribution','CalinskiHarabasz','KList',[1:6]);
gmobj = fitgmdist([bond.x' bond.y'],numClust);
gidx = cluster(gmobj,[bond.x' bond.y']);
gscatter(bond.x', bond.y', gidx)
densityplot(dx, dy, [50,50])
gscatter(bond.x',bond.y', gidx)
scatter3(bond.x',bond.y', gidx)