Reading-eScience-Centre / edal-java

Environmental Data Abstraction Layer libraries
Other
39 stars 30 forks source link

Indicate when a parameter is a parameter group #42

Open letmaik opened 8 years ago

letmaik commented 8 years ago

Currently, a group parameter cannot be distinguished as such just by looking at the Parameter object. Starting from a DiscreteFeature, I have to test this via getValues(paramId) and check whether the result is null, in which case I assume it's a group. Still, then I have no information on which parameters this group contains. It would be good if all this information is available more directly.

This issue came up while writing the CoverageJSON module which just takes a Feature or collection of such. In CoverageJSON, there is a separate concept of a ParameterGroup which is identical to a Parameter, except that it contains references to the Parameters in that group and that those groups and stored in a separate list.

guygriffiths commented 8 years ago

The Parameter object is really just a description of the physical parameter being measured. For grouping relationships, the information is contained in the VariableMetadata class. Currently there's no methods which specify whether a particular VariableMetadata object is part of a group, but there are methods to determine whether it has a parent, any children, and whether or not it contains scalar data. Adding some convenience methods is a good idea, but I think that should be part of VariableMetadata rather than Parameter.

letmaik commented 8 years ago

The only problem is that VariableMetadata cannot be accessed from a Feature. I think I agree though that it doesn't belong to Parameter itself, since an EDAL Parameter corresponds to the "observedProperty" in CoverageJSON, and an EDAL Variable(Metadata) corresponds to a CoverageJSON "Parameter". I guess the question then is, why doesn't the EDAL Feature know about it's VariableMetadata?

letmaik commented 8 years ago

This would also explain why the category encoding info (mapping to integers) is within a Parameter where it doesn't really belong, it rather belongs to VariableMetadata.

jonblower commented 8 years ago

Do we have a resolution for this? Can EDAL and CoverageJSON be aligned in this respect or will that cause too much damage to one or the other?

guygriffiths commented 8 years ago

It's a tricky one. The simplest solution would be to make the VariableMetadata available to Feature objects and then simply delegate the getParameter method to the same method on VariableMetadata (or just remove it and access it indirectly). The problem comes because the VariableMetadata hierarchy is fully enclosed within a Dataset, but not necessarily within a Feature. For example, if we have a Dataset with some vector fields (x, y, magnitude, direction, all with a common grouping parent) and we extract a Feature containing only the magnitude, should the VariableMetadata included in that Feature contain a reference to the parent VariableMetadata and the siblings? Or should a new VariableMetadata tree be constructed which only contains the VariableMetadata objects which are actually present in the Feature? My preference is towards the latter, but that becomes complicated when faced with the example where a parent Parameter and its grandchild Parameter are extracted - the two are related, but the metadata which would link them is missing. Having said that, that's only a hypothetical example at the moment...