Skip to content

Re-introduced the option to turn off comparison with ACMEv0 pre-processed data #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# User defined config files
/config.analysis.*
/config.analysis_*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
32 changes: 16 additions & 16 deletions config.analysis
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
casename = 20160805v0atm.A_WCYCL1850_v0atm.ne30_oEC.edison.alpha7_00
native_res = ne30
short_term_archive = 0
casename_model_tocompare = B1850C5_ne30_v0.4
ref_casename_v0 = B1850C5_ne30_v0.4

[paths]
# paths to simulation and observational datasets
Expand All @@ -15,14 +15,14 @@ log_dir = /global/project/projectdirs/acme/xylar/coupled_diagnostics_20160805v0a
obs_ocndir = /global/project/projectdirs/acme/observations/Ocean
obs_sstdir = /global/project/projectdirs/acme/observations/Ocean/SST
obs_seaicedir = /global/project/projectdirs/acme/observations/SeaIce
ocndir_model_tocompare = /global/project/projectdirs/acme/ACMEv0_lowres/B1850C5_ne30_v0.4/ocn/postprocessing
seaicedir_model_tocompare = /global/project/projectdirs/acme/ACMEv0_lowres/B1850C5_ne30_v0.4/ice/postprocessing
ref_archive_v0_ocndir = /global/project/projectdirs/acme/ACMEv0_lowres/B1850C5_ne30_v0.4/ocn/postprocessing
ref_archive_v0_seaicedir = /global/project/projectdirs/acme/ACMEv0_lowres/B1850C5_ne30_v0.4/ice/postprocessing

[data]
# paths to mesh and mapping files
mpas_meshfile = /global/project/projectdirs/acme/milena/MPAS-grids/ocn/gridfile.oEC60to30.nc
mpas_remapfile = /global/project/projectdirs/acme/mapping/maps/map_oEC60to30_TO_0.5x0.5degree_blin.160412.nc
model_tocompare_remapfile = /global/project/projectdirs/acme/mapping/maps/map_gx1v6_TO_0.5x0.5degree_blin.160413.nc
pop_remapfile = /global/project/projectdirs/acme/mapping/maps/map_gx1v6_TO_0.5x0.5degree_blin.160413.nc
# path to climotology dataset
mpas_climodir = /global/project/projectdirs/acme/xylar/20160805v0atm.A_WCYCL1850_v0atm.ne30_oEC.edison.alpha7_00.test.pp

Expand Down Expand Up @@ -66,8 +66,8 @@ generate = 1
generate = 1

[ohc_timeseries]
# compare to output from another model run?
compare_with_model = True
## compare to output from another model run?
#compare_with_model = True
# compare to observations?
compare_with_obs = False
# list of region indices to plot from the region list below
Expand All @@ -77,8 +77,8 @@ regionIndicesToPlot = [6]
N_movavg = 12

[sst_timeseries]
# compare to output from another model run?
compare_with_model = True
## compare to output from another model run?
#compare_with_model = True
# compare to observations?
compare_with_obs = True
# list of region indices to plot from the region list below
Expand All @@ -88,35 +88,35 @@ regionIndicesToPlot = [6]
N_movavg = 12

[nino34_timeseries]
# compare to output from another model run?
compare_with_model = True
## compare to output from another model run?
#compare_with_model = True
# compare to observations?
compare_with_obs = True
# Number of points over which to compute moving average (e.g., for monthly
# output, N_movavg=12 corresponds to a 12-month moving average window)
N_movavg = 12

[mht_timeseries]
# compare to output from another model run?
compare_with_model = True
## compare to output from another model run?
#compare_with_model = True
# compare to observations?
compare_with_obs = True
# Number of points over which to compute moving average (e.g., for monthly
# output, N_movavg=12 corresponds to a 12-month moving average window)
N_movavg = 12

[moc_timeseries]
# compare to output from another model run?
compare_with_model = True
## compare to output from another model run?
#compare_with_model = True
# compare to observations?
compare_with_obs = True
# Number of points over which to compute moving average (e.g., for monthly
# output, N_movavg=12 corresponds to a 12-month moving average window)
N_movavg = 12

