Open jvandegriff opened 1 year ago
A long time ago I was experimenting with a case where an integer was used in place of a string. Here the possible values of the integer are 0, 1, and 2.
When hapiclient
encounters x_categoryMap
, it replaces "0" on the axis with the word "good". This is different but slightly related to the proposed enumeration
.
"name": "scalarcats",
"type": "integer",
"units": null,
"fill": null,
"x_categorymap": {
"good": 0,
"bad ": 1,
"ugly": 2
},
"description": "Category of test result"
},
This looks more like a special kind of label. Maybe we could support it inside the label
portion of the parameter description.
We have this example already in the spec (note the quality_flag
parameter):
"parameters": [
{ "name": "Time",
"type": "isotime",
"units": "UTC",
"fill": null,
"length": 24 },
{ "name": "radial_position",
"type": "double",
"units": "km",
"fill": null,
"description": "radial position of the spacecraft",
"label": "R Position"},
{ "name": "quality_flag",
"type": "integer",
"units": "none",
"fill": null,
"description ": "0=OK and 1=bad"},
{ "name": "mag_GSE",
"type": "double",
"units": "nT",
"fill": "-1e31",
"size" : [3],
"coordinateSystemName": "GSE",
"description": "hourly average Cartesian magnetic field in nT in GSE",
"label": "B field in GSE"}
]
}
So maybe we could allow an enumeration in the label:
{ "name": "quality_flag",
"type": "integer",
"units": "none",
"fill": null,
"description ": "0=OK and 1=bad"
"label": {"enumeration": { 0:"OK", 1: "bad"} }
},
But if it was a double parameter, you might want a range of values for each enum value, and you might want this for integers too. Then it gets complicated, so maybe we just support single integer values.
Here's what it might look like for ranges:
{ "name": "quality_flag",
"type": "integer",
"units": "none",
"fill": null,
"description ": "0-9=OK and 10-19=questionable, >20=bad",
"label": {"enumeration": [ {valueRange: [0,9]; "valueLabel": "OK"},
{valueRange: [10,19]; "valueLabel": "OK"},
{valueRange: [20,infinity]; "valueLabel": "OK"}
]
}
},
(This looks too complex - so not a great idea really.)
What are the use cases for enumerated labels?
We've added a
stringType
for URIs, but most string values in data are for short strings where the values are one from a small set of possibilities, i.e., the parameter is a kind of enumerated type. Examples would be things like a status value, location indicators, or data classification labels.We could add another special
stringType
ofenumeration
. The object associated with thisstringType
lists the set of allowed string values:Here are som examples: