addit package¶
Submodules¶
addit.dit module¶
-
addit.dit.
rundit
(S, nu_lines, beta, gammaL, nu_grid, beta_grid, gammaL_grid)¶ run DIT
- Parameters
S – line strength (Nlines)
nu_lines – line center (Nlines)
beta – Gaussian STD (Nlines)
gammaL – Lorentian half width (Nlines)
nu_grid – linear wavenumber grid
beta_grid – beta grid
gammaL_grid – gammaL grid
- Returns
Cross section
-
addit.dit.
voigt_kernel
(k, beta, gammaL)¶ Fourier Kernel of the Voigt Profile
- Parameters
k – conjugated of wavenumber
beta – Gaussian standard deviation
gammaL – Lorentian Half Width
- Returns
kernel (N_x,N_beta,N_gammaL)
Note
Conversions to the (full) width, wG and wL are as follows: wG=2*sqrt(2*ln2) beta wL=2*gamma
addit.interpolate module¶
-
addit.interpolate.
interp2d
(x, y, xp, yp, fp)¶ interpolation of a 2D function f(x,y) from given precomputed x,y,f arrays.
- Parameters
x – x value to be evaluated
y – y value to be evaluated
xp – Arrays defining the data point coordinates for x
yp – Arrays defining the data point coordinates for y
fp – 2D array of the function to interpolate at the data points.
- Returns
f(x,y)
addit.ncf module¶
Neighbouring Contribution Function
Assume a given x-grid xv[k], and a value x. For a 1D case, the Neighbouring Contribution Function gives ncf(k,x) = (x-xv[s])/dv for k=s, (xv[s]-x)/dv for k=s+1, and 0 elsewhere, where s is the nearest index of xv[k] to x but xv[k]<x.
For a 2D case, NCF gives the non-zero values for 4 points around (x,y)
-
addit.ncf.
conti
(i, x, xv)¶ neighbouring contribution function for index i.
- Parameters
i – index
x – x value
xv – x-grid
- Returns
neighbouring contribution function of x to the i-th component of the array with the same dimension as xv.
-
addit.ncf.
inc2D
(w, x, y, xv, yv)¶ integrated neighbouring contribution function for 2D (memory reduced sum).
- Parameters
w – weight (N)
x – x values (N)
y – y values (N)
xv – x grid
yv – y grid
- Returns
integrated neighbouring contribution function
Note
This function computes sum_n w_n fx_n otimes fy_n, where w_n is the weight, fx_n and fy_n are the n-th NCFs for 1D. A direct sum uses huge RAM. In this function, we use jax.lax.scan to compute the sum
Example
>>> N=10000 >>> xv=jnp.linspace(0,1,11) #grid >>> yv=jnp.linspace(0,1,13) #grid >>> w=np.logspace(1.0,3.0,N) >>> x=np.random.rand(N) >>> y=np.random.rand(N) >>> val=inc2D(w,x,y,xv,yv) >>> #the comparision with the direct sum >>> valdirect=jnp.sum(nc2D(x,y,xv,yv)*w,axis=2) >>> #maximum deviation >>> print(jnp.max(jnp.abs((val-valdirect)/jnp.mean(valdirect)))*100,"%") #% >>> 5.196106e-05 % >>> #mean deviation >>> print(jnp.sqrt(jnp.mean((val-valdirect)**2))/jnp.mean(valdirect)*100,"%") #% >>> 1.6135311e-05 %
-
addit.ncf.
inc3D
(w, x, y, z, xv, yv, zv)¶ integrated neighbouring contribution for 3D (memory reduced sum).
- Parameters
w – weight (N)
x – x values (N)
y – y values (N)
z – z values (N)
xv – x grid
yv – y grid
zv – z grid
- Returns
integrated neighbouring contribution
Note
This function computes sum_n w_n fx_n otimes fy_n otimes fz_n, where w_n is the weight, fx_n, fy_n, and fz_n are the n-th NCFs for 1D. A direct sum uses huge RAM. In this function, we use jax.lax.scan to compute the sum
Example
>>> N=10000 >>> xv=jnp.linspace(0,1,11) #grid >>> yv=jnp.linspace(0,1,13) #grid >>> zv=jnp.linspace(0,1,17) #grid >>> w=np.logspace(1.0,3.0,N) >>> x=np.random.rand(N) >>> y=np.random.rand(N) >>> z=np.random.rand(N) >>> val=inc3D(w,x,y,z,xv,yv,zv) >>> #the comparision with the direct sum >>> valdirect=jnp.sum(nc3D(x,y,z,xv,yv,zv)*w,axis=3) >>> #maximum deviation >>> print(jnp.max(jnp.abs((val-valdirect)/jnp.mean(valdirect)))*100,"%") #% >>> 5.520862e-05 % >>> #mean deviation >>> print(jnp.sqrt(jnp.mean((val-valdirect)**2))/jnp.mean(valdirect)*100,"%") #% >>> 8.418057e-06 %
-
addit.ncf.
nc1D
(x, xv)¶ neighbouring contribution function for 1D.
- Parameters
x – x value
xv – x grid
- Returns
neighbouring contribution function
Example
>>> xv=jnp.linspace(0,1,11) #grid >>> print(nc1D(0.23,xv)) >>> [0. 0. 0.70000005 0.29999995 0. 0. 0. 0. 0. 0. 0. ]
-
addit.ncf.
nc2D
(x, y, xv, yv)¶ neighbouring contribution function for 2D.
- Parameters
x – x value
y – y value
xv – x grid
yv – y grid
- Returns
2D neighbouring contribution function
-
addit.ncf.
nc3D
(x, y, z, xv, yv, zv)¶ neighbouring contribution function for 3D.
Note
See Fig. 1 in van den Bekerom and Pannier (2021) JQSR 261, 107476
- Parameters
x – x value
y – y value
z – z value
xv – x grid
yv – y grid
zv – z grid
- Returns
3D neighbouring contribution function