htrdrPy.postprocess module

class htrdrPy.postprocess.Postprocess(script: Script = None, skip=False, localPath=False, kwargs={})[source]

Bases: object

The htrdrPy.Postprocess module aims at providing tools to process the outputs generated by htrdr-planets or auto-process the outputs based on the htrdrPy.Script used.

Examples

In the case of the use of a predefined htrdrPy.Script other than htrdrPy.Script.startMultipleObsGeometry, the user simply needs to provide the htrdrPy.Script used at the creatin of the htrdrPy.Postprocess instance.

>>> pp = htrdrPy.Postprocess(script)

This will generate the output files (‘.json’, images, …) in a ‘result_{name}/’ folder, where the ‘name’ is the name of the htrdrPy.Data instance passed to the htrdrPy.Script.

Parameters:
  • script (htrdrPy.Script, optional) – htrdrPy.Script object which as been called on a htrdrPy.Data object.

  • skip (bool, default False) – Whether or not to skip the default post-processing operation. Default is False.

  • localPath (bool, default False) – Whether or not to create the result directory at the root of the the script running the post-processing. If True, the result directory will be located in the same directory as the running post-processing script, otherwise, it is located in the directory where htrdr-planets was run.

  • kwargs (dict) –

    Dictionary containing the arguments for the post-processing routine. You will find the required items, depending on the script used, in the following table.

    kwargs

    Script

    Items

    • htrdPy.Script.visibleImage or

    • htrdPy.Script.monochromaticImage or

    • htrdPy.Script.bandIntegratedImage

    • ”exposure”float, default 1.

      Exposure time [s] for the generation of the image.

    • ”cmap”str, default “inferno”

      Color map to be used. See htrdr documentation for all possibilities.

    htrdPy.Script.imageRatio

    • ”threshold”float, default 0.

      Threshold limit below which the data are considered zero (expressed relatively to the data maximale value: threshold * max(data)).

    • htrdPy.Script.spectrum or

    • htrdPy.Script.reflectanceSpectrum or

    • htrdPy.Script.compositeRBG

    htrdPy.Script.startRadBudgetGCM

    • ”heatCapacity”float, optional

      Heat capacity of the atmosphere [J/kg/K]. If not provided, the calculation of the heating rate is not realised and the resulting file only contains the flux divergence.

    • ”rho”float, optional

      Mass volume density of the atmosphere [kg/m3]. If not provided, the calculation of the heating rate is not realised and the resulting file only contains the flux divergence.

Notes

Im most cases, the module recognize the kind of script and automatically apply the required post-process function. This is not the case for script based on “startMultipleObsGeometry”, as the post-processing routine to be used is not trivial. A bunch of additional methods are therefore provided.

extractMeanRadianceFromOutput(file, time=False)[source]

Calculate the average radiance and standard deviation over all pixels

Parameters:

file (str) – Path to the htrdr output file containing the pixels information.

Returns:

  • float – Average radiance over the pixel grid (units are similar to htrdr outputs).

  • float – Standard deviation of the radiance over the pixel grid (units are similar to htrdr outputs).

  • float – Mean computation time per path [µs].

  • float – Standard deviation of the computation time per path [µs].

extractMeanRadiances(indices=False)[source]

Extract the mean radiances of all (or a subset) images generated by the Script.

Parameters:

indices (array-like) – List containing the indices of the file to be processed. In case multiple outputs are generated (can be the case for a spectrum, or using htrdrPy.Script.startMultipleGeometry) the file index follows the order of execution of the runs (for a spectrum, the order in which the wavelength have been given and for htrdrPy.Script.startMultipleGeometry the order of the list of geometries.)

Returns:

Dictionnary with mean radiances and standard deviations (c.f. htrdrPy.Postprocess.extractMeanRadianceFromOutput) for all requested output files.

Return type:

dict

getImage(file)[source]

Recover the image data from a htrdr output file.

Parameters:

file (str) – Path to the htrdr output file.

Returns:

  • numpy.ndarray – Radiances associated to each pixel (shape=(nPixelX,nPixelY)).

  • numpy.ndarray – Standard deviation associated to each pixel (shape=(nPixelX,nPixelY)).

getImages()[source]

Recover the images data from all htrdr output files generated by the Script.

Returns:

Dictionnary with radiances and standard deviations map for all output files.

Return type:

dict

processImages(exposure=1, cmap='inferno')[source]

Generates the image corresponding to all output files.

Parameters:
  • exposure (float, default 1.) – Exposure time [s] for the generation of the image.

  • cmap (str, default "inferno") – Color map to be used. See htrdr documentation for all possibilities.

processSingleArrayObsSW()[source]

Processes the previously generated files in the case of single array (one of the image definition is 1).

Returns:

Dictionnary containing 2-D numpy.ndarray (shape=(nPixel,2)) for each output file. The first column of the arrays are radiances (units are similar to htrdr outputs) and the second columns are the associated standard deviation (units are similar to htrdr outputs).

Return type:

dict