Skip to content

The fix when there are nan in Latitude / Longitude didn't work #120

Description

@eeholmes

Reopening: #119

It got farther but then stopped with a new error:

This gave

res = pc.matchup(plan, 
                 variables = ["UVAerosolIndex"], 
                 open_method=discovr_epic_aer)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[12], line 1
----> 1 get_ipython().run_cell_magic('time', '', 'res = pc.matchup(plan, \n                 variables = ["UVAerosolIndex"], \n                 open_method=discovr_epic_aer)\n')

File [/srv/conda/envs/notebook/lib/python3.12/site-packages/IPython/core/interactiveshell.py:2572](https://nmfs-openscapes.2i2c.cloud/srv/conda/envs/notebook/lib/python3.12/site-packages/IPython/core/interactiveshell.py#line=2571), in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
   2570 with self.builtin_trap:
   2571     args = (magic_arg_s, cell)
-> 2572     result = fn(*args, **kwargs)
   2574 # The code below prevents the output from being displayed
   2575 # when using magics with decorator @output_can_be_silenced
   2576 # when the last Python token in the expression is a ';'.
   2577 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File [/srv/conda/envs/notebook/lib/python3.12/site-packages/IPython/core/magics/execution.py:1447](https://nmfs-openscapes.2i2c.cloud/srv/conda/envs/notebook/lib/python3.12/site-packages/IPython/core/magics/execution.py#line=1446), in ExecutionMagics.time(self, line, cell, local_ns)
   1445 if interrupt_occured:
   1446     if exit_on_interrupt and captured_exception:
-> 1447         raise captured_exception
   1448     return
   1449 return out

File [/srv/conda/envs/notebook/lib/python3.12/site-packages/IPython/core/magics/execution.py:1411](https://nmfs-openscapes.2i2c.cloud/srv/conda/envs/notebook/lib/python3.12/site-packages/IPython/core/magics/execution.py#line=1410), in ExecutionMagics.time(self, line, cell, local_ns)
   1409 st = clock2()
   1410 try:
-> 1411     exec(code, glob, local_ns)
   1412     out = None
   1413     # multi-line %%time case

File <timed exec>:1

File [~/point-collocation/src/point_collocation/core/engine.py:283](https://nmfs-openscapes.2i2c.cloud/user/eeholmes/lab/tree/point-collocation/examples/point-collocation/src/point_collocation/core/engine.py#line=282), in matchup(plan, open_method, variables, spatial_method, open_dataset_kwargs, silent, batch_size, save_dir, granule_range)
    280 spec = _normalize_open_method(effective_open_method, open_dataset_kwargs)
    282 effective_vars: list[str] = variables if variables is not None else plan.variables
--> 283 return _execute_plan(
    284     plan,
    285     spec=spec,
    286     spatial_method=spatial_method,
    287     variables=effective_vars,
    288     silent=silent,
    289     batch_size=batch_size,
    290     save_dir=save_dir,
    291     granule_range=granule_range,
    292 )

File [~/point-collocation/src/point_collocation/core/engine.py:693](https://nmfs-openscapes.2i2c.cloud/user/eeholmes/lab/tree/point-collocation/examples/point-collocation/src/point_collocation/core/engine.py#line=692), in _execute_plan(plan, spec, spatial_method, variables, silent, batch_size, save_dir, granule_range)
    691     _extract_xoak_batch(ds, rows_for_granule, variables, lon_name, lat_name, time_dim)
    692 else:
--> 693     _extract_ndpoint_batch(ds, rows_for_granule, variables, lon_name, lat_name, time_dim)
    694 output_rows.extend(rows_for_granule)
    695 batch_rows.extend(rows_for_granule)

File [~/point-collocation/src/point_collocation/core/engine.py:1312](https://nmfs-openscapes.2i2c.cloud/user/eeholmes/lab/tree/point-collocation/examples/point-collocation/src/point_collocation/core/engine.py#line=1311), in _extract_ndpoint_batch(ds, rows, variables, lon_name, lat_name, time_dim)
   1307 ds_work = _drop_nan_geoloc(ds_work, lat_name, lon_name)
   1309 # Build the NDPointIndex once for all query points using the built-in
   1310 # scipy adapter (ScipyKDTreeAdapter).  No tree_adapter_cls argument is
   1311 # passed so xarray's default applies.
-> 1312 indexed_ds = ds_work.set_xindex(
   1313     [lat_name, lon_name],
   1314     xr.indexes.NDPointIndex,
   1315 )
   1317 # Build the target dataset with all query points at once.
   1318 lats = [row["lat"] for row in rows]

File [/srv/conda/envs/notebook/lib/python3.12/site-packages/xarray/core/dataset.py:5019](https://nmfs-openscapes.2i2c.cloud/srv/conda/envs/notebook/lib/python3.12/site-packages/xarray/core/dataset.py#line=5018), in Dataset.set_xindex(self, coord_names, index_cls, **options)
   5013     raise ValueError(
   5014         f"those coordinates already have an index: {indexed_coords}"
   5015     )
   5017 coord_vars = {name: self._variables[name] for name in coord_names}
-> 5019 index = index_cls.from_variables(coord_vars, options=options)
   5021 new_coord_vars = index.create_variables(coord_vars)
   5023 # special case for setting a pandas multi-index from level coordinates
   5024 # TODO: remove it once we depreciate pandas multi-index dimension (tuple
   5025 # elements) coordinate

File [/srv/conda/envs/notebook/lib/python3.12/site-packages/xarray/indexes/nd_point_index.py:262](https://nmfs-openscapes.2i2c.cloud/srv/conda/envs/notebook/lib/python3.12/site-packages/xarray/indexes/nd_point_index.py#line=261), in NDPointIndex.from_variables(cls, variables, options)
    259 var0 = next(iter(variables.values()))
    261 if len(variables) != len(var0.dims):
--> 262     raise ValueError(
    263         f"the number of variables {len(variables)} doesn't match "
    264         f"the number of dimensions {len(var0.dims)}"
    265     )
    267 opts = dict(options)
    269 tree_adapter_cls: type[T_TreeAdapter] = opts.pop("tree_adapter_cls", None)

ValueError: the number of variables 2 doesn't match the number of dimensions 1

Activity

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

Metadata

Metadata

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