Return optics information.
321247
def get_optics(self):
        """"""
        optics_table = junos_views.junos_intf_optics_table(self.device)
        optics_table.get()
        optics_items = optics_table.items()

        # optics_items has no lane information, so we need to re-format data
        # inserting lane 0 for all optics. Note it contains all optics 10G/40G/100G
        # but the information for 40G/100G is incorrect at this point
        # Example: intf_optic item is now: ('xe-0/0/0', [ optical_values ])
        optics_items_with_lane = []
        for intf_optic_item in optics_items:
            temp_list = list(intf_optic_item)
            temp_list.insert(1, "0")
            new_intf_optic_item = tuple(temp_list)
            optics_items_with_lane.append(new_intf_optic_item)

        # Now optics_items_with_lane has all optics with lane 0 included
        # Example: ('xe-0/0/0', u'0', [ optical_values ])

        # Get optical information for 40G/100G optics
        optics_table40G = junos_views.junos_intf_40Goptics_table(self.device)
        optics_table40G.get()
        optics_40Gitems = optics_table40G.items()

        # Re-format data as before inserting lane value
        new_optics_40Gitems = []
        for item in optics_40Gitems:
            lane = item[0]
            iface = item[1].pop(0)
            new_optics_40Gitems.append((iface[1], py23_compat.text_type(lane), item[1]))

        # New_optics_40Gitems contains 40G/100G optics only:
        # ('et-0/0/49', u'0', [ optical_values ]),
        # ('et-0/0/49', u'1', [ optical_values ]),
        # ('et-0/0/49', u'2', [ optical_values ])

        # Remove 40G/100G optics entries with wrong information returned
        # from junos_intf_optics_table()
        iface_40G = [item[0] for item in new_optics_40Gitems]
        for intf_optic_item in optics_items_with_lane:
            iface_name = intf_optic_item[0]
            if iface_name not in iface_40G:
                new_optics_40Gitems.append(intf_optic_item)

        # New_optics_40Gitems contains all optics 10G/40G/100G with the lane
        optics_detail = {}
        for intf_optic_item in new_optics_40Gitems:
            lane = intf_optic_item[1]
            interface_name = py23_compat.text_type(intf_optic_item[0])
            optics = dict(intf_optic_item[2])
            if interface_name not in optics_detail:
                optics_detail[interface_name] = {}
                optics_detail[interface_name]["physical_channels"] = {}
                optics_detail[interface_name]["physical_channels"]["channel"] = []

            INVALID_LIGHT_LEVEL = [None, C.OPTICS_NULL_LEVEL, C.OPTICS_NULL_LEVEL_SPC]

            # Defaulting avg, min, max values to 0.0 since device does not
            # return these values
            intf_optics = {
                "index": int(lane),
                "state": {
                    "input_power": {
                        "instant": (
                            float(optics["input_power"])
                            if optics["input_power"] not in INVALID_LIGHT_LEVEL
                            else 0.0
                        ),
                        "avg": 0.0,
                        "max": 0.0,
                        "min": 0.0,
                    },
                    "output_power": {
                        "instant": (
                            float(optics["output_power"])
                            if optics["output_power"] not in INVALID_LIGHT_LEVEL
                            else 0.0
                        ),
                        "avg": 0.0,
                        "max": 0.0,
                        "min": 0.0,
                    },
                    "laser_bias_current": {
                        "instant": (
                            float(optics["laser_bias_current"])
                            if optics["laser_bias_current"] not in INVALID_LIGHT_LEVEL
                            else 0.0
                        ),
                        "avg": 0.0,
                        "max": 0.0,
                        "min": 0.0,
                    },
                },
            }
            optics_detail[interface_name]["physical_channels"]["channel"].append(
                intf_optics
            )

        return optics_detail
637071
def calibrate(self, data, calibration):
        """"""
        tic = datetime.now()

        if calibration == 'counts':
            return data

        if calibration in ['radiance', 'reflectance', 'brightness_temperature']:
            data = self.convert_to_radiance(data)
        if calibration == 'reflectance':
            data = self._vis_calibrate(data)
        elif calibration == 'brightness_temperature':
            data = self._ir_calibrate(data)

        logger.debug("Calibration time " + str(datetime.now() - tic))
        return data
