Skip to content

Using PET with ROMS model #278

Description

@vicemagui

I have a time series of surface 'zeta', 'u', and 'v' fields modeled with ROMS. The model outputs can be found here: https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be. I have downloaded PET dev version in a virtual environment, as the 'pip' and 'mamba install' options failed to be downloaded.

You can open the dataset using xarray, like:

import xarray as xr

path_to_file = 'https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be'
df = xr.open_dataset(path_to_file, engine='netcdf4').sel(time=slice('2026-01-01', '2026-01-02'))

I have tried to apply the eddy identification using both the unregular and regular grid options. For the former, I get the following error:

[IN]: g = UnRegularGridDataset(
    dataset,
    "lon",
    "lat",
)

---- > NumbaTypeError: Unsupported array type: numpy.ma.MaskedArray.

Conversely, if I use the option 'RegularGrid'

g = RegularGridDataset(
    dataset,
    "X",
    "Y",
)

g.add_uv("zeta", "u_eastward", "v_northward")

date = datetime(2026, 1, 1, 0)

a_adt, c_adt = g.eddy_identification("zeta", "u_eastward", "v_northward", date, 0.002)

and the output of that:

We assume pixel position of grid is centered for [./test_nk_nomask.nc](http://sm-nx10076537-bc-compute.int.met.no:8925/lab/tree/test_nk_nomask.nc)
[/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/numpy/ma/core.py:1044](http://sm-nx10076537-bc-compute.int.met.no:8925/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/numpy/ma/core.py#line=1043): RuntimeWarning: invalid value encountered in cast
  np.copyto(result, da, casting='unsafe', where=m)
[/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/py_eddy_tracker/dataset/grid.py:1915](http://sm-nx10076537-bc-compute.int.met.no:8925/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/py_eddy_tracker/dataset/grid.py#line=1914): RuntimeWarning: invalid value encountered in sqrt
  self._speed_ev = sqrt(u * u + v * v)
[/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/numpy/lib/function_base.py:4824](http://sm-nx10076537-bc-compute.int.met.no:8925/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/numpy/lib/function_base.py#line=4823): UserWarning: Warning: 'partition' will ignore the 'mask' of the MaskedArray.
  arr.partition(

---------------------------------------------------------------------------
TypingError                               Traceback (most recent call last)
Cell In[21], line 16
     12 g.add_uv("zeta", "u_eastward", "v_northward")
     14 date = datetime(2026, 1, 1, 0)
---> 16 a_adt, c_adt = g.eddy_identification("zeta", "u_eastward", "v_northward", date, 0.002)

File [~/mambaforge/envs/pet/lib/python3.10/site-packages/py_eddy_tracker/dataset/grid.py:780](http://sm-nx10076537-bc-compute.int.met.no:8925/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/py_eddy_tracker/dataset/grid.py#line=779), in GridDataset.eddy_identification(self, grid_height, uname, vname, date, step, shape_error, presampling_multiplier, sampling, sampling_method, pixel_limit, precision, force_height_unit, force_speed_unit, **kwargs)
    777     continue
    778 # FIXME : center could be outside the contour due to the fit
    779 # FIXME : warning : the fit is made on raw sampling
--> 780 _, _, _, aerr = contour.fit_circle()
    782 # Filter for shape
    783 if aerr < 0 or aerr > shape_error or isnan(aerr):

File [~/mambaforge/envs/pet/lib/python3.10/site-packages/py_eddy_tracker/dataset/grid.py:143](http://sm-nx10076537-bc-compute.int.met.no:8925/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/py_eddy_tracker/dataset/grid.py#line=142), in fit_circle_path(self, method)
    141 if method not in self._circle_params.keys():
    142     if method == "fit":
--> 143         self._circle_params["fit"] = _fit_circle_path(self.vertices)
    144     if method == "equal_area":
    145         self._circle_params["equal_area"] = _circle_from_equal_area(self.vertices)

File [~/mambaforge/envs/pet/lib/python3.10/site-packages/numba/core/dispatcher.py:422](http://sm-nx10076537-bc-compute.int.met.no:8925/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/numba/core/dispatcher.py#line=421), in _DispatcherBase._compile_for_args(self, *args, **kws)
    418         msg = (f"{str(e).rstrip()} \n\nThis error may have been caused "
    419                f"by the following argument(s):\n{args_str}\n")
    420         e.patch_message(msg)
--> 422     error_rewrite(e, 'typing')
    423 except errors.UnsupportedError as e:
    424     # Something unsupported is present in the user code, add help info
    425     error_rewrite(e, 'unsupported_error')

File [~/mambaforge/envs/pet/lib/python3.10/site-packages/numba/core/dispatcher.py:363](http://sm-nx10076537-bc-compute.int.met.no:8925/home/victorm/mambaforge/envs/pet/lib/python3.10/site-packages/numba/core/dispatcher.py#line=362), in _DispatcherBase._compile_for_args.<locals>.error_rewrite(e, issue_type)
    361     raise e
    362 else:
--> 363     raise e.with_traceback(None)

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'fit_circle': Cannot determine Numba type of <class 'function'>


File "../mambaforge/envs/pet/lib/python3.10/site-packages/py_eddy_tracker/dataset/grid.py", line 180:
def _fit_circle_path(vertice):
    <source elided>
        return 0, -90, nan, nan
    centlon, centlat, eddy_radius, err = fit_circle(c_x, c_y)
    ^

During: Pass nopython_type_inference

Note: X and Y here represent the x- and y- coordinates in Cartesian system. Therefore, they are not lat and lon values. Given that the model resolution is 800 m, points have assigned values of 0, 800, 1600, ...., N $\times$ 800, where N is the number of grid points.

Has anyone experienced this before?

Thanks in advance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions