File indexing completed on 2026-04-09 07:48:49
0001
0002 """
0003 profilesmrytab.py
0004 ===================
0005
0006 Loads and displays profile summaries, ie the results from scan-::
0007
0008 [blyth@localhost ana]$ profilesmrytab.py scan-pf-1/cvd_0_rtx_1
0009 0
0010 ProfileSmry FromDict:scan-pf-1:cvd_0_rtx_1 /home/blyth/local/opticks/evtbase/scan-pf-1 0:Quadro_RTX_8000
0011 0:Quadro_RTX_8000, RTX ON
0012 CDeviceBriefAll : 0:Quadro_RTX_8000
0013 CDeviceBriefVis : 0:Quadro_RTX_8000
0014 RTXMode : 1
0015 NVIDIA_DRIVER_VERSION : 435.21
0016 name note av.interv av.launch av.overhd : launch : q
0017 cvd_0_rtx_1_1M MULTIEVT 0.1584 0.1324 1.1963 : 0.1367 0.1328 0.1328 0.1328 0.1289 0.1328 0.1328 0.1328 0.1328 0.1289 : 0.1373 0.1332 0.1329 0.1328 0.1324 0.1326 0.1325 0.1328 0.1328 0.1324
0018 cvd_0_rtx_1_10M MULTIEVT 1.4918 1.3062 1.1420 : 1.3086 1.3047 1.3047 1.3047 1.3086 1.3086 1.3047 1.3047 1.3047 1.3086 : 1.3086 1.3047 1.3044 1.3048 1.3055 1.3058 1.3052 1.3059 1.3061 1.3072
0019 cvd_0_rtx_1_20M MULTIEVT 2.8702 2.7578 1.0408 : 2.7578 2.7578 2.7578 2.7539 2.7617 2.7578 2.7578 2.7578 2.7578 2.7578 : 2.7578 2.7552 2.7577 2.7564 2.7587 2.7569 2.7586 2.7588 2.7602 2.7608
0020 ...
0021
0022 """
0023
0024 from __future__ import print_function
0025 import os, sys, logging, numpy as np, argparse, textwrap
0026 from collections import OrderedDict as odict
0027 log = logging.getLogger(__name__)
0028 from opticks.ana.profilesmry import ProfileSmry
0029
0030 class ProfileSmryTab(object):
0031
0032 @classmethod
0033 def MakeCrossList(cls, pfxs, cats):
0034 pfxcats = []
0035 for pfx in pfxs:
0036 for cat in cats:
0037 pfxcat = "/".join([pfx, cat])
0038 pfxcats.append(pfxcat)
0039 pass
0040 pass
0041 return pfxcats
0042
0043 @classmethod
0044 def FromCrossList(cls, pfxs, cats):
0045 pfxcats=cls.MakeCrossList(pfxs, cats)
0046 return cls(pfxcats)
0047
0048 @classmethod
0049 def FromText(cls, txt):
0050 pfxcats=filter(None,textwrap.dedent(txt).split("\n"))
0051 return cls(pfxcats)
0052
0053 def __init__(self, pfxcats):
0054 ps = odict()
0055
0056 upfxs = []
0057 ucats = []
0058
0059 for idx,pfxcat in enumerate(pfxcats):
0060 elem = pfxcat.split("/")
0061 assert len(elem) == 2
0062 pfx, cat = elem
0063 if not pfx in upfxs:
0064 upfxs.append(pfx)
0065 pass
0066 if not cat in ucats:
0067 ucats.append(cat)
0068 pass
0069 ps[idx] = ProfileSmry.Load(pfx, startswith=cat, gpufallback=None )
0070 pass
0071 self.ps = ps
0072 self.pfxcats = pfxcats
0073 self.upfxs = upfxs
0074 self.ucats = ucats
0075
0076 def addG4Extrapolation(self, g4_seconds_1M=239.):
0077 ps = self.ps
0078 assert len(ps) < 9 and len(ps) > 0, len(ps)
0079 pass
0080 ps[9] = ProfileSmry.FromExtrapolation( ps[0].npho, seconds_1M=g4_seconds_1M )
0081
0082
0083 def idx(self, pfx, cat):
0084 pfxcat = "/".join([pfx,cat])
0085 return self.pfxcats.index(pfxcat)
0086
0087 def pfxcat(self, idx):
0088 pfxcat = self.pfxcats[idx]
0089 return pfxcat.split("/")
0090
0091 def __str__(self):
0092 return "\n".join(map(lambda kv:"%s\n%s\n" % (kv[0],kv[1]), self.ps.items()) + self.pfxcats)
0093
0094 def __repr__(self):
0095 return "\n".join(["ProfileSmryTab"] + self.pfxcats)
0096
0097 scanid = property(lambda self:"_".join(self.upfxs))
0098
0099
0100
0101 def test_ph_8_9():
0102 pfxs = "scan-ph-8 scan-ph-9".split()
0103 cvd = "1"
0104 cats = "cvd_%(cvd)s_rtx_0 cvd_%(cvd)s_rtx_1" % locals()
0105 cats = cats.split()
0106 pst = ProfileSmryTab.FromCrossList(pfxs, cats)
0107 return pst
0108
0109
0110 if __name__ == '__main__':
0111 logging.basicConfig(level=logging.INFO)
0112
0113 import argparse
0114 parser = argparse.ArgumentParser(__doc__)
0115 parser.add_argument( "pfxcats", nargs="*", default=[], help="List of pfxcat to load and display eg scan-pf-0/cvd_1_rtx_0" )
0116 args = parser.parse_args()
0117
0118 if len(args.pfxcats) == 0:
0119 pst = ProfileSmryTab.FromText("""
0120 scan-pf-0/cvd_1_rtx_0
0121 scan-pf-1/cvd_0_rtx_0
0122 scan-pf-0/cvd_1_rtx_1
0123 scan-pf-1/cvd_0_rtx_1
0124 """)
0125 else:
0126 pst = ProfileSmryTab(args.pfxcats)
0127 pass
0128 print(pst)
0129
0130
0131
0132
0133
0134