The internal representation of datetime values in CODA is a double value representing seconds since 2000-01-01.
However, in Python we often want to have such values as datetime.datetime objects.
But this not always the case, since datetime.datetime objects are more expensive in terms of memory and creation, and may therefore impose a performance penalty. Because of this and because of backward compatibility, we should make a conversion to datetime.datetime optional.
The idea would then be to create functions coda.set_option_convert_to_datetime and coda.get_option_convert_to_datetime that would allow setting/getting a global (python-only) option to enable the automatic conversion of time values to datetime.datetime. This option is disabled by default.
This will be a 'high level' CODA python interface just as for coda.set_option_filter_record_fields/coda.get_option_filter_record_fields.
If the conversion is enabled then a coda.fetch for a coda_special_time element will return a datetime.datetime object instead of a double value.
We should also introduce a coda.time_to_datetime function that will act as support function for the above, but can also be called manually by users.
When returning arrays of time values we should use numpy.datetime64 instead of datetime.datetime.
The internal representation of datetime values in CODA is a double value representing seconds since 2000-01-01.
However, in Python we often want to have such values as
datetime.datetimeobjects.But this not always the case, since
datetime.datetimeobjects are more expensive in terms of memory and creation, and may therefore impose a performance penalty. Because of this and because of backward compatibility, we should make a conversion todatetime.datetimeoptional.The idea would then be to create functions
coda.set_option_convert_to_datetimeandcoda.get_option_convert_to_datetimethat would allow setting/getting a global (python-only) option to enable the automatic conversion of time values todatetime.datetime. This option is disabled by default.This will be a 'high level' CODA python interface just as for
coda.set_option_filter_record_fields/coda.get_option_filter_record_fields.If the conversion is enabled then a
coda.fetchfor acoda_special_timeelement will return adatetime.datetimeobject instead of a double value.We should also introduce a
coda.time_to_datetimefunction that will act as support function for the above, but can also be called manually by users.When returning arrays of time values we should use
numpy.datetime64instead ofdatetime.datetime.