manipulating non-missing elements in a field
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- numpy, python, scikit-learn
- Bereich
- data
Rechercherichtung
Beginnen Sie mit der Untersuchung des CF-Felds und der im Bericht genannten Data-Einstiegspunkte: compressed(), reshape(), get_data() und set_data(), einschließlich der Behandlung maskierter und von dask unterstützter Arrays. Definieren Sie die gewünschten komfortablen Operationen zum Extrahieren nicht fehlender Werte und zum Zuweisen von Ergebnissen. Fügen Sie anschließend Abdeckung für den 3D-to-2D-Workflow und den Fall einer unbekannten dask-Chunk-Größe hinzu.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
In order to use a scikit regression module, I need to
-
Extract the non-missing elements from a 3D field
fin(z,y,x) into a numpy array (z,p), where p is a 1D index over all the non-missing (y,x) locations, which are the same for every z. -
Put a 1D array of results
r(p) into the non-missing data elements of a 2D fieldfout(y,x).
I've done it as follows:
findata=fin.data.compressed().to_dask_array()
findata.compute_chunk_sizes()
findata=findata.reshape(fin.shape[0],fin[0,:].data.compressed().size)
# compute r from findata
foutdata=fout.get_data().flatten()
foutdata[~foutdata.mask]=r
fout.set_data(foutdata.reshape(fout.shape))
Are there better ways, or could you provide better ways? The following occur to me:
- It would be handy if
compressed()was a method of a CF field, to flatten it into a 1D array containing only the non-missing values. - I needed three lines to produce
findatabecause of having tocompute_chunk_sizeson the dask array. Without that step, I got errors as below. - Is there a way to avoid having to get the
Dataout of the field in order to assign to some elements of it using the mask? This was a bit clumsy.
In the Met O IDL lib, both input and output are easier:
findata=fin.data(where(fin(0).data ne fin(0).bmdi))
; compute r from findata
fout.data(where(fout.data ne fout.bmdi))=r
It would be good to have something equally convenient in cf-python. Perhaps there is?
Here's the dask problem:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/users/sws02jmg/.local/lib/python3.11/site-packages/cfdm/decorators.py", line 44, in inplace_wrapper
processed_copy = operation_method(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/users/sws02jmg/.local/lib/python3.11/site-packages/cf/data/data.py", line 10489, in reshape
dx = dx.reshape(*shape, merge_chunks=merge_chunks, limit=limit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/software/applications/anaconda/2023.09-0/lib/python3.11/site-packages/dask/array/core.py", line 2220, in reshape
return reshape(self, shape, merge_chunks=merge_chunks, limit=limit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/software/applications/anaconda/2023.09-0/lib/python3.11/site-packages/dask/array/reshape.py", line 222, in reshape
raise ValueError(
ValueError: Array chunk size or shape is unknown. shape: (nan,)
Possible solution with x.compute_chunk_sizes()
Thanks. Jonathan
- Vorherrschende Sprache
- Python
- Sterne
- 151
- Forks
- 23
- Ø Merge
- 1 T. 2 Std.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus NCAS-CMS/cf-python
-
installation
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
-
Attempt at unsupported conservative 3D mesh regriddingEvtl. wieder frei @sadielbartholomew hat das vor 35 Tagen übernommen, und es ist kein Pull Request offen. Offenbug?
-
bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
-
API review (4.0.0) documentation
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
-
enhancement xarray
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
Alle Issues in NCAS-CMS/cf-python
Ähnliche Issues
-
documentation good first issue
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 72/100
sujithputta02/Esapay#13 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
Flaky: credential-proxy admission metric test asserts a wall-clock bound it does not establishOffenneeds-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
gke-labs/kube-agents#3277 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
jbacalso24/mimry#291 ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
eli-alvarado/us-watchlist-alerts#14 ·
Maintainer antworten meist innerhalb von 1 Tag