[seaice_timeseries]
# compare to output from another model run?
compare_with_model = True
## compare to output from another model run?
#compare_with_model = True
# compare to observations?
compare_with_obs = True
# Number of points over which to compute moving average (e.g., for monthly
Expand Down
41 changes: 18 additions & 23 deletions mpas_analysis/ocean/ohc_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ def ohc_timeseries(config):
indir = config.get('paths','archive_dir_ocn')
meshfile = config.get('data','mpas_meshfile')
casename = config.get('case','casename')
casename_model_tocompare = config.get('case','casename_model_tocompare')
indir_model_tocompare = config.get('paths','ocndir_model_tocompare')
ref_casename_v0 = config.get('case','ref_casename_v0')
indir_v0data = config.get('paths','ref_archive_v0_ocndir')

compare_with_model = config.getboolean('ohc_timeseries','compare_with_model')
compare_with_obs = config.getboolean('ohc_timeseries','compare_with_obs')

plots_dir = config.get('paths','plots_dir')
Expand Down Expand Up @@ -77,19 +76,18 @@ def ohc_timeseries(config):
time_start = datetime.datetime(year_start,1,1)
time_end = datetime.datetime(year_end,12,31)

if compare_with_model:
print " Load OHC for model_to_compare and make plots..."
# load in other model run data
infiles_model_tocompare = "".join([indir_model_tocompare,'/OHC.',casename_model_tocompare,'.year*.nc'])
ds_model_tocompare = xr.open_mfdataset(infiles_model_tocompare,preprocess=lambda x: preprocess_mpas(x, yearoffset=yr_offset))
ds_model_tocompare = remove_repeated_time_index(ds_model_tocompare)
ds_model_tocompare_tslice = ds_model_tocompare.sel(Time=slice(time_start,time_end))
if ref_casename_v0 != "None":
print " Load in OHC for ACMEv0 case..."
infiles_v0data = "".join([indir_v0data,'/OHC.',ref_casename_v0,'.year*.nc'])
ds_v0 = xr.open_mfdataset(infiles_v0data,preprocess=lambda x: preprocess_mpas(x, yearoffset=yr_offset))
ds_v0 = remove_repeated_time_index(ds_v0)
ds_v0_tslice = ds_v0.sel(Time=slice(time_start,time_end))

sumLayerMaskValue = ds.time_avg_avgValueWithinOceanLayerRegion_sumLayerMaskValue
avgLayerArea = ds.time_avg_avgValueWithinOceanLayerRegion_avgLayerArea
avgLayerThickness = ds.time_avg_avgValueWithinOceanLayerRegion_avgLayerThickness

print " Compute OHC..."
print " Compute OHC and make plots..."
for index in range(len(iregions)):
iregion = iregions[index]

Expand Down Expand Up @@ -118,25 +116,22 @@ def ohc_timeseries(config):
xlabel = "Time [years]"
ylabel = "[x$10^{22}$ J]"

if compare_with_model:
figname = "%s/ohc_%s_%s_%s.png" % (plots_dir,regions[iregion],casename,casename_model_tocompare)
# load in other model run data
ohc_model_tocompare_tot = ds_model_tocompare_tslice.ohc_tot
ohc_model_tocompare_700m = ds_model_tocompare_tslice.ohc_700m
ohc_model_tocompare_2000m = ds_model_tocompare_tslice.ohc_2000m
ohc_model_tocompare_btm = ds_model_tocompare_tslice.ohc_btm
title = "".join([title," (r), ",casename_model_tocompare," (b)"])
if ref_casename_v0 != "None":
figname = "%s/ohc_%s_%s_%s.png" % (plots_dir,regions[iregion],casename,ref_casename_v0)
ohc_v0_tot = ds_v0_tslice.ohc_tot
ohc_v0_700m = ds_v0_tslice.ohc_700m
ohc_v0_2000m = ds_v0_tslice.ohc_2000m
ohc_v0_btm = ds_v0_tslice.ohc_btm
title = "".join([title," (r), ",ref_casename_v0," (b)"])
timeseries_analysis_plot(config, [ohc_tot, ohc_700m, ohc_2000m, ohc_btm,
ohc_model_tocompare_tot, ohc_model_tocompare_700m,
ohc_model_tocompare_2000m, ohc_model_tocompare_btm],
ohc_v0_tot, ohc_v0_700m, ohc_v0_2000m, ohc_v0_btm],
N_movavg, title, xlabel, ylabel, figname,
lineStyles = ['r-', 'r-', 'r--', 'r-.', 'b-', 'b-', 'b--', 'b-.'],
lineWidths = [2, 1, 1.5, 1.5, 2, 1, 1.5, 1.5])

