CampbellGroup / common

Shared campbell lab code.
GNU Lesser General Public License v3.0
8 stars 5 forks source link

Data vault saves values with arbitrary header (section name) #240

Closed fanmingyu212 closed 6 years ago

fanmingyu212 commented 6 years ago

Addresses #238.

Data vault can only save Independent, Dependent, Parameter, and Comment in the .ini file now.

With this PR, data vault can save values with any header in the ,ini file (displayed as sections in the .ini).

An example .ini is shown below:

[General]
dtype = float
created = 2018-01-08, 17:59:21
accessed = 2018-06-16, 11:33:01
modified = 2018-01-08, 17:59:21
title = Photodiode
independent = 1
dependent = 1
parameters = 3
comments = 0
wavemeter_frequency = 2
temperature = 1

[Independent 1]
label = t
units = num

[Dependent 1]
label = Photodiode Voltage
units = V
category = 

[Parameter 1]
label = Window
data = ['photodiode']

[Parameter 2]
label = plotLive
data = True

[Parameter 3]
label = startTime
data = 1515463161.655

[wavemeter_frequency 1]
label = 422_nm
data = Value(711.0, 'THz')

[wavemeter_frequency 2]
label = 461_nm
data = Value(650.0, 'THz')

[temperature 1]
label = lab
data = Value(21.0, 'degC')

[Comments]

wavemeter_frequency and temperature are the new header names. Number of those sections are saved in wavemeter_frequency and temperature options in General section.

Also added data vault functions to add the headers and read the headers:

The headers are designed to work very similar to parameters, but with flexibility to rename the sections. It could provide new naming schemes for the values saved in .ini to allow better organization.

aransfor commented 6 years ago

I dont have time to look at this right now but it seems to me that you are just renaming the header meant to number parameters, e.g.

[temperature 1] label = lab data = Value(21.0, 'degC')

could just be:

[parameter N] label = lab temperature 1 data = Value(21.0, 'degC')

is this not equally as flexible with no code changes?

jayich commented 6 years ago

We would like control over the bracket ([]'s) namespace. Right now you only have several fixed values. This way we can define (in our lab) what is a "Parameter", and what would fall under other categories as the need arises.

This certainly can be done all through the "Parameter" value, but we want access to the bracket namespace for hierarchical organization.

@aransfor does this make sense?

aransfor commented 6 years ago

@jayich for sure I can see for organizational reasons. Give me a day or two to find time to go through the code but it should be straight forward

jayich commented 6 years ago

@theoriginaljuice @gregllong Can you guys please take a look at this code before Tony does to save him some time? I feel like the majority of our PR's Tony is taking the time to look through.