typhon.arts

This module contains functions to interact with ARTS.

typhon.arts.atm_fields_compact_get(abs_species, gf4)[source]

Extract species from atm_fields_compact.

Parameters:
Returns:

Extracted profiles.

typhon.arts.atm_fields_compact_update(abs_species, gf4, vmr)[source]

Update profile for given species.

Parameters:
  • abs_species (string) – SpeciesTag.
  • gf4 (GriddedField4) – GriddedField4.
  • vmr (ndarray) – New VMR field.
Returns:

Updated atm_fields_compact.

Return type:

GriddedField4

typhon.arts.run_arts(controlfile=None, arts='arts', writetxt=False, ignore_error=False, **kwargs)[source]

Start an ARTS Simulation.

Parameters:
  • controlfile (str) – Path to the ARTS controlfile.
  • arts (str) – Path to the arts executable.
  • writetxt (bool) – Write stdout and stderr to ASCII files.
  • ignore_error (bool) – If set to True, erros during the ARTS run do not result in an exception (default is False).
  • **kwargs – Additional command line arguments passed as keyword. See arts –help for more details.
Returns:

Named tuple containing the fields stdout, stderr and retcode.

Examples

Run a simple ARTS job and set the output directory and the report level:

>>> run_arts('foo.arts', outdir='bar', reporting='020')

If a keyword is set to True it is added as flag. Show the ARTS help message:

>>> run_arts(help=True)

typhon.arts.catalogues

Implementation of classes to handle various catalogue information.

class typhon.arts.catalogues.ArrayOfLineRecord(data=None, version=None)[source]

Bases: object

Represents an ArrayOfLineRecord object.

See online ARTS documentation for object details.

data

List of strings representing line records.

classmethod from_xml(xmlelement)[source]

Loads an ArrayOfLineRecord object from an existing file.

version

ArrayOfRecord version number.

write_xml(xmlwriter, attr=None)[source]

Write an ArrayOfLineRecord object to an ARTS XML file.

class typhon.arts.catalogues.CIARecord(molecule1=None, molecule2=None, data=None)[source]

Bases: object

Represents a CIARecord object.

See online ARTS documentation for object details.

data

Actual data stored in (list of) GriddedField2 objects.

classmethod from_xml(xmlelement)[source]

Loads a CIARecord object from an existing file.

molecule1

Name of the first molecule.

molecule2

Name of the second molecule.

write_xml(xmlwriter, attr=None)[source]

Write a CIARecord object to an ARTS XML file.

class typhon.arts.catalogues.GasAbsLookup(speciestags=None, nonlinearspecies=None, frequencygrid=None, pressuregrid=None, referencevmrprofiles=None, referencetemperatureprofile=None, temperaturepertubations=None, nonlinearspeciesvmrpertubations=None, absorptioncrosssection=None)[source]

Bases: object

Represents a GasAbsLookup object.

See online ARTS documentation for object details.

absorptioncrosssection

Absorption crosssections.

frequencygrid

Frequency vector.

classmethod from_xml(xmlelement)[source]

Loads a GasAbsLookup object from an existing file.

nonlinearspecies

Indices to indentify nonlinear species.

nonlinearspeciesvmrpertubations

Vector with VMR pertubations for nonlinear species.

pressuregrid

Pressure level vector.

referencetemperatureprofile

Reference temperature profile.

referencevmrprofiles

Reference VMR profiles.

speciestags

List of SpeciesTag.

temperaturepertubations

Vector with temperature pertubations.

write_xml(xmlwriter, attr=None)[source]

Write a ScatterinMetaData object to an ARTS XML file.

class typhon.arts.catalogues.LineMixingRecord(tag=None, quantumnumberrecord=None, data=None)[source]

Bases: object

Represents a LineMixingRecord object.

See online ARTS documentation for object details.

data

Lineshape parameters.

classmethod from_xml(xmlelement)[source]

