Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`SwathDef.aggregate` bugs and enhancements

Aperta
#407 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
numpy, python
Ambito
data

Direzione di ricerca

Inizia leggendo i punti di ingresso SwathDefinition.aggregate e AreaDef.aggregate, quindi riproduci gli esempi NumPy e DataArray non suddivisi in chunk dell’issue. Confronta il comportamento esistente di downsampling con l’approccio di upsampling proposto e con l’issue #28. Il lavoro è completato quando le operazioni SwathDefinition richieste funzionano per gli input indicati e corrispondono al comportamento documentato di AreaDef.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem description

SwathDef.aggregate currently works only if SwathDefinition is defined by passing lons/lats xr.DataArray with lons and lats dimensions and dask arrays.

Code Sample
import numpy as np
import dask.array as da
import xarray as xr
from pyresample.geometry import SwathDefinition

lons = np.arange(-179.75, 179.75 + 0.5, 0.5)
lats = np.arange(-89.75,  0.5,  0.5)
lons, lats = np.meshgrid(lons, lats)

# BUG: This does not work. It expects an xr.DataArray  
swath_def = SwathDefinition(lons=lons, lats=lats)
swath_def.aggregate(x=2, y=1)      # Downsample by factor of 2 along x

# BUG: This does not work. It expects a chunked dask array.
lons_da = xr.DataArray(lons, dims=("lats","lons"))
lats_da = xr.DataArray(lats, dims=("lats","lons"))
swath_def = SwathDefinition(lons=lons_da, lats=lats_da)
swath_def.aggregate(x=2, y=1)      # Downsample by factor of 2 along x
 
# This works to coarse the data
lons = da.from_array(lons)
lats = da.from_array(lats) 
lons_da = xr.DataArray(lons, dims=("lats","lons"))
lats_da = xr.DataArray(lats, dims=("lats","lons"))
swath_def = SwathDefinition(lons=lons_da, lats=lats_da)
swath_def.aggregate(x=2, y=1)      # Downsample by factor of 2 along x

Limitations & Consistency

AreaDef.aggregate enables to also upsampling (downscaling) the area by providing x, y dimensions < 1

swath_def.aggregate(x=1/2, y=1/2)  # Split each pixel in 4 pixels

In contrast, SwathDef.aggregate is able to just coarse the grid by averaging geocentric x, y, z coordinates, as dask.array coarsen accepts only accepts only x, y integers >= 1.

swath_def.aggregate(x=1/2, y=1)   
swath_def.aggregate(x=1/2, y=1)   

Suggested improvements
  • Enable swath_def.aggregate to work also with lons/lats defined in numpy arrays
  • Add method area_def.upsample (straighforward)
  • Add method swath_def.upsample
  • Switch name from aggregate to downsample?

This would address also issue https://github.com/pytroll/pyresample/issues/28

Implementation idea for swath_def.upsample
  1. Conversion of lons/lats to geocentric x,y,z
  2. Infer current "pixel" corners in x,y,z
  3. Define new pixel centroids in x,y,z
  4. Backconversion to lats/lons
Lingua principale
Python
Stelle
388
Fork
102
Merge medio
5g 17h
PR unite (30g)
5

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytroll/pyresample

Tutte le issue di pytroll/pyresample

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.