Add Resampler helper decorators
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza revisando el ejemplo de dimension-checker de #341 y las referencias a BaseResampler y resamplers.utils en el ejemplo de array-converter propuesto. Define las comprobaciones compatibles de dimensiones, clases de arrays y geometrías, y verifica después que los helpers resultantes cubran los casos de Resampler descritos en el issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Context
The assigned developers (among others) have been meeting during the Spring 2021 PCW to discuss a Pyresample 2.0. This issue discusses one of the changes that we think should be implemented on our road to version 2.0. Most features for version 2.0 will be backwards compatible and will not require a deprecation cycle.
For related issues, see the other issues in the v2.0 milestone (see sidebar).
Dimension Checker
A common limitation or check that has to be done on Resampler provided data is the number of dimensions the input data has and what the resampler can accept. To help with this we propose a decorator that checks and slices arrays so that they can be passed to the resample method. Similar work has been done by Martin in #341:
def ensure_3d_data(func):
"""Ensure the data is in three dimensions."""
@wraps(func)
def wrapper(data, *args, **kwargs):
"""Wrap around the original function."""
if data.ndim == 2:
data_3d = data[np.newaxis, :, :]
else:
data_3d = data
resampled = func(data_3d, *args, **kwargs)
if data.ndim == 2:
resampled = resampled.squeeze(0)
return resampled
return wrapper
There could also be one for 3D+ to 2D when we know what dimensions are Y and X.
Array Class Converter
Sometimes algorithms are written with specific classes in mind. They could be written specifically for xarray objects or may only work efficiently for numpy arrays. A decorator that converts between the common cases or raises an exception when things can be converted would simplify a lot of logic for the resamplers and reduce duplicate code. I'm not exactly sure what this would look like but here's what I propose originally:
from pyresample.resamplers import BaseResampler
from pyresample.resamplers.utils import array_converter
from pyresample import register_resampler
@register_resampler('some_name')
class MyResamplerClass(BaseResampler):
...
@array_converter(as_numpy=True, as_dask=True, as_xr_data_array=True,
as_xr_dataset=True, as_arraylike=True)
@require_2d() # produce 2D with (y, x) - see DaskResampler ensure_3d
def resample(self, data, ...):
self.precompute(...)
return self.compute()
Other options might be to require the resampler to pick a single input type and simplify what the array converted decorator looks like.
Geometry Checker
A decorator to check what geometry types have been provided to the resampler and verifies that the resampler knows how to resample from one geometry type to another could be helpful. Here's an example:
class MyResampler(BaseResampler):
@instance_check({
SwathDefinition: [SwathDefinition, AreaDefinition],
AreaDefinition: [AreaDefinition],
})
def __init__(self, src_geom, dst_geom):
super().__init__(src_geom, dst_geom)
This says that this resampler can resample from SwathDefinitions to SwathDefinitions or AreaDefinitions or it can resample AreaDefinitions to AreaDefinitions, but no other combinations.
- Lenguaje dominante
- Python
- Estrellas
- 388
- Forks
- 103
- Merge medio
- 7 d 4 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pytroll/pyresample
-
Geometry `__eq__` and `__hash__` violate Python's hash/equality contractQuizá libre de nuevo @pnuu la tomó hace 47 días y no hay ningún pull request abierto. Abiertobug Priority-Medium
pytroll/pyresample#745 · 1 comentario · 3 asignados ·
-
Improve resampler x/y coordinate metadataQuizá libre de nuevo @djhoese la tomó hace 66 días y no hay ningún pull request abierto. Abiertobug
pytroll/pyresample#739 · 1 asignado ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
pytroll/pyresample#698 · 1 comentario ·
-
`AreaDefinition.get_area_slices` doesn't work for cropped geostationary areas like SEVIRI RSSAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
pytroll/pyresample#694 · 5 comentarios ·
-
gradient_search comb effectQuizá libre de nuevo @mraspaud la tomó hace 386 días y no hay ningún pull request abierto. Abierto
pytroll/pyresample#682 · 7 comentarios · 1 asignado ·
Todos los issues de pytroll/pyresample
Issues similares
-
type-bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
push_gh-pages fails on master branch on forksPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertogood first issue infrastructure
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
kuznia-rdzeni/coreblocks#1135 ·
-
good first issue server
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
documentation priority: high
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
a-lex-s/mealie-telegram-bot#54 ·
Los mantenedores suelen responder en 1 día