Cell Measures, Ancillary Variables, and Cell Methods lost when performing magic methods on cubes (e.g. `__iadd__`, `__div__`)

Abierto
#7,378 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
53/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
data

Línea de trabajo

Start in lib/iris/cube.py at the linked magic-method implementation, then trace how cube attributes, ancillary variables, and cell methods are handled during arithmetic. Check the single-cube array case as well as operations between cubes, and identify the relevant tests before changing behavior. Done means the applicable operations preserve metadata that remains valid and tests cover the cases reported.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

https://github.com/SciTools/iris/blob/2c05b4cc8e77c02748fd4caa2e46e49474408b31/lib/iris/cube.py#L155

I believe that 2 cubes cannot be added when their grids do not line up, so it is strange that common attributes like cell_area and ancillary variables like land_area_fraction are lost, and need to be manually added back in. Can this be fixed?

I have noticed the problem for __add__,__idiv__ and __div__ as well, and would guess that it applies to all magic operations on multiple cubes, whether in place (__iadd__,__imul__, __isub__, __idiv__ , and __itruediv__) or not (__add__,__mul__, __sub__, __div__ , and __truediv__)

I have also used __imul__ with an array of the same shape as the cube, which should implicitly only work because we assume the grid is the same, and cell_area is also lost! Furthermore, records of Cell Methods that were used (0 | time: mean) were also dropped.

Perhaps other attributes are getting dropped as well -- it would be good for someone to thoroughly check.

(FYI @valeriupredoi )

Lenguaje dominante
Python
Estrellas
730
Forks
323
Merge medio
3 d 21 h
PR fusionados (30 d)
16

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de SciTools/iris

Todos los issues de SciTools/iris

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.