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
26 changes: 26 additions & 0 deletions config.analysis
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ plots_dir = /global/project/projectdirs/acme/xylar/coupled_diagnostics_20160805v
log_dir = /global/project/projectdirs/acme/xylar/coupled_diagnostics_20160805v0atm.A_WCYCL1850_v0atm.ne30_oEC.edison.alpha7_00-20160520.A_WCYCL1850.ne30_oEC.edison.alpha6_01.logs
obs_ocndir = /global/project/projectdirs/acme/observations/Ocean
obs_sstdir = /global/project/projectdirs/acme/observations/Ocean/SST
obs_sssdir = /global/project/projectdirs/acme/observations/Ocean/SSS
obs_mlddir = /global/project/projectdirs/acme/observations/Ocean/MLD
obs_seaicedir = /global/project/projectdirs/acme/observations/SeaIce
ref_archive_v0_ocndir = /global/project/projectdirs/acme/ACMEv0_lowres/B1850C5_ne30_v0.4/ocn/postprocessing
Expand Down Expand Up @@ -70,6 +71,9 @@ generate = 0
[sst_modelvsobs]
generate = 1

[sss_modelvsobs]
generate = 1

[mld_modelvsobs]
generate = 1

Expand Down Expand Up @@ -161,6 +165,28 @@ clevsDiff = [-5, -3, -2, -1, 0, 1, 2, 3, 5]
# Times for comparison times (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, JFM, AMJ, JAS, OND, ANN)
comparisonTimes = ['JFM', 'JAS', 'ANN']

[sss_modelvsobs]
# colormap for model/observations
#cmapModelObs = viridis
cmapModelObs = RdYlBu_r
# colormap for differences
#cmapDiff = RdBu_r
cmapDiff = coolwarm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vanroekel, do we really need all the commented lines above? The same is true below too...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My recommendation would be to keep this file as clean as possible by only having comments as absolutely necessary to help avoid confusion in the long term.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pwolfram and @vanroekel, I agree that I don't love having these commented out options in the default config file. Ideally comments should be for clarification rather than alternative options, and instead we would have alternative config files or scripts for modifying config files or something along those lines for changing color maps, etc.

But I also know that this convention has been used for other modelvsobs entries so it's probably not something to address in this specific case but rather to clean up more broadly later on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me.


# indices into cmapModelObs for contour color
cmapIndicesModelObs = [0,40,80,110,140,170,200,230,255]
# indices into cmapModelObs for contour color
cmapIndicesDiff = [0,40,80,120,140,170,210,255]
#cmapIndicesDiff = [0,40,80,127,170,210,255] # good for RdBu_r

# colormap levels/values for contour boundaries
clevsModelObs = [28,29,30,31,32,33,34,35,36,38]
clevsDiff = [-3,-2,-1,-0.5,0.5,1,2,3]
#clevsDiff = [-3,-2,-1,-0.5,0.5,1,2,3] # good for RdBu_r

# Times for comparison times (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,JFM,AMJ,JAS,OND,ANN)
comparisonTimes = ['JFM','JAS','ANN']

[mld_modelvsobs]
# colormap for model/observations
cmapModelObs = viridis
Expand Down
29 changes: 29 additions & 0 deletions mpas_analysis/ocean/ocean_modelvsobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,35 @@ def ocn_modelvsobs(config, field, streamMap=None, variableMap=None):
fileOutLabel = "sstHADOI"
unitsLabel = r'$^o$C'

elif field == 'sss':

selvals = {'nVertLevels': 0}

obs_filename = "{}/Aquarius_V3_SSS_Monthly.nc".format(obsdir)
dsData = xr.open_mfdataset(obs_filename)

time_start = datetime.datetime(2011, 8, 1)
time_end = datetime.datetime(2014, 12, 31)

ds_tslice = dsData.sel(time=slice(time_start, time_end))

# The following line converts from DASK to numpy to supress an odd
# warning that doesn't influence the figure output
ds_tslice.SSS.values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we will be able to remove this line, most likely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to submit an xarray / dask bug report if we could get a simple xarray or dask - only reproducible manifestation of this error if possible. However, this may be time consuming and not worth it, at least in the short-term.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pwolfram not sure if this is helpful information, but I can also suppress this warning if I open the SSS observations with xr.open_dataset instead of xr.open_mfdataset. It's curious that the multiple file version of open throws a warning for SSS, but not for SST or MLD.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is some type of dask-xarray integration error. Getting to the bottom of it will potentially be tricky. I'd say pass on this for now.


monthly_clim_data = ds_tslice.groupby('time.month').mean('time')

# Rename the observation data for code compactness
dsData = monthly_clim_data.transpose('month', 'lon', 'lat')
obsFieldName = 'SSS'

# Set appropriate figure labels for SSS
preIndustrial_txt = "2011-2014"

obsTitleLabel = "Observations (Aquarius, {})".format(preIndustrial_txt)
fileOutLabel = 'sssAquarius'
unitsLabel = 'PSU'

ds = xr.open_mfdataset(
infiles,
preprocess=lambda x: preprocess_mpas(x, yearoffset=yr_offset,
Expand Down
7 changes: 6 additions & 1 deletion mpas_analysis/ocean/variable_stream_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
oceanVariableMap['avgLayerTemperature'] = \
['time_avg_avgValueWithinOceanLayerRegion_avgLayerTemperature',
'time_avg_avgValueWithinOceanLayerRegion_avgLayerTemperature_1',
'timeMonthly_avg_avgValueWithinOceanLayerRegion_avgLayerTemperature']
'timeMonthly_avg_avgValueWithinOceanLayerRegion_avgLayerTemperature']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto for me too!

oceanVariableMap['sumLayerMaskValue'] = \
['time_avg_avgValueWithinOceanLayerRegion_sumLayerMaskValue',
'time_avg_avgValueWithinOceanLayerRegion_sumLayerMaskValue_1',
Expand All @@ -44,3 +44,8 @@
['time_avg_activeTracers_temperature',
'time_avg_activeTracers_temperature_1',
'timeMonthly_avg_activeTracers_temperature']

oceanVariableMap['sss'] = \
['time_avg_activeTracers_salinity',
'time_avg_activeTracers_salinity_1',
'timeMonthly_avg_activeTracers_salinity']
8 changes: 8 additions & 0 deletions run_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ def analysis(config): # {{{
ocn_modelvsobs(config, 'mld', streamMap=oceanStreamMap,
variableMap=oceanVariableMap)

if config.getboolean('sss_modelvsobs', 'generate'):
print ""
print "Plotting 2-d maps of SSS climatologies..."
from mpas_analysis.ocean.ocean_modelvsobs import ocn_modelvsobs
ocn_modelvsobs(config, 'sss', streamMap=oceanStreamMap,
variableMap=oceanVariableMap)


# GENERATE SEA-ICE DIAGNOSTICS
if config.getboolean('seaice_timeseries', 'generate'):
print ""
Expand Down