66 if (n == 0)
return (1.0);
117 const Numeric Dlimit = 1.00000e-15;
122 if ((n_x != 4) || (n_y != 4)) {
124 os <<
"The vectors x and y must all have the same length of 4 elements!\n" 125 <<
"Actual lengths:\n" 126 <<
"x:" << n_x <<
", " 127 <<
"y:" << n_y <<
".";
128 throw runtime_error(os.
str());
132 if ((a < x[1]) || (a > x[2])) {
134 os <<
"LagrangeInterpol4: the relation x[1] =< a < x[2] is not satisfied. " 135 <<
"No interpolation can be calculated.\n";
136 throw runtime_error(os.
str());
143 for (
Index k = 0; k < 4; ++k) {
144 if ((k !=
i) && (fabs(x[
i] - x[k]) > Dlimit))
145 b[
i] = b[
i] * ((a - x[k]) / (x[
i] - x[k]));
150 for (
Index i = 0;
i < n_x; ++
i) ya = ya + b[
i] * y[
i];
166 assert(x.
nelem() > 0);
167 return x[x.
nelem() - 1];
181 assert(x.
nelem() > 0);
182 return x[x.
nelem() - 1];
211 for (
Index i = 0;
i < n;
i++) x[
i] = start + (
double)
i * step;
238 for (
Index i = 0;
i < n - 1;
i++) x[
i] = start + (
double)
i * step;
246 for (
Index i = 0;
i < n - 1;
i++) x[
i] = start + (
double)
i * step;
279 Numeric step = (log(stop) - a) / ((
double)n - 1);
281 for (
Index i = 1;
i < n - 1;
i++) x[
i] = exp(a + (
double)
i * step);
302 assert(
is_size(Integrand, n, m));
307 for (
Index j = 0; j < m - 1; ++j) {
308 res1[
i] += 0.5 *
DEG2RAD * (Integrand(
i, j) + Integrand(
i, j + 1)) *
309 (aa_grid[j + 1] - aa_grid[j]) * sin(za_grid[
i] *
DEG2RAD);
315 0.5 *
DEG2RAD * (res1[
i] + res1[
i + 1]) * (za_grid[
i + 1] - za_grid[
i]);
345 if ((grid_stepsize[0] > 0) && (grid_stepsize[1] > 0)) {
348 Numeric stepsize_za = grid_stepsize[0];
349 Numeric stepsize_aa = grid_stepsize[1];
351 assert(
is_size(Integrand, n, m));
356 temp = Integrand(
i, 0);
357 for (
Index j = 1; j < m - 1; j++) {
358 temp += Integrand(
i, j) * 2;
360 temp += Integrand(
i, m - 1);
370 res *= 0.5 *
DEG2RAD * stepsize_za;
402 (Integrand[
i] * sin(za_grid[
i] *
DEG2RAD) +
403 Integrand[
i + 1] * sin(za_grid[
i + 1] * DEG2RAD)) *
404 (za_grid[
i + 1] - za_grid[
i]);
459 assert(psd.
nelem() == nx);
464 for (
Index ix = 0; ix < nx; ix++) {
465 const Numeric eterm = exp(-la * x[ix]);
466 psd[ix] = n0 * eterm;
471 os <<
"Given mu is " << mu << endl
472 <<
"Seems unreasonable. Have you mixed up the inputs?";
473 throw runtime_error(os.
str());
476 for (
Index ix = 0; ix < nx; ix++) {
477 const Numeric eterm = exp(-la * x[ix]);
479 psd[ix] = n0 * xterm * eterm;
480 psd[ix] = n0 *
pow(x[ix], mu) * exp(-la * x[ix]);
487 os <<
"Given mu is " << mu << endl
488 <<
"Seems unreasonable. Have you mixed up the inputs?";
489 throw runtime_error(os.
str());
493 os <<
"Given gamma is " << ga << endl
494 <<
"Seems unreasonable. Have you mixed up the inputs?";
495 throw runtime_error(os.
str());
497 for (
Index ix = 0; ix < nx; ix++) {
499 const Numeric eterm = exp(-la * pterm);
501 psd[ix] = n0 * xterm * eterm;
537 const bool& do_n0_jac,
538 const bool& do_mu_jac,
539 const bool& do_la_jac,
540 const bool& do_ga_jac) {
543 assert(psd.
nelem() == nx);
544 assert(jac_data.
nrows() == 4);
545 assert(jac_data.
ncols() == nx);
547 if (ga == 1 && !do_ga_jac) {
548 if (mu == 0 && !do_mu_jac) {
550 for (
Index ix = 0; ix < nx; ix++) {
551 const Numeric eterm = exp(-la * x[ix]);
552 psd[ix] = n0 * eterm;
554 jac_data(0, ix) = eterm;
557 jac_data(2, ix) = -x[ix] * psd[ix];
563 os <<
"Given mu is " << mu << endl
564 <<
"Seems unreasonable. Have you mixed up the inputs?";
565 throw runtime_error(os.
str());
568 for (
Index ix = 0; ix < nx; ix++) {
569 const Numeric eterm = exp(-la * x[ix]);
571 psd[ix] = n0 * xterm * eterm;
573 jac_data(0, ix) = xterm * eterm;
576 jac_data(1, ix) = log(x[ix]) * psd[ix];
579 jac_data(2, ix) = -x[ix] * psd[ix];
581 psd[ix] = n0 *
pow(x[ix], mu) * exp(-la * x[ix]);
588 os <<
"Given mu is " << mu << endl
589 <<
"Seems unreasonable. Have you mixed up the inputs?";
590 throw runtime_error(os.
str());
594 os <<
"Given gamma is " << ga << endl
595 <<
"Seems unreasonable. Have you mixed up the inputs?";
596 throw runtime_error(os.
str());
598 for (
Index ix = 0; ix < nx; ix++) {
600 const Numeric eterm = exp(-la * pterm);
602 psd[ix] = n0 * xterm * eterm;
604 jac_data(0, ix) = xterm * eterm;
607 jac_data(1, ix) = log(x[ix]) * psd[ix];
610 jac_data(2, ix) = -pterm * psd[ix];
613 jac_data(3, ix) = -la * pterm * log(x[ix]) * psd[ix];
624 Numeric f_c = tgamma(4.0) / 256.0;
625 f_c *=
pow(tgamma((alpha + 5.0) / beta), 4 + alpha);
626 f_c /=
pow(tgamma((alpha + 4.0) / beta), 5 + alpha);
628 Numeric f_d = tgamma((alpha + 5.0) / beta);
629 f_d /= tgamma((alpha + 4.0) / beta);
633 psd[
i] = beta * f_c *
pow(xi, alpha) * exp(-
pow(f_d * xi, beta));
635 psd[
i] * (alpha / xi - beta * f_d *
pow(f_d * xi, beta - 1.0));
657 if (x > 0. && N0 > 0. && Lambda > 0. && (mu + 1) / gamma > 0.) {
659 dN = N0 *
pow(x, mu) * exp(-Lambda *
pow(x, gamma));
664 os <<
"At least one argument is zero or negative.\n" 665 <<
"Modified gamma distribution can not be calculated.\n" 666 <<
"x = " << x <<
"\n" 667 <<
"N0 = " << N0 <<
"\n" 668 <<
"lambda = " << Lambda <<
"\n" 669 <<
"mu = " << mu <<
"\n" 670 <<
"gamma = " << gamma <<
"\n";
672 throw runtime_error(os.
str());
688 assert(x.
nelem() > 0);
691 for (
Index i = 0;
i < x.nelem();
i++) x[
i] /= l;
823 w[0] = (x[1] - x[0]) / 2.;
825 for (
Index i = 1;
i < nph * 2 - 1;
i++) {
826 w[
i] = (x[
i + 1] - x[
i - 1]) / 2.;
INDEX Index
The type to use for all integer numbers and indices.
void unitl(Vector &x)
unitl
Index nelem() const
Number of elements.
Numeric AngIntegrate_trapezoid_opti(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, ConstVectorView grid_stepsize)
AngIntegrate_trapezoid_opti.
Numeric fac(const Index n)
fac
Numeric LagrangeInterpol4(ConstVectorView x, ConstVectorView y, const Numeric a)
Lagrange Interpolation (internal function).
Numeric last(ConstVectorView x)
last
bool is_multiple(const Index &x, const Index &y)
Checks if an integer is a multiple of another integer.
cmplx FADDEEVA() w(cmplx z, double relerr)
void delanoe_shape_with_derivative(VectorView psd, MatrixView jac_data, const Vector &x, const Numeric &alpha, const Numeric &beta)
! Shape functions for normalized PSD.
Index nrows() const
Returns the number of rows.
Index nelem() const
Returns the number of elements.
void flat(VectorView x, ConstMatrixView X)
flat
Numeric sign(const Numeric &x)
sign
This file contains the definition of Array.
Index ncols() const
Returns the number of columns.
void mgd_with_derivatives(VectorView psd, MatrixView jac_data, const Vector &x, const Numeric &n0, const Numeric &mu, const Numeric &la, const Numeric &ga, const bool &do_n0_jac, const bool &do_mu_jac, const bool &do_la_jac, const bool &do_ga_jac)
void reshape(Tensor3View X, ConstVectorView x)
reshape
_CS_string_type str() const
Index ncols() const
Returns the number of columns.
Numeric mod_gamma_dist(Numeric x, Numeric N0, Numeric Lambda, Numeric mu, Numeric gamma)
Generalized Modified Gamma Distribution.
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
NUMERIC Numeric
The type to use for all floating point numbers.
Index integer_div(const Index &x, const Index &y)
integer_div
void nlogspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlogspace
Numeric pow(const Rational base, Numeric exp)
Power of.
Header file for logic.cc.
Index npages() const
Returns the number of pages.
This can be used to make arrays out of anything.
void resize(Index n)
Resize function.
A constant view of a Tensor3.
A constant view of a Vector.
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
A constant view of a Matrix.
bool is_size(ConstVectorView x, const Index &n)
Verifies that the size of x is l.
void linspace(Vector &x, const Numeric start, const Numeric stop, const Numeric step)
linspace
void mgd(VectorView psd, const Vector &x, const Numeric &n0, const Numeric &mu, const Numeric &la, const Numeric &ga)
void calculate_weights_linear(Vector &x, Vector &w, const Index nph)
calculate_weights_linear
Index nrows() const
Returns the number of rows.
Numeric AngIntegrate_trapezoid(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid)
AngIntegrate_trapezoid.
This file contains the definition of String, the ARTS string class.
Numeric sqrt(const Rational r)
Square root.