resqpy.time_series.TimeSeries

class resqpy.time_series.TimeSeries(parent_model, uuid=None, first_timestamp=None, daily=None, monthly=None, quarterly=None, yearly=None, title=None, originator=None, extra_metadata=None)

Bases: AnyTimeSeries

Class for RESQML Time Series without year offsets.

Notes

individual RESQML timestamps are strings formatted in accordance with ISO 8601; use this class for time series on a human timeframe; use the resqpy GeologicTimeSeries class instead if the time series is on a geological timeframe

Public Data Attributes:

Inherited from AnyTimeSeries

resqml_type

Inherited from BaseResqpy

resqml_type

part

Standard part name corresponding to self.uuid.

root

XML node corresponding to self.uuid.

citation_title

Citation block title equivalent to self.title.

Commonly Used Methods:

__init__(parent_model[, uuid, ...])

Create a TimeSeries object, either from a time series node in parent model, or from given data.

index_for_timestamp_not_later_than(timestamp)

Returns the index of the latest timestamp that is not later than the specified date.

index_for_timestamp_not_earlier_than(timestamp)

Returns the index of the earliest timestamp that is not earlier than the specified date.

index_for_timestamp_closest_to(timestamp)

Returns the index of the timestamp that is closest to the specified date.

duration_between_timestamps(earlier_index, ...)

Returns the duration between a pair of timestamps.

duration_since_start(index)

Returns the duration between the start of the time series and the indexed timestamp.

step_duration(index)

Returns the duration of the time step between the indexed timestamp and preceding one.

Inherited from AnyTimeSeries

number_of_timestamps()

Returns the number of timestamps in the series.

timestamp(index[, as_string])

Returns an individual timestamp, indexed by its position in the series.

iter_timestamps([as_string])

Iterator over timestamps.

last_timestamp([as_string])

Returns the last timestamp in the series.

index_for_timestamp(timestamp)

Returns the index for a given timestamp.

create_xml([add_as_part, title, originator, ...])

Create a RESQML time series xml node from a TimeSeries or GeologicTimeSeries object, optionally add as part.

Methods:

is_equivalent(other_ts[, tol_seconds])

Returns True if the this timestep series is essentially identical to the other; otherwise False.

days_between_timestamps(earlier_index, ...)

Returns the number of whole days between a pair of timestamps, as an integer.

days_since_start(index)

Returns the number of days between the start of the time series and the indexed timestamp.

step_days(index)

Returns the number of days between the indexed timestamp and preceding one.

add_timestamp(new_timestamp[, allow_insertion])

Inserts a new timestamp into the time series.

extend_by_duration(duration)

Adds a timestamp to the end of the series, at duration beyond the last timestamp.

extend_by_days(days)

Adds a timestamp to the end of the series, at a duration of days beyond the last timestamp.

datetimes()

Returns the timestamps as a list of python-datetime objects.

Inherited from AnyTimeSeries

is_equivalent(other_ts[, tol_seconds])

Returns True if the this timestep series is essentially identical to the other; otherwise False.

set_model(parent_model)

Associate the time series with a resqml model (does not create xml or write hdf5 data).

create_time_index(time_index[, root, ...])

Create a time index node, including time series reference, optionally add to root.

Inherited from BaseResqpy

__init__(parent_model[, uuid, ...])

Create a TimeSeries object, either from a time series node in parent model, or from given data.

try_reuse()

Look for an equivalent existing RESQML object and modify the uuid of this object if found.

create_xml([add_as_part, title, originator, ...])

Create a RESQML time series xml node from a TimeSeries or GeologicTimeSeries object, optionally add as part.

append_extra_metadata(meta_dict)

Append a given dictionary of metadata to the existing metadata.

__eq__(other)

Implements equals operator; uses is_equivalent() otherwise compares class type and uuid.

__ne__(other)

Implements not equal operator.

__repr__()

String representation.


__init__(parent_model, uuid=None, first_timestamp=None, daily=None, monthly=None, quarterly=None, yearly=None, title=None, originator=None, extra_metadata=None)[source]

Create a TimeSeries object, either from a time series node in parent model, or from given data.

Parameters
  • parent_model (model.Model) – the resqpy model to which the time series will belong

  • uuid (uuid.UUID, optional) – the uuid of a TimeSeries object to be loaded from xml

  • first_timestamp (str, optional) – the first timestamp (in RESQML format) if not loading from xml; this and the remaining arguments are ignored if loading from xml; if present, timestamp must be in ISO 8601 format, eg ‘2023-01-31’ or ‘2023-01-31T13:30:00Z’ or ‘2023-01-31T13:30:00.912’

  • daily (non-negative int, optional) – the number of one day interval timesteps to start the series

  • monthly (non-negative int, optional) – the number of 30 day interval timesteps to follow the daily timesteps

  • quarterly (non-negative int, optional) – the number of 90 day interval timesteps to follow the monthly timesteps

  • yearly (non-negative int, optional) – the number of 365 day interval timesteps to follow the quarterly timesteps

  • title (str, optional) – the citation title to use for a new time series; ignored if uuid is not None

  • originator (str, optional) – the name of the person creating the time series, defaults to login id; ignored if uuid is not None

  • extra_metadata (dict, optional) – string key, value pairs to add as extra metadata for the time series; ignored if uuid is not None

Returns

newly instantiated TimeSeries object

Note

a new bespoke time series can be populated by passing the first timestamp here and using the add_timestamp() and/or extend_by…() methods

add_timestamp(new_timestamp, allow_insertion=False)[source]

Inserts a new timestamp into the time series.

append_extra_metadata(meta_dict)

Append a given dictionary of metadata to the existing metadata.

property citation_title

Citation block title equivalent to self.title.

create_time_index(time_index, root=None, check_valid_index=True)

Create a time index node, including time series reference, optionally add to root.

Parameters
  • time_index (int) – non-negative integer index into the time series, identifying the datetime being referenced by the new node

  • root (optional) – if present, the newly created time index xml node is added as a child to this node

  • check_valid_index (boolean, default True) – if True, an assertion error is raised if the time index is out of range for this time series

Returns

the newly created time index xml node

Note

a time index node is typically part of a recurrent property object; it identifies the datetime relevant to the property array (or other data) by indexing into a time series object

create_xml(add_as_part=True, title=None, originator=None, reuse=True)

Create a RESQML time series xml node from a TimeSeries or GeologicTimeSeries object, optionally add as part.

Parameters
  • add_as_part (boolean, default True) – if True, the newly created xml node is added as a part in the model

  • title (string) – used as the citation Title text for the new time series node

  • originator (string, optional) – the name of the human being who created the time series object; default is to use the login name

Returns

the newly created time series xml node

datetimes()[source]

Returns the timestamps as a list of python-datetime objects.

days_between_timestamps(earlier_index, later_index)[source]

Returns the number of whole days between a pair of timestamps, as an integer.

days_since_start(index)[source]

Returns the number of days between the start of the time series and the indexed timestamp.

duration_between_timestamps(earlier_index, later_index)[source]

Returns the duration between a pair of timestamps.

duration_since_start(index)[source]

Returns the duration between the start of the time series and the indexed timestamp.

extend_by_days(days)[source]

Adds a timestamp to the end of the series, at a duration of days beyond the last timestamp.

extend_by_duration(duration)[source]

Adds a timestamp to the end of the series, at duration beyond the last timestamp.

index_for_timestamp(timestamp)

Returns the index for a given timestamp.

Note

this method uses a simplistic string or int comparison; if the timestamp is not found, None is returned

index_for_timestamp_closest_to(timestamp)[source]

Returns the index of the timestamp that is closest to the specified date.

index_for_timestamp_not_earlier_than(timestamp)[source]

Returns the index of the earliest timestamp that is not earlier than the specified date.

index_for_timestamp_not_later_than(timestamp)[source]

Returns the index of the latest timestamp that is not later than the specified date.

is_equivalent(other_ts, tol_seconds=1)[source]

Returns True if the this timestep series is essentially identical to the other; otherwise False.

iter_timestamps(as_string=True)

Iterator over timestamps.

last_timestamp(as_string=True)

Returns the last timestamp in the series.

number_of_timestamps()

Returns the number of timestamps in the series.

property part

Standard part name corresponding to self.uuid.

property root

XML node corresponding to self.uuid.

set_model(parent_model)

Associate the time series with a resqml model (does not create xml or write hdf5 data).

step_days(index)[source]

Returns the number of days between the indexed timestamp and preceding one.

step_duration(index)[source]

Returns the duration of the time step between the indexed timestamp and preceding one.

timestamp(index, as_string=True)

Returns an individual timestamp, indexed by its position in the series.

Parameters
  • index (int) – the time index for which the timestamp is required

  • as_string (boolean, default True) – if True and this is series is on a geologic timeframe, the return value is a string, otherwise an int; for human timeframe series, this argument has no effect

Returns

string or int being the selected timestamp

Notes

index may be negative in which case it is taken to be relative to the end of the series with the last timestamp being referenced by an index of -1; the string form of a geologic timestamp is a positive number in millions of years, with the suffix Ma

try_reuse()

Look for an equivalent existing RESQML object and modify the uuid of this object if found.

Returns

boolean – True if an equivalent object was found, False if not

Note

by design this method may change this object’s uuid as a side effect

title

Citation title

originator

Creator of object. By default, user id.

uuid

Unique identifier