GCJ-02 to WGS-84 exactly
483146
public function gcj_decrypt_exact($gcjLat, $gcjLon) {
		$initDelta = 0.01;
		$threshold = 0.000000001;
		$dLat = $initDelta; $dLon = $initDelta;
		$mLat = $gcjLat - $dLat; $mLon = $gcjLon - $dLon;
		$pLat = $gcjLat + $dLat; $pLon = $gcjLon + $dLon;
		$wgsLat = 0; $wgsLon = 0; $i = 0;
		while (TRUE) {
			$wgsLat = ($mLat + $pLat) / 2;
			$wgsLon = ($mLon + $pLon) / 2;
			$tmp = $this->gcj_encrypt($wgsLat, $wgsLon);
			$dLat = $tmp['lat'] - $gcjLat;
			$dLon = $tmp['lon'] - $gcjLon;
			if ((abs($dLat) < $threshold) && (abs($dLon) < $threshold))
				break;

			if ($dLat > 0) $pLat = $wgsLat; else $mLat = $wgsLat;
			if ($dLon > 0) $pLon = $wgsLon; else $mLon = $wgsLon;

			if (++$i > 10000) break;
		}
		//console.log(i);
		return array('lat' => $wgsLat, 'lon'=> $wgsLon);
	}
754220
def mag_to_fnu(self, mag):
        
        return cgs.cgsperjy * self._zeropoints[self.band] * 10**(-0.4 * mag)
1289868
def compute_trans(expnums, ccd, version, prefix=None, default="WCS"):
    
    wcs_dict = {}
    for expnum in expnums:
        try:
            # TODO This assumes that the image is already N/E flipped.
            # If compute_trans is called after the image is retrieved from archive then we get the disk version.
            filename = storage.get_image(expnum, ccd, version, prefix=prefix)
            this_wcs = wcs.WCS(fits.open(filename)[0].header)
        except Exception as err:
            logging.warning("WCS Trans compute failed. {}".format(str(err)))
            return
        wcs_dict[expnum] = this_wcs
    x0 = wcs_dict[expnums[0]].header['NAXIS1'] / 2.0
    y0 = wcs_dict[expnums[0]].header['NAXIS2'] / 2.0
    (ra0, dec0) = wcs_dict[expnums[0]].xy2sky(x0, y0)
    result = ""
    for expnum in expnums:
        filename = storage.get_file(expnum, ccd, version, ext='.trans.jmp', prefix=prefix)
        jmp_trans = file(filename, 'r').readline().split()
        (x, y) = wcs_dict[expnum].sky2xy(ra0, dec0)
        x1 = float(jmp_trans[0]) + float(jmp_trans[1]) * x + float(jmp_trans[2]) * y
        y1 = float(jmp_trans[3]) + float(jmp_trans[4]) * x + float(jmp_trans[5]) * y
        dr = math.sqrt((x1 - x0) ** 2 + (y1 - y0) ** 2)
        if dr > 0.5:
            result += "WARNING: WCS-JMP transforms mis-matched {} reverting to using {}.\n".format(expnum, default)
            if default == "WCS": 
               uri = storage.dbimages_uri(expnum, ccd, version, ext='.trans.jmp', prefix=prefix)
               filename = os.path.basename(uri)
               trans = file(filename, 'w')
               trans.write("{:5.2f} 1. 0. {:5.2f} 0. 1.\n".format(x0 - x, y0 - y))
               trans.close()
        else:
            result += "WCS-JMP transforms match {}\n".format(expnum)
    return result
1320527
def gcj02tobd09(lng, lat):
    
    z = math.sqrt(lng * lng + lat * lat) + 0.00002 * math.sin(lat * x_pi)
    theta = math.atan2(lat, lng) + 0.000003 * math.cos(lng * x_pi)
    bd_lng = z * math.cos(theta) + 0.0065
    bd_lat = z * math.sin(theta) + 0.006
    return [bd_lng, bd_lat]
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(),
        )
973416
def _ge_from_gt(self, other):
    """"""
    op_result = self.__gt__(other)
    return op_result or self == other
217894
def _hgvs_coord_to_ci(s, e):
    """"""

    def _hgvs_to_ci(c):
        assert c != 0, "received CDS coordinate 0; expected ..,-2,-1,1,1,..."
        return c - 1 if c > 0 else c

    return (None if s is None else _hgvs_to_ci(s), None if e is None else _hgvs_to_ci(e) + 1)
1087359
def convertWCS(inwcs,drizwcs):
    
    drizwcs[0] = inwcs.crpix[0]
    drizwcs[1] = inwcs.crval[0]
    drizwcs[2] = inwcs.crpix[1]
    drizwcs[3] = inwcs.crval[1]
    drizwcs[4] = inwcs.cd[0][0]
    drizwcs[5] = inwcs.cd[1][0]
    drizwcs[6] = inwcs.cd[0][1]
    drizwcs[7] = inwcs.cd[1][1]

    return drizwcs
801401
private void transfer(Entry[] src, Entry[] dest)
    {
        for (int j = 0; j < src.length; ++j)
        {
            Entry e = src[j];
            src[j] = null;
            while (e != null)
            {
                Entry next = e.next;
                Object key = e.get();
                if (key == null || (timeToLive > 0 && ((TimedEntry)e).isExpired(timeToLive)))
                {
                    e.next = null;  // Help GC
                    size--;
                }
                else
                {
                    int i = indexFor(e.hash, dest.length);
                    e.next = dest[i];
                    dest[i] = e;
                }
                e = next;
            }
        }
    }
277398
def get_conversion_factor(self, in_nc, num_nc_files):
        """"""
        data_in_nc = Dataset(in_nc)

        # convert from kg/m^2 (i.e. mm) to m
        conversion_factor = 0.001

        # ECMWF units are in m
        if data_in_nc.variables[self.runoff_vars[0]] \
                .getncattr("units") == "m":
            conversion_factor = 1

        # ftp://hydro1.sci.gsfc.nasa.gov/data/s4pa/GLDAS_V1/README.GLDAS.pdf
        if "s" in data_in_nc.variables[self.runoff_vars[0]] \
                .getncattr("units"):
            # that means kg/m^2/s in GLDAS v1 that is 3-hr avg,
            # so multiply by 3 hr (ex. 3*3600). Assumed same
            # for others (ex. 1*3600).
            # If combining files, need to take average of these,
            # so divide by number of files
            conversion_factor *= \
                self.simulation_time_step_seconds / \
                num_nc_files
        data_in_nc.close()

        return conversion_factor
1166222
function fixSRS(obj) {
    if (!obj.srs) return;

    var normalized = _(obj.srs.split(' ')).chain()
        .select(function(s) { return s.indexOf('=') > 0; })
        .sortBy(function(s) { return s; })
        .reduce(function(memo, s) {
            var key = s.split('=')[0];
            var val = s.split('=')[1];
            if (val === '0') val = '0.0';
            memo[key] = val;
            return memo;
        }, {})
        .value();
    var legacy = {
        '+a': '6378137',
        '+b': '6378137',
        '+lat_ts': '0.0',
        '+lon_0': '0.0',
        '+proj': 'merc',
        '+units': 'm',
        '+x_0': '0.0',
        '+y_0': '0.0'
    };
    if (!_(legacy).chain()
        .reject(function(v, k) { return normalized[k] === v; })
        .size()
        .value()) obj.srs = SRS['900913'];
}
270381
def kuten_to_gb2312(kuten):
    
    zone, point = int(kuten[:2]), int(kuten[2:])
    hi, lo = hexd(zone + 0x20), hexd(point + 0x20)

    gb2312 = "%s%s" % (hi, lo)

    assert isinstance(gb2312, bytes)
    return gb2312
884148
protected function updateRGB()
	{
		$h = $this->_h;
		$s = $this->_s;
		$v = $this->_v;
		if($s == 0) {
			$this->_r = (int) $v * 255;
			$this->_g = (int) $v * 255;
			$this->_b = (int) $v * 255;
		}else{
			$hi = ($h/60)>>0;
			$f = ($h/60 - $hi);
			$p = $v*(1 - $s);
			$q = $v*(1 - $f*$s);
			$t = $v*(1-(1-$f)*$s);
			if($hi==0){
				$this->_r = (int)($v * 255);
				$this->_g = (int)($t * 255);
				$this->_b = (int)($p * 255);
			}else if($hi==1){
				$this->_r = (int)($q * 255);
				$this->_g = (int)($v * 255);
				$this->_b = (int)($p * 255);
			}else if($hi==2){
				$this->_r = (int)($p * 255);
				$this->_g = (int)($v * 255);
				$this->_b = (int)($t * 255);
			}else if($hi==3){
				$this->_r = (int)($p * 255);
				$this->_g = (int)($q * 255);
				$this->_b = (int)($v * 255);
			}else if($hi==4){
				$this->_r = (int)($t * 255);
				$this->_g = (int)($p * 255);
				$this->_b = (int)($v * 255);
			}else if($hi==5){
				$this->_r = (int)($v * 255);
				$this->_g = (int)($p * 255);
				$this->_b = (int)($q * 255);
			}
		}
	}
1288380
def valid_GC(x):
    
    x = float(x)
    if x < 0.0 or x > 1.0:
        raise ArgumentTypeError("{} not in range [0.0, 1.0]".format(x))
    return x
445439
def group2commdct(commdct, glist):
    """"""
    for (gname, objname), commitem in zip(glist, commdct):
        commitem[0]['group'] = gname
        commitem[0]['idfobj'] = objname
    return commdct
132723
def _jdn(self):
        """"""
        if self._last_updated == "gdate":
            return conv.gdate_to_jdn(self.gdate)
        return conv.hdate_to_jdn(self.hdate)
1300085
def mjd2gmst(mjd):
    

    tu = (mjd - MJD0) / (100*DPY)

    st = math.fmod(mjd, 1.0) * D2PI + (24110.54841 + (8640184.812866 + (0.093104 - 6.2e-6 * tu) * tu) * tu) * DS2R

    w = math.fmod(st, D2PI)
    if w >= 0.0:
        return w
    else:
        return w + D2PI