esm_analysis package

Submodules

esm_analysis.cli module

esm_analysis.esm_analysis module

The ESM Analysis module allows for creation of several common analyis from Python objects.

The main object you probably want to use is: EsmAnalysis. You can create one like this, if you are currently working within an experiment directory:

>>> analyser = EsmAnalysis()

Optionally, you can give it a path where to start from:

>>> analyser = EsmAnalysis(exp_base="/work/ba0989/a270077/AWICM_PISM/LGM_011")

You can also tell it where to store analysis:

>>> analyser = EsmAnalysis(preferred_analysis_dir="/work/ba0989/a270077/store_analysis_here")

Once you have created the analyzer object, you can use the attached methods to quickly get some typical analyses. The methods always return an xarray.Dataset object. Typically, the only required argument is the variable name.

>>> t2m_fldmean = analyser.fldmean("temp2")
class esm_analysis.esm_analysis.AnalysisComponent[source]

Bases: object

class esm_analysis.esm_analysis.EsmAnalysis(exp_base=None, preferred_analysis_dir=None)[source]

Bases: object

create_analysis_dir(preferred_analysis_dir=None)[source]

Create the analysis directory and any intermediate directories if needed.

preferred_analysis_dir : str
The location where analysis should be stored

If you give an argument to preferred_analysis_dir, the attribute self.ANALYSIS_DIR is changed to this.

determine_variable_dict_from_code_files()[source]

A generic method to create a dictionary containing file patterns and variable information for each file pattern found in the OUTDATA_DIR folder.

This is meant to be overloaded!! The default implementation works for ECHAM6 and JSBACH. Maybe it is better to completely move this to just those two classes, or a base class which both can build on.

A nested dictionary. The outermost key is a file pattern, with the value/inner key is the variable short name. The inner value is a dictionary of code_number, levels, short_name, long_name.

fldmean(varname)[source]

Generates a field mean over the entire model domain for a the specified varname.

get_component_for_variable_short_name(varname)[source]

Checks all known component and gets a list of files that should be used for a specific variable name.

There is currently an implicit assumption for the following to be true: 1. Each component has a private attribute _variables 1. This attribute should be a dictionary 1. The dictionary needs to have a “file_pattern” as a key, and all

short names contained in this file pattern as values.
varname : str
The short variable name which is being looked for
file_pattern_list, component : tuple

A tuple of: 1. A list for all files currently available with the varname. Note

that sorting currently does not have a specific mechanism, so it probably sorts alphabetically/numerically.
  1. The component object for analysis with these files.
initialize_analysis_components(preferred_analysis_dir=None)[source]

Creates analysis objects for each component found in the OUTDATA_DIR directory.

It is assumed that the component analysis object can be initialized without any arguments. If no class has been defined yet, a warning is sent.

newest_climatology(varname)[source]
ymonmean(varname)[source]

Generates a ymonmean over the entire model domain for the specified varname.

yseasmean(varname)[source]

Generates a yseasmean over the entire model domain for the specified varname.

esm_analysis.esm_analysis.clean_top_of_tree(basedir)[source]

Cleans up top of experiment tree by adding comment character to the first line

basedir : str
Whre the file .top_of_exp_tree should be found

None

esm_analysis.esm_analysis.load_yaml(f)[source]

Returns dictionary of YAML file f

esm_analysis.esm_analysis.walk_up(bottom)[source]

mimic os.walk, but walk ‘up’ instead of down the directory tree

bottom: str
Where to start walking up from

Tuple of (bottom, dirs, nondirs)

esm_analysis.logfile module

Class for Logfiles

class esm_analysis.logfile.Logfile(log, esm_style=True)[source]

Bases: object

Makes a Pandas Dataframe from a logfile

compute_throughput()[source]
classmethod from_file(fin)[source]
run_stats()[source]

Module contents

Top-level package for ESM Analysis.