esm_analysis package¶
Subpackages¶
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.
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 attributeself.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 allshort 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.- 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.
-
esm_analysis.logfile module¶
Class for Logfiles
Module contents¶
Top-level package for ESM Analysis.