00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00044
00045
00046
00047
00048 #include "arts.h"
00049 #include "auto_md.h"
00050 #include "check_input.h"
00051 #include "logic.h"
00052 #include "math_funcs.h"
00053 #include "messages.h"
00054 #include "physics_funcs.h"
00055
00056 extern const Numeric COSMIC_BG_TEMP;
00057 extern const Numeric TEMP_0_C;
00058
00059
00060
00061
00062
00063
00064
00065
00066 void complex_nWaterLiebe93(
00067 Matrix& complex_n,
00068 const Vector& f_grid,
00069 const Numeric& t )
00070 {
00071 chk_if_in_range( "t", t, TEMP_0_C, TEMP_0_C+100 );
00072 chk_if_in_range( "min of f_grid", min(f_grid), 10e9, 1000e9 );
00073 chk_if_in_range( "max of f_grid", max(f_grid), 10e9, 1000e9 );
00074
00075 out2 << " Sets *complex_n* to model properties of liquid water,\n"
00076 << " according to Liebe 1993\n";
00077 out3 << " temperature : " << t << " K.\n";
00078
00079 const Index nf = f_grid.nelem();
00080
00081 complex_n.resize( nf, 2 );
00082
00083
00084
00085
00086 const Numeric theta = 1 - 300 / t;
00087 const Numeric e0 = 77.66 - 103.3 * theta;
00088 const Numeric e1 = 0.0671 * e0;
00089 const Numeric f1 = 20.2 + 146.4 * theta + 316 * theta * theta;
00090 const Numeric e2 = 3.52;
00091 const Numeric f2 = 39.8 * f1;
00092
00093 for( Index iv=0; iv<nf; iv++ )
00094 {
00095 const Complex ifGHz( 0.0, f_grid[iv]/1e9 );
00096
00097 Complex eps = e2 + (e1-e2) / (Numeric(1.0)-ifGHz/f2) +
00098 (e0-e1) / (Numeric(1.0)-ifGHz/f1);
00099
00100 complex_n(iv,0) = eps.real();
00101 complex_n(iv,1) = eps.imag();
00102 }
00103 }
00104
00105
00106
00107 void emissionPlanck(
00108 Vector& emission,
00109 const Vector& f,
00110 const Numeric& t )
00111 {
00112 const Index n = f.nelem();
00113
00114 emission.resize(n);
00115
00116 for( Index i=0; i<n; i++ )
00117 { emission[i] = planck( f[i], t ); }
00118 }
00119
00120
00121
00122 void MatrixCBR(
00123
00124 Matrix& m,
00125
00126 const Index& stokes_dim,
00127
00128 const Vector& f)
00129 {
00130 const Index n = f.nelem();
00131
00132 if( n == 0 )
00133 throw runtime_error( "The given frequency vector is empty." );
00134
00135 m.resize(n,stokes_dim);
00136 m = 0;
00137
00138 for( Index i=0; i<n; i++ )
00139 { m(i,0) = planck( f[i], COSMIC_BG_TEMP ); }
00140 }
00141
00142
00143
00144 void MatrixPlanck(
00145
00146 Matrix& m,
00147
00148 const Index& stokes_dim,
00149
00150 const Vector& f,
00151 const Numeric& t)
00152 {
00153 const Index n = f.nelem();
00154
00155 if( n == 0 )
00156 throw runtime_error( "The given frequency vector is empty." );
00157
00158 out2 << " Setting blackbody radiation for a temperature of " << t << " K.\n";
00159
00160 m.resize(n,stokes_dim);
00161 m = 0;
00162
00163 for( Index i=0; i<n; i++ )
00164 { m(i,0) = planck( f[i], t ); }
00165 }
00166
00167
00168
00169
00170
00171 void MatrixUnitIntensity(
00172
00173 Matrix& m,
00174
00175 const Index& stokes_dim,
00176
00177 const Vector& f)
00178 {
00179 const Index n = f.nelem();
00180
00181 if( n == 0 )
00182 throw runtime_error( "The given frequency vector is empty." );
00183
00184 out2 << " Setting unpolarised radiation with an intensity of 1.\n";
00185
00186 m.resize(n,stokes_dim);
00187 m = 0;
00188
00189 for( Index i=0; i<n; i++ )
00190 { m(i,0) = 1.0; }
00191 }
00192
00193
00194
00195 void Tensor6ToPlanckBT(
00196 Tensor6& y_out,
00197
00198 const Index& scat_f_index,
00199 const Vector& f_grid,
00200
00201 const Tensor6& y_in)
00202
00203 {
00204
00205 const Index nv = y_in.nvitrines();
00206 const Index ns = y_in.nshelves();
00207 const Index nb = y_in.nbooks();
00208 const Index np = y_in.npages();
00209 const Index nr = y_in.nrows();
00210 const Index nc = y_in.ncols();
00211
00212 Numeric f = f_grid[scat_f_index];
00213
00214
00215 if ( &y_out != &y_in )
00216 {
00217 y_out.resize(nv, ns, nb, np, nr, nc);
00218 }
00219
00220 for( Index iv = 0; iv < nv; ++ iv )
00221 {
00222 for( Index is = 0; is < ns; ++ is )
00223 {
00224 for( Index ib = 0; ib < nb; ++ ib )
00225 {
00226 for( Index ip = 0; ip < np; ++ ip )
00227 {
00228 for( Index ir = 0; ir < nr; ++ ir )
00229 {
00230 for( Index ic = 0; ic < nc; ++ ic)
00231 {
00232 y_out(iv, is, ib, ip, ir, ic) =
00233 invplanck( y_in (iv, is, ib, ip, ir, ic ), f);
00234 }
00235 }
00236 }
00237 }
00238 }
00239 }
00240 }
00241