Skip to content

Commit

Permalink
Merge branch 'ccpp_scheme_sim' of https://github.com/dustinswales/ccp…
Browse files Browse the repository at this point in the history
…p-scm into ccpp_scheme_simulator
  • Loading branch information
dustinswales committed Jul 27, 2023
2 parents a6ff956 + 9fc88d1 commit 0be6594
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 29 deletions.
43 changes: 27 additions & 16 deletions scm/etc/scripts/ccpp_suite_sim/plt_scmout_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def read_SCMout2d(fileIN,vars2plt):
parser = ap.ArgumentParser()
parser.add_argument('-n', '--case_name', help='name of case', required=True)
parser.add_argument('-sdf', '--suite', help='CCPP suite definition file',required=True)
parser.add_argument('-nmls', '--nml_list', help='namelists, separated by a space', nargs='*', required=True)
parser.add_argument('-nmls', '--nml_list', help='namelists, separated by a space', nargs='*')
parser.add_argument('-vars', '--var_list', help='varaibles to plot, separated by a space', nargs='*', required=True)

def main():
Expand All @@ -51,7 +51,12 @@ def main():
args = parser.parse_args()
case_name = args.case_name
suite = args.suite
namelist = args.nml_list
have_nml = True
if (args.nml_list):
namelist = args.nml_list
else:
have_nml = False
namelist = ['']
vars2plt = args.var_list

#############################################################################################
Expand All @@ -62,7 +67,11 @@ def main():
nfiles = 0
fileSCM = []
for nml in namelist:
fileSCM.append("../../../../scm/run/output_" + case_name + "_" + suite+"_"+nml+"/output.nc")
if have_nml:
fileSCM.append("../../../../scm/run/output_" + case_name + "_" + suite+"_"+nml+"/output.nc")
else:
fileSCM.append("../../../../scm/run/output_" + case_name + "_" + suite+"/output.nc")

# Check that file exists (Exit if not)
if (not os.path.exists(fileSCM[nfiles])):
print('ERROR: ',fileSCM[nfiles],' does not exist.')
Expand Down Expand Up @@ -91,7 +100,8 @@ def main():
for var2plt in vars2plt:

# Top row) Absolute plot
plt.subplot(2,len(vars2plt),varcount)
if (nfiles > 1): plt.subplot(2,len(vars2plt),varcount)
if (nfiles == 1): plt.subplot(1,len(vars2plt),varcount)
plt.title(var2plt, fontsize=fontsize*1.5)
ccount = 0
for ifile in range(0,nfiles):
Expand All @@ -102,18 +112,19 @@ def main():
plt.ylabel("("+stateSCM[ifile][var2plt+"_units"]+")")

# Bottom row) Difference plot (assumes first element is reference)
plt.subplot(2,len(vars2plt),len(vars2plt)+varcount)
ccount = 1
for ifile in range(1,nfiles):
plt.plot(stateSCM[ifile][var2plt+"_time"], stateSCM[ifile][var2plt][:] - stateSCM[0][var2plt][:], colors[ccount])
plt.plot([0,tlimit],[0,0],color='grey',linestyle='--')
ccount = ccount+ 1
plt.xlim(0,tlimit)
ylimit = max(stateSCM[ifile][var2plt][:] - stateSCM[0][var2plt][:], key=abs)*1.05
plt.ylim(-ylimit,ylimit)
plt.yticks(fontsize=fontsize)
plt.ylabel("("+stateSCM[ifile][var2plt+"_units"]+")")
plt.xlabel("(hours)")
if (nfiles > 1):
plt.subplot(2,len(vars2plt),len(vars2plt)+varcount)
ccount = 1
for ifile in range(1,nfiles):
plt.plot(stateSCM[ifile][var2plt+"_time"], stateSCM[ifile][var2plt][:] - stateSCM[0][var2plt][:], colors[ccount])
plt.plot([0,tlimit],[0,0],color='grey',linestyle='--')
ccount = ccount+ 1
plt.xlim(0,tlimit)
ylimit = max(stateSCM[ifile][var2plt][:] - stateSCM[0][var2plt][:], key=abs)*1.05
plt.ylim(-ylimit,ylimit)
plt.yticks(fontsize=fontsize)
plt.ylabel("("+stateSCM[ifile][var2plt+"_units"]+")")
plt.xlabel("(hours)")
#
varcount = varcount + 1
plt.show()
Expand Down
37 changes: 24 additions & 13 deletions scm/etc/scripts/ccpp_suite_sim/plt_scmout_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def read_SCMout3d(fileIN,vars2plt):
parser = ap.ArgumentParser()
parser.add_argument('-n', '--case_name', help='name of case', required=True)
parser.add_argument('-sdf', '--suite', help='CCPP suite definition file',required=True)
parser.add_argument('-nmls', '--nml_list', help='namelists, separated by a space', nargs='*', required=True)
parser.add_argument('-nmls', '--nml_list', help='namelists, separated by a space', nargs='*')
parser.add_argument('-vars', '--var_list', help='varaibles to plot, separated by a space', nargs='*', required=True)
parser.add_argument('-time', '--time_plot', help='time to plot, in seconds', type=int, default = 3600)

