how to speed up the process of `getvar`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 28/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- data, performance
Direzione di ricerca
Inizia riproducendo il confronto dei tempi riportato nell’issue con Python, wrf.getvar, netCDF4 e le variabili indicate SINALPHA, COSALPHA e uvmet_wspd_wdir. Traccia il punto di ingresso getvar e confronta la gestione di ALL_TIMES e delle diagnostiche derivate con le letture dirette; il lavoro è completato quando viene identificato il collo di bottiglia e viene dimostrato un approccio più veloce senza modificare i risultati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I found that using wrf.getvar to get variables is quite slow.
For example
import time
import wrf
import netCDF4 as nc
wrfout = nc.Dataset(wrfout_file)
t0 = time.time()
SINALPHA_WRF = wrf.getvar(wrfout, 'SINALPHA', timeidx=wrf.ALL_TIMES, squeeze=False)
COSALPHA_WRF = wrf.getvar(wrfout, 'COSALPHA', timeidx=wrf.ALL_TIMES, squeeze=False)
t1 = time.time()
sinalpha = wrfout['SINALPHA'][:]
cosalpha = wrfout['COSALPHA'][:]
t2 = time.time()
print(f'getvar: {t1 - t0},directly: {t2 - t1}')
In my PC, the time of getvar is about 0.084 s, and the time of directly is about 0.015 s.
To be a little more complicated, to get the wind speed and the wind direction using wrf.getvar(wrfout, 'uvmet_wspd_wdir', timeidx=wrf.ALL_TIMES, squeeze=False) would take the time about 14.596 s, while we first get ua, va, SINALPHA, COSALPHA by wrf.getvarand then using the relation between these variables to get the wspd and wdir, whose values are not significant different from the result of getvar, but it only takes 2.263 s.
So, what reason make it seems that the calculation speed of getvar is slow and how to improve it?
In my case, I want to extract some variables from wrfout and backup, e.g, most of the variables may be the shape of (4,50,300,300), and I want to save some diagnostic variables to be (4, 10, 300, 300)(interpolated on certain pressure level or height). Any suggestion to efficiently accomplish this kind of task.
wrf.__version__='1.3.2'
- Lingua principale
- Python
- Stelle
- 498
- Fork
- 178
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di NCAR/wrf-python
-
NCAR/wrf-python#309 · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
NCAR/wrf-python#307 · 5 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
NCAR/wrf-python#286 · 3 commenti ·
-
Windows builds and testing Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
NCAR/wrf-python#282 · 1 commento ·
-
PyPI releases Aperta
NCAR/wrf-python#274 · 5 commenti · 1 reazione · 1 assegnatario ·
Tutte le issue di NCAR/wrf-python
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
stephrobert/dsoxlab#238 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
sublimehq/package_control#1780 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nwg-piotr/nwg-displays#145 ·