Skip to main content

No project description provided

Project description

CircleCI codecov DOI

TimeAxis

Manages Time Axis and different operations related to time. Main focus is on Earth Science Data. The main goal of this package is to provide a unified mechanism to convert/transform date from time axis to another. For example, if your original data set is on a daily basis, and you want to convert it to weekly average, TimeAxis package would be handy. This package follows the same concept as in ESMF and SCRIPS. Although these two packages are for spatial coordinate interpolation, TimeAxis, obviously, deals with the time dimension of the data. It calculates a weight matrix stored as sparse matrix. Once you have the weights, any data field could be converted from the original time axis to the provided destination time axis.

How To Install

using pip

as usual, you could use pip installation as follows:

pip install timeaxis

Examples:

Daily data averaged to weekly

In this example, first we create a daily time-axis of length 14 days, i.e. we just have 14 data points along the time axis:

from_axis = DailyTimeAxisBuilder(
    start_date=date(2019, 1, 1),
    n_interval=14
).build()

Now we create a weekly time-axis of length 3, i.e. the time axis would have three elements with span of 3 weeks:

to_axis = WeeklyTimeAxisBuilder(
    start_date=date(2019, 1, 1),
    n_interval=3
).build()

now we create a time axis converter object, as follows:

tc = TimeAxisConverter(
    from_time_axis=from_axis, 
    to_time_axis=to_axis
)

Now we can use tc to convert data from the from_axis to to_axis, as follows:

to_data = tc.average(from_data)

the resulting to_data is the weekly average of the from_data. By default, we are assuming that the first dimension is the time dimension. If the time dimension is not the first dimension, you could define it as the following:

to_data = tc.average(from_data, time_dimension=n)

where n is the time dimension.

Rolling/moving weekly avarage

You could easily calculate a rolling or moving average of your data. Here is an example:

from_axis = DailyTimeAxisBuilder(
    start_date=date(2019, 1, 1),
    n_interval=14
).build()

to_axis = RollingWindowTimeAxisBuilder(
    start_date=date(2019, 1, 1),
    end_date=date(2019, 1, 15),
    window_size=7
).build()

tc = TimeAxisConverter(from_time_axis=from_axis, to_time_axis=to_axis)

to_data = tc.average(from_data)

as you can see, the only difference is the construction og the to_axis. In this example, we are building a rolling time axis that starts on Jan. 1st, 2019 and ends on Jan. 15th, 2019 with a window size of 7. Since the base time delta, if not provided, is one day, our window is one week (7 * 1day). However, this is a rolling time axis, meaning that the next element on time axis is shifted only one day. Yes, the intervals in the time-axis overlap each other.

Daily Averaged to Monthly

# Daily time axis spanning ten years.
from_axis = DailyTimeAxisBuilder(
    start_date=date(2010, 1, 1),
    end_date=date(2020, 1, 1)
).build()

# Monthly Time Axis spanning 10 years.
to_axis = MonthlyTimeAxisBuilder(
    start_year=2010,
    end_year=2019,
).build()

tc = TimeAxisConverter(from_time_axis=from_axis, to_time_axis=to_axis)
monthly_avg = tc.average(daily_data)

if you do not provide any month, the start month is assumed to be the January and the end month is assumed to be the December. If you want to control that you could pass the start_month and/or end_month to change this behavior:

to_axis = MonthlyTimeAxisBuilder(
    start_year=2010,
    start_monnth=4,
    end_year=2019,
    end_month=10
).build()

Authors:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TimeAxis-19.11.7.59750.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

TimeAxis-19.11.7.59750-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file TimeAxis-19.11.7.59750.tar.gz.

File metadata

  • Download URL: TimeAxis-19.11.7.59750.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191029 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3

File hashes

Hashes for TimeAxis-19.11.7.59750.tar.gz
Algorithm Hash digest
SHA256 3657bfb71013dfd30afd14bcb105145687e7ad187d5f00617b085e1c637340eb
MD5 06297fe62fc32f49a4aa3a72e11ac2d7
BLAKE2b-256 b5e0bf4567a41487c73cacee8fad6675daeda0ec4cdf97b99bdeccc4462234a9

See more details on using hashes here.

File details

Details for the file TimeAxis-19.11.7.59750-py3-none-any.whl.

File metadata

  • Download URL: TimeAxis-19.11.7.59750-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191029 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3

File hashes

Hashes for TimeAxis-19.11.7.59750-py3-none-any.whl
Algorithm Hash digest
SHA256 b211092b36241a1599e4506a4d43b61ba3195795b86b9d3bb58e47dd852b7c7b
MD5 80a5e43179372c1ac637173838c0a154
BLAKE2b-256 c7bf040c9fc32676f5e0625d0566c49c5d1ebb59ab94d7b8c7af5265190837aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page