21#include "matpack_complex.h"
64 const Index nf = f_grid.nelem();
66 complex_n.resize(nf, 2);
70 const Numeric theta = 1 - 300 / t;
71 const Numeric e0 = 77.66 - 103.3 * theta;
72 const Numeric e1 = 0.0671 * e0;
73 const Numeric f1 = 20.2 + 146 * theta + 316 * theta * theta;
74 const Numeric e2 = 3.52;
75 const Numeric f2 = 39.8 * f1;
77 for (Index iv = 0; iv < nf; iv++) {
78 const Complex ifGHz(0.0, f_grid[iv] / 1e9);
80 Complex n = sqrt(e2 + (e1 - e2) / (Numeric(1.0) - ifGHz / f2) +
81 (e0 - e1) / (Numeric(1.0) - ifGHz / f1));
83 complex_n(iv, 0) = n.real();
84 complex_n(iv, 1) = n.imag();
108 const Vector& f_grid,
114 const Index nf = f_grid.nelem();
116 complex_n.resize(nf, 2);
119 const Numeric B1 = 0.0207;
120 const Numeric B2 = 1.16e-11;
121 const Numeric
b = 335.;
123 const Numeric deltabeta = exp(-9.963 + 0.0372 * (t - 273));
124 const Numeric ebdt = exp(
b / t);
125 const Numeric betam = (B1 / t) * ebdt / ((ebdt - 1.) * (ebdt - 1.));
127 const Numeric theta = 300. / t - 1;
128 const Numeric alfa = (0.00504 + 0.0062 * theta) * exp(-22.1 * theta);
129 const Numeric reps = 3.1884 + 9.1e-4 * (t - 273);
131 for (Index iv = 0; iv < nf; iv++) {
132 Numeric f = f_grid[iv] / 1e9;
133 Numeric beta = betam + B2 * f * f + deltabeta;
134 Numeric ieps = alfa / f + beta * f;
136 Complex eps(reps, ieps);
137 Complex n = sqrt(eps);
138 complex_n(iv, 0) = n.real();
139 complex_n(iv, 1) = n.imag();
171 Numeric& refr_index_air,
172 Numeric& refr_index_air_group,
173 const Agenda& refr_index_air_agenda,
174 ConstVectorView p_grid,
175 ConstVectorView refellipsoid,
176 ConstTensor3View z_field,
177 ConstTensor3View t_field,
178 ConstTensor4View vmr_field,
179 ConstVectorView f_grid,
181 Numeric rtp_pressure, rtp_temperature;
186 gridpos(gp, z_field(joker, 0, 0), Vector(1, r - refellipsoid[0]));
194 itw2p(dummy, p_grid, gp, itw);
195 rtp_pressure = dummy[0];
198 interp(dummy, itw, t_field(joker, 0, 0), gp);
199 rtp_temperature = dummy[0];
202 const Index ns = vmr_field.nbooks();
206 for (Index is = 0; is < ns; is++) {
207 interp(dummy, itw, vmr_field(is, joker, 0, 0), gp);
208 rtp_vmr[is] = dummy[0];
213 refr_index_air_group,
218 refr_index_air_agenda);
251 Numeric& refr_index_air,
252 Numeric& refr_index_air_group,
253 const Agenda& refr_index_air_agenda,
254 ConstVectorView p_grid,
255 ConstVectorView lat_grid,
256 ConstVectorView refellipsoid,
257 ConstTensor3View z_field,
258 ConstTensor3View t_field,
259 ConstTensor4View vmr_field,
260 ConstVectorView f_grid,
262 const Numeric& lat) {
263 Numeric rtp_pressure, rtp_temperature;
267 const Index np = p_grid.nelem();
271 gridpos(gp_lat, lat_grid, ExhaustiveConstVectorView{lat});
272 z_at_lat_2d(z_grid, p_grid, lat_grid, z_field(joker, joker, 0), gp_lat[0]);
275 const Numeric rellips =
refell2d(refellipsoid, lat_grid, gp_lat[0]);
279 gridpos(gp_p, z_grid, Vector(1, r - rellips));
287 itw2p(dummy, p_grid, gp_p, itw);
288 rtp_pressure = dummy[0];
293 interp(dummy, itw, t_field(joker, joker, 0), gp_p, gp_lat);
294 rtp_temperature = dummy[0];
297 const Index ns = vmr_field.nbooks();
301 for (Index is = 0; is < ns; is++) {
302 interp(dummy, itw, vmr_field(is, joker, joker, 0), gp_p, gp_lat);
303 rtp_vmr[is] = dummy[0];
308 refr_index_air_group,
313 refr_index_air_agenda);
344 Numeric& refr_index_air,
345 Numeric& refr_index_air_group,
346 const Agenda& refr_index_air_agenda,
347 ConstVectorView p_grid,
348 ConstVectorView lat_grid,
349 ConstVectorView lon_grid,
350 ConstVectorView refellipsoid,
351 ConstTensor3View z_field,
352 ConstTensor3View t_field,
353 ConstTensor4View vmr_field,
354 ConstVectorView f_grid,
357 const Numeric& lon) {
358 Numeric rtp_pressure, rtp_temperature;
362 const Index np = p_grid.nelem();
366 gridpos(gp_lat, lat_grid, ExhaustiveConstVectorView{lat});
367 gridpos(gp_lon, lon_grid, ExhaustiveConstVectorView{lon});
369 z_grid, p_grid, lat_grid, lon_grid, z_field, gp_lat[0], gp_lon[0]);
372 const Numeric rellips =
refell2d(refellipsoid, lat_grid, gp_lat[0]);
376 gridpos(gp_p, z_grid, Vector(1, r - rellips));
384 itw2p(dummy, p_grid, gp_p, itw);
385 rtp_pressure = dummy[0];
390 interp(dummy, itw, t_field, gp_p, gp_lat, gp_lon);
391 rtp_temperature = dummy[0];
394 const Index ns = vmr_field.nbooks();
398 for (Index is = 0; is < ns; is++) {
400 dummy, itw, vmr_field(is, joker, joker, joker), gp_p, gp_lat, gp_lon);
401 rtp_vmr[is] = dummy[0];
406 refr_index_air_group,
411 refr_index_air_agenda);
441 Numeric& refr_index_air,
442 Numeric& refr_index_air_group,
444 const Agenda& refr_index_air_agenda,
445 ConstVectorView p_grid,
446 ConstVectorView refellipsoid,
447 ConstTensor3View z_field,
448 ConstTensor3View t_field,
449 ConstTensor4View vmr_field,
450 ConstVectorView f_grid,
454 refr_index_air_group,
455 refr_index_air_agenda,
464 const Numeric n0 = refr_index_air;
470 refr_index_air_agenda,
479 dndr = refr_index_air - n0;
518 Numeric& refr_index_air,
519 Numeric& refr_index_air_group,
522 const Agenda& refr_index_air_agenda,
523 ConstVectorView p_grid,
524 ConstVectorView lat_grid,
525 ConstVectorView refellipsoid,
526 ConstTensor3View z_field,
527 ConstTensor3View t_field,
528 ConstTensor4View vmr_field,
529 ConstVectorView f_grid,
531 const Numeric& lat) {
534 refr_index_air_group,
535 refr_index_air_agenda,
546 const Numeric n0 = refr_index_air;
552 refr_index_air_agenda,
563 dndr = refr_index_air - n0;
565 const Numeric dlat = 1e-4;
570 refr_index_air_agenda,
581 dndlat = (refr_index_air - n0) / (
DEG2RAD * dlat * r);
624 Numeric& refr_index_air,
625 Numeric& refr_index_air_group,
629 const Agenda& refr_index_air_agenda,
630 ConstVectorView p_grid,
631 ConstVectorView lat_grid,
632 ConstVectorView lon_grid,
633 ConstVectorView refellipsoid,
634 ConstTensor3View z_field,
635 ConstTensor3View t_field,
636 ConstTensor4View vmr_field,
637 ConstVectorView f_grid,
640 const Numeric& lon) {
643 refr_index_air_group,
644 refr_index_air_agenda,
657 const Numeric n0 = refr_index_air;
663 refr_index_air_agenda,
676 dndr = refr_index_air - n0;
678 const Numeric dlat = 1e-4;
683 refr_index_air_agenda,
696 dndlat = (refr_index_air - n0) / (
DEG2RAD * dlat * r);
698 const Numeric dlon = 1e-4;
703 refr_index_air_agenda,
716 dndlon = (refr_index_air - n0) / (
DEG2RAD * dlon * r * cos(
DEG2RAD * lat));
722 const Index& only_valid_range,
723 const Numeric& frequency,
724 const Numeric& temperature,
725 const Numeric& density) {
730 const Numeric T_star = 273.15;
731 const Numeric rho_star = 1000;
732 const Numeric lambda_star = 0.589;
735 bool T_ok = (temperature > T_star - 12) && (temperature < T_star + 500);
736 bool rho_ok = (density > 0) && (density < 1060);
737 bool wvl_ok = (wavelength > 0.2) && (wavelength < 1.9);
739 if (only_valid_range) {
741 "Refractive index is calculated outside range of "
743 "Temperature must be between ",
748 "Desired temperature: ",
753 "Refractive index is calculated outside range of "
755 "Density must be between ",
768 "Refractive index is calculated outside range of "
770 "Frequency must be between ",
781 const Numeric a0 = 0.244257733;
782 const Numeric a1 = 9.74634476e-3;
783 const Numeric a2 = -3.73234996e-3;
784 const Numeric a3 = 2.68678472e-4;
785 const Numeric a4 = 1.58920570e-3;
786 const Numeric a5 = 2.45934259e-3;
787 const Numeric a6 = 0.900704920;
788 const Numeric a7 = -1.66626219e-2;
790 const Numeric lambda_uv = 0.2292020;
791 const Numeric lambda_ir = 5.432937;
794 Numeric T_bar = temperature / T_star;
795 Numeric rho_bar = density / rho_star;
796 Numeric lambda_bar = wavelength / lambda_star;
802 rhs += a3 * lambda_bar * lambda_bar * T_bar;
803 rhs += a4 / (lambda_bar * lambda_bar);
804 rhs += a5 / (lambda_bar * lambda_bar - lambda_uv * lambda_uv);
805 rhs += a6 / (lambda_bar * lambda_bar - lambda_ir * lambda_ir);
806 rhs += a7 * rho_bar * rho_bar;
812 Complex n_cmplx = sqrt(-2 *
a - 1);
813 n_cmplx /= sqrt(
a - 1);
base max(const Array< base > &x)
Max function.
base min(const Array< base > &x)
Min function.
Constants of physical expressions as constexpr.
void refr_index_air_agendaExecute(Workspace &ws, Numeric &refr_index_air, Numeric &refr_index_air_group, const Numeric rtp_pressure, const Numeric rtp_temperature, const Vector &rtp_vmr, const Vector &f_grid, const Agenda &input_agenda)
#define ARTS_USER_ERROR_IF(condition,...)
Numeric refell2d(ConstVectorView refellipsoid, ConstVectorView lat_grid, const GridPos gp)
refell2d
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
Header file for interpolation.cc.
constexpr Numeric temperature_at_0c
Global constant, Temperature in Celsius of 0 Kelvin.
constexpr auto deg2rad(auto x) noexcept
Converts degrees to radians.
constexpr auto freq2wavelen(auto x) noexcept
Conversion from Hz to wavelength.
constexpr auto rad2deg(auto x) noexcept
Converts radians to degrees.
constexpr auto wavelen2freq(auto x) noexcept
Conversion from wavelength to Hz.
void refr_gradients_3d(Workspace &ws, Numeric &refr_index_air, Numeric &refr_index_air_group, Numeric &dndr, Numeric &dndlat, Numeric &dndlon, const Agenda &refr_index_air_agenda, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstVectorView refellipsoid, ConstTensor3View z_field, ConstTensor3View t_field, ConstTensor4View vmr_field, ConstVectorView f_grid, const Numeric &r, const Numeric &lat, const Numeric &lon)
refr_gradients_3d
void get_refr_index_3d(Workspace &ws, Numeric &refr_index_air, Numeric &refr_index_air_group, const Agenda &refr_index_air_agenda, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstVectorView refellipsoid, ConstTensor3View z_field, ConstTensor3View t_field, ConstTensor4View vmr_field, ConstVectorView f_grid, const Numeric &r, const Numeric &lat, const Numeric &lon)
void complex_n_ice_matzler06(Matrix &complex_n, const Vector &f_grid, const Numeric &t)
complex_n_ice_matzler06
void get_refr_index_1d(Workspace &ws, Numeric &refr_index_air, Numeric &refr_index_air_group, const Agenda &refr_index_air_agenda, ConstVectorView p_grid, ConstVectorView refellipsoid, ConstTensor3View z_field, ConstTensor3View t_field, ConstTensor4View vmr_field, ConstVectorView f_grid, const Numeric &r)
get_refr_index_1d
void refr_gradients_2d(Workspace &ws, Numeric &refr_index_air, Numeric &refr_index_air_group, Numeric &dndr, Numeric &dndlat, const Agenda &refr_index_air_agenda, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView refellipsoid, ConstTensor3View z_field, ConstTensor3View t_field, ConstTensor4View vmr_field, ConstVectorView f_grid, const Numeric &r, const Numeric &lat)
refr_gradients_2d
constexpr Numeric DEG2RAD
void get_refr_index_2d(Workspace &ws, Numeric &refr_index_air, Numeric &refr_index_air_group, const Agenda &refr_index_air_agenda, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView refellipsoid, ConstTensor3View z_field, ConstTensor3View t_field, ConstTensor4View vmr_field, ConstVectorView f_grid, const Numeric &r, const Numeric &lat)
get_refr_index_2d
constexpr Numeric RAD2DEG
void refr_gradients_1d(Workspace &ws, Numeric &refr_index_air, Numeric &refr_index_air_group, Numeric &dndr, const Agenda &refr_index_air_agenda, ConstVectorView p_grid, ConstVectorView refellipsoid, ConstTensor3View z_field, ConstTensor3View t_field, ConstTensor4View vmr_field, ConstVectorView f_grid, const Numeric &r)
refr_gradients_1d
void complex_n_water_liebe93(Matrix &complex_n, const Vector &f_grid, const Numeric &t)
complex_n_water_liebe93
void refractive_index_water_and_steam_VisNIR(Numeric &n, const Index &only_valid_range, const Numeric &frequency, const Numeric &temperature, const Numeric &density)
Refractive index of water and steam for the optical and near infrared .
constexpr Numeric TEMP_0_C
void itw2p(VectorView p_values, ConstVectorView p_grid, const ArrayOfGridPos &gp, ConstMatrixView itw)
Converts interpolation weights to pressures.
void z_at_latlon(VectorView z, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstTensor3View z_field, const GridPos &gp_lat, const GridPos &gp_lon)
Returns the geomtrical altitudes of p_grid for one latitude and one longitude.
void z_at_lat_2d(VectorView z, ConstVectorView p_grid, ConstVectorView lat_grid, ConstMatrixView z_field, const GridPos &gp_lat)
Returns the geomtrical altitudes of p_grid for one latitude.
Header file for special_interp.cc.