-
Notifications
You must be signed in to change notification settings - Fork 8
support maccor binary files #31
Comments
I am currently looking into decoding the binary format, as I did not receive any response from Maccor themselves regarding their format. I am not sure how much the binary format differs between different hardware/software versions of the Maccor suite. Could you provide me some example data files? |
@adamL-D @davidhowey, do you have a variety of binary maccor files that can be used for this issue? |
@martinjrobins Yes, I will send some to you via email as I can't link them here for some reason. |
Upload from @adamL-D 's email: |
Thank you very much for the example datasets. Unfortunately, the file format seems to be bit complexer than I thought. The file starts with ~25kbytes long header, which consists of the battery program (in table and xml form, both ASCII coded), the name of the used device (ASCII), probably some calibration data and some more, unfortunately unknown, information in a binary format. The header is followed by 264 byte-long records, each representing one data point including its timestamp, voltage, current, current step, cycle number, etc.. While the location of e.g. current inside of the 264 byte-long record seems to be the same for different devices, the factor needed to obtain the physical current in Ampere differs between different data sets. A few more details: Data file accessviewData.exe accesses the data file by the following read calls. Italic font represents offset or length values which differ between different example datasets.
Datapoint structureEach datapoint record consists of at least the following elements:
Mode codeThe current mode is given by the following table. It seems like the mode is only coded by the 5 LSB. Changing the
Example extraction code (does not always work)Based on above info, the following function extracts the known elements of each data points and converts them to the appropriate physical units, if possible. However, this does only work for some example dataset files, while some others require additional factors of e.g. 8 for the current values. import numpy as np
import pandas as pd
import struct
def maccor_load_file(filename):
with open(filename, 'rb') as f:
fb = f.read()
num_records = struct.unpack("I",fb[-264+230:-264+230+4])[0]
data = {}
data["dpt"] = np.frombuffer(fb[-num_records*264+0:], count=(num_records-1)*264//8+1, dtype=np.float64)[::264//8]
data["dpt"] = (np.round(data["dpt"]*1e9*3600*24).astype(np.int64)+np.datetime64("1899-12-30","ns").astype(np.int64)).astype("datetime64[ns]", copy=False)
data["mode"] = np.frombuffer(fb[-num_records*264+9:], count=(num_records-1)*264//1+1, dtype=np.uint8)[::264//1]
data["es"] = np.frombuffer(fb[-num_records*264+10:], count=(num_records-1)*264//1+1, dtype=np.uint8)[::264//1]
data["cycle"] = np.frombuffer(fb[-num_records*264+11:], count=(num_records-1)*264//4+1, dtype=np.uint32)[::264//4]
data["step"] = np.frombuffer(fb[-num_records*264+15:], count=(num_records-1)*264//1+1, dtype=np.uint8)[::264//1] + 1
data["current (A)"] = np.frombuffer(fb[-num_records*264+16:], count=(num_records-1)*264//2+1, dtype=np.uint16)[::264//2]/65535*10
data["voltage (V)"] = np.frombuffer(fb[-num_records*264+18:], count=(num_records-1)*264//2+1, dtype=np.uint16)[::264//2]/65535*10
data["test_time"] = (np.frombuffer(fb[-num_records*264+21:], count=(num_records-1)*264//8+1, dtype=np.uint64)[::264//8]/6000*60*1e9).astype("timedelta64[ns]")
data["step_time"] = (np.frombuffer(fb[-num_records*264+29:], count=(num_records-1)*264//8+1, dtype=np.uint64)[::264//8]/6000*60*1e9).astype("timedelta64[ns]")
data["capacity (Ah)"] = np.frombuffer(fb[-num_records*264+37:], count=(num_records-1)*264//8+1, dtype=np.int64)[::264//8]/65535/360/1e3
data["energy (Wh)"] = np.frombuffer(fb[-num_records*264+45:], count=(num_records-1)*264//8+1, dtype=np.int64)[::264//8]/65535/65535/360/1e1
record = np.frombuffer(fb[-num_records*264+230:], count=(num_records-1)*264//4+1, dtype=np.uint32)[::264//4]
pd_data = pd.DataFrame(data=data, index=pd.Index(data=record, name="Record number"))
return pd_data |
thanks @momoson this is great information! can I ask how you normally go about interrogating the binary file to be able to work this out? Its not something I've had previous experience in |
I've sent you an email regarding the binary interrogation process |
Also, wanted to add to the discussion that an NI plugin exists to read the Maccor data files: https://www.ni.com/en-us/support/downloads/dataplugins/download.maccor-dataplugin.html#426304 . And I know anecdotally that Voltaiq platform can read the Maccor binary files. So, in the past, Maccor has been open about how the binary file can be read. They should, ideally, make this public. Their suggested approach is to use the MIMS server. |
also looks like you can directly get data from maccor cyclers via MacNet, e.g. using this library: https://github.com/BattGenie/pymacnet |
Is your feature request related to a problem? Please describe.
Would be great to be able to import maccor binary files as the test is progressing
Describe the solution you'd like
maccor parser currently supports text versions of maccor output files, need to extend to handle binary files
Additional context
blocker: currently can't find any information about the maccor binary file format or programs/libraries for import
The text was updated successfully, but these errors were encountered: