htrdrPy.script module

class htrdrPy.script.Script(case='', threadFlag='', MPIcmd='', verbose=True)[source]

Bases: object

The htrdrPy.Script module aims at creating a callable (a function) taking as input a htrdrPy.Data object.

Examples

The first step is to create an instance of htrdrPy.Script:

>>> script = htrdrPy.script(case="caseName")

The second step is to define the kind of script to be executed (see the documentation for all possibilities). If none of the predefined script suits your use, you can use the htrdrPy.Script.startMultipleObsGeometry method.

>>> script.startMultipleObsGeometry(...)

Finally, you can call the script on an already defined htrdrPy.Data object:

>>> script(data)

The Script module aims at creating a callable (a function) to be called on a Data object.

Parameters:
  • case (str, optional) – String to identify the script. This is mostly usefull in case different scripts are used on the same htrdrPy.Data instance. The output files being stored in the same folder (see htrdrPy.Data documentation), the case name is used to differentiate the output files of the different scripts.

  • threadFlag (str, optional) – Thread option to use in the htrdr command. Should take the form “-t <num>” where <num> is the number of threads to be used. If left empty, the maximum number of threads (corresponding to the number of virtual cores on the computer) will be used.

  • MPIcmd (str, optional) – MPI command to pass before the call to htrdr-planets, depending on the MPI runner on your system. For insatnce, it could be an ‘mpirun’ command on many computers, or a ‘srun’ command on a slurm-based supercalculator.

  • verbose (bool, default True) – Whether or not activate the verbose of htrdr-planets.

bandIntegratedImage(geometry: Geometry, kind, wavelengthLow, wavelengthUp)[source]

Set up the script to calculate an image integrated over a given spectral range.

Parameters:
  • geometry (htrdrPy.Geometry) – A htrdrPy.Geometry object previously created and set up.

  • kind ({"sw", "lw"}) – Type of calculation. “sw” for a calculation with an external source, and “lw” to use the atmosphere emission as source.

  • wavelengthLow (float) – Lower boundary wavelength [m].

  • wavelengthUp (float) – Upper boundary wavelength [m].

compositeRBG(geometry: Geometry, kind, wavelengthRed, wavelengthGreen, wavelengthBlue)[source]

Set up the script to calculate the composite image from 3 monochromatic images.

Parameters:
  • geometry (htrdrPy.Geometry) – A htrdrPy.Geometry object previously created and set up.

  • kind ({"sw", "lw"}) – Type of calculation. “sw” for a calculation with an external source, and “lw” to use the atmosphere emission as source.

  • wavelengthRed (float) – Wavelength for red chanel image [m].

  • wavelengthGreen (float) – Wavelength for green chanel image [m].

  • wavelengthBlue (float) – Wavelength for red chanel image [m].

Warning

This script has not bee tested yet and may not work correctly. This should be treated in future versions.

imageRatio(geometry: Geometry, kind, wavelengthNum, wavelengthDen)[source]

Set up the script to calculate the ratio of 2 monochromatic images.

Parameters:
  • geometry (htrdrPy.Geometry) – A htrdrPy.Geometry object previously created and set up.

  • kind ({"sw", "lw"}) – Type of calculation. “sw” for a calculation with an external source, and “lw” to use the atmosphere emission as source.

  • wavelengthNum (float) – Wavelength for numerator image [m].

  • wavelengthDen (float) – Wavelength for denominator image [m].

monochromaticImage(geometry: Geometry, kind, wavelength)[source]

Set up the script to calculate a monochromatic image.

Parameters:
  • geometry (htrdrPy.Geometry) – A htrdrPy.Geometry object previously created and set up.

  • kind ({"sw", "lw"}) – Type of calculation. “sw” for a calculation with an external source, and “lw” to use the atmosphere emission as source.

  • wavelength (float) – Wavelength to use for the calculation [m].

reflectanceSpectrum(geometry: Geometry, kind, wavelengths, bandWidths=None)[source]

Start mutliple runs of htrdr-planets to calculate a reflectance spectrum, producing an output for each wavelength.

Parameters:
  • geometry (htrdrPy.Geometry) – A htrdrPy.Geometry object previously created and set up.

  • kind ({"sw", "lw"}) – Type of calculation. “sw” for a calculation with an external source, and “lw” to use the atmosphere emission as source.

  • wavelength (float) – Wavelength to use for the calculation [m].

  • bandWidths (numpy.ndarray) – Integration band around each wavelength. If not provided, the calculation is monochromatic (shape=(nWavelength), [m]).

spectrum(geometry: Geometry, kind, wavelengths, bandWidths=None)[source]

Start mutliple runs of htrdr-planets to calculate a spectrum, producing an output for each wavelength.

Parameters:
  • geometry (htrdrPy.Geometry) – A htrdrPy.Geometry object previously created and set up.

  • kind ({"sw", "lw"}) – Type of calculation. “sw” for a calculation with an external source, and “lw” to use the atmosphere emission as source.

  • wavelength (float) – Wavelength to use for the calculation [m].

  • bandWidths (numpy.ndarray) – Integration band around each wavelength. If not provided, the calculation is monochromatic (shape=(nWavelength), [m]).

startMultipleObsGeometry(obsList: list[Geometry], wavelength)[source]

Start multiple runs with different observation geometries but the same planet inputs

Parameters:
  • obsList (array-like) – List of htrdrPy.Geometry instances.

  • wavelength (dict) –

    Dictionnary containing the spectral information with the following items:

    • ”type”{“cie_xyz”, “sw”, “lw”}

      Type of calculation.

    • ”low”float

      Lower bound of integration band [m].

    • ”up”float

      Upper bound of integration band [m] (if monochromatic calculation, “up” = “low”).

startRadBudgetGCM(geometry: Geometry, kind)[source]

Set up the script to calculate athe radiative budget of each GCM cell.

Parameters:
  • geometry (htrdrPy.Geometry) – A htrdrPy.Geometry object previously created and set up.

  • kind ({"sw", "lw"}) – Type of calculation. “sw” for a calculation with an external source, and “lw” to use the atmosphere emission as source.

visibleImage(geometry: Geometry)[source]

Set up the script to calculate a visible (RGB) image.

Parameters:

geometry (htrdrPy.Geometry) – A htrdrPy.Geometry object previously created and set up.

htrdrPy.script.loadScript(filename)[source]

Load a htrdrPy.Script object from the binary file where it is saved (generated after the call on a htrdrPy.Data object).

Parameters:

filename (str) – Path to the binary file to be loaded.