56 #define F11 pha_mat_int[0] 57 #define F12 pha_mat_int[1] 58 #define F22 pha_mat_int[2] 59 #define F33 pha_mat_int[3] 60 #define F34 pha_mat_int[4] 61 #define F44 pha_mat_int[5] 98 if (stokes_dim > 4 || stokes_dim < 1){
99 throw runtime_error(
"The dimension of the stokes vector \n" 100 "must be 1,2,3 or 4");
103 switch (particle_type){
108 out0 <<
"Case PARTICLE_TYPE_GENERAL not yet implemented. \n";
118 abs_vec_lab[0] = abs_vec_data(0,0,0);
124 assert (abs_vec_data.
ncols() == 2);
143 gridpos(gp,this_za_datagrid,180-za_sca);
147 gridpos(gp,this_za_datagrid,za_sca);
153 if( stokes_dim == 1 ){
162 out0 <<
"Not all particle type cases are implemented\n";
203 if (stokes_dim > 4 || stokes_dim < 1){
204 throw runtime_error(
"The dimension of the stokes vector \n" 205 "must be 1,2,3 or 4");
208 switch (particle_type){
213 out0 <<
"Case PARTICLE_TYPE_GENERAL not yet implemented. \n";
218 assert (ext_mat_data.
ncols() == 1);
226 ext_mat_lab(0,0) = ext_mat_data(0,0,0);
229 if( stokes_dim == 1 ){
233 ext_mat_lab(1,1) = ext_mat_data(0,0,0);
235 if( stokes_dim == 2 ){
239 ext_mat_lab(2,2) = ext_mat_data(0,0,0);
241 if( stokes_dim == 3 ){
245 ext_mat_lab(3,3) = ext_mat_data(0,0,0);
251 assert (ext_mat_data.
ncols() == 3);
273 gridpos(gp,this_za_datagrid,180-za_sca);
277 gridpos(gp,this_za_datagrid,za_sca);
284 ext_mat_lab(0,0)=Kjj;
286 if( stokes_dim == 1 ){
291 ext_mat_lab(1,1)=Kjj;
292 ext_mat_lab(0,1)=K12;
293 ext_mat_lab(1,0)=K12;
295 if( stokes_dim == 2 ){
299 ext_mat_lab(2,2)=Kjj;
301 if( stokes_dim == 3 ){
306 ext_mat_lab(2,3)=K34;
307 ext_mat_lab(3,2)=-K34;
308 ext_mat_lab(3,3)=Kjj;
315 out0 <<
"Not all particle type cases are implemented\n";
352 const Index& za_sca_idx,
353 const Index& aa_sca_idx,
354 const Index& za_inc_idx,
355 const Index& aa_inc_idx,
362 Numeric za_sca = scat_za_grid[za_sca_idx];
363 Numeric aa_sca = scat_aa_grid[aa_sca_idx];
364 Numeric za_inc = scat_za_grid[za_inc_idx];
365 Numeric aa_inc = scat_aa_grid[aa_inc_idx];
367 if (stokes_dim > 4 || stokes_dim < 1){
368 throw runtime_error(
"The dimension of the stokes vector \n" 369 "must be 1,2,3 or 4");
372 switch (particle_type){
377 out0 <<
"Case PARTICLE_TYPE_GENERAL not yet implemented. \n";
390 za_datagrid, za_sca, aa_sca,
410 assert (pha_mat_data.
ncols()==16);
411 Numeric delta_aa=aa_sca-aa_inc+(aa_sca-aa_inc<-180)*360-
412 (aa_sca-aa_inc>180)*360;
419 gridpos(delta_aa_gp,aa_datagrid,
abs(delta_aa));
422 gridpos(za_inc_gp,this_za_datagrid,180-za_inc);
423 gridpos(za_sca_gp,za_datagrid,180-za_sca);
427 gridpos(za_inc_gp,this_za_datagrid,za_inc);
428 gridpos(za_sca_gp,za_datagrid,za_sca);
435 za_sca_gp,delta_aa_gp,za_inc_gp);
436 if( stokes_dim == 1 ){
441 za_sca_gp,delta_aa_gp,za_inc_gp);
444 za_sca_gp,delta_aa_gp,za_inc_gp);
447 za_sca_gp,delta_aa_gp,za_inc_gp);
448 if( stokes_dim == 2 ){
451 if ((za_inc<=90 && delta_aa>=0)||(za_inc>90 && delta_aa<0))
455 za_sca_gp,delta_aa_gp,za_inc_gp);
458 za_sca_gp,delta_aa_gp,za_inc_gp);
461 za_sca_gp,delta_aa_gp,za_inc_gp);
464 za_sca_gp,delta_aa_gp,za_inc_gp);
470 za_sca_gp,delta_aa_gp,za_inc_gp);
473 za_sca_gp,delta_aa_gp,za_inc_gp);
476 za_sca_gp,delta_aa_gp,za_inc_gp);
479 za_sca_gp,delta_aa_gp,za_inc_gp);
483 za_sca_gp,delta_aa_gp,za_inc_gp);
484 if( stokes_dim == 3 ){
487 if ((za_inc<=90 && delta_aa>=0)||(za_inc>90 && delta_aa<0))
491 za_sca_gp,delta_aa_gp,za_inc_gp);
494 za_sca_gp,delta_aa_gp,za_inc_gp);
497 za_sca_gp,delta_aa_gp,za_inc_gp);
500 za_sca_gp,delta_aa_gp,za_inc_gp);
506 za_sca_gp,delta_aa_gp,za_inc_gp);
509 za_sca_gp,delta_aa_gp,za_inc_gp);
512 za_sca_gp,delta_aa_gp,za_inc_gp);
515 za_sca_gp,delta_aa_gp,za_inc_gp);
519 za_sca_gp,delta_aa_gp,za_inc_gp);
522 za_sca_gp,delta_aa_gp,za_inc_gp);
525 za_sca_gp,delta_aa_gp,za_inc_gp);
532 out0 <<
"Not all particle type cases are implemented\n";
572 const Index& stokes_dim)
574 assert( stokes_dim>=1 && stokes_dim<=4 );
575 assert( ext_mat.
nrows() == stokes_dim );
576 assert( ext_mat.
ncols() == stokes_dim );
577 assert( abs_vec.
nelem() == stokes_dim );
580 for (
Index is=0; is<stokes_dim; is++)
582 ext_mat(is,is) += abs_vec[0];
585 for (
Index is=1; is<stokes_dim; is++)
587 ext_mat(0,is) += abs_vec[is];
588 ext_mat(is,0) += abs_vec[is];
623 const Index& za_sca_idx,
624 const Index& aa_sca_idx,
625 const Index& za_inc_idx,
626 const Index& aa_inc_idx,
635 for (
Index i = 0; i < 6; i++)
637 pha_mat_int[i] =
interp(itw, pha_mat_data(
joker, 0, 0, 0, i),
638 scat_theta_gps[za_sca_idx][aa_sca_idx][za_inc_idx][aa_inc_idx]);
690 if( (
abs(aa_sca-aa_inc)<ANG_TOL) || (
abs(
abs(aa_sca-aa_inc)-360) < ANG_TOL) )
694 else if (
abs(
abs(aa_sca-aa_inc)-180)<ANG_TOL)
696 theta_rad=
DEG2RAD*(za_sca+za_inc);
697 if (theta_rad>
PI){theta_rad=2*
PI-theta_rad;}
707 assert (pha_mat_data.
ncols() == 6);
709 theta_rad = acos(cos(za_sca_rad) * cos(za_inc_rad) +
710 sin(za_sca_rad) * sin(za_inc_rad) *
711 cos(aa_sca_rad - aa_inc_rad));
718 gridpos(thet_gp, za_datagrid, theta);
723 for (
Index i = 0; i < 6; i++)
725 pha_mat_int[i] =
interp(itw, pha_mat_data(
joker, 0, 0, 0, i),
782 pha_mat_lab(0,0) =
F11;
784 if( stokes_dim > 1 ){
794 ((theta > -.01) && (theta < .01) ) ||
796 ((theta > 179.99) && (theta < 180.01)) ||
798 ((aa_sca == aa_inc) || (aa_sca == 360-aa_inc) || (aa_inc == 360-aa_sca) ||
799 (aa_sca == 180-aa_inc) || (aa_inc == 180-aa_sca) )
802 pha_mat_lab(0,1) =
F12;
803 pha_mat_lab(1,0) =
F12;
804 pha_mat_lab(1,1) =
F22;
806 if( stokes_dim > 2 ){
807 pha_mat_lab(0,2) = 0;
808 pha_mat_lab(1,2) = 0;
809 pha_mat_lab(2,0) = 0;
810 pha_mat_lab(2,1) = 0;
811 pha_mat_lab(2,2) =
F33;
813 if( stokes_dim > 3 ){
814 pha_mat_lab(0,3) = 0;
815 pha_mat_lab(1,3) = 0;
816 pha_mat_lab(2,3) =
F34;
817 pha_mat_lab(3,0) = 0;
818 pha_mat_lab(3,1) = 0;
819 pha_mat_lab(3,2) = -
F34;
820 pha_mat_lab(3,3) =
F44;
834 if (za_inc_rad < ANGTOL)
836 sigma1 =
PI + aa_sca_rad - aa_inc_rad;
839 else if (za_inc_rad >
PI-ANGTOL)
841 sigma1 = aa_sca_rad - aa_inc_rad;
844 else if (za_sca_rad < ANGTOL)
847 sigma2 =
PI + aa_sca_rad - aa_inc_rad;
849 else if (za_sca_rad >
PI - ANGTOL)
852 sigma2 = aa_sca_rad - aa_inc_rad;
856 s1 = (cos(za_sca_rad) - cos(za_inc_rad) * cos(theta_rad))
857 /(sin(za_inc_rad)*sin(theta_rad));
858 s2 = (cos(za_inc_rad) - cos(za_sca_rad) * cos (theta_rad))/
859 (sin(za_sca_rad)*sin(theta_rad));
866 if ( isnan(sigma1) || isnan(sigma2) )
868 if (
abs(s1 - 1) < ANGTOL)
870 if (
abs(s1 + 1) < ANGTOL)
872 if (
abs(s2 - 1) < ANGTOL)
874 if (
abs(s2 + 1) < ANGTOL)
879 const Numeric C1 = cos(2*sigma1);
880 const Numeric C2 = cos(2*sigma2);
882 const Numeric S1 = sin(2*sigma1);
883 const Numeric S2 = sin(2*sigma2);
885 pha_mat_lab(0,1) = C1 *
F12;
886 pha_mat_lab(1,0) = C2 *
F12;
887 pha_mat_lab(1,1) = C1 * C2 *
F22 - S1 * S2 *
F33;
889 assert(!isnan(pha_mat_lab(0,1)));
890 assert(!isnan(pha_mat_lab(1,0)));
891 assert(!isnan(pha_mat_lab(1,1)));
893 if( stokes_dim > 2 ){
903 Numeric delta_aa=aa_sca-aa_inc+(aa_sca-aa_inc<-180)*360-
904 (aa_sca-aa_inc>180)*360;
907 pha_mat_lab(0,2) = S1 *
F12;
908 pha_mat_lab(1,2) = S1 * C2 *
F22 + C1 * S2 *
F33;
909 pha_mat_lab(2,0) = -S2 *
F12;
910 pha_mat_lab(2,1) = -C1 * S2 *
F22 - S1 * C2 *
F33;
914 pha_mat_lab(0,2) = -S1 *
F12;
915 pha_mat_lab(1,2) = -S1 * C2 *
F22 - C1 * S2 *
F33;
916 pha_mat_lab(2,0) = S2 *
F12;
917 pha_mat_lab(2,1) = C1 * S2 *
F22 + S1 * C2 *
F33;
919 pha_mat_lab(2,2) = -S1 * S2 *
F22 + C1 * C2 *
F33;
921 if( stokes_dim > 3 ){
924 pha_mat_lab(1,3) = S2 *
F34;
925 pha_mat_lab(3,1) = S1 *
F34;
929 pha_mat_lab(1,3) = -S2 *
F34;
930 pha_mat_lab(3,1) = -S1 *
F34;
932 pha_mat_lab(0,3) = 0;
933 pha_mat_lab(2,3) = C2 *
F34;
934 pha_mat_lab(3,0) = 0;
935 pha_mat_lab(3,2) = -C1 *
F34;
936 pha_mat_lab(3,3) =
F44;
946 os <<
"SingleScatteringData: Output operator not implemented";
953 os <<
"ArrayOfSingleScatteringData: Output operator not implemented";
959 os <<
"ScatteringMetaData: Output operator not implemented";
966 os <<
"ArrayOfScatteringMetaData: Output operator not implemented";
991 const Tensor4 propmat_clearsky)
999 abs_vec.
resize( freq_dim, stokes_dim );
1003 ext_mat.
resize( freq_dim, stokes_dim, stokes_dim );
1007 for (
Index iv=0; iv<freq_dim; ++iv )
1008 for (
Index is1=0; is1<stokes_dim; ++is1 )
1010 abs_vec(iv,is1) += propmat_clearsky(
joker,iv,is1,0).sum();
1011 for (
Index is2=0; is2<stokes_dim; ++is2 )
1012 ext_mat(iv,is1,is2) += propmat_clearsky(
joker,iv,is1,is2).sum();
1029 if (particle_type_string ==
"general")
1031 else if (particle_type_string ==
"macroscopically_isotropic")
1033 else if (particle_type_string ==
"horizontally_aligned")
1035 else if (particle_type_string ==
"spherical")
1040 os <<
"Unknown particle type: " << particle_type_string << endl
1041 <<
"Valid types are: general, macroscopically_isotropic, " 1042 <<
"horizontally_aligned and spherical.";
1043 throw std::runtime_error(os.str());
1046 return particle_type;
1061 String particle_type_string;
1063 switch (particle_type) {
1065 particle_type_string =
"general";
1068 particle_type_string =
"macroscopically_isotropic";
1071 particle_type_string =
"horizontally_aligned";
1074 particle_type_string =
"spherical";
1078 os <<
"Internal error: Cannot map ParticleType enum value " 1079 << particle_type <<
" to String.";
1080 throw std::runtime_error(os.str());
1084 return particle_type_string;
1100 if (particle_ssdmethod_string ==
"tmatrix")
1105 os <<
"Unknown particle SSD method: " << particle_ssdmethod_string << endl
1106 <<
"Valid methods: tmatrix";
1107 throw std::runtime_error(os.str());
1110 return particle_ssdmethod;
1125 String particle_ssdmethod_string;
1127 switch (particle_ssdmethod) {
1129 particle_ssdmethod_string =
"tmatrix";
1133 os <<
"Internal error: Cannot map ParticleSSDMethod enum value " 1134 << particle_ssdmethod <<
" to String.";
1135 throw std::runtime_error(os.str());
1139 return particle_ssdmethod_string;
Index npages() const
Returns the number of pages.
INDEX Index
The type to use for all integer numbers and indices.
void pha_mat_labCalc(MatrixView pha_mat_lab, ConstVectorView pha_mat_int, const Numeric &za_sca, const Numeric &aa_sca, const Numeric &za_inc, const Numeric &aa_inc, const Numeric &theta_rad)
Calculate phase matrix in laboratory coordinate system.
Declarations having to do with the four output streams.
void ext_matTransform(MatrixView ext_mat_lab, ConstTensor3View ext_mat_data, ConstVectorView za_datagrid, ConstVectorView aa_datagrid, const ParticleType &particle_type, const Numeric &za_sca, const Numeric &aa_sca, const Verbosity &verbosity)
Transformation of extinction matrix.
void abs_vecTransform(VectorView abs_vec_lab, ConstTensor3View abs_vec_data, ConstVectorView za_datagrid, ConstVectorView aa_datagrid, const ParticleType &particle_type, const Numeric &za_sca, const Numeric &aa_sca, const Verbosity &verbosity)
Transformation of absorption vector.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
Index npages() const
Returns the number of pages.
ParticleType
An attribute to classify the particle type in a SingleScatteringData structure.
This file contains basic functions to handle XML data files.
Structure which describes the single scattering properties of a particle or a particle distribution...
Header file for interpolation.cc.
String ParticleTypeToString(const ParticleType &particle_type)
Convert particle type enum value to String.
Index nelem() const
Returns the number of elements.
Structure to store a grid position.
This file contains the definition of Array.
The implementation for String, the ARTS string class.
Index ncols() const
Returns the number of columns.
The global header file for ARTS.
ParticleSSDMethod ParticleSSDMethodFromString(const String &particle_ssdmethod_string)
Convert particle ssd method name to enum value.
Index ncols() const
Returns the number of columns.
void pha_matTransform(MatrixView pha_mat_lab, ConstTensor5View pha_mat_data, ConstVectorView za_datagrid, ConstVectorView aa_datagrid, const ParticleType &particle_type, const Index &za_sca_idx, const Index &aa_sca_idx, const Index &za_inc_idx, const Index &aa_inc_idx, ConstVectorView scat_za_grid, ConstVectorView scat_aa_grid, const Verbosity &verbosity)
Transformation of phase matrix.
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
void interpolate_scat_angle(VectorView pha_mat_int, Numeric &theta_rad, ConstTensor5View pha_mat_data, ConstVectorView za_datagrid, const Numeric &za_sca, const Numeric &aa_sca, const Numeric &za_inc, const Numeric &aa_inc)
Interpolate data on the scattering angle.
A constant view of a Tensor5.
NUMERIC Numeric
The type to use for all floating point numbers.
ParticleSSDMethod
An attribute to classify the method to be used for SingleScatteringData.
void resize(Index p, Index r, Index c)
Resize function.
Header file for logic.cc.
Index npages() const
Returns the number of pages.
This can be used to make arrays out of anything.
A constant view of a Tensor3.
A constant view of a Vector.
void interpolate_scat_angleDOIT(VectorView pha_mat_int, ConstTensor5View pha_mat_data, const Index &za_sca_idx, const Index &aa_sca_idx, const Index &za_inc_idx, const Index &aa_inc_idx, const ArrayOfArrayOfArrayOfArrayOfGridPos &scat_theta_gps, ConstTensor5View scat_theta_itws)
Interpolate data on the scattering angle.
Index ncols() const
Returns the number of columns.
Index ncols() const
Returns the number of columns.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
Scattering database structure and functions.
void ext_matFromabs_vec(MatrixView ext_mat, ConstVectorView abs_vec, const Index &stokes_dim)
Derive extinction matrix from absorption vector.
Index nrows() const
Returns the number of rows.
ostream & operator<<(ostream &os, const SingleScatteringData &)
ParticleType ParticleTypeFromString(const String &particle_type_string)
Convert particle name to enum value.
void resize(Index r, Index c)
Resize function.
void opt_prop_sum_propmat_clearsky(Tensor3 &ext_mat, Matrix &abs_vec, const Tensor4 propmat_clearsky)
Get optical properties from propmat_clearsky.