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

3D feature detection with min_distance fails if dz is not provided #413

Closed
4 tasks done
w-k-jones opened this issue Mar 7, 2024 · 1 comment · Fixed by #452
Closed
4 tasks done

3D feature detection with min_distance fails if dz is not provided #413

w-k-jones opened this issue Mar 7, 2024 · 1 comment · Fixed by #452
Assignees
Labels
bug Code that is failing or producing the wrong result
Milestone

Comments

@w-k-jones
Copy link
Member

w-k-jones commented Mar 7, 2024

If dz is not given, filter_min_distance tries to find the vertical coordinate from the dataframe but as this occurs before coordinate interpolate it fails, causing an error.

Easiest solution is to move this after coordinate interpolation I think

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[22], line 1
----> 1 features_w = tobac.feature_detection_multithreshold(
      2     w_iris, **parameters_features
      3 )

File ~/python/tobac/tobac/utils/decorators.py:168, in xarray_to_iris.<locals>.wrapper(*args, **kwargs)
    165             output = xarray.DataArray.from_iris(output)
    167 else:
--> 168     output = func(*args, **kwargs)
    169 # print(output)
    170 return output

File ~/python/tobac/tobac/feature_detection.py:1375, in feature_detection_multithreshold(field_in, dxy, threshold, min_num, target, position_threshold, sigma_threshold, n_erosion_threshold, n_min_threshold, min_distance, feature_number_start, PBC_flag, vertical_coord, vertical_axis, detect_subset, wavelength_filtering, dz, strict_thresholding, statistic)
   1372     # Loop over DataFrame to remove features that are closer than distance_min to each
   1373     # other:
   1374     if min_distance > 0:
-> 1375         features_thresholds = filter_min_distance(
   1376             features_thresholds,
   1377             dxy=dxy,
   1378             dz=dz,
   1379             min_distance=min_distance,
   1380             z_coordinate_name=vertical_coord,
   1381             target=target,
   1382             PBC_flag=PBC_flag,
   1383             min_h1=0,
   1384             max_h1=hdim1_max,
   1385             min_h2=0,
   1386             max_h2=hdim2_max,
   1387         )
   1388 list_features_timesteps.append(features_thresholds)
   1390 logging.debug(
   1391     "Finished feature detection for " + time_i.strftime("%Y-%m-%d_%H:%M:%S")
   1392 )

File ~/python/tobac/tobac/feature_detection.py:1492, in filter_min_distance(features, dxy, dz, min_distance, x_coordinate_name, y_coordinate_name, z_coordinate_name, target, PBC_flag, min_h1, max_h1, min_h2, max_h2)
   1489 is_3D = "vdim" in features
   1491 if is_3D and dz is None:
-> 1492     z_coordinate_name = internal_utils.find_dataframe_vertical_coord(
   1493         features, z_coordinate_name
   1494     )
   1496 # Check if both dxy and their coordinate names are specified.
   1497 # If they are, warn that we will use dxy.
   1498 if dxy is not None and (
   1499     x_coordinate_name in features and y_coordinate_name in features
   1500 ):

File ~/python/tobac/tobac/utils/internal/basic.py:187, in find_dataframe_vertical_coord(variable_dataframe, vertical_coord)
    185     return vertical_coord
    186 else:
--> 187     raise ValueError("Please specify vertical coordinate")

ValueError: Please specify vertical coordinate
  • Have you searched the issue tracker for the same problem?
  • Have you checked if you're using the latest version? If not, which version are you using?
  • Have you mentioned the steps to reproduce the issue?
  • Have you, if applicable, included error messages?
@w-k-jones w-k-jones added the bug Code that is failing or producing the wrong result label Mar 7, 2024
@w-k-jones w-k-jones self-assigned this Mar 7, 2024
@w-k-jones w-k-jones linked a pull request Oct 1, 2024 that will close this issue
11 tasks
@w-k-jones w-k-jones added this to the Version 1.5.4 milestone Oct 1, 2024
@w-k-jones
Copy link
Member Author

Resolved by #452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Code that is failing or producing the wrong result
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant