WGS-84 to GCJ-02
353238
function (wgsLon, wgsLat) {
        if (this.outOfChina(wgsLat, wgsLon))
            return [wgsLon, wgsLat];

        var d = this.delta(wgsLat, wgsLon);
        return [wgsLon + d.lon, wgsLat + d.lat];
    }
1144002
def _load_converted_gssha_data_from_lsm(self, gssha_var, lsm_var, load_type, time_step=None):
        
        super(ERAtoGSSHA, self).\
            _load_converted_gssha_data_from_lsm(gssha_var, lsm_var, load_type, time_step)
        self.data.lsm.lon_to_180 = True
442663
def _g(self, h, xp, s):
        """"""

        nphi = sum(self.phi)

        return (nphi / 2.0) * log(2 * pi) + nphi * \
            log(s) + 0.5 * sum((h - xp) ** 2) / (s ** 2)
351335
def get_inflators_cn_to_cn(target_year):
    '''
        
    '''
    data_year = find_nearest_inferior(data_years, target_year)
    data_year_cn_aggregates = get_cn_aggregates(data_year)['consoCN_COICOP_{}'.format(data_year)].to_dict()
    target_year_cn_aggregates = get_cn_aggregates(target_year)['consoCN_COICOP_{}'.format(target_year)].to_dict()

    return dict(
        (key, target_year_cn_aggregates[key] / data_year_cn_aggregates[key])
        for key in data_year_cn_aggregates.keys()
        )
875209
def do_gc(self, args):
        """"""

        ### humm...
        instance_type = getattr(types, 'InstanceType', object)

        # snapshot of counts
        type2count = {}
        type2all = {}
        for o in gc.get_objects():
            if type(o) == instance_type:
                type2count[o.__class__] = type2count.get(o.__class__,0) + 1
                type2all[o.__class__] = type2all.get(o.__class__,0) + sys.getrefcount(o)

        # count the things that have changed
        ct = [ ( t.__module__
            , t.__name__
            , type2count[t]
            , type2count[t] - self.type2count.get(t,0)
            , type2all[t] - self.type2all.get(t,0)
            ) for t in type2count.iterkeys()
            ]

        # ready for the next time
        self.type2count = type2count
        self.type2all = type2all

        fmt = "%-30s %-30s %6s %6s %6s\n"
        self.stdout.write(fmt % ("Module", "Type", "Count", "dCount", "dRef"))

        # sorted by count
        ct.sort(lambda x, y: cmp(y[2], x[2]))
        for i in range(min(10,len(ct))):
            m, n, c, delta1, delta2 = ct[i]
            self.stdout.write(fmt % (m, n, c, delta1, delta2))
        self.stdout.write("\n")

        self.stdout.write(fmt % ("Module", "Type", "Count", "dCount", "dRef"))

        # sorted by module and class
        ct.sort()
        for m, n, c, delta1, delta2 in ct:
            if delta1 or delta2:
                self.stdout.write(fmt % (m, n, c, delta1, delta2))
        self.stdout.write("\n")
1364691
def transformToRef(self,ref_wcs,force=False):
        
        if not isinstance(ref_wcs, pywcs.WCS):
            print(textutil.textbox('Reference WCS not a valid HSTWCS object'),
                  file=sys.stderr)
            raise ValueError
        # Need to concatenate catalogs from each input
        if self.outxy is None or force:
            outxy = ref_wcs.wcs_world2pix(self.all_radec[0],self.all_radec[1],self.origin)
            # convert outxy list to a Nx2 array
            self.outxy = np.column_stack([outxy[0][:,np.newaxis],outxy[1][:,np.newaxis]])
            if self.pars['writecat']:
                catname = self.rootname+"_refxy_catalog.coo"
                self.write_outxy(catname)
                self.catalog_names['ref_xy'] = catname
760832
def mach2cas(Mach, H):
    """"""
    Vtas = mach2tas(Mach, H)
    Vcas = tas2cas(Vtas, H)
    return Vcas
1063341
def mjd2gmst(mjd):
    """"""
    
    D2PI= 6.2831853071795864769252867665590057683943387987502
    DS2R= 7.2722052166430399038487115353692196393452995355905e-5
    
    tu = (mjd-51544.5)/36525.0;
    
    st = fmod(mjd,1.0) * D2PI + ( 24110.54841 + ( 8640184.812866 + ( 0.093104 - 6.2e-6 * tu ) * tu ) * tu ) * DS2R 
    
    w = fmod(st,D2PI)
    if w >= 0.0 :
        return w
    else:
        return w+D2PI
315406
def transfer(cls, field_mappings, source, destination_factory):
    """"""
    data = dict()
    for index, field_mapping in enumerate(field_mappings):
      try:
        data[field_mapping.destination_name] = field_mapping.get_value(source)
      except Exception as ex:
        raise Exception(
          "Error with mapping #{0} '{1}'->'{2}': {3}".format(
            index,
            field_mapping.source_name,
            field_mapping.destination_name, ex)) from ex
    return destination_factory(data)
561680
def _gt_from_ge(self, other):
    """"""
    op_result = self.__ge__(other)
    if op_result is NotImplemented:
        return NotImplemented
    return op_result and self != other
448186
public function OSGB36ToWGS84()
	{
		$airy1830 = new ReferenceEllipsoid;

		$a		= $airy1830->maj;
		$b		= $airy1830->min;
		$eSquared = $airy1830->ecc;
		$phi = deg2rad($this->lat);
		$lambda = deg2rad($this->lng);
		$v = $a / (sqrt(1 - $eSquared * Trig::sinSquared($phi)));
		$H = 0; // height
		$x = ($v + $H) * cos($phi) * cos($lambda);
		$y = ($v + $H) * cos($phi) * sin($lambda);
		$z = ((1 - $eSquared) * $v + $H) * sin($phi);

		$tx =		446.448;
		$ty =		 -124.157;
		$tz =		542.060;
		$s	=		 -0.0000204894;
		$rx = deg2rad(0.00004172222);
		$ry = deg2rad(0.00006861111);
		$rz = deg2rad(0.00023391666);

		$xB = $tx + ($x * (1 + $s)) + (-$rx * $y)	 + ($ry * $z);
		$yB = $ty + ($rz * $x)		+ ($y * (1 + $s)) + (-$rx * $z);
		$zB = $tz + (-$ry * $x)	 + ($rx * $y)		+ ($z * (1 + $s));

		$wgs84 = new ReferenceEllipsoid(ReferenceEllipsoid::WGS84_MAJ, ReferenceEllipsoid::WGS84_MIN);
		$a		= $wgs84->maj;
		$b		= $wgs84->min;
		$eSquared = $wgs84->ecc;

		$lambdaB = rad2deg(atan($yB / $xB));
		$p = sqrt(($xB * $xB) + ($yB * $yB));
		$phiN = atan($zB / ($p * (1 - $eSquared)));

		for ($i = 1; $i < 10; $i++) {
			$v = $a / (sqrt(1 - $eSquared * Trig::sinSquared($phiN)));
			$phiN1 = atan(($zB + ($eSquared * $v * sin($phiN))) / $p);
			$phiN = $phiN1;
		}

		$phiB = rad2deg($phiN);

		$this->lat = $phiB;
		$this->lng = $lambdaB;
	}
227826
void updateGCcounters(){
    long gccount = 0;
    long gctime = 0;
        
    for(GarbageCollectorMXBean gc :
      ManagementFactory.getGarbageCollectorMXBeans()) {
    
      long count = gc.getCollectionCount();
      if(count >= 0) {
        gccount += count;
      }
      
      long time = gc.getCollectionTime();
      if(time >= 0) {
        gctime += time;
      }
    }
    
    Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator();
    long aftergc = 0;
    long maxaftergc = 0;
    
    while (beans.hasNext()){
      MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();
      String beanname = bean.getName();
      
      if(!beanname.toUpperCase().contains("OLD GEN")) continue;
      
      MemoryUsage mu = bean.getCollectionUsage();
      
      if(mu == null) continue;
      
      aftergc = mu.getUsed();
      
      if(aftergc > maxaftergc) {
        maxaftergc = aftergc;
      }
      
    }
    
    counters.findCounter(GC_COUNTER_GROUP,"Total number of GC")
      .setValue(gccount);
    counters.findCounter(GC_COUNTER_GROUP,"Total time of GC in milliseconds")
      .setValue(gctime);
    counters.findCounter(GC_COUNTER_GROUP,"Heap size after last GC in bytes")
      .setValue(maxaftergc);
    
    long currentMax =
      counters.findCounter(GC_COUNTER_GROUP,"Max heap size after GC in bytes")
        .getValue();
    
    if(maxaftergc>currentMax){
      counters.findCounter(GC_COUNTER_GROUP,"Max heap size after GC in bytes")
        .setValue(maxaftergc);
    }
    
  }
595059
public void addGGA( GGASentence gga ) {
        try {
            if (gga.isValid()) {
                gpsFixQuality = gga.getFixQuality();
                position = gga.getPosition();
                altitude = gga.getAltitude();
                if (time == null) {
                    time = gga.getTime();
                }
            }
        } catch (Exception e) {
            // ignore it, this should be handled in the isValid,
            // if an exception is thrown, we can't deal with it here.
        }
    }
20253
def to_pb(self):
        
        if self.gc_rule is None:
            return table_v2_pb2.ColumnFamily()
        else:
            return table_v2_pb2.ColumnFamily(gc_rule=self.gc_rule.to_pb())
81322
def fromimportreg(cls, bundle, import_reg):
        # type: (Bundle, ImportRegistration) -> RemoteServiceAdminEvent
        
        exc = import_reg.get_exception()
        if exc:
            return RemoteServiceAdminEvent(
                RemoteServiceAdminEvent.IMPORT_ERROR,
                bundle,
                import_reg.get_import_container_id(),
                import_reg.get_remoteservice_id(),
                None,
                None,
                exc,
                import_reg.get_description(),
            )

        return RemoteServiceAdminEvent(
            RemoteServiceAdminEvent.IMPORT_REGISTRATION,
            bundle,
            import_reg.get_import_container_id(),
            import_reg.get_remoteservice_id(),
            import_reg.get_import_reference(),
            None,
            None,
            import_reg.get_description(),
        )
707637
def to_hmtk(self, use_centroid=True):
        '''
        
        '''
        self._preallocate_data_dict()
        for iloc, gcmt in enumerate(self.catalogue.gcmts):
            self.catalogue.data['eventID'][iloc] = iloc

            if use_centroid:
                self.catalogue.data['year'][iloc] = \
                    gcmt.centroid.date.year
                self.catalogue.data['month'][iloc] = \
                    gcmt.centroid.date.month
                self.catalogue.data['day'][iloc] = \
                    gcmt.centroid.date.day
                self.catalogue.data['hour'][iloc] = \
                    gcmt.centroid.time.hour
                self.catalogue.data['minute'][iloc] = \
                    gcmt.centroid.time.minute
                self.catalogue.data['second'][iloc] = \
                    gcmt.centroid.time.second
                self.catalogue.data['longitude'][iloc] = \
                    gcmt.centroid.longitude
                self.catalogue.data['latitude'][iloc] = \
                    gcmt.centroid.latitude
                self.catalogue.data['depth'][iloc] = \
                    gcmt.centroid.depth
            else:
                self.catalogue.data['year'][iloc] = \
                    gcmt.hypocentre.date.year
                self.catalogue.data['month'][iloc] = \
                    gcmt.hypocentre.date.month
                self.catalogue.data['day'][iloc] = \
                    gcmt.hypocentre.date.day
                self.catalogue.data['hour'][iloc] = \
                    gcmt.hypocentre.time.hour
                self.catalogue.data['minute'][iloc] = \
                    gcmt.hypocentre.time.minute
                self.catalogue.data['second'][iloc] = \
                    gcmt.hypocentre.time.second
                self.catalogue.data['longitude'][iloc] = \
                    gcmt.hypocentre.longitude
                self.catalogue.data['latitude'][iloc] = \
                    gcmt.hypocentre.latitude
                self.catalogue.data['depth'][iloc] = \
                    gcmt.hypocentre.depth
            # Moment, magnitude and relative errors
            self.catalogue.data['moment'][iloc] = gcmt.moment
            self.catalogue.data['magnitude'][iloc] = gcmt.magnitude
            self.catalogue.data['f_clvd'][iloc] = gcmt.f_clvd
            self.catalogue.data['e_rel'][iloc] = gcmt.e_rel
            self.catalogue.data['centroidID'][iloc] = gcmt.identifier
            # Nodal planes
            self.catalogue.data['strike1'][iloc] = \
                gcmt.nodal_planes.nodal_plane_1['strike']
            self.catalogue.data['dip1'][iloc] = \
                gcmt.nodal_planes.nodal_plane_1['dip']
            self.catalogue.data['rake1'][iloc] = \
                gcmt.nodal_planes.nodal_plane_1['rake']
            self.catalogue.data['strike2'][iloc] = \
                gcmt.nodal_planes.nodal_plane_2['strike']
            self.catalogue.data['dip2'][iloc] = \
                gcmt.nodal_planes.nodal_plane_2['dip']
            self.catalogue.data['rake2'][iloc] = \
                gcmt.nodal_planes.nodal_plane_2['rake']
            # Principal axes
            self.catalogue.data['eigenvalue_b'][iloc] = \
                gcmt.principal_axes.b_axis['eigenvalue']
            self.catalogue.data['azimuth_b'][iloc] = \
                gcmt.principal_axes.b_axis['azimuth']
            self.catalogue.data['plunge_b'][iloc] = \
                gcmt.principal_axes.b_axis['plunge']
            self.catalogue.data['eigenvalue_p'][iloc] = \
                gcmt.principal_axes.p_axis['eigenvalue']
            self.catalogue.data['azimuth_p'][iloc] = \
                gcmt.principal_axes.p_axis['azimuth']
            self.catalogue.data['plunge_p'][iloc] = \
                gcmt.principal_axes.p_axis['plunge']
            self.catalogue.data['eigenvalue_t'][iloc] = \
                gcmt.principal_axes.t_axis['eigenvalue']
            self.catalogue.data['azimuth_t'][iloc] = \
                gcmt.principal_axes.t_axis['azimuth']
            self.catalogue.data['plunge_t'][iloc] = \
                gcmt.principal_axes.t_axis['plunge']
        return self.catalogue
686228
function (gcjLon, gcjLat) {
        if (this.outOfChina(gcjLat, gcjLon))
            return [gcjLon, gcjLat];

        var d = this.delta(gcjLat, gcjLon);
        return [gcjLon - d.lon, gcjLat - d.lat];
    }