class exploreREB(): def __init__(self, db='Prod', prodServer='Prod', appSuffix=''): if prodServer == 'Prod': pS = True else: pS = False self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix) def REBContents(self, REBName=None): kwds = { 'experimentSN': REBName, 'htype': 'LCA-13574', 'noBatched': 'true' } response = self.connect.getHardwareHierarchy(**kwds) # LCA-11721 is the ASPIC. aspic_list = [] for row in response: kid = row['child_experimentSN'] if '11721' in kid: aspic_list.append((kid, row['slotName'])) return aspic_list def ASPIC_parent(self, ASPIC_name=None, htype='LCA-11721'): # now find ASPIC for a REB kwds = { 'experimentSN': ASPIC_name, 'htype': htype, 'noBatched': 'true' } response = self.connect.getContainingHardware(**kwds) for child in response: if '13574' in child['parent_experimentSN']: parentREB = child['parent_experimentSN'] break return parentREB
class exploreRaft(): def __init__(self, db='Prod', prodServer='Prod', appSuffix=''): self.SR_htype = "LCA-11021_RTM" self.CR_htype = "LCA-10692_CRTM" self.REB_htype = "LCA-13574" self.WREB_htype = "LCA-13537" self.GREB_htype = "LCA-13540" if prodServer == 'Prod': pS = True else: pS = False self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix) def raftContents(self, raftName=None, when=None, run=None): # when format: %Y-%m-%dT%H:%M:%S.%f eg: 2016-11-11T04:24:35.0 raft_htype = self.SR_htype if self.CR_htype in raftName: raft_htype = self.CR_htype kwds = { 'experimentSN': raftName, 'htype': raft_htype, 'noBatched': 'true' } if run is not None: run_info = self.connect.getRunSummary(run=run) kwds['timestamp'] = run_info['begin'] elif when is not None: kwds['timestamp'] = when response = self.connect.getHardwareHierarchy(**kwds) # LCA-13574 is the REB. reb_list = [] for row in response: kid = row['child_experimentSN'] if self.REB_htype in kid or self.WREB_htype in kid or self.GREB_htype in kid: reb_list.append((kid, row['slotName'])) # match up the CCD to the REB via REB and slot numbering. The CCD in slot # Sxy is on REBx. Note that the CCD is actually # assembled onto the RSA. ccd_list = [] for child in response: # print child['parent_experimentSN'], child['relationshipTypeName'], # child['child_experimentSN'], child['slotName'] rebId = "" kid = child['child_experimentSN'] if 'ITL' in kid.upper() or 'E2V' in kid.upper(): slotName = child['slotName'] if raft_htype == self.SR_htype: slotNumber = 3 else: slotNumber = 0 for reb in reb_list: rebLoc = reb[1][slotNumber] # two CCDs per GREB, but treated as 1 if self.GREB_htype in reb[0] and "3800C" in kid: rebId = reb[0] slotName = "guider" break # 2 CCDs per WREB elif self.WREB_htype in reb[0] and "4400B" in kid: rebId = reb[0] break elif self.REB_htype in reb[0]: # CCD slotname first digit encodes the REB number rebNumber = slotName[1] if rebLoc == rebNumber: rebId = reb[0] break else: continue ccd_list.append((kid, slotName, rebId)) return ccd_list def raft_type(self, raft=None): ccd_list = self.raftContents(raftName=raft) if 'ITL' in ccd_list[0][0]: type = 'ITL' else: type = 'e2v' return type def CCD_parent(self, CCD_name=None, htype='ITL-CCD', when=None, run=None): # now find raft for a CCD kwds = {'experimentSN': CCD_name, 'htype': htype, 'noBatched': 'true'} if run is not None: run_info = self.connect.getRunSummary(run=run) kwds['timestamp'] = run_info['begin'] elif when is not None: kwds['timestamp'] = when # connect = connection.Connection('richard', db='Dev', exp='LSST-CAMERA', prodServer=True) response = self.connect.getContainingHardware(**kwds) parentRTM = "" for child in response: if 'RTM' in child['parent_experimentSN']: parentRTM = child['parent_experimentSN'] break return parentRTM def REB_parent(self, REB_name=None, when=None, run=None): # now find raft for a REB htype = REB_name.rsplit("-", 1)[0] kwds = { 'experimentSN': REB_name, 'htype': htype, 'noBatched': 'true' } # need to fix REB htype! if run is not None: run_info = self.connect.getRunSummary(run=run) kwds['timestamp'] = run_info['begin'] elif when is not None: kwds['timestamp'] = when response = self.connect.getContainingHardware(**kwds) parentRTM = "" for child in response: if 'RTM' in child['parent_experimentSN']: parentRTM = child['parent_experimentSN'] break return parentRTM def REB_CCD(self, REB_name=None, when=None, run=None): raft = self.REB_parent(REB_name) if run is not None: run_info = self.connect.getRunSummary(run=run) when = run_info['begin'] ccd_list = self.raftContents(raftName=raft, when=when) ccd_in_reb = [] for ccd in ccd_list: if REB_name == ccd[2]: ccd_in_reb.append(ccd[0]) return ccd_in_reb
class exploreRaft(): def __init__(self, db='Prod', prodServer='Dev', appSuffix='-jrb'): if prodServer == 'Prod': pS = True else: pS = False self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix) def raftContents(self, raftName=None): kwds = { 'experimentSN': raftName, 'htype': 'LCA-11021_RTM', 'noBatched': 'true' } response = self.connect.getHardwareHierarchy(**kwds) # LCA-13574 is the REB. reb_list = [] for row in response: kid = row['child_experimentSN'] if '13574' in kid: reb_list.append((kid, row['slotName'])) # match up the CCD to the REB via REB and slot numbering. The CCD in slot # Sxy is on REBx. Note that the CCD is actually # assembled onto the RSA. ccd_list = [] for child in response: # print child['parent_experimentSN'], child['relationshipTypeName'], # child['child_experimentSN'], child['slotName'] kid = child['child_experimentSN'] if 'ITL' in kid.upper() or 'E2V' in kid.upper(): slotName = child['slotName'] rebNumber = slotName[1] for reb in reb_list: rebLoc = reb[1][3] if rebLoc == rebNumber: rebId = reb[0] break ccd_list.append((kid, slotName, rebId)) return ccd_list def CCD_parent(self, CCD_name=None, htype='ITL-CCD'): # now find raft for a CCD kwds = {'experimentSN': CCD_name, 'htype': htype, 'noBatched': 'true'} # connect = connection.Connection('richard', db='Dev', exp='LSST-CAMERA', prodServer=True) response = self.connect.getContainingHardware(**kwds) for child in response: if 'RTM' in child['parent_experimentSN']: parentRTM = child['parent_experimentSN'] break return parentRTM def REB_parent(self, REB_name=None): # now find raft for a REB kwds = { 'experimentSN': REB_name, 'htype': 'LCA-13574', 'noBatched': 'true' } # need to fix REB htype! response = self.connect.getContainingHardware(**kwds) for child in response: if 'RTM' in child['parent_experimentSN']: parentRTM = child['parent_experimentSN'] break return parentRTM def REB_CCD(self, REB_name=None): raft = self.REB_parent(REB_name) ccd_list = self.raftContents(raft) ccd_in_reb = [] for ccd in ccd_list: if REB_name == ccd[2]: ccd_in_reb.append(ccd[0]) return ccd_in_reb
def PrepareInfo(): ### Prepare necesarry information from eTraveler p = re.compile(r".*CCD") connection = Connection(operator="youtsumi", db='Prod', exp='LSST-CAMERA', prodServer=True, localServer=False, appSuffix='', cnfPath='~/.ssh/.etapi.cnf') experimentSN = "LCA-10134_Cryostat-0001" htype = "LCA-10134_Cryostat" results = connection.getHardwareHierarchy(experimentSN=experimentSN, htype=htype) rebs = [] ccds = [] for Baylevel in results: if Baylevel['child_hardwareTypeName'] not in ('LCA-11021_RTM', 'LCA-10692_CRTM'): continue Bayinfo = connection.getHardwareInstances( htype=Baylevel['child_hardwareTypeName'], experimentSN=Baylevel['child_experimentSN'])[0] if Baylevel['child_hardwareTypeName'] == 'LCA-11021_RTM': flavor = (Bayinfo["model"].split("-")[2]) else: flavor = "ITL" print("#############") print(Bayinfo, Baylevel, flavor) print("#############") sub = connection.getHardwareHierarchy( experimentSN=Baylevel["child_experimentSN"], htype=Baylevel["child_hardwareTypeName"]) for areb in sub: # REB if areb['child_hardwareTypeName'] == 'LCA-13574': rebinfo = connection.getHardwareInstances( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN'])[0] rebs.append({ "Bay": Baylevel["slotName"], "Flavor": flavor, "Name": Baylevel['child_experimentSN'], "Slot": areb["slotName"].lower().capitalize(), "slot": areb["slotName"].lower().capitalize(), "SerialNum": rebinfo["manufacturerId"], "RebName": rebinfo["experimentSN"], "path": "R{:02d}".format( int(Baylevel["slotName"].replace("Bay", ""))) }) # RSA if areb['parent_hardwareTypeName'] == 'LCA-10753_RSA' and (p.match( areb["child_hardwareTypeName"]) is not None): sensorinfo = connection.getHardwareInstances( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN'])[0] ccds.append({ "Bay": Baylevel["slotName"], "Flavor": flavor, "Name": areb["child_experimentSN"], "Slot": areb["slotName"], "manSerNum": sensorinfo["manufacturerId"], "path": "R{:02d}/Reb{:01d}/{}".format( int(Baylevel["slotName"].replace("Bay", "")), int(areb["slotName"][1]), areb["slotName"]) }) # WGREB if areb['child_hardwareTypeName'] in [ 'LCA-13537', # WREB 'LCA-13540' # GREB ]: rebinfo = connection.getHardwareInstances( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN'])[0] rebs.append({ "Bay": Baylevel["slotName"], "Flavor": flavor, "Name": Baylevel['child_experimentSN'], "Slot": "WREB" if areb['child_hardwareTypeName'] == 'LCA-13537' else "GREB", "slot": "RebW" if areb['child_hardwareTypeName'] == 'LCA-13537' else "RebG", "RebName": rebinfo["experimentSN"], "SerialNum": rebinfo["manufacturerId"], "path": "R{:02d}".format( int(Baylevel["slotName"].replace("Bay", ""))) }) # CRSA print(areb) if ( areb['child_hardwareTypeName'] == "ITL-CCD" and areb["parent_hardwareTypeName"] == "LCA-10628" ) or \ ( areb['child_hardwareTypeName'] == "ITL-Wavefront-CCD" and areb["parent_hardwareTypeName"] == "LCA-10626" ): ccdhier = connection.getContainingHardware( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN']) if areb["parent_hardwareTypeName"] == "LCA-10628": # G slot = (ccdhier[1]["slotName"]) else: # W slot = "W{}".format((ccdhier[0]["slotName"])[-1]) sensorinfo = connection.getHardwareInstances( htype=areb['child_hardwareTypeName'], experimentSN=areb['child_experimentSN'])[0] ccds.append({ "Bay": Baylevel["slotName"], "Flavor": flavor, "Name": areb["child_experimentSN"], "Slot": areb["slotName"], "manSerNum": sensorinfo["manufacturerId"], "path": "R{:02d}/Reb{}/S{}{}".format( int(Baylevel["slotName"].replace("Bay", "")), slot[0].upper(), slot[0].upper(), int(slot[-1]) - 1) }) return rebs, ccds