TParameter Units


I believe many of us use TParameter to store values associate with the data we acquired. Often these values have units. It would be nice to be able to store the unit along with the value.

A TParameter has both a value and a string name. You can either embedded the unit inside the name.

Otherwise, what kind of field did you envision to hold the unit information?


You are correct, that one could stick the units in the name, but this is sometimes cumbersome. For example, flux can have units of [m^-2 s^-1 sr^-1 J^-1], this would be a lot to place in a name. Instead it would be nice to have:

TParameter< double > flux("someFlux", 1000, "m^-2 s^-1 sr^-1 J^-1");
std::cout << flux.GetName() << " has a value of " <<
      flux.GetVal() << " " << flux.GetUnits() << "\n"

I don’t think this should be conflated into TParameter.

There have been several efforts in creating a C++ unit system, some are better than others.
Nice examples from a web search:

and less recommended:

And a discussion:

Pick yours! :slight_smile: