Time Management

Ophidia supports a number of operations to handle time dimensions and measures: selection filters based on dates as well as data reduction based on days, months, years, etc.. To this end, the platform associates a concept hierarchy to each time dimension. A concept hierarchy is a sequence of mappings from a set of low-level concepts (e.g. seconds) to higher-level, more general concept (e.g. years).

Concept hierarchies

Ophidia supports two concept hierachies:

  • oph_base includes only two concept levels, cell (single values) and ALL (all the values), and is adopted by default for any dimension.
  • oph_time can be associated with the dimensions to be handled as time; it includes several concept levels as shown in the following table
Concept level (long name) Short name Aggregate set size
second s  
minute m 60 seconds
hour h 60 minutes
3_hour 3 3 hours
6_hour 6 6 hours - 2 3_hours
day d 24 hours - 4 6_hours
week w 7 days
month M 30 days (*)
quarter q 3 months
year y 4 quarters - 52 weeks (**)
ALL A All the values


(*) Actual number of days per month depends on the calendar type as described below.


(**) Actual number of weeks depends on the calendar and, hence, year duration.

The third column of this table reports the relations among the concept levels (aggregate set size), whereas the following figure displays them graphically.

Time concept hierarchy

The graph shows how data can be aggregated in Ophidia using the operators OPH_AGGREGATE2 and OPH_REDUCE2. For example, daily data can be aggregated to obtain monthly data.

Note that actual number of elements to be aggregated when the user changes the level depends on input dataset. For instance, time series of monthly averages is equal to daily data if only one value is available for each month.

See operator OPH_HIERARCHY for further information.

Time metadata

Time management is provided only for the dimensions associated with concept hierarchy oph_time. In this regard, a number of metadata must be associated with input data following a vocabulary specification.

Embedded vocabulary CF (Climate and Forecast metadata) includes:

  • units, formatted as “units since stating_date
  • calendar type
  • frequency (optional)

Units provides mainly the starting_date, i.e. the date used as offest to evaluate the real dimension values based on the values stored by I/O server.

Supported calendars are:

  • julian: no-leap years consist of 365 days and the durations of months are:

    • January: 31 days
    • February: 28 days
    • March: 31 days
    • April: 30 days
    • May: 31 days
    • June: 30 days
    • July: 31 days
    • August: 31 days
    • September: 30 days
    • October: 31 days
    • November: 30 days
    • December: 31 days

    leap years consist of 366 days and include February 29th; a year is leap if it is multiple of 4

  • gregorian or standard: is equal to julian calendar except for the following rules:

    • a year is leap if it is multiple of 4 and, provided that it is higher than 1582 and it is not multiple of 400, it also is multiple of 100;
    • the day after 1582-10-04 is 1582-10-15;
    • days between 1582-10-05 and 1582-10-14 do not exist
  • proleptic_gregorian: is equal to julian calendar except that a year is leap if it is multiple of 4 and, provided that it is not multiple of 400, it also is multiple of 100.

  • 360_day: the duration of each month is 30 days

  • no_leap: the durations of months are the same of julian calendar and no year is leap

  • all_leap: the durations of months are the same of julian calendar and all the years are leap (they include February 29th is included)

Ophidia partially supports user_defined calendars.

Frequency represents the concept level associated to time dimension. By default, it is set to the units.

Frequency is internally coded by one character as reported in table above (see the column called Short name), which reports the available values. Data reduction operations change the Frequency based on the argument concept_level; the new value has to be set to the Short name of the corresponding level. See OPH_AGGREGATE2 and OPH_REDUCE2 for further details.

Data reduction

Dimension values and the corresponding measures can be aggregated in two ways:

  • by group size
  • by concept hiearchy level

The former approach is adopted by the operators OPH_AGGREGATE, for tuples, and OPH_REDUCE, for arrays. Use group_size to set the number of elements to be aggregated. In this case, concept hierachy is not considered, data reduction is executed along tuples or arrays independently from number and organization of explicit and implicit dimensions; the inner dimensions are aggregated first and then passes the outer ones (in case group_size is higher than the size of the most inner dimension).

The latter approach is adopted by the operators OPH_AGGREGATE2, for explicit dimensions, and OPH_REDUCE2, for implicit dimensions. Use concept_level to set the new concept level of data along the dimension specified by dim. It is possible to process only one dimension at once.

Commands at glance

The following commands refer to the operator OPH_CREATECONTAINER, but time dimension parameters can be set by OPH_IMPORTNC as well as imported automatically from source files using the option import_metadata.

How to create a time dimension?

oph_createcontainer container=foo;dim=foo;hierarchy=oph_time;

How to init the starting date 2000-01-01 for a time dimension (the values will represent offsets from this date)?

oph_createcontainer container=foo;dim=foo;hierarchy=oph_time;base_time=2000-01-01;

How to set the calendar and the units of a time dimension to gregorian and days?

oph_createcontainer container=foo;dim=foo;hierarchy=oph_time;calendar=gregorian;units=d;

How to evaluate monthly averages (assuming that time dimension is explicit)?

oph_aggregate2 cube=http://hostname/ophidia/1/1;operation=avg;dim=time;concept_level=M;

How to evaluate daily averages (assuming that time dimension is implicit)?

oph_reduce2 cube=http://hostname/ophidia/1/1;operation=avg;dim=time;concept_level=d;

How to extract a subset by means of time bounds, e.g. the measures corresponding to the range between 2000-01-01 and 2001-01-01?

oph_subset cube=http://hostname/ophidia/1/1;subset_dims=time;subset_filter=2000-01-01_2001-01-01;