Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DataTree in auto_regression #570

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6648a61
implement datatree in autoregression
veni-vidi-vici-dormivi Nov 27, 2024
8dd2a68
test
veni-vidi-vici-dormivi Nov 27, 2024
57aa95c
fixes
veni-vidi-vici-dormivi Nov 27, 2024
aec153c
adjust tests to new names
veni-vidi-vici-dormivi Nov 30, 2024
043002c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 30, 2024
bd25946
fix
veni-vidi-vici-dormivi Nov 30, 2024
4b295bc
extend tests
veni-vidi-vici-dormivi Nov 30, 2024
6abffbb
extend tests
veni-vidi-vici-dormivi Nov 30, 2024
a61e5cf
refactor and test errors
veni-vidi-vici-dormivi Nov 30, 2024
0cfc7cf
test draw
veni-vidi-vici-dormivi Nov 30, 2024
bfd1bb6
precommit
veni-vidi-vici-dormivi Nov 30, 2024
2b55ca9
forgot this
veni-vidi-vici-dormivi Nov 30, 2024
1900650
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 30, 2024
1050d63
Update mesmer/stats/_auto_regression.py
veni-vidi-vici-dormivi Dec 2, 2024
dff5669
Update mesmer/stats/_auto_regression.py
veni-vidi-vici-dormivi Dec 2, 2024
e89d217
Update mesmer/stats/_auto_regression.py
veni-vidi-vici-dormivi Dec 2, 2024
4dc6e38
Update mesmer/stats/_auto_regression.py
veni-vidi-vici-dormivi Dec 2, 2024
11a46a2
fix
veni-vidi-vici-dormivi Dec 2, 2024
dca1535
_to_temp_dataset()
veni-vidi-vici-dormivi Dec 2, 2024
5648b37
precomit
veni-vidi-vici-dormivi Dec 2, 2024
5d109a7
Update tests/unit/test_auto_regression_scen_ens.py
veni-vidi-vici-dormivi Dec 4, 2024
0f86159
Update tests/unit/test_auto_regression_scen_ens.py
veni-vidi-vici-dormivi Dec 4, 2024
fb1eae2
rename format_wrapper
veni-vidi-vici-dormivi Dec 5, 2024
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
6 changes: 3 additions & 3 deletions mesmer/calibrate_mesmer/train_gv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import xarray as xr

from mesmer.io.save_mesmer_bundle import save_mesmer_data
from mesmer.stats import _fit_auto_regression_scen_ens, _select_ar_order_scen_ens
from mesmer.stats import fit_auto_regression_scen_ens, select_ar_order_scen_ens


def train_gv(gv, targ, esm, cfg, save_params=True, **kwargs):
Expand Down Expand Up @@ -172,10 +172,10 @@ def train_gv_AR(params_gv, gv, max_lag, sel_crit):
# create temporary DataArray objects
data = [xr.DataArray(data, dims=["run", "time"]) for data in gv.values()]

AR_order = _select_ar_order_scen_ens(
AR_order = select_ar_order_scen_ens(
*data, dim="time", ens_dim="run", maxlag=max_lag, ic=sel_crit
)
params = _fit_auto_regression_scen_ens(
params = fit_auto_regression_scen_ens(
*data, dim="time", ens_dim="run", lags=AR_order
)

Expand Down
4 changes: 2 additions & 2 deletions mesmer/calibrate_mesmer/train_lv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
)
from mesmer.io.save_mesmer_bundle import save_mesmer_data
from mesmer.stats import (
_fit_auto_regression_scen_ens,
adjust_covariance_ar1,
find_localized_empirical_covariance,
fit_auto_regression_scen_ens,
)


Expand Down Expand Up @@ -235,7 +235,7 @@ def train_lv_AR1_sci(params_lv, targs, y, wgt_scen_eq, aux, cfg):
dims = ("run", "time", "cell")
data = [xr.DataArray(data, dims=dims) for data in targ.values()]

params = _fit_auto_regression_scen_ens(*data, dim="time", ens_dim="run", lags=1)
params = fit_auto_regression_scen_ens(*data, dim="time", ens_dim="run", lags=1)

params_lv["AR1_int"][targ_name] = params.intercept.values
params_lv["AR1_coef"][targ_name] = params.coeffs.values.squeeze()
Expand Down
8 changes: 4 additions & 4 deletions mesmer/stats/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from mesmer.stats._auto_regression import (
_fit_auto_regression_scen_ens,
_select_ar_order_scen_ens,
draw_auto_regression_correlated,
draw_auto_regression_monthly,
draw_auto_regression_uncorrelated,
fit_auto_regression,
fit_auto_regression_monthly,
fit_auto_regression_scen_ens,
select_ar_order,
select_ar_order_scen_ens,
)
from mesmer.stats._gaspari_cohn import gaspari_cohn, gaspari_cohn_correlation_matrices
from mesmer.stats._harmonic_model import fit_harmonic_model, predict_harmonic_model
Expand All @@ -27,8 +27,8 @@

__all__ = [
# auto regression
"_fit_auto_regression_scen_ens",
"_select_ar_order_scen_ens",
"fit_auto_regression_scen_ens",
"select_ar_order_scen_ens",
"draw_auto_regression_correlated",
"draw_auto_regression_uncorrelated",
"fit_auto_regression",
Expand Down
Loading
Loading