Skip to content

an error while running batch_i_metric.py #4

@ZhengYinuo0414

Description

@ZhengYinuo0414

I’m sorry to bother you, but I’d like to ask you some questions.
I encountered an error while running batch_i_metric.py
error:
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "src/models/batch_i_metric.py", line 129, in
run_through()
File "src/models/batch_i_metric.py", line 124, in run_through
run_through_sep(k_clusters=k_clusters)
File "src/models/batch_i_metric.py", line 89, in run_through_sep
pcm_object, _ = tim.train_on_interpolated_year(
File "/public/home/cyli/so-fronts-main/src/time_wrapper.py", line 24, in timed
result = method(*args, **kw)
File "/public/home/cyli/so-fronts-main/src/models/train_pyxpcm.py", line 86, in train_on_interpolated_year
pcm_object.fit(ds, features=features, dim=cst.Z_COORD)
File "/public/home/cyli/.local/lib/python3.8/site-packages/pyxpcm/models.py", line 1104, in fit
X, sampling_dims = self.preprocessing(ds, features=features,
File "/public/home/cyli/.local/lib/python3.8/site-packages/pyxpcm/models.py", line 1008, in preprocessing
X, sampling_dims = self.preprocessing_that(ds, dim=dim, features=features_dict, action=action)
File "/public/home/cyli/.local/lib/python3.8/site-packages/pyxpcm/models.py", line 816, in preprocessing_that
X = self._interpoler[feature_name].transform(X, z)
File "/public/home/cyli/.local/lib/python3.8/site-packages/pyxpcm/utils.py", line 208, in transform
C = C.interp(coords={vertical_dim: self.axis})
File "/public/home/cyli/.local/lib/python3.8/site-packages/xarray/core/dataarray.py", line 1360, in interp
ds = self._to_temp_dataset().interp(
File "/public/home/cyli/.local/lib/python3.8/site-packages/xarray/core/dataset.py", line 2610, in interp
variables[name] = missing.interp(var, var_indexers, method, **kwargs)
File "/public/home/cyli/.local/lib/python3.8/site-packages/xarray/core/missing.py", line 611, in interp
var, indexes_coords = _localize(var, indexes_coords)
File "/public/home/cyli/.local/lib/python3.8/site-packages/xarray/core/missing.py", line 552, in _localize
imin = index.get_loc(np.min(new_x.values))
File "/public/home/cyli/.local/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 3655, in get_loc
raise KeyError(key) from err
KeyError: -1990.0

At the final error point, I modified the get_loc function from index.get_loc(np.min(new_x.values), method='nearest') to index.get_loc(np.min(new_x.values)). The direct execution shows an error, and after checking the documentation, it seems that get_loc does not have a method parameter. I removed it on my own and am not sure if this is causing the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions