Skip to content

Commit

Permalink
worked
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuang-jedi committed Aug 17, 2022
1 parent b6274cd commit e507908
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 13 deletions.
91 changes: 91 additions & 0 deletions make-jedi-perf-panel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import os, sys
import matplotlib.pyplot as plt
from matplotlib import image
import numpy as np
import getopt

import matplotlib as mpl
mpl.rcParams['figure.dpi']= 300

#=========================================================================
class MakePanelPlot():
def __init__(self, debug=0, output=0, caselist=[], funclist=[]):
self.debug = debug
self.output = output
self.caselist = caselist
self.funclist = funclist

if(self.debug):
print('debug = ', debug)

if(self.debug > 10):
print('self.caselist = ', self.caselist)
print('self.funclist = ', self.funclist)

for funcname in self.funclist:
self.genit(funcname)

def genit(self, funcname):
#initialise grid of axes
#fig, axes = plt.subplots(2, 2, constrained_layout=True)
fig, axes = plt.subplots(2, 2)
axes = axes.ravel()

#iterate over axes
for i, ax in enumerate(axes):
imgname = '%s/log_%s_%s_timing.png' %(self.caselist[i],
self.caselist[i], funcname)
im = image.imread(imgname)
ax.axis('off')
ax.imshow(im)

#plt.subplots_adjust(left=0.05, bottom=0.05,
# right=0.95, top=0.95,
# wspace=0.05, hspace=0.05)
#The parameter meanings (and suggested defaults) are:
#left = 0.125 # the left side of the subplots of the figure
#right = 0.9 # the right side of the subplots of the figure
#bottom = 0.1 # the bottom of the subplots of the figure
#top = 0.9 # the top of the subplots of the figure
#wspace = 0.2 # the amount of width reserved for blank space between subplots
#hspace = 0.2 # the amount of height reserved for white space between subplots

plt.tight_layout()

if(self.output):
imgname = 'panel-%s' %(funcname)
#fig.savefig(imgname, dpi=300, bbox_inches="tight")
fig.savefig(imgname, bbox_inches="tight", quality=100)
else:
plt.show()

#------------------------------------------------------------------------------
if __name__ == '__main__':
debug = 1
output = 0
caselist = ['aircraft', 'iasi', 'scatwind', 'sondes']
funclist = ['main', 'sum', 'GetValues', 'ObsError',
'ObsSpace', 'ObsVector',
'ObsOperator', 'VariableChange', 'ObsFilter']

opts, args = getopt.getopt(sys.argv[1:], '', ['debug=', 'output=',
'caselist=', 'funclist='])

for o, a in opts:
if o in ('--debug'):
debug = int(a)
elif o in ('--output'):
output = int(a)
elif o in ('--caselist'):
caselist = a
elif o in ('--funclist'):
funclist = a
#else:
# assert False, 'unhandled option'

print('debug = ', debug)
print('output = ', output)

mpp = MakePanelPlot(debug=debug, output=output,
caselist=caselist, funclist=funclist)

9 changes: 5 additions & 4 deletions parallel-stats-profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def __init__(self, debug=0, corelist=[], casename=None, output=0,
os.makedirs(casename)

self.colorlist = ['red', 'blue', 'green', 'orange', 'royalblue', 'cyan',
'magenta', 'lime', 'yellowgreen']
'magenta', 'lime', 'yellowgreen',
'violet', 'navy', 'teal']

#self.get_top_functions()

Expand Down Expand Up @@ -449,7 +450,7 @@ def plot(self, statstime, statsname):
output = 0
linear = 0

opts, args = getopt.getopt(sys.argv[1:], '', ['debug=', 'workdir=',
opts, args = getopt.getopt(sys.argv[1:], '', ['debug=', 'workdir=', 'output=',
'corelist=', 'nodelist=', 'casename='])

for o, a in opts:
Expand Down Expand Up @@ -492,7 +493,7 @@ def plot(self, statstime, statsname):
# 'oops::LocalEnsembleSolver::computeHofX']
statsname = '%s_main' %(casename)
statstime = pr.get_main_statstime(main_funclabels, main_funclist)
#pr.plot(statstime, statsname)
pr.plot(statstime, statsname)

sum_funclabels = ['sum(oops::GetValues)',
'sum(oops::ObsError)',
Expand All @@ -511,7 +512,7 @@ def plot(self, statstime, statsname):
statsname = '%s_sum' %(casename)
statstime = pr.get_sum_statstime(sum_funclabels, sum_funclist)
print('Ready to plot sum functions')
#pr.plot(statstime, statsname)
pr.plot(statstime, statsname)

for sumname in sum_funclist:
item = sumname.split('::')
Expand Down
13 changes: 4 additions & 9 deletions timingit
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@
#workdir=/work2/noaa/gsienkf/weihuang/jedi/case_study/develop_code
workdir=/work2/noaa/gsienkf/weihuang/jedi/case_study
#caselist=(amsua iasi aircraft sfcship sondes surf satwind scatwind vadwind windprof)
caselist=(iasi aircraft sondes scatwind)
#caselist=(iasi aircraft sondes scatwind)
caselist=(scatwind)

for i in ${!caselist[@]}
do
rm -rf ${caselist[$i]}
mkdir -p ${caselist[$i]}
python obs_timing.py --casename=${caselist[$i]} --workdir=${workdir} --output=1
python main_timing.py --casename=${caselist[$i]} --workdir=${workdir} --output=1
python sum_timing.py --casename=${caselist[$i]} --workdir=${workdir} --output=1
python parallel-stats-profiling.py --casename=${caselist[$i]} --workdir=${workdir} --output=1
done

for name in ObsFilter ObsSpace ObsVector ObsOperator GetValues VariableChange main sum
#for name in main
do
python make-obs-panel.py --output=1 --name=$name
done
python make-jedi-perf-panel.py --output=1

0 comments on commit e507908

Please sign in to comment.