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.
I found that using
wrf.getvar
to get variables is quite slow. For exampleIn my PC, the time of
getvar
is about 0.084 s, and the time ofdirectly
is about 0.015 s. To be a little more complicated, to get the wind speed and the wind direction usingwrf.getvar(wrfout, 'uvmet_wspd_wdir', timeidx=wrf.ALL_TIMES, squeeze=False)
would take the time about 14.596 s, while we first getua, va, SINALPHA, COSALPHA
bywrf.getvar
and then using the relation between these variables to get thewspd
andwdir
, whose values are not significant different from the result ofgetvar
, 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'