Expand All @@ -53,6 +53,12 @@ def main():
case_name = args.case_name
suite = args.suite
namelist = args.nml_list
have_nml = True
if (args.nml_list):
namelist = args.nml_list
else:
have_nml = False
namelist = ['']
vars2plt = args.var_list
time2plt = args.time_plot

Expand All @@ -64,7 +70,10 @@ def main():
nfiles = 0
fileSCM = []
for nml in namelist:
fileSCM.append("../../../../scm/run/output_" + case_name + "_" + suite+"_"+nml+"/output.nc")
if have_nml:
fileSCM.append("../../../../scm/run/output_" + case_name + "_" + suite+"_"+nml+"/output.nc")
else:
fileSCM.append("../../../../scm/run/output_" + case_name + "_" + suite+"/output.nc")
# Check that file exists (Exit if not)
if (not os.path.exists(fileSCM[nfiles])):
print('ERROR: ',fileSCM[nfiles],' does not exist.')
Expand Down Expand Up @@ -96,7 +105,8 @@ def main():
exit()

# Top row) Absolute plot
plt.subplot(2,len(vars2plt),varcount)
if (nfiles > 1): plt.subplot(2,len(vars2plt),varcount)
if (nfiles == 1): plt.subplot(1,len(vars2plt),varcount)
plt.title(var2plt, fontsize=fontsize*1.5)
ccount = 0
for ifile in range(0,nfiles):
Expand All @@ -110,16 +120,17 @@ def main():
plt.ylabel("("+stateSCM[ifile][var2plt+"_units"]+")")

# Bottom row) Difference plot
plt.subplot(2,len(vars2plt),len(vars2plt)+varcount)
ccount = 1
for ifile in range(1,nfiles):
plt.plot(stateSCM[ifile][var2plt][itime,:,0][0] - stateSCM[ifile][var2plt][0,:,0][0],stateSCM[ifile]["pres"][itime,:,0][0], color=colors[ccount])
ccount = ccount+ 1
plt.plot([0,0],[1000.,100.],color='grey',linestyle='--')
plt.yticks(fontsize=fontsize)
plt.ylim(1000.,100.)
plt.xlim(-xlima,xlima)
plt.ylabel("("+stateSCM[ifile][var2plt+"_units"]+")")
if (nfiles > 1):
plt.subplot(2,len(vars2plt),len(vars2plt)+varcount)
ccount = 1
for ifile in range(1,nfiles):
plt.plot(stateSCM[ifile][var2plt][itime,:,0][0] - stateSCM[ifile][var2plt][0,:,0][0],stateSCM[ifile]["pres"][itime,:,0][0], color=colors[ccount])
ccount = ccount+ 1
plt.plot([0,0],[1000.,100.],color='grey',linestyle='--')
plt.yticks(fontsize=fontsize)
plt.ylim(1000.,100.)
plt.xlim(-xlima,xlima)
plt.ylabel("("+stateSCM[ifile][var2plt+"_units"]+")")

#
varcount = varcount + 1
Expand Down

0 comments on commit 0be6594

Please sign in to comment.