Closed basilleaf closed 4 years ago
Implementation ideas:
We also need to show the units when displaying metadata, like "observation duration (secs)" or perhaps "observation duration: 45.0 secs".
The initial implementation of this is just going to consist of:
1) Choosing which units we support in the database 2) Putting the proper units in the tableschemas JSON files for all RANGE entries in all obs* tables 3) Creating a dictionary that converts between the internal database unit abbreviations and the "pretty" versions we want users to see (such as "s" -> "seconds") 3) Modifying api_get_widget() to put the unit type in the widget title 4) Modifying get_metadata() to put the unit type in the metadata name
Later we will allow the user to select the specific units they want to use.
In the table_schemas JSON files, the "data_source" field tells you where the data comes from, and thus where to look to figure out the proper units.
The first version of this has been fixed (displaying the internal units to the user). The second part (allowing the selection of new units) is yet to be done.
Current to do list:
Here are the units we currently use:
cm^-1 (wave number) cm^-1/pixel (wave number resolution) microns (wavelength) microns/pixel (wavelength resolution)
degrees (RA, dec, various ring/surface geo latitude, longitude, lighting angles)
km (ring radius, ring edge on altitude, ring distance, surface geo distance) km/pixel (ring/surface geo resolution)
seconds (all types of image/exposure duration)
milliseconds (COVIMS IR/VIS pixel/line exposure - should we have made these seconds to begin with?)
For each default unit, we can have a set of other units that can be selected by the user.
I think the immediately obvious ones are:
microns => microns, nm, angstroms
degrees => degrees, radians
km => km, Saturn radii, Jupiter radii, Neptune radii, Uranus radii (m? feet? miles?)
seconds => seconds, milliseconds, maybe microseconds milliseconds => milliseconds, seconds
/meta/range/endpoints now takes a units parameter and adjusts the return format accordingly:
http://127.0.0.1:8000/api/meta/range/endpoints/observationduration.json?units=milliseconds`
{"min": "0.0", "max": "50000000.0", "nulls": 11, "units": "milliseconds"}
http://127.0.0.1:8000/api/meta/range/endpoints/observationduration.json?units=seconds
{"min": "0.0000", "max": "50000.0000", "nulls": 11, "units": "seconds"}
http://127.0.0.1:8000/api/meta/range/endpoints/observationduration.json?units=minutes
{"min": "0.000000", "max": "833.333333", "nulls": 11, "units": "minutes"}
http://127.0.0.1:8000/api/meta/range/endpoints/observationduration.json?units=hours
{"min": "0.00000000", "max": "13.88888889", "nulls": 11, "units": "hours"}
http://127.0.0.1:8000/api/meta/range/endpoints/observationduration.json?units=days
{"min": "0.000000000", "max": "0.578703704", "nulls": 11, "units": "days"}
Originally reported by: lisa ballard (Bitbucket: basilleaf, GitHub: basilleaf)