Closed vincelhx closed 1 year ago
I managed to reproduce this error with "land_mask" variable for RS2 product and S1 product.
A larger log with:
dataset_1000m['land_mask'].compute()
gives:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[18], line 1
----> 1 dataset_1000m['land_mask'].compute()
File /opt/conda-envs/dev/lib/python3.10/site-packages/xarray/core/dataarray.py:1092, in DataArray.compute(self, **kwargs)
1073 """Manually trigger loading of this array's data from disk or a
1074 remote source into memory and return a new array. The original is
1075 left unaltered.
(...)
1089 dask.compute
1090 """
1091 new = self.copy(deep=False)
-> 1092 return new.load(**kwargs)
File /opt/conda-envs/dev/lib/python3.10/site-packages/xarray/core/dataarray.py:1066, in DataArray.load(self, **kwargs)
1048 def load(self: T_DataArray, **kwargs) -> T_DataArray:
1049 """Manually trigger loading of this array's data from disk or a
1050 remote source into memory and return this array.
1051
(...)
1064 dask.compute
1065 """
-> 1066 ds = self._to_temp_dataset().load(**kwargs)
1067 new = self._from_temp_dataset(ds)
1068 self._variable = new._variable
File /opt/conda-envs/dev/lib/python3.10/site-packages/xarray/core/dataset.py:739, in Dataset.load(self, **kwargs)
736 import dask.array as da
738 # evaluate all the dask arrays simultaneously
--> 739 evaluated_data = da.compute(*lazy_data.values(), **kwargs)
741 for k, data in zip(lazy_data, evaluated_data):
742 self.variables[k].data = data
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/base.py:600, in compute(traverse, optimize_graph, scheduler, get, *args, **kwargs)
597 keys.append(x.__dask_keys__())
598 postcomputes.append(x.__dask_postcompute__())
--> 600 results = schedule(dsk, keys, **kwargs)
601 return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/threaded.py:89, in get(dsk, keys, cache, num_workers, pool, **kwargs)
86 elif isinstance(pool, multiprocessing.pool.Pool):
87 pool = MultiprocessingPoolExecutor(pool)
---> 89 results = get_async(
90 pool.submit,
91 pool._max_workers,
92 dsk,
93 keys,
94 cache=cache,
95 get_id=_thread_get_id,
96 pack_exception=pack_exception,
97 **kwargs,
98 )
100 # Cleanup pools associated to dead threads
101 with pools_lock:
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/local.py:511, in get_async(submit, num_workers, dsk, result, cache, get_id, rerun_exceptions_locally, pack_exception, raise_exception, callbacks, dumps, loads, chunksize, **kwargs)
509 _execute_task(task, data) # Re-execute locally
510 else:
--> 511 raise_exception(exc, tb)
512 res, worker_id = loads(res_info)
513 state["cache"][key] = res
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/local.py:319, in reraise(exc, tb)
317 if exc.__traceback__ is not tb:
318 raise exc.with_traceback(tb)
--> 319 raise exc
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/local.py:224, in execute_task(key, task_info, dumps, loads, get_id, pack_exception)
222 try:
223 task, data = loads(task_info)
--> 224 result = _execute_task(task, data)
225 id = get_id()
226 result = dumps((result, id))
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/core.py:119, in _execute_task(arg, cache, dsk)
115 func, args = arg[0], arg[1:]
116 # Note: Don't assign the subtask results to a variable. numpy detects
117 # temporaries by their reference count and can execute certain
118 # operations in-place.
--> 119 return func(*(_execute_task(a, cache) for a in args))
120 elif not ishashable(arg):
121 return arg
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/optimization.py:990, in SubgraphCallable.__call__(self, *args)
988 if not len(args) == len(self.inkeys):
989 raise ValueError("Expected %d args, got %d" % (len(self.inkeys), len(args)))
--> 990 return core.get(self.dsk, self.outkey, dict(zip(self.inkeys, args)))
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/core.py:149, in get(dsk, out, cache)
147 for key in toposort(dsk):
148 task = dsk[key]
--> 149 result = _execute_task(task, cache)
150 cache[key] = result
151 result = _execute_task(out, cache)
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/core.py:119, in _execute_task(arg, cache, dsk)
115 func, args = arg[0], arg[1:]
116 # Note: Don't assign the subtask results to a variable. numpy detects
117 # temporaries by their reference count and can execute certain
118 # operations in-place.
--> 119 return func(*(_execute_task(a, cache) for a in args))
120 elif not ishashable(arg):
121 return arg
File /opt/conda-envs/dev/lib/python3.10/site-packages/dask/array/core.py:523, in _pass_extra_kwargs(func, keys, *args, **kwargs)
516 """Helper for :func:`dask.array.map_blocks` to pass `block_info` or `block_id`.
517
518 For each element of `keys`, a corresponding element of args is changed
519 to a keyword argument with that key, before all arguments re passed on
520 to `func`.
521 """
522 kwargs.update(zip(keys, args))
--> 523 return func(*args[len(keys) :], **kwargs)
File /home1/datahome/agrouaze/sources/git/xsar/src/xsar/utils.py:78, in bind.__call__(self, *args, **keywords)
76 iargs = iter(args)
77 args = (next(iargs) if arg is ... else arg for arg in self.args)
---> 78 return self.func(*args, *iargs, **keywords)
File /home1/datahome/agrouaze/sources/git/xsar/src/xsar/utils.py:257, in map_blocks_coords.<locals>._evaluate_from_coords(block, f, coords, block_info, dtype)
254 # use loc to get corresponding coordinates
255 coords_sel = tuple(c[loc[i][0]:loc[i][1]] for i, c in enumerate(coords))
--> 257 result = f(*coords_sel, **func_kwargs)
259 if dtype is not None:
260 result = result.astype(dtype)
File /home1/datahome/agrouaze/sources/git/xsar/src/xsar/base_dataset.py:464, in BaseDataset.load_rasterized_masks.<locals>._rasterize_mask_by_chunks(line, sample, mask)
461 chunk_footprint_ll = self.objet_meta.coords2ll(chunk_footprint_coords)
463 # get vector mask over chunk, in lon/lat
--> 464 vector_mask_ll = self.objet_meta.get_mask(mask).intersection(chunk_footprint_ll)
466 if vector_mask_ll.is_empty:
467 # no intersection with mask, return zeros
468 return np.zeros((line.size, sample.size))
File /home1/datahome/agrouaze/sources/git/xsar/src/xsar/utils.py:428, in BlockingActorProxy.__getattr__.<locals>.func(*args, **kwargs)
426 @wraps(attr)
427 def func(*args, **kwargs):
--> 428 res = attr(*args, **kwargs)
429 if isinstance(res, dask.distributed.ActorFuture):
430 return res.result()
File /home1/datahome/agrouaze/sources/git/xsar/src/xsar/base_meta.py:169, in BaseMeta.get_mask(self, name, describe)
165 return descr
167 if self._mask_geometry[name] is None:
168 poly = self._get_mask_intersecting_geometries(name) \
--> 169 .unary_union.intersection(self.footprint)
171 if poly.is_empty:
172 poly = Polygon()
AttributeError: 'NoneType' object has no attribute 'intersection'
re open this ticket since, with last PR #159 we have now some acquisition with incorrect (only ocean) land_flag
content:
RS2_OK135107_PK1187782_DK1151894_SCWA_20220407_182127_VV_VH_SGF
Adding a land mask with,
leads to this error :
instead of returning an array.
(testing safe was
)