Octave:来自地热热泵的 Plotyy 日志文件(import/plot 日期时间)
Octave: Plotyy log files from geothermal heat pump (import/plot datetime)
我正在尝试绘制地热热泵日志文件中的值以分析其性能。我尝试使用 excel 但速度很慢并且无法获得我想要的绘图类型所以我正在尝试使用 Octave。我完全没有八度的经验所以请原谅我的无能!
我已经用 open office calc 处理了 .log 文件,使其成为一种合适的分隔格式。第一列是日期时间,格式为 MM/DD/YY HH:MM:SS,总共有 21 列(但我只需要 5 列)和一个带有标签的 header 行,逗号分隔符是 '.'分隔符是','。该文件可以下载 here,前 7 列如下所示:
02/19/2018 23:07:00,-0.7,47.5,42,47.3,52.1,1.5
我目前正在尝试使用 here 中的演示 3 plotyy 绘制此图。第 2、3、5 和 8 列正确导入,所以我认为这是日期时间第 1 列的问题。如何让 Octave 正确导入第 1 列并将其用作该图中的 x 轴?:
data=csvread('heatpump.csv');
clf;
hold on
t=data(:,1);
x=data(:,3);
y=data(:,5);
z=data(:,2);
o=data(:,8);
[hax, h1, h2] = plotyy (t, x, t, y);
[~, h3, h4] = plotyy (t, z, t, o);
set ([h3, h4], "linestyle", "--");
xlabel (hax(1), "Time");
title (hax(2), 'Heat pump analysis');
ylabel (hax(1), "Radiator and hot water temp");
ylabel (hax(2), "Outdoor temp and brine out");
有很多很多方法。在这里,我将向您展示如何使用 io 包中的 csv2cell
读取 csv。我试图尽可能少地修改您现有的代码。第一列逐字使用(好吧,我插入了一个换行符)到情节。还有一个实际进行转换的注释版本,然后您可以使用 datetick
。顺便说一句,如果您添加 google 驱动器链接,那么如果您添加直接链接会很酷,这样其他人就可以像我所做的那样轻松获取 csv 或在代码中插入 url,请参见下文。
set (0, "defaultlinelinewidth", 2);
url = "https://drive.google.com/uc?export=download&id=1K_czefz-Wz4HPdvc7YqIqIupPwMi8a7r";
fn = "heatpump.csv";
if (! exist (fn, "file"))
urlwrite (url, fn);
endif
pkg load io
d = csv2cell (fn);
# convert to serial date
# (but you don't have if you want to keep the old format)
#t = datenum (d(2:end,1), "mm/dd/yyyy HH:MM:SS");
data = cell2mat (d(2:end,2:end));
clf;
hold on
t = 1:rows (data);
# Attention: the date/time column time was removed above, so the indizes are shifted
x = data(:,2);
y = data(:,4);
z = data(:,1);
o = data(:,7);
[hax, h1, h2] = plotyy (t, x, t, y);
[hax2, h3, h4] = plotyy (t, z, t, o);
grid on
#set ([h3, h4], "linestyle", "--");
xlabel (hax(1), "Time");
title (hax(2), 'Heat pump analysis');
ylabel (hax(1), "Radiator and hot water temp");
ylabel (hax(2), "Outdoor temp and brine out");
# use date as xtick
# extract them
date_time = d (get(hax2(1), "xtick"), 1);
# break them after the date part
date_time = strrep (date_time, " ", "\n");
# feed them back
set (hax, "xticklabel", date_time)
set (hax2, "xticklabel", date_time)
print ("-S1200,1000", "-F:10", "out.png")
我正在尝试绘制地热热泵日志文件中的值以分析其性能。我尝试使用 excel 但速度很慢并且无法获得我想要的绘图类型所以我正在尝试使用 Octave。我完全没有八度的经验所以请原谅我的无能!
我已经用 open office calc 处理了 .log 文件,使其成为一种合适的分隔格式。第一列是日期时间,格式为 MM/DD/YY HH:MM:SS,总共有 21 列(但我只需要 5 列)和一个带有标签的 header 行,逗号分隔符是 '.'分隔符是','。该文件可以下载 here,前 7 列如下所示:
02/19/2018 23:07:00,-0.7,47.5,42,47.3,52.1,1.5
我目前正在尝试使用 here 中的演示 3 plotyy 绘制此图。第 2、3、5 和 8 列正确导入,所以我认为这是日期时间第 1 列的问题。如何让 Octave 正确导入第 1 列并将其用作该图中的 x 轴?:
data=csvread('heatpump.csv');
clf;
hold on
t=data(:,1);
x=data(:,3);
y=data(:,5);
z=data(:,2);
o=data(:,8);
[hax, h1, h2] = plotyy (t, x, t, y);
[~, h3, h4] = plotyy (t, z, t, o);
set ([h3, h4], "linestyle", "--");
xlabel (hax(1), "Time");
title (hax(2), 'Heat pump analysis');
ylabel (hax(1), "Radiator and hot water temp");
ylabel (hax(2), "Outdoor temp and brine out");
有很多很多方法。在这里,我将向您展示如何使用 io 包中的 csv2cell
读取 csv。我试图尽可能少地修改您现有的代码。第一列逐字使用(好吧,我插入了一个换行符)到情节。还有一个实际进行转换的注释版本,然后您可以使用 datetick
。顺便说一句,如果您添加 google 驱动器链接,那么如果您添加直接链接会很酷,这样其他人就可以像我所做的那样轻松获取 csv 或在代码中插入 url,请参见下文。
set (0, "defaultlinelinewidth", 2);
url = "https://drive.google.com/uc?export=download&id=1K_czefz-Wz4HPdvc7YqIqIupPwMi8a7r";
fn = "heatpump.csv";
if (! exist (fn, "file"))
urlwrite (url, fn);
endif
pkg load io
d = csv2cell (fn);
# convert to serial date
# (but you don't have if you want to keep the old format)
#t = datenum (d(2:end,1), "mm/dd/yyyy HH:MM:SS");
data = cell2mat (d(2:end,2:end));
clf;
hold on
t = 1:rows (data);
# Attention: the date/time column time was removed above, so the indizes are shifted
x = data(:,2);
y = data(:,4);
z = data(:,1);
o = data(:,7);
[hax, h1, h2] = plotyy (t, x, t, y);
[hax2, h3, h4] = plotyy (t, z, t, o);
grid on
#set ([h3, h4], "linestyle", "--");
xlabel (hax(1), "Time");
title (hax(2), 'Heat pump analysis');
ylabel (hax(1), "Radiator and hot water temp");
ylabel (hax(2), "Outdoor temp and brine out");
# use date as xtick
# extract them
date_time = d (get(hax2(1), "xtick"), 1);
# break them after the date part
date_time = strrep (date_time, " ", "\n");
# feed them back
set (hax, "xticklabel", date_time)
set (hax2, "xticklabel", date_time)
print ("-S1200,1000", "-F:10", "out.png")