Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:46

0001 #
0002 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003 #
0004 # This file is part of Opticks
0005 # (see https://bitbucket.org/simoncblyth/opticks).
0006 #
0007 # Licensed under the Apache License, Version 2.0 (the "License"); 
0008 # you may not use this file except in compliance with the License.  
0009 # You may obtain a copy of the License at
0010 #
0011 #   http://www.apache.org/licenses/LICENSE-2.0
0012 #
0013 # Unless required by applicable law or agreed to in writing, software 
0014 # distributed under the License is distributed on an "AS IS" BASIS, 
0015 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016 # See the License for the specific language governing permissions and 
0017 # limitations under the License.
0018 #
0019 
0020 
0021 class MXD(object):
0022     def __init__(self, ab, key, cut, erc, shortname): 
0023         """
0024         :param ab:
0025         :param key: property name which returns a dict with numerical values  
0026         :param cut: warn/error/fatal maximum permissable deviations, exceeding error level yields non-zero RC
0027         :param erc: integer return code if any of the values exceeds the cut 
0028 
0029         RC passed from python to C++ via system calls 
0030         are truncated beyond 0xff see: SSysTest
0031         """ 
0032         self.ab = ab 
0033         self.key = key
0034         self.cut = cut
0035         self.erc = erc
0036         self.shortname = shortname
0037 
0038     mxd = property(lambda self:getattr(self.ab, self.key))
0039 
0040     def _get_mx(self):
0041         mxd = self.mxd
0042         return max(mxd.values()) if len(mxd) > 0 else 999.
0043     mx = property(_get_mx)
0044 
0045     def _get_rc(self):
0046         return self.erc if self.mx > self.cut[1] else 0  
0047     rc = property(_get_rc)
0048 
0049     def __repr__(self):
0050         mxd = self.mxd
0051         pres_ = lambda d:" ".join(map(lambda kv:"%10s : %8.3g " % (kv[0], kv[1]),d.items()))  
0052         return "\n".join(["%s  .rc %d  .mx %7.3f .cut %7.3f/%7.3f/%7.3f   %s  " % ( self.shortname, self.rc,  self.mx, self.cut[0], self.cut[1], self.cut[2], pres_(mxd) )]) 
0053                        
0054 
0055 class RC(object):
0056     def __init__(self, ab ):
0057         self.ab = ab 
0058         self.c2p = MXD(ab, "c2p",  ab.ok.c2max,  77, "ab.rc.c2p") 
0059         self.rdv = MXD(ab, "rmxs", ab.ok.rdvmax, 88, "ab.rc.rdv") 
0060         self.pdv = MXD(ab, "pmxs", ab.ok.pdvmax, 99, "ab.rc.pdv") 
0061 
0062     def _get_rcs(self):
0063         return map(lambda _:_.rc, [self.c2p, self.rdv, self.pdv])
0064     rcs = property(_get_rcs) 
0065         
0066     def _get_rc(self):
0067         return max(self.rcs+[0])
0068     rc = property(_get_rc) 
0069 
0070     def __repr__(self):
0071         return "\n".join([
0072                 "ab.rc     .rc %3d      %r " % (self.rc, self.rcs) , 
0073                  repr(self.c2p),
0074                  repr(self.rdv),
0075                  repr(self.pdv),
0076                  "."
0077                   ])
0078 
0079 
0080 
0081