Loads a LineMixingRecord object from an existing file.

quantumnumberrecord

QuantumNumberRecord

tag

SpeciesTag

write_xml(xmlwriter, attr=None)[source]

Write a LineMixingRecord object to an ARTS XML file.

class typhon.arts.catalogues.QuantumIdentifier[source]

Bases: str

Represents a QuantumIdentifier object.

See online ARTS documentation for object details.

classmethod from_xml(xmlelement)[source]

Loads a QuantumIdentifier object from an existing file.

write_xml(xmlwriter, attr=None)[source]

Write a QuantumIdentifier object to an ARTS XML file.

class typhon.arts.catalogues.QuantumNumberRecord(upper=None, lower=None)[source]

Bases: object

Represents a QuantumNumberRecord object.

See online ARTS documentation for object details.

classmethod from_xml(xmlelement)[source]

Loads a QuantumNumberRecord object from an existing file.

lower

QuantumNumbers object representing the lower quantumnumber.

upper

QuantumNumbers object representing the upper quantumnumber.

write_xml(xmlwriter, attr=None)[source]

Write a SpeciesTag object to an ARTS XML file.

class typhon.arts.catalogues.QuantumNumbers(numbers=None, nelem=None)[source]

Bases: object

Represents a QuantumNumbers object.

See online ARTS documentation for object details.

classmethod from_xml(xmlelement)[source]

Loads a QuantumNumbers object from an existing file.

nelem

Number of quantumnumbers stored.

numbers

String representing the quantumnumbers.

write_xml(xmlwriter, attr=None)[source]

Write a SpeciesTag object to an ARTS XML file.

class typhon.arts.catalogues.Sparse(arg1, shape=None, dtype=None, copy=False)[source]

Bases: scipy.sparse.csc.csc_matrix

Wrapper around scipy.sparse.csc_matrix.

This class wraps around the SciPy Compressed Sparse Column matrix. The usage is exactly the same, but support for reading and writing XML files is added. Also additional attributes were added, which follow the ARTS names.

See ARTS and SciPy documentations for more details.

colindex

Column indices to locate data in matrix.

classmethod from_xml(xmlelement)[source]

Loads a Sparse object from an existing file.

ncols

Number of columns.

nrows

Number of rows.

rowindex

Row indices to locate data in matrix.

sparsedata

Data value at specified positions in matrix.

write_xml(xmlwriter, attr=None)[source]

Write a Sparse object to an ARTS XML file.

class typhon.arts.catalogues.SpeciesAuxData(data, version, nparam=None)[source]

Bases: object

Represents a SpeciesAuxData object.

See online ARTS documentation for object details.

classmethod from_xml(xmlelement)[source]

Loads a SpeciesAuxData object from an existing file.

write_xml(xmlwriter, attr=None)[source]

Write a ScatterinMetaData object to an ARTS XML file.

class typhon.arts.catalogues.SpeciesTag[source]

Bases: str

Represents a SpeciesTag object.

See online ARTS documentation for object details.

classmethod from_xml(xmlelement)[source]

Loads a SpeciesTag object from an existing file.

write_xml(xmlwriter, attr=None)[source]

Write a SpeciesTag object to an ARTS XML file.

typhon.arts.griddedfield

class typhon.arts.griddedfield.GriddedField(dimension, grids=None, data=None, gridnames=None, dataname=None, name=None)[source]

Bases: object

GriddedField implements the same-named ARTS dataype.

This class provides the facility of storing gridded data. For this purpose the grid-axes as well as the data are stored. GriddedFields can be easily written to XML-files as they define a clear datastructure.

GriddedField should not be used directly. Use one of the derived types such as GriddedField1 instead.

Note

For the special case of storing atmospheric profiles as GriddedField3 the latitude and longitude grids have to be initialised as empty np.array.

Examples

Create and manipulate a GriddedField object.

