Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mpasMeshName = oEC60to30v3
# Directory for mapping files (if they have been generated already). If mapping
# files needed by the analysis are not found here, they will be generated and
# placed in the output mappingSubdirectory
mappingDirectory = /lcrc/group/acme/mapping
mappingDirectory = /lcrc/group/acme/mpas_analysis/mapping

[output]
## options related to writing out plots, intermediate cached data sets, logs,
Expand Down
7 changes: 7 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ Shared modules

Reading MPAS Datasets
---------------------
.. currentmodule:: mpas_analysis.shared.io

.. autosummary::
:toctree: generated/

open_mpas_dataset

.. currentmodule:: mpas_analysis.shared.mpas_xarray

.. autosummary::
Expand Down
63 changes: 30 additions & 33 deletions mpas_analysis/ocean/index_nino34.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import pandas as pd
import numpy as np
from scipy import signal, stats
import os
import matplotlib.pyplot as plt

from ..shared.climatology import climatology
from ..shared.constants import constants
from ..shared.io.utility import build_config_full_path
from ..shared.generalized_reader.generalized_reader \
import open_multifile_dataset

from ..shared.timekeeping.utility import get_simulation_start_time, \
datetime_to_days, string_to_days_since_date

from ..shared.io import open_mpas_dataset

from ..shared.plot.plotting import plot_xtick_format, plot_size_y_axis

from ..shared import AnalysisTask
Expand All @@ -26,12 +26,18 @@ class IndexNino34(AnalysisTask): # {{{
A task for computing and plotting time series and spectra of the El Nino
3.4 climate index

Attributes
----------

mpasTimeSeriesTask : ``MpasTimeSeriesTask``
The task that extracts the time series from MPAS monthly output

Authors
-------
Luke Van Roekel, Xylar Asay-Davis
'''

def __init__(self, config): # {{{
def __init__(self, config, mpasTimeSeriesTask): # {{{
'''
Construct the analysis task.

Expand All @@ -40,6 +46,9 @@ def __init__(self, config): # {{{
config : instance of MpasAnalysisConfigParser
Contains configuration options

mpasTimeSeriesTask : ``MpasTimeSeriesTask``
The task that extracts the time series from MPAS monthly output

Authors
-------
Xylar Asay-Davis
Expand All @@ -52,6 +61,10 @@ def __init__(self, config): # {{{
componentName='ocean',
tags=['index', 'nino'])

self.mpasTimeSeriesTask = mpasTimeSeriesTask

self.run_after(mpasTimeSeriesTask)

# }}}

def setup_and_check(self): # {{{
Expand All @@ -70,19 +83,14 @@ def setup_and_check(self): # {{{
# self.calendar
super(IndexNino34, self).setup_and_check()

# get a list of timeSeriesStats output files from the streams file,
# reading only those that are between the start and end dates
streamName = 'timeSeriesStatsMonthlyOutput'
self.startDate = self.config.get('index', 'startDate')
self.endDate = self.config.get('index', 'endDate')
self.inputFiles = self.historyStreams.readpath(
streamName, startDate=self.startDate, endDate=self.endDate,
calendar=self.calendar)
self.startDate = self.config.get('timeSeries', 'startDate')
self.endDate = self.config.get('timeSeries', 'endDate')

self.variableList = \
['timeMonthly_avg_avgValueWithinOceanRegion_avgSurfaceTemperature']
self.mpasTimeSeriesTask.add_variables(variableList=self.variableList)

if len(self.inputFiles) == 0:
raise IOError('No files were found in stream {} between {} and '
'{}.'.format(streamName, self.startDate,
self.endDate))
self.inputFile = self.mpasTimeSeriesTask.outputFile

mainRunName = self.config.get('runs', 'mainRunName')

Expand Down Expand Up @@ -110,7 +118,6 @@ def run_task(self): # {{{
self.logger.info(' Load SST data...')
fieldName = 'nino'

simulationStartTime = get_simulation_start_time(self.runStreams)
config = self.config
calendar = self.calendar

Expand All @@ -130,29 +137,18 @@ def run_task(self): # {{{
obsTitle = 'ERS SSTv4'
refDate = '1800-01-01'

self.logger.info('\n Reading files:\n'
' {} through\n {}'.format(
os.path.basename(self.inputFiles[0]),
os.path.basename(self.inputFiles[-1])))
mainRunName = config.get('runs', 'mainRunName')

# regionIndex should correspond to NINO34 in surface weighted Average
# AM
regionIndex = config.getint('indexNino34', 'regionIndicesToPlot')

# Load data:
varName = \
'timeMonthly_avg_avgValueWithinOceanRegion_avgSurfaceTemperature'
varList = [varName]
ds = open_multifile_dataset(fileNames=self.inputFiles,
calendar=calendar,
config=config,
simulationStartTime=simulationStartTime,
timeVariableName=['xtime_startMonthly',
'xtime_endMonthly'],
variableList=varList,
startDate=self.startDate,
endDate=self.endDate)
ds = open_mpas_dataset(fileName=self.inputFile,
calendar=calendar,
variableList=self.variableList,
startDate=self.startDate,
endDate=self.endDate)

# Observations have been processed to the nino34Index prior to reading
dsObs = xr.open_dataset(dataPath, decode_cf=False, decode_times=False)
Expand All @@ -163,6 +159,7 @@ def run_task(self): # {{{
nino34Obs = dsObs.sst

self.logger.info(' Compute NINO3.4 index...')
varName = self.variableList[0]
regionSST = ds[varName].isel(nOceanRegions=regionIndex)
nino34 = self._compute_nino34_index(regionSST, calendar)

Expand Down
2 changes: 0 additions & 2 deletions mpas_analysis/ocean/meridional_heat_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ def setup_and_check(self): # {{{

self.mhtFile = mhtFiles[0]

self.simulationStartTime = get_simulation_start_time(self.runStreams)

self.sectionName = 'meridionalHeatTransport'

# Read in obs file information
Expand Down
Loading