Open IanMayo opened 9 years ago
@dinkoivanov - I'd appreciate you considering this code challenge, when you get chance. It will prove important in our CSV import capability: #14
@IanMayo - I see a TODO: we need to replace Length with an attribute pulled out of our quantity types lookup, but I'm not sure I understand the motivation. Why do we need the quantity if we have the unit? Couldn't we just write: new QuantityCollection<>("name", mps2)
?
Maybe you're right. I was expecting to have to put a quantity between the two angle brackets.
From reading the docs, one set of units may apply to more than one quantity. So, the quantity needs to be explicitly stated (I think)...
@IanMayo - Let's consider we have a CSV with distance measurements. Now the unit and dimension can be implied from the header, like m and [Length], but I think yes - many quantities may use that unit, for example "Length", "Depth" or "Diameter" (in those cases "Length" is the base quantity). So I think we won't be able to imply the quantity, it should be somehow specified by the user (either in the CSV or during import). Perhaps we don't need the quantity, when working with Limpet Quantity collections - units (and dimensions) should be sufficient to perform operations.
@dinkoivanov - my junits background comes almost totally from this article: http://www.javaworld.com/article/2077770/core-java/introduction-to-jsr-275--measures-and-units.html?page=4
Here's the relevant paragraph:
Units can have the same dimension and still apply to different quantities.
For example both torque and energy have a dimension of [L]²·[M]/[T]² in the
standard model. Nevertheless it is convenient and safer to consider them as two
different quantities with their own units. Other examples are sea water salinity
(PSS-78), which is some kind of concentration, and angles, which are all
dimensionless but still convenient to treat as different kinds of quantities. A unit's
dimension can be easily retrieved using the Unit.getDimension() method. For
example: ELECTRON_VOLT.getDimension() returns [L]²·[M]/[T]². But the
physical "type" of a unit can be identified only by its standard units. Consider the
REVOLUTION.divide(MINUTE) unit. Its dimension is 1/[T] -- basically the same
dimension as frequency. But REVOLUTION.divide(MINUTE).getStandardUnit()
returns rad/s, which unequivocally identifies the unit as an angular-velocity unit.
We wish to support both specifying units for dimensionless datasets, and for changing the units of dataset with a dimension.
We don't currently have a dimensionless sample (CSV) dataset. But, we do have an operation to clear units (Administration - Clear Units).
We wish to support reading data from CSV, and reading the data type from the header row.
We can determine units from the header row (such as m/s).
But, we can't determine the quantity to use (partially because one set of units could be used by different dimensions).
So, we'll need to use our own lookup table of quantity type from units.
I've created some code to test this flow - it's in branch issue118_dynamic_quantities