Add a shot dictionary to :attr:`shots`, applying this survey's magnetic declination
501897
def add_shot(self, shot):
        """"""
        shot.declination = self.declination
        self.shots.append(shot)
299214
def parse_home_shots(self):
        
        try:
            self.__set_shot_tables()
            self.shots['home'] = self.__parse_shot_tables(
                self.__home_top,
                self.__home_bot
            )
            return self
        except:
            return None
1193238
def mag_heading(RAW_IMU, ATTITUDE, declination=None, SENSOR_OFFSETS=None, ofs=None):
    ''''''
    if declination is None:
        import mavutil
        declination = degrees(mavutil.mavfile_global.param('COMPASS_DEC', 0))
    mag_x = RAW_IMU.xmag
    mag_y = RAW_IMU.ymag
    mag_z = RAW_IMU.zmag
    if SENSOR_OFFSETS is not None and ofs is not None:
        mag_x += ofs[0] - SENSOR_OFFSETS.mag_ofs_x
        mag_y += ofs[1] - SENSOR_OFFSETS.mag_ofs_y
        mag_z += ofs[2] - SENSOR_OFFSETS.mag_ofs_z

    # go via a DCM matrix to match the APM calculation
    dcm_matrix = rotation(ATTITUDE)
    cos_pitch_sq = 1.0-(dcm_matrix.c.x*dcm_matrix.c.x)
    headY = mag_y * dcm_matrix.c.z - mag_z * dcm_matrix.c.y
    headX = mag_x * cos_pitch_sq - dcm_matrix.c.x * (mag_y * dcm_matrix.c.y + mag_z * dcm_matrix.c.z)

    heading = degrees(atan2(-headY,headX)) + declination
    if heading < 0:
        heading += 360
    return heading
658534
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'document_label' in _dict:
            args['document_label'] = _dict.get('document_label')
        if 'location' in _dict:
            args['location'] = Location._from_dict(_dict.get('location'))
        if 'text' in _dict:
            args['text'] = _dict.get('text')
        if 'types' in _dict:
            args['types'] = [
                TypeLabelComparison._from_dict(x) for x in (_dict.get('types'))
            ]
        if 'categories' in _dict:
            args['categories'] = [
                CategoryComparison._from_dict(x)
                for x in (_dict.get('categories'))
            ]
        if 'attributes' in _dict:
            args['attributes'] = [
                Attribute._from_dict(x) for x in (_dict.get('attributes'))
            ]
        return cls(**args)
273717
def Add_text(self):
        
        self.selected_meas = []
        if self.COORDINATE_SYSTEM == 'geographic':
            zijdblock = self.Data[self.s]['zijdblock_geo']
        elif self.COORDINATE_SYSTEM == 'tilt-corrected':
            zijdblock = self.Data[self.s]['zijdblock_tilt']
        else:
            zijdblock = self.Data[self.s]['zijdblock']

        tmin_index, tmax_index = -1, -1
        if self.current_fit and self.current_fit.tmin and self.current_fit.tmax:
            tmin_index, tmax_index = self.get_indices(self.current_fit)

        TEXT = ""
        self.logger.DeleteAllItems()
        for i in range(len(zijdblock)):
            lab_treatment = self.Data[self.s]['zijdblock_lab_treatments'][i]
            Step = ""
            methods = lab_treatment.split('-')
            if "NO" in methods:
                Step = "N"
            elif "AF" in methods:
                Step = "AF"
            elif "ARM" in methods:
                Step = "ARM"
            elif "IRM" in methods:
                Step = "IRM"
            elif "T" in methods:
                Step = "T"
            elif "LT" in methods:
                Step = "LT"
            Tr = zijdblock[i][0]
            Dec = zijdblock[i][1]
            Inc = zijdblock[i][2]
            Int = zijdblock[i][3]
            csd = self.Data[self.s]['csds'][i]
            self.logger.InsertItem(i, "%i" % i)
            self.logger.SetItem(i, 1, Step)
            self.logger.SetItem(i, 2, "%.1f" % Tr)
            self.logger.SetItem(i, 3, "%.1f" % Dec)
            self.logger.SetItem(i, 4, "%.1f" % Inc)
            self.logger.SetItem(i, 5, "%.2e" % Int)
            self.logger.SetItem(i, 6, csd)
            self.logger.SetItemBackgroundColour(i, "WHITE")
            if i >= tmin_index and i <= tmax_index:
                self.logger.SetItemBackgroundColour(i, "LIGHT BLUE")
            if self.Data[self.s]['measurement_flag'][i] == 'b':
                self.logger.SetItemBackgroundColour(i, "red")
1040918
def _add_gmaf(self, variant_obj, info_dict):
        
        ##TODO search for max freq in info dict
        for transcript in variant_obj.transcripts:
            gmaf_raw = transcript.GMAF
            if gmaf_raw:
                gmaf = float(gmaf_raw.split(':')[-1])
                variant_obj.add_frequency('GMAF', gmaf)
                
                if not variant_obj.thousand_g:
                    variant_obj.thousand_g = gmaf
