ARTS  2.3.1285(git:92a29ea9-dirty)
cloudbox.cc File Reference

Internal functions for scattering calculations. More...

#include "cloudbox.h"
#include <algorithm>
#include <cmath>
#include <ctime>
#include <limits>
#include <stdexcept>
#include "arts.h"
#include "check_input.h"
#include "lin_alg.h"
#include "logic.h"
#include "math_funcs.h"
#include "mc_antenna.h"
#include "messages.h"
#include "physics_funcs.h"
#include "ppath.h"
#include "rng.h"
#include "sorting.h"

Go to the source code of this file.

Functions

void chk_pnd_data (const GriddedField3 &pnd_field_raw, const String &pnd_field_file, const Index &atmosphere_dim, const Verbosity &verbosity)
 Check particle number density files. More...
 
void chk_pnd_raw_data (const ArrayOfGriddedField3 &pnd_field_raw, const String &pnd_field_file, const Index &atmosphere_dim, const Verbosity &verbosity)
 Check particle number density files (pnd_field_raw) More...
 
void chk_pnd_field_raw_only_in_cloudbox (const Index &dim, const ArrayOfGriddedField3 &pnd_field_raw, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, const ArrayOfIndex &cloudbox_limits)
 chk_pnd_field_raw_only_in_cloudbox More...
 
void chk_scat_species (const ArrayOfString &scat_species, const String &delim)
 Check validity of scat_species setting. More...
 
void chk_scattering_data (const ArrayOfSingleScatteringData &scat_data, const ArrayOfScatteringMetaData &scat_meta, const Verbosity &)
 Check scattering data general. More...
 
void chk_scattering_meta_data (const ScatteringMetaData &scat_meta_single, const String &scat_meta_file, const Verbosity &verbosity)
 Check scattering data meta. More...
 
void chk_scat_data (const SingleScatteringData &scat_data_single, const Verbosity &verbosity)
 Check single scattering data. More...
 
bool is_gp_inside_cloudbox (const GridPos &gp_p, const GridPos &gp_lat, const GridPos &gp_lon, const ArrayOfIndex &cloudbox_limits, const bool &include_boundaries, const Index &atmosphere_dim)
 
bool is_inside_cloudbox (const Ppath &ppath_step, const ArrayOfIndex &cloudbox_limits, const bool include_boundaries)
 
void bin_quadweights (Vector &w, const Vector &x, const Index &order)
 
void chk_scat_species_field (bool &empty_flag, const Tensor3 &scat_species_field, const String &fieldname, const Index &dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid)
 Check whether field of a specific scattering species zero everywhere. More...
 
void find_cloudlimits (Index &lower, Index &upper, const Tensor3 &scat_species_field, const Index &atmosphere_dim, const Numeric &cloudbox_margin)
 Adjust uppermost and lowermost cloudy level for one scat_species_*_*_field. More...
 
void parse_atmcompact_speciestype (String &species_type, const String &field_name, const String &delim)
 
void parse_atmcompact_speciesname (String &species_name, const String &field_name, const String &delim)
 
void parse_atmcompact_scattype (String &scat_type, const String &field_name, const String &delim)
 
void parse_partfield_name (String &partfield_name, const String &part_string, const String &delim)
 

Variables

const Index GFIELD3_P_GRID
 
const Index GFIELD3_LAT_GRID
 
const Index GFIELD3_LON_GRID
 

Detailed Description

Internal functions for scattering calculations.

Author
Claudia Emde claud.nosp@m.ia.e.nosp@m.mde@d.nosp@m.lr.d.nosp@m.e
Date
Thu May 23 10:59:55 2002

Definition in file cloudbox.cc.

Function Documentation

◆ bin_quadweights()

void bin_quadweights ( Vector w,
const Vector x,
const Index order 
)

Derives weights of a bin-type quadrature for arbitrary wide bins.

