diff --git a/docs/further-background/representations.py b/docs/further-background/representations.py index 877df27..0ab32d7 100644 --- a/docs/further-background/representations.py +++ b/docs/further-background/representations.py @@ -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 @@ -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 diff --git a/docs/further-background/why-this-api.py b/docs/further-background/why-this-api.py index c1efb1e..5278687 100644 --- a/docs/further-background/why-this-api.py +++ b/docs/further-background/why-this-api.py @@ -365,14 +365,14 @@ for label, updated_time_axis, updated_interpolation in ( ("starting_point", None, None), ( - "same time - piecewise constant previous", + "same time - piecewise constant next left-closed", ts_varying_step_size.time_axis, - ct.InterpolationOption.PiecewiseConstantPreviousLeftClosed, + ct.InterpolationOption.PiecewiseConstantNextLeftClosed, ), ( - "decadal steps - piecewise constant previous", + "decadal steps - piecewise constant next left-closed", decadal_steps, - ct.InterpolationOption.PiecewiseConstantPreviousLeftClosed, + ct.InterpolationOption.PiecewiseConstantNextLeftClosed, ), ): if updated_time_axis is not None: diff --git a/docs/tutorials/continuous_timeseries_tutorial.py b/docs/tutorials/continuous_timeseries_tutorial.py index 1154960..799f8c9 100644 --- a/docs/tutorials/continuous_timeseries_tutorial.py +++ b/docs/tutorials/continuous_timeseries_tutorial.py @@ -32,11 +32,9 @@ import pint import scipy.interpolate +import continuous_timeseries as ct from continuous_timeseries.exceptions import ExtrapolationNotAllowedError -from continuous_timeseries.timeseries_continuous import ( - ContinuousFunctionScipyPPoly, - TimeseriesContinuous, -) +from continuous_timeseries.timeseries_continuous import ContinuousFunctionScipyPPoly # %% [markdown] # ## Handy pint aliases @@ -110,7 +108,7 @@ # We then create our `TimeseriesContinuous` instance. # %% -ts = TimeseriesContinuous( +ts = ct.TimeseriesContinuous( name="piecewise_constant", time_units=time_axis.u, values_units=values.u, @@ -143,7 +141,7 @@ ) continuous_linear = ContinuousFunctionScipyPPoly(piecewise_polynomial_linear) -ts_linear = TimeseriesContinuous( +ts_linear = ct.TimeseriesContinuous( name="piecewise_linear", time_units=time_axis.u, values_units=values.u, @@ -178,7 +176,7 @@ ) continuous_quadratic = ContinuousFunctionScipyPPoly(piecewise_polynomial_quadratic) -ts_quadratic = TimeseriesContinuous( +ts_quadratic = ct.TimeseriesContinuous( name="piecewise_quadratic", time_units=time_axis.u, values_units=values.u, @@ -215,7 +213,7 @@ ) continuous_quadratic = ContinuousFunctionScipyPPoly(piecewise_polynomial_quadratic) -ts_cubic = TimeseriesContinuous( +ts_cubic = ct.TimeseriesContinuous( name="piecewise_cubic", time_units=time_axis.u, values_units=values.u, diff --git a/docs/tutorials/discrete_timeseries_tutorial.py b/docs/tutorials/discrete_timeseries_tutorial.py index 3822384..2246718 100644 --- a/docs/tutorials/discrete_timeseries_tutorial.py +++ b/docs/tutorials/discrete_timeseries_tutorial.py @@ -30,9 +30,7 @@ import matplotlib.units import pint -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] # ## Handy pint aliases @@ -55,7 +53,7 @@ # the third from `bounds[2]`, to `bounds[3]` etc. # %% -time_axis = TimeAxis( +time_axis = ct.TimeAxis( Q([1900.0, 1950.0, 1975.0, 2000.0, 2010.0, 2020.0, 2030.0, 2050.0], "yr") ) time_axis @@ -67,7 +65,7 @@ # These must represent the values at each bound (i.e. value) in `time_axis`. # %% -values_at_bounds = ValuesAtBounds( +values_at_bounds = ct.ValuesAtBounds( Q([2.3, 4.5, 6.4, 10.0, 11.0, 12.3, 10.2, 3.5], "Gt / yr") ) values_at_bounds @@ -79,7 +77,7 @@ # and initialise our instance. # %% -ts = TimeseriesDiscrete( +ts = ct.TimeseriesDiscrete( name="example", time_axis=time_axis, values_at_bounds=values_at_bounds, @@ -134,15 +132,15 @@ # will automatically be plotted with the same units. # %% -ts_compatible_unit = TimeseriesDiscrete( +ts_compatible_unit = ct.TimeseriesDiscrete( name="example_compatible_unit", - time_axis=TimeAxis( + time_axis=ct.TimeAxis( Q( [(1932 + 6) * 12.0, 2000 * 12.0, (2010 + 5) * 12.0, (2025 + 3) * 12.0], "month", ) ), - values_at_bounds=ValuesAtBounds(Q([140.0, 160.0, 120.0, -10.0], "Mt / month")), + values_at_bounds=ct.ValuesAtBounds(Q([140.0, 160.0, 120.0, -10.0], "Mt / month")), ) ax = ts.plot() @@ -177,15 +175,15 @@ # Instead, you will get an error. # %% -ts_incompatible_unit = TimeseriesDiscrete( +ts_incompatible_unit = ct.TimeseriesDiscrete( name="example_incompatible_unit", - time_axis=TimeAxis( + time_axis=ct.TimeAxis( Q( [(1932 + 6) * 12.0, 2000 * 12.0, (2010 + 5) * 12.0, (2025 + 3) * 12.0], "month", ) ), - values_at_bounds=ValuesAtBounds(Q([10.0, 20.0, 30.0, 40.0], "Mt")), + values_at_bounds=ct.ValuesAtBounds(Q([10.0, 20.0, 30.0, 40.0], "Mt")), ) ax = ts.plot() diff --git a/docs/tutorials/timeseries_tutorial.py b/docs/tutorials/timeseries_tutorial.py index 7c1204b..42042f1 100644 --- a/docs/tutorials/timeseries_tutorial.py +++ b/docs/tutorials/timeseries_tutorial.py @@ -378,7 +378,7 @@ integral_preserving_demo_annual_time_axis ) annual_average = ts_linear_annual_to_show.update_interpolation_integral_preserving( - interpolation=ct.InterpolationOption.PiecewiseConstantPreviousLeftClosed, + interpolation=ct.InterpolationOption.PiecewiseConstantNextLeftClosed, name_res="annual_average", ) @@ -404,7 +404,7 @@ decadal_average = ts_integral_preserving_demo_start.interpolate( Q(np.hstack([[2025, 2040], np.arange(2060, 2100 + 1, 20)]), "yr"), ).update_interpolation_integral_preserving( - interpolation=ct.InterpolationOption.PiecewiseConstantPreviousLeftClosed, + interpolation=ct.InterpolationOption.PiecewiseConstantNextLeftClosed, name_res="custom_average", ) @@ -523,12 +523,12 @@ ), show_discrete=True, discrete_plot_kwargs=dict( - alpha=0.3, + alpha=0.7, + zorder=3, marker="x", s=150, color="tab:blue", label="demo_continuous_and_discrete", - zorder=3, ), )