working with dimensionless parameters in the MetPy realm #3396
-
Hello, New to MetPy, xArrays and GRIB2 files. I would like to calculate the dimensionless refractive index using atmospheric data from NOAA GFS GRIB2 files. The goal is to use this index in other calculations, and plot it like other parameters (temperature, relative humidity, etc.). It is pretty clear that MetPy does not work with dimensionless data. What would be the proper way to work with a parameter like this, while still working with other parameters in the GRIB2 file? I'm using MetPy version 2.27.0. Here's the code i've tried: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The key here is to encode proper unit information on the empirical constants in the relationship that's calculating the dimensionless constant--these constants by nature rely on the data being used in the equation being in certain units. So you have: ds2['N'][i] = (77.6/ds2['t'][i])*(press_hPa+(4810*ds2['e'][i]/ds2['t'][i])) We can write that as k1 = 77.6 * units('K / hPa')
k2 = 4810 * units('K')
ds2['N'][i] = (k1 / ds2['t'][i]) * (press_hPa + k2 * ds2['e'][i] / ds2['t'][i]) With that dimensionality assigned to those constants, the net dimensionality of the entire expression is dimensionless. The huge benefit of this is that regardless of what dimensionality is actually used above for t and e, proper conversions should take place and the expression will give correct results. |
Beta Was this translation helpful? Give feedback.
The key here is to encode proper unit information on the empirical constants in the relationship that's calculating the dimensionless constant--these constants by nature rely on the data being used in the equation being in certain units. So you have:
We can write that as
With that dimensionality assigned to those constants, the net dimensionality of the entire expression is dimensionless. The huge benefit of this is that regardless of what dimensionality is actually used above for t …