1350275
def as_dict(self):
        
        d = {}
        _add_value(d, 'obstory_ids', self.obstory_ids)
        _add_value(d, 'lat_min', self.lat_min)
        _add_value(d, 'lat_max', self.lat_max)
        _add_value(d, 'long_min', self.long_min)
        _add_value(d, 'long_max', self.long_max)
        _add_value(d, 'time_min', self.time_min)
        _add_value(d, 'time_max', self.time_max)
        _add_value(d, 'mime_type', self.mime_type)
        _add_value(d, 'skip', self.skip)
        _add_value(d, 'limit', self.limit)
        _add_string(d, 'semantic_type', self.semantic_type)
        _add_string(d, 'observation_type', self.observation_type)
        _add_value(d, 'observation_id', self.observation_id)
        _add_string(d, 'repository_fname', self.repository_fname)
        _add_boolean(d, 'exclude_imported', self.exclude_imported)
        _add_string(d, 'exclude_export_to', self.exclude_export_to)
        d['meta'] = list((x.as_dict() for x in self.meta_constraints))
        return d
1207498
def addmags(*mags):
    
    tot = 0
    uncs = []
    for mag in mags:
        try:
            tot += 10**(-0.4*mag)
        except:
            m, dm = mag
            f = 10**(-0.4*m)
            tot += f
            unc = f * (1 - 10**(-0.4*dm))
            uncs.append(unc)

    totmag = -2.5*np.log10(tot)
    if len(uncs) > 0:
        f_unc = np.sqrt(np.array([u**2 for u in uncs]).sum())
        return totmag, -2.5*np.log10(1 - f_unc/tot)
    else:
        return totmag
728556
def make_coord_dict(coord):
    """"""
    return dict(
        z=int_if_exact(coord.zoom),
        x=int_if_exact(coord.column),
        y=int_if_exact(coord.row),
    )
1244231
def update_from_dict(self, d):
        
        d = d.copy()
        if 'query' in d:
            self.query._proxied = Q(d.pop('query'))
        if 'post_filter' in d:
            self.post_filter._proxied = Q(d.pop('post_filter'))

        aggs = d.pop('aggs', d.pop('aggregations', {}))
        if aggs:
            self.aggs._params = {
                'aggs': {
                    name: A(value) for (name, value) in iteritems(aggs)}
            }
        if 'sort' in d:
            self._sort = d.pop('sort')
        if '_source' in d:
            self._source = d.pop('_source')
        if 'highlight' in d:
            high = d.pop('highlight').copy()
            self._highlight = high.pop('fields')
            self._highlight_opts = high
        if 'suggest' in d:
            self._suggest = d.pop('suggest')
            if 'text' in self._suggest:
                text = self._suggest.pop('text')
                for s in self._suggest.values():
                    s.setdefault('text', text)
        if 'script_fields' in d:
            self._script_fields = d.pop('script_fields')
        self._extra = d
        return self
974609
def invert_dictset(d):
    """"""
    # Based on recipe from ASPN
    result = {}
    for k, c in d.items():
        for v in c:
            keys = result.setdefault(v, [])
            keys.append(k)
    return result
1085311
def _merge_unbound_var_dicts(src, dst):
  """"""
  for k, v in six.iteritems(src):
    if dst.get(k, v) != v:
      trace1 = ''.join(scopes.skip_common_stack_elements(v.stacktrace, dst[
          k].stacktrace))
      trace2 = ''.join(
          scopes.skip_common_stack_elements(dst[k].stacktrace, v.stacktrace))
      raise ValueError('Key conflict: %s\nDefined At:\n%s\nand\n%s' %
                       (k, trace1, trace2))
    else:
      dst[k] = v
570635
def add_arrows(self, cent, direction, mag=1, **kwargs):
        
        direction = direction.copy()
        if cent.ndim != 2:
            cent = cent.reshape((-1, 3))

        if direction.ndim != 2:
            direction = direction.reshape((-1, 3))

        direction[:,0] *= mag
        direction[:,1] *= mag
        direction[:,2] *= mag

        pdata = vtki.vector_poly_data(cent, direction)
        # Create arrow object
        arrow = vtk.vtkArrowSource()
        arrow.Update()
        glyph3D = vtk.vtkGlyph3D()
        glyph3D.SetSourceData(arrow.GetOutput())
        glyph3D.SetInputData(pdata)
        glyph3D.SetVectorModeToUseVector()
        glyph3D.Update()

        arrows = wrap(glyph3D.GetOutput())

        return self.add_mesh(arrows, **kwargs)
72175
def rebin(a, newshape):
    
        
    shape = a.shape

    lenShape = len(shape)

    factor = np.asarray(shape)/np.asarray(newshape)
    #print factor

    evList = ['a.reshape('] + \
             ['newshape[%d],factor[%d],'%(i,i) for i in xrange(lenShape)] + \
             [')'] + ['.sum(%d)'%(i+1) for i in xrange(lenShape)] + \
             ['/factor[%d]'%i for i in xrange(lenShape)]

    return eval(''.join(evList))
655784
def set_dictionary(dictionary)
      dict = StringValue dictionary

      err = Zlib.deflateSetDictionary pointer, dict, dict.length

      Zlib.handle_error err, message

      dictionary
    end
1284589
def setdict(self, D):
        """"""

        self.D = np.asarray(D, dtype=self.dtype)
        self.DTS = self.D.T.dot(self.S)
        # Factorise dictionary for efficient solves
        self.lu, self.piv = sl.cho_factor(self.D, self.rho)
        self.lu = np.asarray(self.lu, dtype=self.dtype)
998746
def _get_stddev_rock(self, mag, imt):
        
        C = self.COEFFS_ROCK_STDDERR[imt]
        if mag > C['maxmag']:
            return C['maxsigma']
        else:
            return C['sigma0'] + C['magfactor'] * mag