so-wise / so-fronts

Full scripts to generate figures for "Defining Southern Ocean fronts using unsupervised classification" https://doi.org/10.5194/os-17-1545-2021
https://so-fronts.readthedocs.io
MIT License
9 stars 2 forks source link

an error while running batch_i_metric.py #4

Open ZhengYinuo0414 opened 2 months ago

ZhengYinuo0414 commented 2 months ago

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 pcmobject, = 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 commented 2 months ago

Hi, thanks for getting in touch! It looks like that function may have been updated since I wrote this script. I will try and fix this this weekend.


From: ZhengYinuo0414 @.> Sent: Wednesday, August 14, 2024 2:50:27 PM To: so-wise/so-fronts @.> Cc: Subscribed @.***> Subject: [so-wise/so-fronts] an error while running batch_i_metric.py (Issue #4)

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 pcmobject, = 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.

— Reply to this email directly, view it on GitHubhttps://github.com/so-wise/so-fronts/issues/4, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHH7U7WAXKUMKEI7MNJS6ZTZRNOCHAVCNFSM6AAAAABMQMXRR2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3DKOJQGAZDQMY. You are receiving this because you are subscribed to this thread.Message ID: @.***>