if not compare_with_obs and not compare_with_model:
if not compare_with_obs and ref_casename_v0 == "None":
figname = "%s/ohc_%s_%s.png" % (plots_dir,regions[iregion],casename)
timeseries_analysis_plot(config, [ohc_tot, ohc_700m, ohc_2000m, ohc_btm],
N_movavg, title, xlabel, ylabel, figname,
lineStyles = ['r-', 'r-', 'r--', 'r-.'],
lineWidths = [2, 1, 1.5, 1.5])

36 changes: 13 additions & 23 deletions mpas_analysis/ocean/sst_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ def sst_timeseries(config):
infiles = '%s/am.mpas-o.timeSeriesStats.????-??*nc'%indir

casename = config.get('case','casename')
casename_model_tocompare = config.get('case','casename_model_tocompare')
indir_model_tocompare = config.get('paths','ocndir_model_tocompare')
ref_casename_v0 = config.get('case','ref_casename_v0')
indir_v0data = config.get('paths','ref_archive_v0_ocndir')

compare_with_model = config.getboolean('sst_timeseries','compare_with_model')
compare_with_obs = config.getboolean('sst_timeseries','compare_with_obs')

plots_dir = config.get('paths','plots_dir')
Expand All @@ -34,10 +33,8 @@ def sst_timeseries(config):
ds = xr.open_mfdataset(infiles, preprocess=lambda x: preprocess_mpas(x, yearoffset=yr_offset,
timeSeriesStats=True, timestr='time_avg_daysSinceStartOfSim',
onlyvars=['time_avg_avgValueWithinOceanRegion_avgSurfaceTemperature']))

ds = remove_repeated_time_index(ds)


SSTregions = ds.time_avg_avgValueWithinOceanRegion_avgSurfaceTemperature

year_start = (pd.to_datetime(ds.Time.min().values)).year
Expand All @@ -46,17 +43,14 @@ def sst_timeseries(config):
time_end = datetime.datetime(year_end,12,31)


if compare_with_model:
# load in other model run data
infiles_model_tocompare = "".join([indir_model_tocompare,'/SST.',casename_model_tocompare,'.year*.nc'])
ds_model_tocompare = xr.open_mfdataset(infiles_model_tocompare,preprocess=lambda x: preprocess_mpas(x, yearoffset=yr_offset))
ds_model_tocompare = remove_repeated_time_index(ds_model_tocompare)
ds_model_tocompare_tslice = ds_model_tocompare.sel(Time=slice(time_start,time_end))
if ref_casename_v0 != "None":
print " Load in SST for ACMEv0 case..."
infiles_v0data = "".join([indir_v0data,'/SST.',ref_casename_v0,'.year*.nc'])
ds_v0 = xr.open_mfdataset(infiles_v0data,preprocess=lambda x: preprocess_mpas(x, yearoffset=yr_offset))
ds_v0 = remove_repeated_time_index(ds_v0)
ds_v0_tslice = ds_v0.sel(Time=slice(time_start,time_end))


# Load data and make plot for every region
print " Make plots..."

for index in range(len(iregions)):
iregion = iregions[index]

Expand All @@ -67,20 +61,16 @@ def sst_timeseries(config):

SST = SSTregions[:,iregion]

if compare_with_model:
# load in other model run data
figname = "%s/sst_%s_%s_%s.png" % (plots_dir,regions[iregion],casename,casename_model_tocompare)
SST_model_tocompare = ds_model_tocompare_tslice.SST
if ref_casename_v0 != "None":
figname = "%s/sst_%s_%s_%s.png" % (plots_dir,regions[iregion],casename,ref_casename_v0)
SST_v0 = ds_v0_tslice.SST

title = "%s\n %s (b-)" % (title, casename_model_tocompare)
timeseries_analysis_plot(config, [SST,SST_model_tocompare], N_movavg,
title = "%s\n %s (b-)" % (title, ref_casename_v0)
timeseries_analysis_plot(config, [SST,SST_v0], N_movavg,
title, xlabel, ylabel, figname,
lineStyles = ['r-','b-'],
lineWidths = [1.2,1.2])
else:
figname = "%s/sst_%s_%s.png" % (plots_dir,regions[iregion],casename)
timeseries_analysis_plot(config, [SST], N_movavg, title, xlabel, ylabel, figname,
lineStyles = ['r-'], lineWidths = [1.2])



Loading