Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PACKAGE_SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ climatecritters/

## Core Framework (`core/`)

### `CCModel` ([climatecritters/core/ccmodel.py](climatecritters/core/ccmodel.py))
### `CCModel` ([climatecritters/core/ccmodel.py](climatecritters/core/model.py))

The abstract base class for all signal models. Subclasses must implement `dydt(t, x)`. Key capabilities:

Expand Down
2 changes: 1 addition & 1 deletion climatecritters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import utils
from .model_critters import * # all concrete models at cc.*
from .core import Forcing, CCModel, CCOutput # top-level abstractions
from .core import Forcing, Model, Output # top-level abstractions
from .core import forcing as forcing # builder namespace at cc.forcing.*
# from .utils import *

Expand Down
4 changes: 2 additions & 2 deletions climatecritters/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .forcing import Forcing
from .ccmodel import CCModel
from .ccoutput import CCOutput
from .model import Model
from .output import Output
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
milstein_method, rk4_method, Solution,
validate_initial_state as _validate_initial_state,
build_state_from_history as _build_state_from_history)
from .ccoutput import CCOutput
from .output import Output
from .forcing import ForcingSpec


Expand Down Expand Up @@ -73,7 +73,7 @@ def _format_value(v):
return repr(v)


class CCModel:
class Model:
"""The overarching model structure for ClimateCritters.

CCModel serves as the archetype/parent class for models within the
Expand Down Expand Up @@ -810,7 +810,7 @@ def integrate(self, t_span=None, y0=None, method='RK45', dt=None,
k: v[keep] for k, v in self.diagnostic_variables.items()
}

output = CCOutput(
output = Output(
time=self.time,
state_variables=self.state_variables,
state_variable_names=list(self.state_variables_names),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np


class CCOutput:
class Output:
"""Container for the results of one call to ``CCModel.integrate()``.

``CCOutput`` carries the full trajectory produced by the solver and
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/box_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

import numpy as np

from climatecritters.core.ccmodel import CCModel
from climatecritters.core.model import Model


@dataclass(frozen=True)
Expand Down Expand Up @@ -388,7 +388,7 @@ def make_boxmodel(self, var_name=None, **parameter_overrides):
return self.make_model(var_name=var_name, **parameter_overrides)


class GenericBoxModel(CCModel):
class GenericBoxModel(Model):
"""``CCModel`` subclass produced by :class:`BoxModelSpec`.

Users construct this via :meth:`BoxModelSpec.make_boxmodel` rather than
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/daisyworld.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np

from ..core.ccmodel import CCModel
from ..core.model import Model


class Daisyworld(CCModel):
class Daisyworld(Model):
"""Minimal 0D Daisyworld model with black/white daisy coverage and temperature.

The model couples daisy population dynamics to a zero-dimensional energy
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/damped_spring.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import numpy as np

from ..core.ccmodel import CCModel
from ..core.model import Model


class DampedSpring(CCModel):
class DampedSpring(Model):
"""Damped (and optionally driven) spring-mass oscillator.

Parameters
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/ebm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from ..utils import constants as phys
from ..core.ccmodel import CCModel
from ..core.model import Model

__all__ = [
'EBMBase', 'EBM0D', 'EBM1DLat',
Expand Down Expand Up @@ -133,7 +133,7 @@ def albedo_func1D(t, state, model, *, a2=0.25, alpha_ice=0.6, alpha_0=0.1, T1=26
# Base class
# ---------------------------------------------------------------------------

class EBMBase(CCModel):
class EBMBase(Model):
"""Shared energy balance physics for all EBM variants.

Provides default implementations of ``calc_OLR``, ``calc_albedo``, and
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/enso_recharge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from climatecritters.core.ccmodel import CCModel
from climatecritters.core.model import Model


def seasonal_forcing(A=0.5, period=6.0):
Expand Down Expand Up @@ -52,7 +52,7 @@ def _func(t):
return _func


