class exploreRun(): 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 hardware_sn(self, run): run_info = self.connect.getRunSummary(run=run) return run_info['experimentSN'] def slot_raft_map(self, run, parentName="LCA-10134_Cryostat-0001"): run_info = self.connect.getRunSummary(run=run) kwds = { 'experimentSN': run_info['experimentSN'], 'htype': 'LCA-10134_Cryostat', 'noBatched': 'true', 'timestamp': run_info['begin'] } response = self.connect.getHardwareHierarchy(**kwds) raft_list = [] for ind in response: raft = ind['child_experimentSN'] # ignore mechanical rafts if 'MTR' in raft or ind[ "child_hardwareTypeName"] != "LCA-11021_RTM": continue slot = ind['slotName'] # kludge for first cryo definition with slot names as BayXY, not RXY if 'Bay' in slot: slot = slot.replace("Bay", "R") if ind['parent_experimentSN'] == parentName: raft_list.append([raft, slot]) return response
class exploreFocalPlane: def __init__(self, db='Prod', prodServer='Prod', appSuffix=''): self.SR_htype = "LCA-11021_RTM" self.CR_htype = "LCA-10692_CRTM" self.raft_types = [self.SR_htype, self.CR_htype] if prodServer == 'Prod': pS = True else: pS = False self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix) def focalPlaneContents(self, parentName="LCA-10134_Cryostat-0001", htype='LCA-10134_Cryostat', when=None, run=None): # when format: %Y-%m-%dT%H:%M:%S.%f eg: 2016-11-11T04:24:35.0 kwds = { 'experimentSN': parentName, '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 response = self.connect.getHardwareHierarchy(**kwds) raft_list = [] for ind in response: raft = ind['child_experimentSN'] # ignore mechanical rafts if 'MTR' in raft or ind[ "child_hardwareTypeName"] not in self.raft_types: continue slot = ind['slotName'] # kludge for first cryo definition with slot names as BayXY, not RXY if 'Bay' in slot: slot = slot.replace("Bay", "R") if ind['parent_experimentSN'] == parentName: raft_list.append([raft, slot]) return raft_list
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 raft_observation(): def __init__(self, run=None, step=None, imgtype=None, db='Prod', prodServer='Prod', appSuffix='', site='slac.lca.archive'): chk_list = (run, step) if None in chk_list: print('Error: missing input to raft_observation') raise ValueError if prodServer == 'Prod': pS = True else: pS = False self.db = db self.prodServer = prodServer self.appSuffix = appSuffix self.site = site self.connect = Connection(operator='richard', db=db, exp='LSST-CAMERA', prodServer=pS, appSuffix=appSuffix, debug=False) self.run = run self.step = step self.imgtype = imgtype def find(self, run=None, step=None, imgtype=None): if run is not None: self.run = run if step is not None: self.step = step if imgtype is not None: self.imgtype = imgtype rsp = self.connect.getRunSummary(run=self.run) raft = rsp['experimentSN'] eR = exploreRaft(db=self.db, prodServer=self.prodServer, appSuffix=self.appSuffix) ccd_list = eR.raftContents(raft) obs_dict = {} XtraOpts = '' if self.imgtype is not None: XtraOpts = 'IMGTYPE=="' + self.imgtype + '"' for row in ccd_list: ccd = str(row[0]) self.fCCD = findCCD(FType='fits', testName=self.step, sensorId=ccd, run=str(self.run), db=self.db, prodServer=self.prodServer, appSuffix=self.appSuffix, site=self.site, XtraOpts=XtraOpts) files = self.fCCD.find() for f in files: # grab the timestamp from the end of the filename name_split = os.path.splitext( os.path.basename(f).split('_')[-1])[0] if name_split not in obs_dict: obs_dict[name_split] = [] obs_dict[name_split].append(f) return obs_dict