>>> gf1 = GriddedField1()
>>> gf1.grids = [np.arange(10)]
>>> gf1.gridnames = ["Indices"]
>>> gf1.data = np.random.randn(10)

Inspect an existing GriddedField object.

>>> gf1.dimension
1
>>> gf1.grids
[array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])]
>>> gf1.gridnames
['Indices']
check_dimension()[source]

Checks the consistency of grids and data.

This functions check if the dimensions defined by the grids fit to the dimension of the passed data. Also check if the number of gridnames fits the number of grids.

Note

This check is done automatically before storing and after loading XML files.

Returns:

True if successful.

Raises:
  • Exception – if number of grids does not fit the GriddedField dimension.
  • Exception – if number of gridnames does not fit the number of grids.
  • Exception – if data dimension does not fit the grid dimensions.
  • Warning – if a dimension is empty.
copy()[source]

Return a deepcopy of the GriddedField.

data

The data matrix stored in the GriddedField.

Note

The data array has to fit the grid dimensions.

dataname

Name of the data array.

dimension

Dimension of the GriddedField.

The dimension has to be defined when creating the GriddedField object. For the convenience subclasses (e.g. GriddedField1) this is done automatically.

classmethod from_nc(inputfile, variable, fill_value=nan)[source]

Create GriddedField from variable in netCDF files.

Extract a given variable from a netCDF file. The data and its dimensions are returned as a GriddedField object.

Parameters:
  • inputfile (str) – Path to netCDF file.
  • variable (str) – Variable key of variable to extract.
  • fill_value (float) – Fill value for masked areas (default: np.nan).
Returns:

GriddedField object of sufficient dimension.

Raises:

Exception – If the variable key can’t be found in the netCDF file.

classmethod from_xml(xmlelement)[source]

Load a GriddedField from an ARTS XML file.

Returns:GriddedField. Dimension depends on data in file.
gridnames

A list or tuple that includes a name for every grid.

Note

The number of gridnames has to match the number of grids. Gridnames are currently not used so it is not neccesarry to set them.

grids

List of grids defining the GriddedField.

Note

The number of grids has to match the GriddedField dimension.

name

Name of the GriddedField.

refine_grid(new_grid, axis=0, **kwargs)[source]

Interpolate GriddedField axis to a new grid.

This function replaces a grid of a GriddField and interpolates all data to match the new coordinates. scipy.interpolate.interp1d() is used for interpolation.

Parameters:
  • new_grid (ndarray) – The coordinates of the interpolated values.
  • axis (int) – Specifies the axis of data along which to interpolate. Interpolation defaults to the first axis of the GriddedField.
  • **kwargs – Keyword arguments passed to scipy.interpolate.interp1d().

Returns: typhon.arts.griddedfield.GriddedField

shape

Shape of the data array.

to_atmlab_dict()[source]

Returns a copy of the GriddedField as a dictionary.

Returns a dictionary compatible with an atmlab structure.

Returns:Dictionary containing the grids and data.
to_dict()[source]

Convert GriddedField to dictionary.

Converts a GriddedField object into a classic Python dictionary. The gridname is used as dictionary key. If the grid is unnamed the key is generated automatically (‘grid1’, ‘grid2’, ...). The data can be accessed through the ‘data’ key.

Returns:Dictionary containing the grids and data.
write_xml(xmlwriter, attr=None)[source]

Save a GriddedField to an ARTS XML file.

class typhon.arts.griddedfield.GriddedField1(*args, **kwargs)[source]

Bases: typhon.arts.griddedfield.GriddedField

GriddedField with 1 dimension.

class typhon.arts.griddedfield.GriddedField2(*args, **kwargs)[source]

Bases: typhon.arts.griddedfield.GriddedField

GriddedField with 2 dimensions.

class typhon.arts.griddedfield.GriddedField3(*args, **kwargs)[source]

Bases: typhon.arts.griddedfield.GriddedField

GriddedField with 3 dimensions.

