Skip to content

Fix time-related columns for Obspack time series #147

@ZogopZ

Description

@ZogopZ

Currently obtaining data for an Obspack time series will return a pandas dataframe with a time column.
Example code:

from icoscp.cpb.dobj import Dobj
dobj = Dobj('https://meta.icos-cp.eu/objects/VvC1QkMAWW5Z9iUSFaPijY5W')
dobj.data

There are other time-related columns that should be in the dataframe but are not.
Here's the code that does the conversions:

"""
The ICOS Carbon Portal provides a TIMESTAMP which is
a unix timestamp in milliseconds [UTC]
Convert the "number" to a pandas date/time object
"""
if 'TIMESTAMP' in df.columns and self._dtconvert:
df['TIMESTAMP'] = pd.to_datetime(df.loc[:,'TIMESTAMP'],unit='ms')
if 'TIMESTAMP_END' in df.columns and self._dtconvert:
df['TIMESTAMP_END'] = pd.to_datetime(df.loc[:,'TIMESTAMP_END'],unit='ms')
# there are files with date and time where
# date is a unixtimestamp
# time seconds per day
if 'date' in df.columns and self._dtconvert:
df['date'] = pd.to_datetime(df.loc[:,'date'],unit='D')
if 'time' in df.columns and self._dtconvert:
# convert unix timestamp
df['time'] = pd.to_datetime(df.loc[:,'time'],unit='s')
# remove the data, so that only time remains
df['time'] = pd.to_datetime(df.loc[:,'time'],format='%H:%M').dt.time

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions