Calculation of zone area
487680
def area(poly):
    """"""
    poly_xy = []
    num = len(poly)
    for i in range(num):
        poly[i] = poly[i][0:2] + (0,)
        poly_xy.append(poly[i])
    return surface.area(poly)
183168
def get_area(self):
        
        polys = sum([polygon.get_area() for polygon in self])
        holes = sum([hole.get_area() for hole in self.holes])
        return polys-holes
518467
def fo_pct_by_zone(self):
        
        bz = self.by_zone
        return {
            t: {
                z: bz[t][z]['won']/(1.0*bz[t][z]['total']) if bz[t][z]['total'] else 0.0
                for z in self.__zones
                if z != 'all'
            }
            for t in [ 'home', 'away' ]
            
        }
784622
def circumradius(self):
        '''
        

        '''
        return (self.a * self.b * self.c) / (self.area * 4)
380022
function shapeArea(vertexes) {
	var area = 0,
		i,
		j;
	for (i = 0; i < vertexes.length; i++) {
		j = (i + 1) % vertexes.length;
		area += vertexes[i].x * vertexes[j].y - vertexes[j].x * vertexes[i].y;
	}
	return area / 2;
}
1031681
def inROI(self, Y):
        ''''''
        if Y.ndim > 1:
            area = np.zeros((Y.shape[0],4))
        else:
            area = np.zeros((1,4))
        pts = np.zeros((0,), int)
        pdist = np.zeros((0,), int)
        dist0 = 0
        for k in range(len(self.prect)):
            self.square_area = (triangle_area(self.prect[k][0,:], self.prect[k][1,:], self.prect[k][2,:]) +
                            triangle_area(self.prect[k][2,:], self.prect[k][3,:], self.prect[k][4,:]))
            for n in range(4):
                area[:,n] = triangle_area(self.prect[k][0+n,:], self.prect[k][1+n,:], Y)
            # points inside prect
            newpts = np.array((area.sum(axis=1) <= self.square_area+1e-5).nonzero()).flatten().astype(int)
            if newpts.size > 0:
                pts = np.concatenate((pts, newpts))
                newdists = self.orthproj(Y[newpts, :], k) + dist0
                pdist = np.concatenate((pdist, newdists))
            dist0 += (np.diff(self.pos[k], axis=0)[0,:]**2).sum()
            # check if in radius of circle
            if k < len(self.prect)-1:
                pcent = self.pos[k][1,:]
                dist = ((Y - pcent[np.newaxis,:])**2).sum(axis=1)**0.5
                newpts = np.array((dist<=self.d).nonzero()[0].astype(int))
                if newpts.size > 0:
                    pts = np.concatenate((pts, newpts))
                    newdists = dist0 * np.ones(newpts.shape)
                    pdist = np.concatenate((pdist, newdists))

        pts, inds = np.unique(pts, return_index=True)
        pdist = pdist[inds]
        return pts, pdist
431512
def _areadist(ax, v, xr, c, bins=100, by=None, alpha=1, label=None):
    
    y, x = np.histogram(v[~np.isnan(v)], bins)
    x = x[:-1]

    if by is None:
        by = np.zeros((bins,))

    ax.fill_between(x, y, by, facecolor=c, alpha=alpha, label=label)
    return y
977840
def get_tri_area(pts):
    
    a, b, c = pts[0], pts[1], pts[2]
    v1 = np.array(b) - np.array(a)
    v2 = np.array(c) - np.array(a)
    area_tri = abs(sp.linalg.norm(sp.cross(v1, v2)) / 2)
    return area_tri
456802
def get_area_def(self, dsid):
        """"""
        cfac = np.int32(self.mda['cfac'])
        lfac = np.int32(self.mda['lfac'])
        coff = np.float32(self.mda['coff'])
        loff = np.float32(self.mda['loff'])

        a = self.mda['projection_parameters']['a']
        b = self.mda['projection_parameters']['b']
        h = self.mda['projection_parameters']['h']
        lon_0 = self.mda['projection_parameters']['SSP_longitude']
        nlines = int(self.mda['number_of_lines'])
        ncols = int(self.mda['number_of_columns'])

        area_extent = self.get_area_extent((nlines, ncols),
                                           (loff, coff),
                                           (lfac, cfac),
                                           h)

        proj_dict = {'a': float(a),
                     'b': float(b),
                     'lon_0': float(lon_0),
                     'h': float(h),
                     'proj': 'geos',
                     'units': 'm'}

        area = geometry.AreaDefinition(
            'some_area_name',
            "On-the-fly area",
            'geosmsg',
            proj_dict,
            ncols,
            nlines,
            area_extent)

        self.area = area
        return area
716422
@Override
    public Object calculate(int[] coeff, int inPos, int[] quant, int[] out, int outOffset, int width, int height) {
        int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
        int tmp10, tmp11, tmp12, tmp13;
        int z5, z10, z11, z12, z13;

        int[] workspace = new int[64];

        int inptr = 0;
        int wsptr = 0;
        int[] outbuf = (out != null ? out : new int[DCTSIZE2]);
        int outptr = 0;
        short[] rangeLimitMap = sampleRangeLimitTable;
        int rangeLimitOffset = sampleRangeLimitOffset + 128;
        int dcval = 0, DCTSIZE = 8;

        int quantptr = 0;

        for (int ctr = 8; ctr > 0; ctr--) {
            int basis = 0;
            for (int n = 1; n < 8; n++) {
                basis |= coeff[inptr + DCTSIZE * n];
            }

            if (basis == 0) {
                dcval = coeff[inptr + DCTSIZE * 0] * quant[quantptr + DCTSIZE * 0];

                workspace[wsptr + DCTSIZE * 0] = dcval;
                workspace[wsptr + DCTSIZE * 1] = dcval;
                workspace[wsptr + DCTSIZE * 2] = dcval;
                workspace[wsptr + DCTSIZE * 3] = dcval;
                workspace[wsptr + DCTSIZE * 4] = dcval;
                workspace[wsptr + DCTSIZE * 5] = dcval;
                workspace[wsptr + DCTSIZE * 6] = dcval;
                workspace[wsptr + DCTSIZE * 7] = dcval;

                inptr++;
                quantptr++;
                wsptr++;

                continue;
            }

            tmp0 = coeff[inptr + DCTSIZE * 0] * quant[quantptr + DCTSIZE * 0];
            tmp1 = coeff[inptr + DCTSIZE * 2] * quant[quantptr + DCTSIZE * 2];
            tmp2 = coeff[inptr + DCTSIZE * 4] * quant[quantptr + DCTSIZE * 4];
            tmp3 = coeff[inptr + DCTSIZE * 6] * quant[quantptr + DCTSIZE * 6];
            tmp10 = tmp0 + tmp2;
            tmp11 = tmp0 - tmp2;

            tmp13 = tmp1 + tmp3;

            tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13;

            tmp0 = tmp10 + tmp13;
            tmp3 = tmp10 - tmp13;
            tmp1 = tmp11 + tmp12;
            tmp2 = tmp11 - tmp12;

            tmp4 = coeff[inptr + DCTSIZE * 1] * quant[quantptr + DCTSIZE * 1];
            tmp5 = coeff[inptr + DCTSIZE * 3] * quant[quantptr + DCTSIZE * 3];
            tmp6 = coeff[inptr + DCTSIZE * 5] * quant[quantptr + DCTSIZE * 5];
            tmp7 = coeff[inptr + DCTSIZE * 7] * quant[quantptr + DCTSIZE * 7];

            z13 = tmp6 + tmp5;
            z10 = tmp6 - tmp5;
            z11 = tmp4 + tmp7;
            z12 = tmp4 - tmp7;

            tmp7 = z11 + z13;
            tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562);

            z5 = MULTIPLY(z10 + z12, FIX_1_847759065);
            tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5;
            tmp12 = MULTIPLY(z10, -FIX_2_613125930) + z5;

            tmp6 = tmp12 - tmp7;
            tmp5 = tmp11 - tmp6;
            tmp4 = tmp10 + tmp5;

            workspace[wsptr + DCTSIZE * 0] = (tmp0 + tmp7);
            workspace[wsptr + DCTSIZE * 7] = (tmp0 - tmp7);
            workspace[wsptr + DCTSIZE * 1] = (tmp1 + tmp6);
            workspace[wsptr + DCTSIZE * 6] = (tmp1 - tmp6);
            workspace[wsptr + DCTSIZE * 2] = (tmp2 + tmp5);
            workspace[wsptr + DCTSIZE * 5] = (tmp2 - tmp5);
            workspace[wsptr + DCTSIZE * 4] = (tmp3 + tmp4);
            workspace[wsptr + DCTSIZE * 3] = (tmp3 - tmp4);

            inptr++;
            quantptr++;
            wsptr++;
        }

        wsptr = 0;
        for (int ctr = 0; ctr < DCTSIZE; ctr++) {
            outptr = ctr * 8;

            int basis = 0;
            for (int u = wsptr + 1; u < wsptr + 8; u++) {
                basis |= workspace[u];
            }
            if (basis == 0) {
                // AC terms all zero
                dcval = rangeLimitMap[rangeLimitOffset + ((workspace[wsptr] >> 5) & RANGE_MASK)];

                outbuf[outptr + 0] = dcval;
                outbuf[outptr + 1] = dcval;
                outbuf[outptr + 2] = dcval;
                outbuf[outptr + 3] = dcval;
                outbuf[outptr + 4] = dcval;
                outbuf[outptr + 5] = dcval;
                outbuf[outptr + 6] = dcval;
                outbuf[outptr + 7] = dcval;

                wsptr += DCTSIZE;
                continue;
            }

            tmp10 = (workspace[wsptr + 0] + workspace[wsptr + 4]);
            tmp11 = (workspace[wsptr + 0] - workspace[wsptr + 4]);

            tmp13 = (workspace[wsptr + 2] + workspace[wsptr + 6]);
            tmp12 = MULTIPLY(workspace[wsptr + 2] - workspace[wsptr + 6], FIX_1_414213562) - tmp13;

            tmp0 = tmp10 + tmp13;
            tmp3 = tmp10 - tmp13;
            tmp1 = tmp11 + tmp12;
            tmp2 = tmp11 - tmp12;

            z13 = workspace[wsptr + 5] + workspace[wsptr + 3];
            z10 = workspace[wsptr + 5] - workspace[wsptr + 3];
            z11 = workspace[wsptr + 1] + workspace[wsptr + 7];
            z12 = workspace[wsptr + 1] - workspace[wsptr + 7];

            tmp7 = z11 + z13;
            tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562);

            z5 = MULTIPLY(z10 + z12, FIX_1_847759065);
            tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5;
            tmp12 = MULTIPLY(z10, (-FIX_2_613125930)) + z5;

            tmp6 = tmp12 - tmp7;
            tmp5 = tmp11 - tmp6;
            tmp4 = tmp10 + tmp5;

            outbuf[outptr + 0] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp0 + tmp7, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 7] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp0 - tmp7, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 1] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp1 + tmp6, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 6] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp1 - tmp6, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 2] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp2 + tmp5, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 5] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp2 - tmp5, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 4] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp3 + tmp4, PASS1_BITS + 3) & RANGE_MASK)];
            outbuf[outptr + 3] = rangeLimitMap[rangeLimitOffset + (IDESCALE(tmp3 - tmp4, PASS1_BITS + 3) & RANGE_MASK)];

            wsptr += DCTSIZE;
        }

        return outbuf;
    }
251344
private Area getArea(double simplifyTolerance, BoundingBox boundingBox,
			ProjectionTransform transform, Polygon polygon) {

		Area area = null;

		for (LineString ring : polygon.getRings()) {

			Path2D path = getPath(simplifyTolerance, boundingBox, transform,
					ring);
			Area ringArea = new Area(path);

			if (area == null) {
				area = ringArea;
			} else {
				area.subtract(ringArea);
			}

		}

		return area;
	}
927307
def Integrate(self):
        
        area = 0.
        X = self.GetX()
        Y = self.GetY()
        for i in range(self.GetN() - 1):
            area += (X[i + 1] - X[i]) * (Y[i] + Y[i + 1]) / 2.
        return area
40269
def width(self, add_quiet_zone=False):
        
        quiet_zone = self.quiet_zone if add_quiet_zone else 0
        return len(self.modules) + 2 * quiet_zone
933873
private void calcInnerBounds() {
        final java.awt.Insets INSETS = getInsets();
        INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, (getWidth() - INSETS.left - INSETS.right), (getHeight() - INSETS.top - INSETS.bottom));
    }
911080
private function getArea($time_zone)
    {
        $area = null;

        if ($time_zone === 'UTC') {
            $area = 'UTC';
        } elseif ($time_zone !== null) {
            $parts = explode('/', $time_zone, 2);
            $area = reset($parts);
        }

        return $area;
    }
1336067
public static double getPolygonArea( int[] x, int[] y, int N ) {
        int i, j;
        double area = 0;

        for( i = 0; i < N; i++ ) {
            j = (i + 1) % N;
            area += x[i] * y[j];
            area -= y[i] * x[j];
        }

        area /= 2;
        return (area < 0 ? -area : area);
    }
87515
def get_median_area(self, mag, rake):
        
        # strike slip
        length = 10.0 ** (-2.57 + 0.62 * mag)
        seis_wid = 20.0

        # estimate area based on length
        if length < seis_wid:
            return length ** 2.
        else:
            return length * seis_wid