Saturday, 14 December 2024

Temperature Data Extraction, Visualization and Analysis using Scilab

Topic: Numerical Analysis of Temperature from Data Acquisition System (DAS);

Subject: Heat Transfer;

Tool: Scilab;

By: Gani Comia, Dec. 2024;

Data acquisition devices or systems record process data over time for monitoring and analysis purposes. This article presented how the Scilab software extracts, visualizes, and analyzes temperature numerical data from a DAS.

While DAS can actually show a graph of the data in real-time, other analysis can only be done after downloading the data soft copy in .CSV format. This blog post presented the two analyses made with the use of Scilab scripting. The first analysis made was to find the specific time for a particular temperature value, and the second one was the calculation of heat rate, or the temperature change per unit time during ramp-up.

The completed plot or graph of numerical data using Scilab is shown.

Fig. 1. Scilab Plot and Analysis of Temperature Data.

Below are the code snippets or scripts for the two sample analyses made. The completed script is shown after.

Analysis (1): Finding the Time for Specific Temperature.

// ----- analysis(1) : finding time @ temp = 232 degC -----
modOvenWallTemp = round(ovenWallTemp);
id = find(modOvenWallTemp >= 232,[-1]);  // max no. of indices
timeStd(1) = time(id(1));
timeStd(2) = time(id($));

Analysis (2): Temperature per Unit Time during Ramping-up.

// ----- analysis(2) : finding heat rate in degC / min -----
tempCond = [ovenWallTemp(1) temp(2)];
timeCond = [time(1) timeStd(1)];
heatRate = diff(tempCond)./diff(timeCond);


Scilab Script (Complete):

// Copyright (C) 2024 - Gani Comia
// Date of creation: 4 Dec 2024
// Heating Oven Temperature Data Analysis using Scilab
clear;clc;
// data extraction
clear importdata;

function [data]=importdata(filename)
    data = csvRead(filename, ",", ".", "double")
endfunction

[A] = importdata("temp_profile_before_repair_xform.csv");

// assigning data to the variables
time = A(2:$,13);
ovenWallTemp = A(2:$,2);
partTemp = A(2:$,9);

// data visualization
clf;
f=gcf();
f.figure_size=[900,600];
plot(time,ovenWallTemp,"-b","linewidth",1.75)
plot(time,partTemp,"-.r","linewidth",1)
legend(["Oven Wall","Workpiece"],"in_upper_right")
title("Analysis of Oven Temperature Profile from Data Logger")
xlabel("Time [ min ]")
ylabel("Temperature [ deg C ]")
xstring(245,100,"https://gani-mech-toolbox.blogspot.com")
a=gca(); 
a.data_bounds = [0 0;400 300]; 

// additional plot properties
t = [0:60:360, 400];
temp = [0 232 300];

// temp = 232 degC horizontal lines
plot([t(1),t($)],[temp(2),temp(2)],"--g","linewidth",1)
xstring(5,232,"Std = 232 C")

// hourly verical lines
for i = 2:length(t)-1
    plot([t(i),t(i)],[temp(1),temp(3)],"--y","linewidth",1)
end

// hourly label 
minute = 60;
hour = 1;
for i = 2:length(t)-1
    note = [string(hour),"hour"];
    xstring(minute,10,note,-90);
    minute = minute + 60;
    hour = hour + 1;
end

// ----- analysis(1) : finding time @ temp = 232 degC -----
modOvenWallTemp = round(ovenWallTemp);
id = find(modOvenWallTemp >= 232,[-1]);  // max no. of indices
timeStd(1) = time(id(1));
timeStd(2) = time(id($));

// plot of analysis(1)
timeStd = [timeStd(1) timeStd(2)];
stdTemp = [232 232];
plot(timeStd, stdTemp, "ro")
xstring(timeStd(1),stdTemp(1)-15,[string(timeStd(1)),"min"])
xstring(timeStd(2),stdTemp(2),[string(timeStd(2)),"min"])
ambient = ["Ini =",string(round(ovenWallTemp(1))),"C"];
xstring(0,ovenWallTemp(1)-15,ambient)

// ----- analysis(2) : finding heat rate in degC / min -----
tempCond = [ovenWallTemp(1) temp(2)];
timeCond = [time(1) timeStd(1)];
heatRate = diff(tempCond)./diff(timeCond);

// plot of analysis(2)
plot(timeCond,tempCond,"--","color","dimgray","linewidth",2)
noteHR = ["RATE:",string(round(heatRate)),"deg C / min"]
xstring(t(2)-20,110,noteHR,-58)

A readily available program script with some minor revision can facilitate visualization and analysis of numerical data for almost similar conditions. Program or code reusability leading to short lead times of engineering analysis is one of the benefits of using a programming tools in the engineering field.

Feel free to comment for inquiry, clarification, or suggestion for improvement. Drop your email to request the soft copy of the file.


No comments:

Post a Comment

C++ and Python for Numerical Solution to Spring-Mass-Damper Model

Topic: SDOF Spring-Mass-Damper System Subject: Numerical Methods & Mechanical Vibration Tools: C++, CodeBlocks, GitHub Copilot, LabP...