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

an error while running batch_i_metric.py #4

Open
ZhengYinuo0414 opened this issue Aug 14, 2024 · 1 comment
Open

an error while running batch_i_metric.py #4

ZhengYinuo0414 opened this issue Aug 14, 2024 · 1 comment

Comments

@ZhengYinuo0414
Copy link

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.

@sdat2
Copy link
Collaborator

sdat2 commented Aug 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants