mpas_analysis.shared.analysis_task.AnalysisTask

class mpas_analysis.shared.analysis_task.AnalysisTask(config, taskName, componentName, tags=[], subtaskName=None)[source]

The base class for analysis tasks.

Variables
  • config (MpasAnalysisConfigParser) – Contains configuration options

  • taskName (str) – The name of the task, typically the same as the class name except starting with lowercase (e.g. ‘myTask’ for class ‘MyTask’)

  • componentName ({'ocean', 'seaIce'}) – The name of the component (same as the folder where the task resides)

  • tags (list of str) – Tags used to describe the task (e.g. ‘timeSeries’, ‘climatology’, horizontalMap’, ‘index’, ‘transect’). These are used to determine which tasks are generated (e.g. ‘all_transect’ or ‘no_climatology’ in the ‘generate’ flags)

  • runDirectory (str) – The base input directory for namelists, streams files and restart files

  • historyDirectory (str) – The base input directory for history files

  • plotsDirectory (str) – The directory for writing plots (which is also created if it doesn’t exist)

  • namelist (shared.io.NameList) – the namelist reader

  • runStreams (shared.io.StreamsFile) – the streams file reader for streams in the run directory (e.g. restart files)

  • historyStreams (shared.io.StreamsFile) – the streams file reader for streams in the history directory (most streams other than restart files)

  • calendar ({'gregorian', 'gregoraian_noleap'}) – The calendar used in the MPAS run

  • runAfterTasks (list of AnalysisTasks) – tasks that must be complete before this task can run

  • subtasks (OrderedDict of AnalysisTasks) – Subtasks of this task, with subtask names as keys

  • xmlFileNames (list of strings) – The XML file associated with each plot produced by this analysis, empty if no plots were produced

  • logger (logging.Logger) – A logger for output during the run phase of an analysis task

__init__(config, taskName, componentName, tags=[], subtaskName=None)[source]

Construct the analysis task.

Individual tasks (children classes of this base class) should first call this method to perform basic initialization, then, define the taskName, componentName and list of tags for the task.

Parameters
  • config (instance of MpasAnalysisConfigParser) – Contains configuration options

  • taskName (str) – The name of the task, typically the same as the class name except starting with lowercase (e.g. ‘myTask’ for class ‘MyTask’)

  • componentName ({'ocean', 'seaIce'}) – The name of the component (same as the folder where the task resides)

  • tags (list of str, optional) – Tags used to describe the task (e.g. ‘timeSeries’, ‘climatology’, horizontalMap’, ‘index’, ‘transect’). These are used to determine which tasks are generated (e.g. ‘all_transect’ or ‘no_climatology’ in the ‘generate’ flags)

  • subtaskName (str, optional) – If this is a subtask of taskName, the name of the subtask

Methods

__init__(config, taskName, componentName[, …])

Construct the analysis task.

add_subtask(subtask)

Add a subtask to this tasks.

check_analysis_enabled(analysisOptionName[, …])

Check to make sure a given analysis is turned on, issuing a warning or raising an exception if not.

check_generate()

Determines if this analysis should be generated, based on the generate config option and taskName, componentName and tags.

close()

Close the Process object.

is_alive()

Return whether process is alive

join([timeout])

Wait until child process terminates

kill()

Terminate process; sends SIGKILL signal or uses TerminateProcess()

run([writeLogFile])

Sets up logging and then runs the analysis task.

run_after(task)

Only run this task after the given task has completed.

run_task()

Run the analysis.

set_start_end_date(section)

Set the start and end dates in the config correspond to the start and end years in a given category of analysis

setup_and_check()

Perform steps to set up the analysis (e.g.

start()

Start child process

terminate()

Terminate process; sends SIGTERM signal or uses TerminateProcess()

Attributes

BLOCKED

FAIL

READY

RUNNING

SUCCESS

UNSET

authkey

daemon

Return whether process is a daemon

exitcode

Return exit code of process or None if it has yet to stop

ident

Return identifier (PID) of process or None if it has yet to start

name

pid

Return identifier (PID) of process or None if it has yet to start

sentinel

Return a file descriptor (Unix) or handle (Windows) suitable for waiting for process termination.