396381
def _get_features(self):
        """"""
        if self._satellite:
            return [("water", [], [])]
        elif self._zoom <= 2:
            return [
                ("water", [], []),
                ("marine_label", [], [1]),
            ]
        elif self._zoom <= 7:
            return [
                ("admin", [], []),
                ("water", [], []),
                ("road", ["motorway"], []),
                ("country_label", [], []),
                ("marine_label", [], [1]),
                ("state_label", [], []),
                ("place_label", [], ["city", "town"]),
            ]
        elif self._zoom <= 10:
            return [
                ("admin", [], []),
                ("water", [], []),
                ("road", ["motorway", "motorway_link", "trunk"], []),
                ("country_label", [], []),
                ("marine_label", [], [1]),
                ("state_label", [], []),
                ("place_label", [], ["city", "town"]),
            ]
        else:
            return [
                ("landuse", ["agriculture", "grass", "park"], []),
                ("water", [], []),
                ("waterway", ["river", "canal"], []),
                ("building", [], []),
                ("road",
                 ["motorway", "motorway_link", "trunk", "primary", "secondary"]
                 if self._zoom <= 14 else
                 ["motorway", "motorway_link", "trunk", "primary", "secondary", "tertiary",
                  "link", "street", "tunnel"],
                 []),
                ("poi_label", [], []),
            ]
358013
def view(self):
        """"""
        spec = []
        for k, v in six.iteritems(self._p4dict):
            if k.startswith('view'):
                match = RE_FILESPEC.search(v)
                if match:
                    spec.append(FileSpec(v[:match.end() - 1], v[match.end():]))

        return spec
798720
def value(self):
        """"""
        if self._outline is None:
            return {
                "type" : "esriSMS",
                "style" : self._style,
                "color" : self._color.value,
                "size" : self._size,
                "angle" : self._angle,
                "xoffset" : self._xoffset,
                "yoffset" : self._yoffset
            }
        else:
            return {
                "type" : "esriSMS",
                "style" : self._style,
                "color" : self._color.value,
                "size" : self._size,
                "angle" : self._angle,
                "xoffset" : self._xoffset,
                "yoffset" : self._yoffset,
                "outline" : {
                    "width" : self._outline['width'],
                    "color" : self._color.value
                }
            }
346028
def information(self, type):
        """"""
        if not self.base:
            return -math.log(self._dist[type])
        else:
            return -math.log(self._dist[type], self.base)
376972
def value(self):
        """"""
        return {
            "objectIdFieldName" : self._objectIdFieldName,
            "displayFieldName" : self._displayFieldName,
            "globalIdFieldName" : self._globalIdFieldName,
            "geometryType" : self._geometryType,
            "spatialReference" : self._spatialReference,
            "hasZ" : self._hasZ,
            "hasM" : self._hasM,
            "fields" : self._fields,
            "features" : [f.asDictionary for f in self._features]
        }
865102
def data(self):
        """"""
        content = {
            'form_data': self.form_data,
            'token': self.token,
            'viz_name': self.viz_type,
            'filter_select_enabled': self.datasource.filter_select_enabled,
        }
        return content
1250733
def data(self):
        """"""
        if self._data is None:
            with open(self.path, 'rb') as f:
                self.read_data(f)
        return self._data
909305
def get_info(self):
        """"""

        reconstructed = self.is_reconstructed()

        site, site_type = self.get_site()

        return reconstructed, site, site_type
1029489
def get_vers_for_target(target):
    """"""
    target_info = get_target_info(target)
    if not target_info:
        return py2_vers + py3_vers
    elif len(target_info) == 1:
        if target_info == (2,):
            return py2_vers
        elif target_info == (3,):
            return py3_vers
        else:
            raise CoconutInternalException("invalid target info", target_info)
    elif target_info == (3, 3):
        return [(3, 3), (3, 4)]
    else:
        return [target_info[:2]]
238357
def _extract_return(self, data):
        '''
        
        '''
        if isinstance(data, dict):
            data = data.get('return', data)

        return data
890486
def look_at(self, x, y, z):
        """"""
        for camera in self.cameras:
            camera.look_at(x, y, z)
576023
def _getWaveProp(self):
        """"""
        wave = units.Angstrom().Convert(self._wavetable, self.waveunits.name)
        return wave
957481
def get_tensor_info(self):
    """"""
    return {
        feature_key: feature.get_tensor_info()
        for feature_key, feature in self._feature_dict.items()
    }
293617
def data(self):
        """"""
        if self.kind == 'data':
            return self._data.data
        else:
            with self.open() as f:
                return f.read()
1235120
def value(self):
        """"""
        return {
            "type" : self._type,
            "style" : self._style,
            "color" : self._color.value,
            "width" : self._width
        }