class typhon.arts.griddedfield.GriddedField4(*args, **kwargs)[source]

Bases: typhon.arts.griddedfield.GriddedField

GriddedField with 4 dimensions.

class typhon.arts.griddedfield.GriddedField5(*args, **kwargs)[source]

Bases: typhon.arts.griddedfield.GriddedField

GriddedField with 5 dimensions.

class typhon.arts.griddedfield.GriddedField6(*args, **kwargs)[source]

Bases: typhon.arts.griddedfield.GriddedField

GriddedField with 6 dimensions.

class typhon.arts.griddedfield.GriddedField7(*args, **kwargs)[source]

Bases: typhon.arts.griddedfield.GriddedField

GriddedField with 7 dimensions.

typhon.arts.retrieval

Implementation of RetrievalQuantity.

class typhon.arts.retrieval.RetrievalQuantity(maintag=None, subtag=None, subsubtag=None, mode=None, analytical=None, pertubation=None, grids=None)[source]

Bases: object

Represents a RetrievalQuantity object.

See online ARTS documentation for object details.

analytical

Flag to determine whether the retrieval was done analytically.

classmethod from_xml(xmlelement)[source]

Loads a RetrievalQuantity object from an existing file.

grids

Pressure grid.

maintag

MainTag of retrieval species.

mode

Retrieval mode.

pertubation

Amplitude of the pertubation.

subsubtag

Subsubtag of retrieval species.

subtag

Subtag of retrieval species.

write_xml(xmlwriter, attr=None)[source]

Write a RetrievalQuantity object to an ARTS XML file.

typhon.arts.scattering

Implementation of scattering related types such as SingleScatteringData and ScatteringMetaData.

class typhon.arts.scattering.SingleScatteringData[source]

Bases: object

The class representing the arts SingleScatteringData class.

The data members of this object are identical to the class of the same name in ARTS; it includes all the single scattering properties required for polarized radiative transfer calculations: the extinction matrix, the phase matrix, and the absorption coefficient vector. The angular, frequency, and temperature grids for which these are defined are also included. Another data member - ptype, describes the orientational symmetry of the particle ensemble, which determines the format of the single scattering properties. The data structure of the ARTS SingleScatteringData class is described in the ARTS User Guide.

The methods in the SingleScatteringData class enable the calculation of the single scattering properties, and the output of the SingleScatteringData structure in the ARTS XML format (see example file). The low-level calculations are performed in arts_scat.

assp2backcoef()[source]

The function returns the radar backscattering coeffcient. This is the phase function times 4pi, following the standard definition in the radar community.

Returns:Backscattering coefficients, one value for each frequency and temperature in S. [m2]
assp2g()[source]

For a normalised phase function (p), g equals the 4pi integral of p*cos(th), where th is the scattering angle. For pure isotropic scattering g = 0, while pure forward scattering has g=1.

Warning, this function does not handle the extreme cases of delta-function type of forward or backward scattering lobes. A g of zero is returned for these cases.

Returns:Backscattering coefficients, one value for each frequency and temperature in S. [m2]
checkassp()[source]

Verfies properties of SSP.

Raises:PyARTSError – If ptype is not macroscopically isotropic, or if first and last value of za_grid does not equal exactly 0 and 180 respectively.
checksize()[source]

Verifies size is consistent.

Raises:RuntimeError
defaults = {'aa_grid': array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180]), 'za_grid': array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180]), 'version': 3, 'ptype': 'totally_random', 'T_grid': array([250]), 'description': 'SingleScatteringData created with Typhon.'}
classmethod from_data(params=None, **kwargs)[source]

Constructor

Parameters:
  • ptype (string) – As for ARTS; see Arts User Guide
  • f_grid (1-D np.array) – np.array for frequency grid [Hz]
  • T_grid (1-D np.array) – np.array for temperature grid [K]
  • za_grid (1-D np.array) – np.array for zenith-angle grid [degree]
  • aa_grid (1-D np.array) – np.array for azimuth-angle grid [degree]
  • inputs have default values, see SingleScatteringData.defaults. (Some) –
