Skip to content

Commit

Permalink
Merge pull request #16 from openscm/timeseries
Browse files Browse the repository at this point in the history
Add Timeseries API
  • Loading branch information
znicholls authored Jan 4, 2025
2 parents 7d81b54 + cdf38e9 commit 1693755
Show file tree
Hide file tree
Showing 80 changed files with 7,045 additions and 283 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.9", "3.10", "3.11" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
runs-on: "${{ matrix.os }}"
defaults:
run:
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.9", "3.10", "3.11" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
runs-on: "${{ matrix.os }}"
steps:
- name: Check out repository
Expand Down
2 changes: 1 addition & 1 deletion changelog/15.docs.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Added a tutorial into our continuous timeseries handling (see the [Continuous timeseries](../tutorials/continuous_timeseries_tutorial)).
Added a tutorial into our continuous timeseries handling (see [Continuous timeseries](../tutorials/continuous_timeseries_tutorial)).
4 changes: 4 additions & 0 deletions changelog/16.docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Added background into why we built this API (see [Why this API?](../further-background/why-this-api)).
- Added a tutorial into our timeseries handling (see [Timeseries](../tutorials/timeseries_tutorial)).
- Added a tutorial into higher-order interpolation (see [Higher-order interpolation](../tutorials/higher_order_interpolation)).
- Added a how-to guide about how to make sharp, step forcings (see [How-to make a step forcing](../how-to-guides/how-to-make-a-step-forcing)).
1 change: 1 addition & 0 deletions changelog/16.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added [`Timeseries`][continuous_timeseries.Timeseries].
1 change: 1 addition & 0 deletions changelog/16.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Extended our CI to check against Python 3.12 and Python 3.13
4 changes: 4 additions & 0 deletions docs/NAVIGATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ See https://oprypin.github.io/mkdocs-literate-nav/
- [Home](index.md)
- [Installation](installation.md)
- [How-to guides](how-to-guides/index.md)
- [How-to make a step forcing](how-to-guides/how-to-make-a-step-forcing.py)
- [Tutorials](tutorials/index.md)
- [Timeseries tutorial](tutorials/timeseries_tutorial.py)
- [Higher-order interpolation](tutorials/higher_order_interpolation.py)
- [Continuous timeseries tutorial](tutorials/continuous_timeseries_tutorial.py)
- [Discrete timeseries tutorial](tutorials/discrete_timeseries_tutorial.py)
- [Further background](further-background/index.md)
- [Why this API?](further-background/why-this-api.py)
- [Representations](further-background/representations.py)
- [Development](development.md)
- [API reference](api/continuous_timeseries/)
Expand Down
11 changes: 9 additions & 2 deletions docs/further-background/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ and explanations about its implementation.
We aim to avoid writing instructions or technical descriptions here,
they belong elsewhere.

Points we will aim to cover:
Points we aim to cover:

- Context and background on the library
- Why it was created
- Help the reader make connections
- Connections within this library and between this library and others

## Why did we build this API?

[Why this API][why-this-api] explains why we built this API the way we did.
In particular, the problems that this API solves.
This is a good starting point if you're wondering,
"Why yet another timeseries representation?".

## Representations of objects

Expand Down
22 changes: 10 additions & 12 deletions docs/further-background/representations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
import pint
from IPython.lib.pretty import pretty

from continuous_timeseries.time_axis import TimeAxis
from continuous_timeseries.timeseries_discrete import TimeseriesDiscrete
from continuous_timeseries.values_at_bounds import ValuesAtBounds
import continuous_timeseries as ct

# %% [markdown]
# ## Set up pint
Expand All @@ -54,26 +52,26 @@
# ## Set up some example objects

# %%
basic_ts = TimeseriesDiscrete(
basic_ts = ct.TimeseriesDiscrete(
name="basic",
time_axis=TimeAxis(Q([1750.0, 1850.0, 1950.0], "yr")),
values_at_bounds=ValuesAtBounds(Q([1.0, 2.0, 3.0], "m")),
time_axis=ct.TimeAxis(Q([1750.0, 1850.0, 1950.0], "yr")),
values_at_bounds=ct.ValuesAtBounds(Q([1.0, 2.0, 3.0], "m")),
)
basic_ts

# %%
long_ts = TimeseriesDiscrete(
long_ts = ct.TimeseriesDiscrete(
name="basic",
time_axis=TimeAxis(Q(np.arange(1850.0, 2300.0, 1), "yr")),
values_at_bounds=ValuesAtBounds(Q(np.arange(450.0), "m")),
time_axis=ct.TimeAxis(Q(np.arange(1850.0, 2300.0, 1), "yr")),
values_at_bounds=ct.ValuesAtBounds(Q(np.arange(450.0), "m")),
)
long_ts

# %%
really_long_ts = TimeseriesDiscrete(
really_long_ts = ct.TimeseriesDiscrete(
name="basic",
time_axis=TimeAxis(Q(np.arange(1850.0, 2300.0, 1 / 12), "yr")),
values_at_bounds=ValuesAtBounds(Q(np.arange(450.0 * 12), "m")),
time_axis=ct.TimeAxis(Q(np.arange(1850.0, 2300.0, 1 / 12), "yr")),
values_at_bounds=ct.ValuesAtBounds(Q(np.arange(450.0 * 12), "m")),
)
really_long_ts

Expand Down
Loading

0 comments on commit 1693755

Please sign in to comment.