McDermott-Group / servers

Public repo that stores LabRAD servers and other non-measurement related code
0 stars 2 forks source link

[DataChest, Grapher] implement labrad unit handling #39

Open roboguy222 opened 8 years ago

amopremcak commented 7 years ago

The idea here will be to make

d.createDataset("voltageTimeSeries",
                [("ind1", [1], "float64", "s")],
                [("dep1", [1], "float64", "V")]
                )

into a more simple call like

d.createDataset("voltageTimeSeries",
                [("ind1", [1])],
                [("dep1", [1])]
                )

with the units and type suppressed or even just

d.createDataset("voltageTimeSeries",
                [("ind1")],
                [("dep1")]
                )

where type, units, and shape are suppressed. In the first call to d.addData(someData) after dataset creation, someData will provide the rest of the info for each variable. There are a few reasons why this wasn't done initially, but the main reason was to keep the dataChest labrad independent. Another reason is that making assumptions about types can be dangerous (if you assume it is int32 because the first number was 2^31-1 and the second number is 2^31, you are in trouble). Similar things must happen for `d.addParameter()'.

patzinak commented 7 years ago

addParameter does not currently support any kind of unit handling, i.e. neither addParameter('Frequency', 5*GHz) nor addParameter('Frequency', 5, 'GHz') works.

roboguy222 commented 7 years ago

Do you need this functionality soon? I like the second style you proposed, that way units are kept as an optional parameter.

patzinak commented 7 years ago

It doesn't really matter to me. I've implemented a workaround, as a temporary solution. This is not the single issue about saving the data into the hdf5 that has to be addressed.. What I mean is the following, by now you should be able to use MATLAB plotting scripts to plot 1D and 2D datasets using hdf5 files saved with the Experiment class, however, these scripts won't likely work if you use an arbitrary hdf5 file, even the one that is saved with the dataChest. This is because the logical (not just format) relationships between the saved datasets have to be explicitly specified inside the hdf5 file. In other words, not only the interface to the dataChest but also the structure of the hdf5 files has to be well defined since there are many ways to organaize internally the same dataset inside a hdf5 file.

patzinak commented 7 years ago

Did not mean to close it.

amopremcak commented 7 years ago

We can write a matlab method to getData from hdf5 files and convert them into whatever format your plotting scripts require. The files are saved in way that is pretty easy to unpack. Basically each variable is its own (sub) dataset within the hdf5 file. The variables are broken up into two categories, independent and dependent which each form there own group (or folder if you will). Parameters form yet another group. There are a few more details than this, but if we sat down for an hour or two, we could have a getData function in matlab ready to go.

patzinak commented 7 years ago

Yes, we have to discuss the nuances. There is already some code that works with the hdf5 data saved by the Experiment class. It won't likely work if you try to open an arbitrary hdf5 file.