Coverage for python/lsst/sims/maf/metrics/chipVendorMetric.py : 21%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import numpy as np
2from .baseMetric import BaseMetric
4__all__ = ['ChipVendorMetric']
6class ChipVendorMetric(BaseMetric):
7 """
8 See what happens if we have chips from different vendors
9 """
11 def __init__(self, cols=None, **kwargs):
12 if cols is None:
13 cols = []
14 super(ChipVendorMetric,self).__init__(col=cols, metricDtype=float,
15 units='1,2,3:v1,v2,both', **kwargs)
17 def _chipNames2vendorID(self, chipName):
18 """
19 given a list of chipnames, convert to 1 or 2, representing
20 different vendors
21 """
22 vendors=[]
23 for chip in chipName:
24 # Parse the chipName string.
25 if int(chip[2]) % 2 == 0:
26 vendors.append(1)
27 else:
28 vendors.append(2)
29 return vendors
31 def run(self, dataSlice, slicePoint=None):
33 if 'chipNames' not in list(slicePoint.keys()):
34 raise ValueError('No chipname info, need to set useCamera=True with a spatial slicer.')
36 uvendorIDs = np.unique(self._chipNames2vendorID(slicePoint['chipNames']))
37 if np.size(uvendorIDs) == 1:
38 result = uvendorIDs
39 else:
40 result = 3
41 return result