classmethod from_xml(xmlelement)[source]

Loads a SingleScatteringData object from an xml.ElementTree.Element.

normalise()[source]

Normalises Z to E-A.

normalised()[source]

Returns normalised copy

ptype

str – Particle type

to_atmlab_dict()[source]

Returns a copy of the SSD as a dictionary.

Returns a dictionary compatible with an atmlab structure.

Returns:Dictionary containing the grids and data.
version

str – Particle type

write_xml(xmlwriter, attr=None)[source]

Write a SingleScatterinData object to an ARTS XML file.

class typhon.arts.scattering.ScatteringMetaData(description=None, source=None, refr_index=None, mass=None, diameter_max=None, diameter_volume_equ=None, diameter_area_equ_aerodynamical=None)[source]

Bases: object

Represents a ScatteringMetaData object.

See online ARTS documentation for object details.

description

Free-form description of the scattering element, holding information deemed of interest by the user but not covered by other structure members (and not used within ARTS).

diameter_area_equ_aerodynamical

The area equivalent sphere diameter of the scattering element, i.e., the diameter of a sphere with the same cross-sectional area. Here, area refers to the aerodynamically relevant area, i.e., the cross-sectional area perpendicular to the direction of fall. Similarly to volume in the definition of diameter_volume_equ, for non-spherical and mixed-material particles, area refers to the area covered by the substance mixture of the particle.

diameter_max

The maximum diameter (or dimension) of the scattering element, defined by the circumferential sphere diameter of the element. Note that this parameter is only used by some size distributions; it does not have a proper meaning if the scattering element represents an ensemble of differently sized particles.

diameter_volume_equ

The volume equivalent sphere diameter of the scattering element, i.e., the diameter of a sphere with the same volume. For nonspherical particles, volume refers to the volume of the particle-forming substance, not that of the circumferential sphere (which can be derived from diameter_max). If the particle consists of a mixture of materials, the substance encompasses the complete mixture. E.g., the substance of ‘soft’ ice particles includes both the ice and the air.

classmethod from_xml(xmlelement)[source]

Loads a ScatteringMetaData object from an existing file.

mass

The mass of the scattering element.

refr_index

Free-form description of the underlying complex refractive index data, e.g., a literature source.

source

Free-form description of the source of the data, e.g., Mie, T-Matrix, or DDA calculation or a database or a literature source.

to_atmlab_dict()[source]

Returns a copy of the SMD as a dictionary.

Returns a dictionary compatible with an atmlab structure.
Returns:Dictionary containing the grids and data.
write_xml(xmlwriter, attr=None)[source]

Write a ScatteringMetaData object to an ARTS XML file.

typhon.arts.sensor

Implementation of functions related to sensor settings.

typhon.arts.sensor.get_f_backend_rel_width(f_start, f_end, bandwidth)[source]

Compute backend frequencies with relative bandwidth.

This function computes backend frequencies for a given frequency range and a relative bandwidth.

Parameters:
  • f_start (float) – beginning of frequency range [Hz]
  • f_end (float) – end of frequency range [Hz]
  • bandwidth (float) – relative bandwidth [dimensionless]
Returns:

backend frequencies [Hz], channel widths [Hz]

Return type:

np.array, np.array

typhon.arts.sensor.get_f_backend_const_width(f_start, f_end, bandwidth)[source]

Compute backend frequencies with constant bandwidth.

This function computes backend frequencies for a given frequency range and a constant bandwidth.

Parameters:
  • f_start (float) – beginning of frequency range [Hz]
  • f_end (float) – end of frequency range [Hz]
  • bandwidth (float) – bandwidth [Hz]
Returns:

backend frequencies [Hz], channel widths [Hz]

Return type:

np.array, np.array