lowEBMs.Packages.Configuration

Package with functions which configure the model setup.

importer Reads a configuration.ini-file and creates the model run setup in a dictionary.
dict_to_list Converts dictionaries returned from Configuration.importer into a list with the same structure.
parameterimporter A function purpose-built to import 1-dimensional parameters for the sellers-type functions.
parameterinterpolator An interpolation method fitting a polynomial of degree 10 to the parameter distributions.
parameterinterpolatorstepwise An interpolation method stepwise fitting and averaging a polynomial of degree 2 to the parameter distribution.
add_sellersparameters Overwrites the model setup with one-dimensional sellers parameters.
import_parallelparameter Imports information from a .ini-file to create a setup of parallelized simulations.
allocate_parallelparameter Transforms parameters for parallelization from tuple [start,end] to list [start,…,end] of length number_of_cycles.
write_parallelparameter Overwrites the single run model setup with a parallelized model setup.
lowEBMs.Packages.Configuration.importer(filename, *args, **kwargs)[source]

Reads a configuration.ini-file and creates the model run setup in a dictionary. It is one of the coremodules of this project, mostly called as first step, because it gathers all information about the model setup and summarizes it.

Note

The file from which the information is imported has to have a specific structure, please read Input first to see how the configuration.ini-files are created.

The specificaton of the path to the filedirectory is optional. If none is given some standard diretories will be tried (python sys.paths and relative paths like ‘../’, ‘../Config/’,..)

Function-call arguments

Parameters:
  • filename (string) –

    The name of the configuration.ini-file

    • type: string
    • value: example: ‘Configuration.ini’
  • args
  • kwargs

    Optional Keyword arguments:

    • path: The directory path where the configuration.ini-file is located.
      • type: string
      • value: full path (‘/home/user/dir0/dir1/filedir/’) or relative path (‘../../filedir/’)
Returns:

configdic: Dictionary of model setup parameters distributed over several subdictionaries

Return type:

Dictionary

lowEBMs.Packages.Configuration.dict_to_list(dic)[source]

Converts dictionaries returned from Configuration.importer into a list with the same structure. This allows calling the content by index not keyword. It works for a maximum of 3 dimensions of dictionaries (dictionary inside a dictionary).

Function-call arguments

Parameters:dic (dict) – The dictionary to convert
Returns:List with same structure as input dictionary
Return type:List
lowEBMs.Packages.Configuration.parameterimporter(filename, *args, **kwargs)[source]

A function purpose-built to import 1-dimensional parameters for the sellers-type functions. The standard parameters (Sellers 1969) are written into a .ini-file and will be extracted to override the 0-dimensional parameters with 1-dimensional ones.

Important

This function is inbound into Configuration.parameterinterpolater or Configuration.parameterinterpolaterstepwise which interpolate the parameters to the gridresolution. To import, interpolate and overwrite these parameter use Configuration.add_sellersparameters.

Parameters which are imported 1-dimensionally:

  • b: Empirical constant to estimate the albedo
  • Z: Zonal mean altitude
  • Q: Solar insolation
  • dp: The tropospheric pressure depth
  • dz: The average zonal ocean depth
  • Kh: The thermal diffusivity of the atmospheric sensible heat term
  • Kwv: The thermal diffusivity of the watervapour term
  • Ko: The thermal diffusivity of the oceanic sensible heat term
  • a: Empricial constant to calculate the meridional windspeed

The parameters are divided into two types, one defined on a latitudinal circle (gridlines) and one defined on a latitudinal belt (center point between two latitudinal circles/gridlines)

Note

The standard parameters from Sellers (1969) are already provided with this project in ‘lowEBMs/Tutorials/Config/Data/’. By specifying no path (path=None) they can directly be used (advised since the parameters are structured in a special way).

Function-call arguments

Parameters:
  • filename (string) –

    The name of the parameter.ini-file

    • type: string
    • value: standard: ‘SellersParameterization.ini’
  • args
  • kwargs

    Optional Keyword arguments:

    • path: The directory path where the parameter.ini-file is located.
      • type: string
      • value: full path (‘/home/user/dir0/dir1/filedir/’) or relative path (‘../../filedir/’)
Returns:

circlecomb, beltcomb: List of parameters defined on a latitudinal circle, and latitudinal belt

Return type:

List, List

lowEBMs.Packages.Configuration.parameterinterpolator(filename, *args, **kwargs)[source]

