Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Convert vertices to bounds for nD arrays

Abierto
#163 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
data

Línea de trabajo

Start with cf_xarray/helpers.py and the vertices_to_bounds entry point shown in the traceback. Reproduce the supplied nD DataArray example and compare it with the working single-profile call. Done means the full array with x, y, time, and test dimensions is accepted and converted into the requested bnds and test bounds.

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

Descripción

enhancement good second issue help wanted

Thank you for developing this amazing package, I am only slowly appreciating its full amazingness.

I am currently trying to convert an array of layer depths that varies in time and space, which represent cell vertices in the vertical into a bound style array.

This is my original array lev_vertices:
image

For a minimal example you can create a similar array with:

lev_vertices = xr.DataArray(np.arange(9), dims='test').expand_dims(x=2,y=2, time=2)
lev_vertices

I would like to convert the dimension test into bounds.
This works as expected when operating on a single profile:

cf_xarray.vertices_to_bounds(
    lev_bounds.isel(time=0,x=0, y=0).load(), out_dims=["bnds", "test"]
)

image

But I cant figure out how to make this work on the full array...

cf_xarray.vertices_to_bounds(
    lev_vertices.load(), out_dims=["bnds", "test"]
)

gives

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-76-4487305bbcdc> in <module>
----> 1 cf_xarray.vertices_to_bounds(
      2     lev_vertices.load(), out_dims=["bnds", "test"]
      3 )

/scratch/gpfs/jbusecke/conda_tigercpu/envs/aguadv_omz_busecke_2021/lib/python3.8/site-packages/cf_xarray/helpers.py in vertices_to_bounds(vertices, out_dims)
    116         )
    117     else:
--> 118         raise ValueError(
    119             f"vertices format not understood. Got {vertices.dims} with shape {vertices.shape}."
    120         )

ValueError: vertices format not understood. Got ('x', 'y', 'time', 'test') with shape (2, 2, 2, 9).

I am wondering if I am missing an option to ignore dimensions here? I was thinking of using xr.map_blocks, but that would impose restrictions on my chunking (which might affect performance). So I first wanted to check in here, and see if there is an easy fix.

Lenguaje dominante
Python
Estrellas
181
Forks
51
Merge medio
6 h 39 min
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 xarray-contrib/cf-xarray

Todos los issues de xarray-contrib/cf-xarray

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.