Skip to content

Allow retrieving coda_special_time values in CODA Python interface as datetime.datetime objects #92

@svniemeijer

Description

@svniemeijer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions