ARTS 2.5.11 (git: 6827797f)
m_microphysics.cc File Reference

Workspace functions related to particle micophysics (e.g. size distributions). More...

#include <cmath>
#include <cstdlib>
#include <stdexcept>
#include "array.h"
#include "arts.h"
#include "arts_constants.h"
#include "auto_md.h"
#include "check_input.h"
#include "cloudbox.h"
#include "disort.h"
#include "file.h"
#include "interpolation.h"
#include "lin_alg.h"
#include "logic.h"
#include "math_funcs.h"
#include "messages.h"
#include "microphysics.h"
#include "optproperties.h"
#include "parameters.h"
#include "physics_funcs.h"
#include "psd.h"
#include "rte.h"
#include "sorting.h"
#include "special_interp.h"
#include "xml_io.h"

Go to the source code of this file.

Functions

void HydrotableCalc (Workspace &ws, GriddedField4 &hydrotable, const ArrayOfAgenda &pnd_agenda_array, const ArrayOfArrayOfString &pnd_agenda_array_input_names, const ArrayOfArrayOfSingleScatteringData &scat_data, const Index &scat_data_checked, const Vector &f_grid, const Index &iss, const Vector &T_grid, const Vector &wc_grid, const Verbosity &)
 WORKSPACE METHOD: HydrotableCalc.
 
void particle_massesFromMetaDataSingleCategory (Matrix &particle_masses, const ArrayOfArrayOfScatteringMetaData &scat_meta, const Verbosity &)
 WORKSPACE METHOD: particle_massesFromMetaDataSingleCategory.
 
void particle_massesFromMetaData (Matrix &particle_masses, const ArrayOfArrayOfScatteringMetaData &scat_meta, const Verbosity &)
 WORKSPACE METHOD: particle_massesFromMetaData.
 
void pndFromPsdBasic (Matrix &pnd_data, Tensor3 &dpnd_data_dx, const Vector &pnd_size_grid, const Matrix &psd_data, const Vector &psd_size_grid, const Tensor3 &dpsd_data_dx, const Index &quad_order, const Verbosity &)
 WORKSPACE METHOD: pndFromPsdBasic.
 
void pndFromPsd (Matrix &pnd_data, Tensor3 &dpnd_data_dx, const Vector &pnd_size_grid, const Matrix &psd_data, const Vector &psd_size_grid, const Tensor3 &dpsd_data_dx, const ArrayOfArrayOfSingleScatteringData &scat_data, const Vector &f_grid, const Index &scat_data_checked, const Index &quad_order, const Index &scat_index, const Numeric &threshold_rsec, const Numeric &threshold_bext, const Numeric &threshold_rpnd, const Verbosity &)
 WORKSPACE METHOD: pndFromPsd.
 
void pnd_fieldCalcFromParticleBulkProps (Workspace &ws, Tensor4 &pnd_field, ArrayOfTensor4 &dpnd_field_dx, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &t_field, const Index &cloudbox_on, const ArrayOfIndex &cloudbox_limits, const ArrayOfString &scat_species, const ArrayOfArrayOfSingleScatteringData &scat_data, const ArrayOfArrayOfScatteringMetaData &scat_meta, const Tensor4 &particle_bulkprop_field, const ArrayOfString &particle_bulkprop_names, const ArrayOfAgenda &pnd_agenda_array, const ArrayOfArrayOfString &pnd_agenda_array_input_names, const Index &jacobian_do, const ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &)
 WORKSPACE METHOD: pnd_fieldCalcFromParticleBulkProps.
 
void ScatSpeciesSizeMassInfo (Vector &scat_species_x, Numeric &scat_species_a, Numeric &scat_species_b, const ArrayOfArrayOfScatteringMetaData &scat_meta, const Index &species_index, const String &x_unit, const Numeric &x_fit_start, const Numeric &x_fit_end, const Index &do_only_x, const Verbosity &)
 WORKSPACE METHOD: ScatSpeciesSizeMassInfo.
 

Variables

constexpr Numeric PI =Constant::pi
 

Detailed Description

Workspace functions related to particle micophysics (e.g. size distributions).

Author
Jana Mendrok, Daniel Kreyling, Manfred Brath, Patrick Eriksson
Date
2017-07-10

These functions are listed in the doxygen documentation as entries of the file auto_md.h.

Definition in file m_microphysics.cc.

Function Documentation

◆ HydrotableCalc()

void HydrotableCalc ( Workspace ws,
GriddedField4 hydrotable,
const ArrayOfAgenda pnd_agenda_array,
const ArrayOfArrayOfString pnd_agenda_array_input_names,
const ArrayOfArrayOfSingleScatteringData scat_data,
const Index &  scat_data_checked,
const Vector &  f_grid,
const Index &  iss,
const Vector &  T_grid,
const Vector &  wc_grid,
const Verbosity verbosity 
)

WORKSPACE METHOD: HydrotableCalc.

Creates a look-up table of scattering properties.

The table produced largely follows the format used in RTTOV-SCATT for its "hydrotables". The table is returned as a GriddedField4, with dimensions (in order): <br> Scattering property <br> Frequency (equals WSV f_grid) <br> Temperature (equals GIN T_grid) <br> Particle content [kg/m3] (equals GIN wc_grid)

Four scattering properties are calculated. They are (in order) <br> Extinction [m-1] <br> Single scattering albedo [-] <br> Asymmetry parameter [-] <br> Radar reflectivity [m2]

Author
Patrick Eriksson
Parameters
[in,out]wsWorkspace
[out]hydrotableGeneric output
[in]pnd_agenda_arrayWS Input
[in]pnd_agenda_array_input_namesWS Input
[in]scat_dataWS Input
[in]scat_data_checkedWS Input
[in]f_gridWS Input
[in]issGeneric Input
[in]T_gridGeneric Input
[in]wc_gridGeneric Input

Definition at line 53 of file m_microphysics.cc.

References ARTS_USER_ERROR_IF, asymmetry_parameter(), GriddedField4::data, ext_abs_pfun_from_tro(), Array< base >::nelem(), nlinspace(), PI, pnd_agenda_arrayExecute(), GriddedField::set_grid(), GriddedField::set_grid_name(), and GriddedField::set_name().

Referenced by HydrotableCalc_g().

◆ particle_massesFromMetaData()

void particle_massesFromMetaData ( Matrix &  particle_masses,
const ArrayOfArrayOfScatteringMetaData scat_meta,
const Verbosity verbosity 
)

WORKSPACE METHOD: particle_massesFromMetaData.

Derives particle_masses from scat_meta.

It extracts the mass information of the scattering elements from scat_meta. Each scattering species is taken as a separate category of particle_masses, i.e., the resulting particle_masses* matrix will contain as many columns as scattering species are present in scat_meta.

Author
Jana Mendrok
Parameters
[out]particle_massesWS Output
[in]scat_metaWS Input

Definition at line 184 of file m_microphysics.cc.

References ARTS_USER_ERROR_IF, Array< base >::nelem(), and TotalNumberOfElements().

Referenced by particle_massesFromMetaData_g().

◆ particle_massesFromMetaDataSingleCategory()

void particle_massesFromMetaDataSingleCategory ( Matrix &  particle_masses,
const ArrayOfArrayOfScatteringMetaData scat_meta,
const Verbosity verbosity 
)

WORKSPACE METHOD: particle_massesFromMetaDataSingleCategory.

Sets particle_masses based on scat_meta assuming all particles are of the same mass category.

This method derives the particle masses from the mass entry of each scattering element. It is assumed that all scattering elements represent particles of the same (bulk) matter (e.g. water or ice). With other words, a single mass category is assumed (see particle_masses for a definition of "mass category").

If just having clouds, the resulting mass category can be seen as the total cloud water content, with possible contribution from both ice and liquid phase.

Author
Jana Mendrok
Patrick Eriksson
Parameters
[out]particle_massesWS Output
[in]scat_metaWS Input

Definition at line 159 of file m_microphysics.cc.

References ARTS_USER_ERROR_IF, Array< base >::nelem(), and TotalNumberOfElements().

Referenced by particle_massesFromMetaDataSingleCategory_g().

◆ pnd_fieldCalcFromParticleBulkProps()

void pnd_fieldCalcFromParticleBulkProps ( Workspace ws,
Tensor4 &  pnd_field,
ArrayOfTensor4 &  dpnd_field_dx,
const Index &  atmosphere_dim,
const Vector &  p_grid,
const Vector &  lat_grid,
const Vector &  lon_grid,
const Tensor3 &  t_field,
const Index &  cloudbox_on,
const ArrayOfIndex cloudbox_limits,
const ArrayOfString scat_species,
const ArrayOfArrayOfSingleScatteringData scat_data,
const ArrayOfArrayOfScatteringMetaData scat_meta,
const Tensor4 &  particle_bulkprop_field,
const ArrayOfString particle_bulkprop_names,
const ArrayOfAgenda pnd_agenda_array,
const ArrayOfArrayOfString pnd_agenda_array_input_names,
const Index &  jacobian_do,
const ArrayOfRetrievalQuantity jacobian_quantities,
const Verbosity verbosity 
)

WORKSPACE METHOD: pnd_fieldCalcFromParticleBulkProps.

Converts particle bulk property data to pnd_field.

In short, the method combines scat_species, pnd_agenda_array, particle_bulkprop_field* and their associated variables to derive pnd_field*.

The method does nothing if cloudbox is inactive.

Otherwise, cloudbox limits must be set before calling the method, and particle_bulkprop_field is checked to have non-zero elements just inside the cloudbox.

Author
Patrick Eriksson, Jana Mendrok
Parameters
[in,out]wsWorkspace
[out]pnd_fieldWS Output
[out]dpnd_field_dxWS Output
[in]atmosphere_dimWS Input
[in]p_gridWS Input
[in]lat_gridWS Input
[in]lon_gridWS Input
[in]t_fieldWS Input
[in]cloudbox_onWS Input
[in]cloudbox_limitsWS Input
[in]scat_speciesWS Input
[in]scat_dataWS Input
[in]scat_metaWS Input
[in]particle_bulkprop_fieldWS Input
[in]particle_bulkprop_namesWS Input
[in]pnd_agenda_arrayWS Input
[in]pnd_agenda_array_input_namesWS Input
[in]jacobian_doWS Input
[in]jacobian_quantitiesWS Input

Definition at line 554 of file m_microphysics.cc.

References ARTS_USER_ERROR_IF, chk_atm_field(), chk_atm_grids(), chk_if_in_range(), find_first(), max(), min(), Array< base >::nelem(), and pnd_agenda_arrayExecute().

Referenced by pnd_fieldCalcFromParticleBulkProps_g().

◆ pndFromPsd()

void pndFromPsd ( Matrix &  pnd_data,
Tensor3 &  dpnd_data_dx,
const Vector &  pnd_size_grid,
const Matrix &  psd_data,
const Vector &  psd_size_grid,
const Tensor3 &  dpsd_data_dx,
const ArrayOfArrayOfSingleScatteringData scat_data,
const Vector &  f_grid,
const Index &  scat_data_checked,
const Index &  quad_order,
const Index &  scat_index,
const Numeric &  threshold_se_ext,
const Numeric &  threshold_ss_ext,
const Numeric &  threshold_se_pnd,
const Verbosity verbosity 
)

WORKSPACE METHOD: pndFromPsd.

Calculates pnd_data from given psd_data for one scattering species.

Performs integration of the size distribution over the size grid bin deriving pnd (units #/m3) from psd (units #/m3/m). Some checks on the sufficiency of the size grid range and coverage are applied.

quad_order* can be 0 for rectangular or 1 for trapezoidal integration. The only difference is the treatment of the start and end nodes. For trapezoidal their corresponding bins end exactly at the nodes, while for rectangular they extend further out by the half distance to the neighbor node (but not beyond 0).

Attempts to check that the size grids and scat_data represent the bulk extinction sufficiently. Specifically, it is tested that <br> (a) psd*ext is decreasing at the small and large particle size <br> ends of the size grid - but only if scattering species bulk <br> extinction exceeds 1% of threshold_ss_ext. <br> (b) removing the smallest and largest particles changes the <br> resulting bulk extinction by less then a fraction of <br> threshold_se_ext - but only if scattering species bulk <br> extinction exceeds threshold_ss_ext and number density (pnd) <br> of the edge size point at this atmospheric level is larger <br> than threshold_se_pnd times the maximum pnd of this <br> scattering element over all atmospheric levels. Skipping tests in case of low extinction is done in order to minimize issues arising from very low mass densities, particularly at single atmospheric levels, and very low bulk extinctions, i.e. in cases where the effects on the radiance fields are estimated to be low. NOTE: The tests are only approximate and do not guarantee the validity of the resulting bulk properties (and increasing the thresholds will decrease the reliability of the bulk properties).

Author
Jana Mendrok, Patrick Eriksson
Parameters
[out]pnd_dataWS Output
[out]dpnd_data_dxWS Output
[in]pnd_size_gridWS Input
[in]psd_dataWS Input
[in]psd_size_gridWS Input
[in]dpsd_data_dxWS Input
[in]scat_dataWS Input
[in]f_gridWS Input
[in]scat_data_checkedWS Input
[in]quad_orderGeneric Input (Default: "1")
[in]scat_indexGeneric Input
[in]threshold_se_extGeneric Input (Default: "0.02")
[in]threshold_ss_extGeneric Input (Default: "1e-8")
[in]threshold_se_pndGeneric Input (Default: "0.02")

Definition at line 283 of file m_microphysics.cc.

References ARTS_USER_ERROR_IF, bin_quadweights(), get_sorted_indexes(), max(), and Array< base >::nelem().

Referenced by pndFromPsd_g().

◆ pndFromPsdBasic()

void pndFromPsdBasic ( Matrix &  pnd_data,
Tensor3 &  dpnd_data_dx,
const Vector &  pnd_size_grid,
const Matrix &  psd_data,
const Vector &  psd_size_grid,
const Tensor3 &  dpsd_data_dx,
const Index &  quad_order,
const Verbosity verbosity 
)

WORKSPACE METHOD: pndFromPsdBasic.

Calculates pnd_data from given psd_data.

As pndFromPsdBasic, but without bulk extinction representation checks.

Author
Jana Mendrok, Patrick Eriksson
Parameters
[out]pnd_dataWS Output
[out]dpnd_data_dxWS Output
[in]pnd_size_gridWS Input
[in]psd_dataWS Input
[in]psd_size_gridWS Input
[in]dpsd_data_dxWS Input
[in]quad_orderGeneric Input (Default: "1")

Definition at line 210 of file m_microphysics.cc.

References ARTS_USER_ERROR_IF, bin_quadweights(), and get_sorted_indexes().

Referenced by pndFromPsdBasic_g().

◆ ScatSpeciesSizeMassInfo()

void ScatSpeciesSizeMassInfo ( Vector &  scat_species_x,
Numeric &  scat_species_a,
Numeric &  scat_species_b,
const ArrayOfArrayOfScatteringMetaData scat_meta,
const Index &  species_index,
const String x_unit,
const Numeric &  x_fit_start,
const Numeric &  x_fit_end,
const Index &  do_only_x,
const Verbosity verbosity 
)

WORKSPACE METHOD: ScatSpeciesSizeMassInfo.

Derives size and mass information for a scattering species. This method assumes that the mass-size relationship can described by scat_species_a and scat_species_b. See documentation of scat_species_a* for details.

The quantity to be used as size descriptor is here denoted as x, and is selected by setting x_unit. The options are: <br> "dveq" : The size grid is set to scat_meta.diameter_volume_equ <br> "dmax" : The size grid is set to scat_meta.diameter_max <br> "area" : The size grid is set to scat_meta.diameter_area_equ_aerodynamical <br> "mass" : The size grid is set to scat_meta.mass This selection determines scat_species_x.

The parameters scat_species_a and scat_species_b are determined by a numeric fit between scat_species_x and corresponding masses in scat_meta*. This fit is performed over sizes inside the range [x_fit_start,x_fit_end]. This range is allowed to be broader than the coverage of scat_species_x. There must be at least two sizes inside [x_fit_start,x_fit_end].

Author
Manfred Brath
Jana Mendrok
Patrick Eriksson
Parameters
[out]scat_species_xWS Output
[out]scat_species_aWS Output
[out]scat_species_bWS Output
[in]scat_metaWS Input
[in]species_indexGeneric Input
[in]x_unitGeneric Input
[in]x_fit_startGeneric Input (Default: "0")
[in]x_fit_endGeneric Input (Default: "1e9")
[in]do_only_xGeneric Input (Default: "0")

Definition at line 817 of file m_microphysics.cc.

References ARTS_USER_ERROR, ARTS_USER_ERROR_IF, derive_scat_species_a_and_b(), and Array< base >::nelem().

Referenced by ScatSpeciesSizeMassInfo_g().

Variable Documentation

◆ PI

constexpr Numeric PI =Constant::pi
inlineconstexpr

Definition at line 46 of file m_microphysics.cc.

Referenced by HydrotableCalc().