src.models package

Submodules

src.models.batch_i_metric module

Make i metric in a batch.

Example

Usage::

python3 src/models/batch_i_metric.py

src.models.batch_i_metric.merge_and_save(k_clusters=5, pca=3)

Merge and save joint.

Return type

None

src.models.batch_i_metric.pca_from_interpolated_year(pcm_object, pca='Depth', k_clusters=5, time_i=40, max_depth=2000, remove_init_var=True)

[summary]

[extended_summary]

Parameters
  • pcm_object (pyxpcm.pcm) – the pcm object which has already been trained.

  • pca (int, optional) – How many principal components were chosen to be fitted. Defaults to cst.D_COORD.

  • k_clusters (int, optional) – how many Guassians were fitted. Defaults to cst.K_CLUSTERS.

  • time_i (int, optional) – [description]. Defaults to cst.EXAMPLE_TIME_INDEX.

  • max_depth (float, optional) – The maximum_depth (in pcm_object) that the data is fitted to. Defaults to cst.MAX_DEPTH.

  • remove_init_var (bool, optional) – Whether or not to remove the initial variables. Defaults to True.

Return type

None

src.models.batch_i_metric.run_through()

Run through.

Return type

None

src.models.batch_i_metric.run_through_sep(k_clusters=5, pca=3)

Run through joint.

Parameters
  • k_clusters (int, optional) – [description]. Defaults to 5.

  • pca (int, optional) – [description]. Defaults to 3.

Return type

None

src.models.make_pair_metric module

To pair i metric.

src.models.make_pair_metric.make_all_pair_i_metric(cart_prod, i_metric, sorted_version, threshold)

Make all pair i metric.

Parameters
  • cart_prod (list) – cartesian product

  • i_metric (np.ndarray) – i metric.

  • sorted_version (np.ndarray) – [description]

  • threshold (float) – [description]

Returns

tuple.

Return type

Tuple[list]

src.models.make_pair_metric.make_one_pair_i_metric(pair, i_metric, sorted_version, threshold)

Make a pair i metric.

Parameters
  • pair (tuple) – [description]

  • i_metric (np.ndarray) – [description]

  • sorted_version (np.ndarray) – [description]

  • threshold (float) – threshold to nan things out below.

Returns

list of numpy arrrays.

Return type

Sequence[np.array]

src.models.make_pair_metric.pair_i_metric(ds, threshold=0.05)

Pair i metric.

# new loading order (to be changed) ds.A_B.values.shape (2, 12, 60, 240) sorted_version.shape (2, 12, 60, 240) i_metric (12, 60, 240) list_no [0, 1, 2, 3, 4] https://numpy.org/doc/stable/reference/generated/numpy.swapaxes.html https://numpy.org/doc/stable/reference/generated/numpy.moveaxis.html “time”].values.shape[0]), (“rank”, dataarray.coords[“rank”].values.shape[0]), (“x”, dataarray.coords[“XC”].values.shape[0]), (“y”, dataarray.coords[“YC”]

Parameters
  • ds (xr.Dataset) – dataset.

  • threshold (float, optional) – threshold to nan out below. Defaults to 0.05.

Returns

pair i metric dataset.

Return type

xr.DataArray

src.models.sobel module

Test sobel vs gradient.

src.models.sobel.grad_v()

Gradient in v direction.

Return type

None

src.models.sobel.sobel_np(values)

Sobel operator on np array.

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.convolve2d.html

Parameters

values (np.ndarray) – values to differentiate.

Returns

gx, gy

Return type

Tuple[np.ndarray, np.ndarray]

src.models.sobel.sobel_scharr_test()

Test scharr / sobel.

Return type

None

src.models.sobel.sobel_vs_grad()

Sobel versus dimension.

Return type

None

src.models.train_pyxpcm module

Train i metric.

Example

To test::

python3 src/models/train_pyxpcm.py

src.models.train_pyxpcm.train_on_interpolated_year(time_i=40, k_clusters=5, maxvar=3, min_depth=300, max_depth=2000, remove_init_var=True, separate_pca=False, interp=True, remake=False)

Train on interpolated year.

Parameters
  • time_i (int, optional) – time index. Defaults to cst.EXAMPLE_TIME_INDEX.

  • k_clusters (int, optional) – clusters. Defaults to cst.K_CLUSTERS.

  • maxvar (int, optional) – num pca. Defaults to cst.D_PCS.

  • min_depth (float, optional) – minimum depth for column. Defaults to cst.MIN_DEPTH.

  • max_depth (float, optional) – maximum depth for column. Defaults to cst.MAX_DEPTH.

  • separate_pca (bool, optional) – separate the pca. Defaults to True.

  • remove_init_var (bool, optional) – remove initial variables. Defaults to True.

Returns

the fitted object and its corresponding dataset.

Return type

Tuple[pyxpcm.pcm, xr.Dataset]

Module contents