An interpolation method fitting a polynomial of degree 10 to the parameter distributions. This creates parameter distributions suitable for the gridresolution (necessary if a higher resolution than 10° is used.

This function includes the function Configuration.parameterimporter and takes the same arguments.

Function-call arguments

Parameters:
  • filename (string) –

    The name of the parameter.ini-file

    • type: string
    • value: standard: ‘SellersParameterization.ini’
  • args
  • kwargs

    Optional Keyword arguments:

    • path: The directory path where the parameter.ini-file is located.
      • type: string
      • value: full path (‘/home/user/dir0/dir1/filedir/’) or relative path (‘../../filedir/’)
Returns:

newcircle, newbelt: List of interpolated parameters defined on a latitudinal circle, and latitudinal belt

Return type:

List, List

lowEBMs.Packages.Configuration.parameterinterpolatorstepwise(filename, *args, **kwargs)[source]

An interpolation method stepwise fitting and averaging a polynomial of degree 2 to the parameter distribution.

The interpolation method is more advanced compared to Configuration.parameterinterpolator. For each point (over the latitudes) a polynomial fit of degree 2 is made over the point plus the neighbouring points and estimates for the new gridresolution between these neighbouring points are stored. This is done for every point of the original parameters (except the endpoints). Because the interpolations overlap, the values are averaged to obtain a best estimate from multiple interpolations.

This function includes the function Configuration.parameterimporter and takes the same arguments.

Function-call arguments

Parameters:
  • filename (string) –

    The name of the parameter.ini-file

    • type: string
    • value: standard: ‘SellersParameterization.ini’
  • args
  • kwargs

    Optional Keyword arguments:

    • path: The directory path where the parameter.ini-file is located.
      • type: string
      • value: full path (‘/home/user/dir0/dir1/filedir/’) or relative path (‘../../filedir/’)
Returns:

newcircle, newbelt: List of interpolated parameters defined on a latitudinal circle, and latitudinal belt

Return type:

List, List

lowEBMs.Packages.Configuration.add_sellersparameters(config, importer, file, transfernumber, downwardnumber, solar, albedo, *args, **kwargs)[source]

Overwrites the model setup with one-dimensional sellers parameters. It takes a model configuration with 0D sellers parameters, the filename of new parameters and a method of interpolation.

This function uses either the method Configuration.parameterinterpolator or Configuration.parameterinterpolatorstepwise which both use the import function Configuration.parameterimporter, therefore it requires their attributes too.

Function-call arguments

Parameters:
  • config (dict) –

    The original config dictionary to overwrite

    • type: dictionary
    • value: created by Configuration.importer
  • importer (function) –

    The name of the interpolator method

    • type: functionname
    • value: parameterinterpolator or parameterinterpolatorstepwise
  • file (string) –

    The name of the parameter.ini-file

    • type: string
    • value: standard: ‘SellersParameterization.ini’
  • transfernumber (integer) –

    The [func] header-number in the configuration.ini-file which describes the transfer flux

    • type: integer
    • value: any
  • incomingnumber (integer) –

    The [func] header-number in the configuration.ini-file which describes the downward flux

    • type: integer
    • value: any
  • solar (boolean) –

    Indicates whether the insolation by Sellers is used

    • type: boolean
    • value: True / False
  • albedo (boolean) –

    Indicates whether the albedo parameters by Sellers are used

    • type: boolean
    • value: True / False
  • args
  • kwargs

    Optional Keyword arguments:

    • path: The directory path where the parameter.ini-file is located.
      • type: string
      • value: full path (‘/home/user/dir0/dir1/filedir/’) or relative path (‘../../filedir/’)
Returns:

configuration, parameters

Return type:

Dictionary, List

lowEBMs.Packages.Configuration.import_parallelparameter(parallelconfig_filename, *args, **kwargs)[source]

Imports information from a .ini-file to create a setup of parallelized simulations. This shall allow time-efficient creation of ensemble run, focused to run simulations with various parameters to gain best-fit parameters.

Function-call arguments

Parameters:
  • parallelconfig_filename (string) –

    The name of the Parallelization.ini-file for parallelization

    • type: string
    • value: standard: ‘Parallelization.ini’
  • args
  • kwargs

    Optional Keyword arguments:

    • path: The directory path where the Parallelization.ini-file is located.
      • type: string
      • value: full path (‘/home/user/dir0/dir1/filedir/’) or relative path (‘../../filedir/’)
Returns:

raw parallelization setup

Return type:

Dictionary

lowEBMs.Packages.Configuration.allocate_parallelparameter(parameter_raw)[source]

Transforms parameters for parallelization from tuple [start,end] to list [start,…,end] of length number_of_cycles. This shall create lists of parameters to be tested in parallelized simulations.

Function-call arguments

Parameters:parameter_raw (dict) –

A dictionary with parameters to allocate. The values of the parameters should have the form [start,end] to create [start,…,end] of length number_of_cycles

  • type: dictionary
  • value: as returned by configuration.import_parallelparameter
Returns:allocated parallelization setup, parallelization information
Return type:Dictionary, Dictionary
lowEBMs.Packages.Configuration.write_parallelparameter(config, parameter, parametersetup)[source]

Overwrites the single run model setup with a parallelized model setup. This function uses the allocated parallelization setup as returned by Configuration.allocate_parallelparameter. Depending on the number of paramters n to parallelize, a n-dimensional matrix is created. This matrix will be transformed to a one-dimensional list by placing one row after another.

Function-call arguments

Parameters:
  • config (dict) –

    The original config dictionary to overwrite

    • type: dictionary
    • value: created by Configuration.importer
  • parameter (dict) –

    A dictionary with allocated parameters for parallelization. First element returned by Configuration.allocate_parallelparameter.

    • type: dictionary
    • value: as returned by Configuration.allocate_parallelparameter
  • parametersetup (dict) –

    A dictionary with information about parallelization. Second element returned by Configuration.allocate_parallelparameter.

    • type: dictionary
    • value: as returned by Configuration.allocate_parallelparameter
Returns:

config: Updated dictionary of model setup parameters for parallelization

Return type:

Dictionary