Open
Description
How would I transpose the below code chunk to C#? I'm trying to convert the following python code to be used in C#. The point of this function is to parse a binary file's data into a collection of defined objects.
dtype = np.dtype([
("reading_1", np.float64),
("reading_2", np.float32),
("reading_3", np.float64)
# and so on
])
...
# file is a binary file of the structured data defined above
datachunks = np.fromfile(file, dtype)
# do things with arrays of reading_1, reading_2, reading_3 from datachunks
My roadblock right now is that I do not know how to write the 'dtype' segment in C#. I have tried to declare a struct of my own and using it as a parameter for np.fromfile, which I know will not work because np.fromfile requires a Dtype.
[StructLayout(LayoutKind.Sequential)]
public struct ReadingData
{
public double reading_1;
public float reading_2;
public double reading_1;
}
...
NDArray datachunks = np.fromfile(filename, ReadingData);
// syntax error as ReadingData is not a dtype
I can't find any examples on writing a dtype struct in SciSharp's C# Numpy, so I am stumped.
Metadata
Metadata
Assignees
Labels
No labels