class ENSORechargeOscillator(CCModel):
class ENSORechargeOscillator(Model):
"""Jin-style ENSO recharge oscillator.

Couples the eastern Pacific SST anomaly ``T`` to the thermocline depth
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/g24.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np
from ..core.ccmodel import CCModel
from ..core.model import Model
from scipy.interpolate import CubicSpline


class Model3(CCModel):
class Model3(Model):
"""Model 3 from Ganopolski (2024) describing glacial cycle evolution under orbital forcing.

The model tracks ice volume ``v`` and glacial regime ``k`` (1 = glaciation,
Expand Down
6 changes: 3 additions & 3 deletions climatecritters/model_critters/lorenz.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np

from ..core.ccmodel import CCModel
from ..core.model import Model


class Lorenz96(CCModel):
class Lorenz96(Model):
"""Lorenz (1996) single-scale and two-scale atmospheric model.

A periodic ring of *n* slow-scale variables with quadratic advection and
Expand Down Expand Up @@ -180,7 +180,7 @@ def _dydt_two_scale(self, t, x):
return np.concatenate([dX, dY]).tolist()


class Lorenz63(CCModel):
class Lorenz63(Model):
"""Lorenz (1963) system.

A minimal three-variable convection model exhibiting sensitive dependence
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/melcher25.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np

from ..core.ccmodel import CCModel
from ..core.model import Model

__all__ = ['Melcher25', 'classify_bistable_states']

Expand Down Expand Up @@ -38,7 +38,7 @@ def _classify_states(db, stadial_threshold, interstadial_threshold):
return states


class Melcher25(CCModel):
class Melcher25(Model):
"""Two-equation bistable Itô SDE for stochastic Dansgaard-Oeschger transitions.

Models the meridional buoyancy gradient Δb and buoyancy flux B as a coupled
Expand Down
10 changes: 5 additions & 5 deletions climatecritters/model_critters/pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@

import numpy as np

from ..core.ccmodel import CCModel
from ..core.model import Model


# ---------------------------------------------------------------------------
# SimplePendulum
# ---------------------------------------------------------------------------

class SimplePendulum(CCModel):
class SimplePendulum(Model):
"""Nonlinear pendulum with optional linear damping.

Parameters
Expand Down Expand Up @@ -173,7 +173,7 @@ def damping_ratio(self):
# DrivenPendulum
# ---------------------------------------------------------------------------

class DrivenPendulum(CCModel):
class DrivenPendulum(Model):
"""Driven damped pendulum in dimensionless form.

The standard dimensionless equation (g = L = m = 1):
Expand Down Expand Up @@ -295,7 +295,7 @@ def driving_period(self):
# DoublePendulum
# ---------------------------------------------------------------------------

class DoublePendulum(CCModel):
class DoublePendulum(Model):
"""Double pendulum — a conservative chaotic system.

Two point masses connected by rigid, massless rods swing freely from a
Expand Down Expand Up @@ -528,7 +528,7 @@ def __post_init__(self):
# MultiPendulumBeta
# ---------------------------------------------------------------------------

class MultiPendulumBeta(CCModel):
class MultiPendulumBeta(Model):
"""Experimental N-rod chain pendulum solved via a Lagrangian mass matrix.

This beta model generalizes the double pendulum to an arbitrary chain of
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/roessler.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np

from climatecritters.core.ccmodel import CCModel
from climatecritters.core.model import Model


class Roessler(CCModel):
class Roessler(Model):
"""Roessler chaotic oscillator.

A three-variable continuous-time system with a single scroll attractor:
Expand Down
6 changes: 3 additions & 3 deletions climatecritters/model_critters/stocker2003_bipolar_seesaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

import numpy as np

from ..core.ccmodel import CCModel
from ..core.model import Model


class Stocker2003BipolarSeesaw(CCModel):
class Stocker2003BipolarSeesaw(Model):
"""Minimum thermodynamic model for the thermal bipolar seesaw.

A single prognostic southern temperature anomaly ``Ts`` relaxes toward
Expand Down Expand Up @@ -126,7 +126,7 @@ def populate_diagnostics_from_history(self, time, history):
self.diagnostic_variables = {"Tn": Tn_vals}


class Stocker2003ExtendedSeaIceSeesaw(CCModel):
class Stocker2003ExtendedSeaIceSeesaw(Model):
"""Extended Stocker-style model with reservoir, Southern Ocean, sea-ice, and Antarctic states.

The model integrates four coupled ODEs with prescribed northern forcing
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/stommel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import numpy as np

from ..core.ccmodel import CCModel
from ..core.model import Model


class Stommel(CCModel):
class Stommel(Model):
"""Minimal two-box Stommel thermohaline circulation model.

State variables are the pole-to-equator temperature contrast ``T`` and
Expand Down
4 changes: 2 additions & 2 deletions climatecritters/model_critters/two_box_carbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import numpy as np

from climatecritters.core.ccmodel import CCModel
from climatecritters.core.model import Model


class TwoBoxCarbon(CCModel):
class TwoBoxCarbon(Model):
"""Two-box carbon exchange model with explicit box volumes.

State variables ``A`` and ``S`` are carbon inventories (mass units) in the
Expand Down
14 changes: 7 additions & 7 deletions climatecritters/tests/test_core_pbmodel_time_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pytest
import climatecritters as cc

from climatecritters.core.ccmodel import CCModel
from climatecritters.core.model import Model
from climatecritters.model_critters import lorenz


Expand All @@ -37,7 +37,7 @@ def test_reframe_time_axis_euler_t0(self):
assert np.allclose(output.time, t_eval)


class _PostHistoryModel(CCModel):
class _PostHistoryModel(Model):
def __init__(self):
super().__init__(variable_name='post_history', state_variables=['x'],
diagnostic_variables=['x_squared'])
Expand All @@ -61,7 +61,7 @@ def test_post_history_model_integrates_t0(self):
assert np.isclose(model.state_variables['x'][0], 1.0)


class _SDEPostHistoryModel(CCModel):
class _SDEPostHistoryModel(Model):
"""uses_post_history=True model with additive noise, for si/forcing tests."""

uses_post_history = True
Expand All @@ -79,7 +79,7 @@ def sde_noise(self, t, x):
return np.array([0.1])


class _SDENoPostHistoryModel(CCModel):
class _SDENoPostHistoryModel(Model):
"""uses_post_history=False model, to exercise the si guard."""

uses_post_history = False
Expand All @@ -96,7 +96,7 @@ def sde_noise(self, t, x):
return np.array([0.1])


class _SDENoNoiseOverrideModel(CCModel):
class _SDENoNoiseOverrideModel(Model):
"""uses_post_history=True model that does NOT override sde_noise, to
confirm the base-class stub recovers deterministic integration."""

Expand Down Expand Up @@ -221,7 +221,7 @@ def test_pre_step_forcing_applied_t3(self, method):
)


class _ParamContractModel(CCModel):
class _ParamContractModel(Model):
def __init__(self, coeff=1.0):
super().__init__(
variable_name='param_contract',
Expand Down Expand Up @@ -257,7 +257,7 @@ def test_attribute_assignment_syncs_param_values_t0(self):
assert model.param_values['coeff'](0.0) == 3.0


class _FunctionSwapModel(CCModel):
class _FunctionSwapModel(Model):
def __init__(self):
super().__init__(variable_name='function_swap', state_variables=['x'])

Expand Down
6 changes: 3 additions & 3 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ website:
- tutorials/index.qmd
- section: "Getting started"
contents:
- text: "CCModel Basics"
- text: "Model Basics"
href: notebooks/base_classes/ccmodel_basics.ipynb
- text: "Forcing Basics"
href: notebooks/base_classes/forcing.ipynb
Expand Down Expand Up @@ -184,8 +184,8 @@ quartodoc:
desc: |
Base classes underlying all models.
contents:
- core.CCModel
- core.CCOutput
- core.Model
- core.Output
- core.Forcing

- subtitle: Forcing
Expand Down
Loading
Loading