What with all the talk around GPT-4 and impressive results being shared. It’s interesting to see how well it does at OpenEnergyMonitor topics that we can verify it’s pretty incredible really!
It gets most of that perfect, not sure about the low write-latency comment, perhaps it is, the optimisation goal was more about reducing the amount of SD card writes as a whole.
I then asked it if it could produce a python script to read from raw PHPFina data files, this was the result:
import os
import struct
def read_phpfina_metadata(meta_file):
with open(meta_file, "rb") as f:
meta_data = f.read(16)
start_time, interval = struct.unpack("<2Q", meta_data)
return start_time, interval
def read_phpfina_data(data_file, start_time, interval):
data_points = []
with open(data_file, "rb") as f:
file_size = os.path.getsize(data_file)
num_points = file_size // 4
for i in range(num_points):
raw_data = f.read(4)
value = struct.unpack("<f", raw_data)[0]
if value != float("nan"):
timestamp = start_time + i * interval
data_points.append((timestamp, value))
return data_points
def main():
meta_file = "feed_1.meta"
data_file = "feed_1.dat"
start_time, interval = read_phpfina_metadata(meta_file)
data_points = read_phpfina_data(data_file, start_time, interval)
for timestamp, value in data_points:
print(f"Timestamp: {timestamp}, Value: {value}")
if __name__ == "__main__":
main()
So close! it didnt quite get the read metdata function right, partly my fault for a confusing metadata structure perhaps…
I tried asking it for a correction but it still got it wrong again. After I explained the correct structure it was able to rewrite the function correctly:
The code now outputs the data correctly!
I tested the earlier ChatGPT and it’s definitely getting a lot better at answering these questions.
While not perfect im still blown away by what it can do!