Note: Rectangular and trapezoidal rule essentially give the same weights when considering the same nodes x (not the mid-points between the nodes as rectangular is sometimes using) and limiting the quadrature range by the first and last node). Keyword order=0 calculates rectangular bins (ie bins extend beyond the first and last nodes), order=1 to trapezoidal bins (ie bins end exactly at nodes).

Parameters
wresulting weights at ordinates.
xordinates.
orderorder of quadrature (see above for details).
Author
Jana Mendrok, Daniel Kreyling
Date
2017-06-16

Definition at line 611 of file cloudbox.cc.

References i, is_increasing(), min, and ConstVectorView::nelem().

Referenced by pndFromPsd(), and pndFromPsdBasic().

◆ chk_pnd_data()

void chk_pnd_data ( const GriddedField3 pnd_field_raw,
const String pnd_field_file,
const Index atmosphere_dim,
const Verbosity verbosity 
)

Check particle number density files.

This function checks, whether the particle number density file has the right atmospheric dimension (check for no non-zero pnd values outside cloudbox removed. done in pnd_fieldCalcFrompnd_field_raw).

Parameters
pnd_field_rawpnd field data
pnd_field_filepnd field filename
atmosphere_dimAtmospheric dimension
Author
Claudia Emde
Date
2005-04-05

Definition at line 67 of file cloudbox.cc.

References CREATE_OUT3, GriddedField::get_numeric_grid(), GFIELD3_LAT_GRID, GFIELD3_LON_GRID, ConstVectorView::nelem(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

Referenced by chk_pnd_raw_data(), ScatElementsPndAndScatAdd(), and ScatElementsToabs_speciesAdd().

◆ chk_pnd_field_raw_only_in_cloudbox()

void chk_pnd_field_raw_only_in_cloudbox ( const Index dim,
const ArrayOfGriddedField3 pnd_field_raw,
ConstVectorView  p_grid,
ConstVectorView  lat_grid,
ConstVectorView  lon_grid,
const ArrayOfIndex cloudbox_limits 
)

chk_pnd_field_raw_only_in_cloudbox

Checks whether the pnd_field is zero outside the cloudbox. This is of a higher level than chk_pnd_data because it does not require any filename and because it works on all pnd_field_raw rather than just one element. Otherwise, it is mostly a new implementation of the same functionality.

Parameters
dimThe atmospheric dimensionality.
pnd_field_rawAll pnd_field_raw data.
p_gridPressure grid.
lat_gridLatitude grid.
lon_gridLongitude grid.
cloudbox_limitsThe edges of the cloudbox.
Author
Gerrit Holl
Date
2011-03-24

Definition at line 146 of file cloudbox.cc.

References GFIELD3_LAT_GRID, GFIELD3_LON_GRID, GFIELD3_P_GRID, n, Array< base >::nelem(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

Referenced by pnd_fieldCalcFrompnd_field_raw().

◆ chk_pnd_raw_data()

void chk_pnd_raw_data ( const ArrayOfGriddedField3 pnd_field_raw,
const String pnd_field_file,
const Index atmosphere_dim,
const Verbosity verbosity 
)

Check particle number density files (pnd_field_raw)

Parameters
pnd_field_rawpnd field raw data (array for all scattering elements)
pnd_field_filepnd field filename
atmosphere_dimAtmospheric dimension
Author
Claudia Emde
Date
2005-04-05

Definition at line 116 of file cloudbox.cc.

References chk_pnd_data(), CREATE_OUT3, i, and Array< base >::nelem().

Referenced by ScatSpeciesPndAndScatAdd().

◆ chk_scat_data()

void chk_scat_data ( const SingleScatteringData scat_data_single,
const Verbosity verbosity 
)

Check single scattering data.

This function checks the self consistency of the data by checking the dimensions of pha_mat, ext_mat and abs_vec depending on the ptype case. It furthermore checks whether the angular grids are defined correctly depending on ptype and the sanity of the temperature grid.

Parameters
scat_data_single[in]Single scattering data of a single scattering element
Author
Claudia Emde
Date
2005-04-04

Definition at line 313 of file cloudbox.cc.

References SingleScatteringData::aa_grid, SingleScatteringData::abs_vec_data, chk_size(), CREATE_OUT3, SingleScatteringData::ext_mat_data, SingleScatteringData::f_grid, last(), ConstVectorView::nelem(), SingleScatteringData::pha_mat_data, SingleScatteringData::ptype, PTYPE_AZIMUTH_RND, PTYPE_GENERAL, PTYPE_TOTAL_RND, _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str(), SingleScatteringData::T_grid, and SingleScatteringData::za_grid.

Referenced by xml_read_from_stream().

◆ chk_scat_species()

void chk_scat_species ( const ArrayOfString scat_species,
const String delim 
)

Check validity of scat_species setting.

This function checks, whether number of elements in each scattering species string is ok, and whether the entries for size limits are indeed numbers (or '*').

  \param scat_species Array of scattering species tags.
Parameters
delimdelimiter string of scat_species elements.
Author
Jana Mendrok
Date
2012-10-25

Definition at line 230 of file cloudbox.cc.

References Absorption::nelem().

◆ chk_scat_species_field()

void chk_scat_species_field ( bool &  empty_flag,
const Tensor3 scat_species_field,
const String fieldname,
const Index dim,
const Vector p_grid,
const Vector lat_grid,
const Vector lon_grid 
)

Check whether field of a specific scattering species zero everywhere.

Returns
empty_flag flag whether all field entries are zero
Parameters
scat_species_fieldscattering species field (e.g. mass density, mass flux, total number density)
fieldnamename of scattering species field (just for info)
dimthe atmosphere dimension
p_gridpressure grid of current atmosphere
lat_gridlatitude grid of current atmosphere
lon_gridlongitude grid of current atmosphere
Author
Daniel Kreyling
Date
2011-01-27

Definition at line 646 of file cloudbox.cc.

References ConstTensor3View::ncols(), ConstVectorView::nelem(), ConstTensor3View::npages(), ConstTensor3View::nrows(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

Referenced by cloudboxSetAutomatically().

◆ chk_scattering_data()

void chk_scattering_data ( const ArrayOfSingleScatteringData scat_data,
const ArrayOfScatteringMetaData scat_meta,
const Verbosity  
)

Check scattering data general.

FIXME

Parameters
scat_dataArray of single scattering data
scat_metaArray of scattering meta data
Author
Daniel Kreyling
Date
2010-12-02

Definition at line 259 of file cloudbox.cc.

References Array< base >::nelem(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

◆ chk_scattering_meta_data()

void chk_scattering_meta_data ( const ScatteringMetaData scat_meta_single,
const String scat_meta_file,
const Verbosity verbosity 
)

Check scattering data meta.

FIXME

Parameters
scat_meta_singlescattering meta data
scat_meta_filefilename of the data to be checked
Author
Daniel Kreyling
Date
2010-12-02

Definition at line 281 of file cloudbox.cc.

References CREATE_OUT3.

◆ find_cloudlimits()

void find_cloudlimits ( Index lower,
Index upper,
const Tensor3 scat_species_field,
const Index atmosphere_dim,
const Numeric cloudbox_margin 
)

Adjust uppermost and lowermost cloudy level for one scat_species_*_*_field.

lower and upper levels have to be preinitialized before calling this function.

Parameters
[in,out]lowerlowermost level containing scattering particles
[in,out]upperuppermost level containing scattering particles
[in]scat_species_fieldscattering species field (e.g. mass density, mass flux, total number density)
[in]atmosphere_dimthe atmosphere dimension
[in]cloudbox_marginflag whether to determine lowermost level or set to surface
Author
Daniel Kreyling, Jana Mendrok
Date
2015-02-09

Definition at line 714 of file cloudbox.cc.

References i, joker, max, ConstTensor3View::npages(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

Referenced by cloudboxSetAutomatically().

◆ is_gp_inside_cloudbox()

bool is_gp_inside_cloudbox ( const GridPos gp_p,
const GridPos gp_lat,
const GridPos gp_lon,
const ArrayOfIndex cloudbox_limits,
const bool &  include_boundaries,
const Index atmosphere_dim 
)

Checks, whether a gridpoint is inside the cloudbox.

Returns
true is returned if the point is inside the cloudbox.
Parameters
gp_ppressure GridPos
gp_latlatitude GridPos
gp_lonlongitude GridPos
cloudbox_limitsThe limits of the cloudbox.
include_boundariesboolean: determines whther or not points on the boundary are considered to be inside the cloudbox.
Author
Claudia Emde (rewritten by Cory Davis 2005-07-03)
Date
2003-06-06

Definition at line 499 of file cloudbox.cc.

References fractional_gp().

Referenced by get_ppath_cloudvars(), get_ppath_transmat(), is_inside_cloudbox(), iyIndependentBeamApproximation(), and mcPathTraceRadar().

◆ is_inside_cloudbox()

bool is_inside_cloudbox ( const Ppath ppath_step,
const ArrayOfIndex cloudbox_limits,
const bool  include_boundaries 
)

Checks, whether the last point of a propagation path is inside the cloudbox.

Works only for 3D !!!

Returns
true is returned if the point is inside the cloudbox.
Parameters
ppath_stepPropagation path step.
cloudbox_limitsThe limits of the cloudbox.
include_boundariesboolean: determines whther or not points on the boundary are considered to be inside the cloudbox.
Author
Claudia Emde (rewritten by Cory Davis 2005-07-03)
Date
2003-06-06

Definition at line 579 of file cloudbox.cc.

References Ppath::gp_lat, Ppath::gp_lon, Ppath::gp_p, is_gp_inside_cloudbox(), Array< base >::nelem(), and Ppath::np.

Referenced by cloud_ppath_update3D().

◆ parse_atmcompact_scattype()

void parse_atmcompact_scattype ( String scat_type,
const String field_name,
const String delim 
)

Parse atm_field_compact fieldname for type of scat_species field

Parameters
scat_typespecies name (second part of field_name)
field_namefieldname of atm_field_compact data entry
delimdelimiter string of field_name
Author
Jana Mendrok
Date
2014-11-20

Definition at line 912 of file cloudbox.cc.

References my_basic_string< charT >::split(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

◆ parse_atmcompact_speciesname()

void parse_atmcompact_speciesname ( String species_name,
const String field_name,
const String delim 
)

Parse atm_field_compact fieldname for species name

Parameters
species_typespecies name (second part of field_name)
field_namefieldname of atm_field_compact data entry
delimdelimiter string of field_name
Author
Jana Mendrok
Date
2014-11-20

Definition at line 880 of file cloudbox.cc.

References my_basic_string< charT >::split(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

Referenced by abs_lookupSetupBatch().

◆ parse_atmcompact_speciestype()

void parse_atmcompact_speciestype ( String species_type,
const String field_name,
const String delim 
)

Parse atm_field_compact fieldname for species type

Parameters
species_typespecies indentifier (first part of field_name)
field_namefieldname of atm_field_compact data entry
delimdelimiter string of field_name
Author
Jana Mendrok
Date
2014-11-20

Definition at line 848 of file cloudbox.cc.

References my_basic_string< charT >::split(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

Referenced by abs_lookupSetupBatch().

◆ parse_partfield_name()

void parse_partfield_name ( String partfield_name,
const String part_string,
const String delim 
)

Splitting scat_species string and parse type of scattering species field

Parameters
partfield_namename of atmospheric scattering species field
part_stringscattering species tag from scat_species
delimdelimiter string of scat_species elements
Author
Daniel Kreyling
Date
2011-02-21

Definition at line 944 of file cloudbox.cc.

References my_basic_string< charT >::split(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

Referenced by ScatElementsSelect(), and ScatSpeciesExtendTemperature().

Variable Documentation

◆ GFIELD3_LAT_GRID

const Index GFIELD3_LAT_GRID

◆ GFIELD3_LON_GRID

const Index GFIELD3_LON_GRID

◆ GFIELD3_P_GRID

const Index GFIELD3_P_GRID