Calibrates a container using the bottom of the first well
770655
def calibrate_container_with_instrument(self,
                                            container: Container,
                                            instrument,
                                            save: bool
                                            ):
        ''''''
        well = container[0]

        # Get the relative position of well with respect to instrument
        delta = pose_tracker.change_base(
            self.poses,
            src=instrument,
            dst=well
        )

        if fflags.calibrate_to_bottom():

            delta_x = delta[0]
            delta_y = delta[1]
            if 'tiprack' in container.get_type():
                delta_z = delta[2]
            else:
                delta_z = delta[2] + well.z_size()
        else:
            delta_x = delta[0]
            delta_y = delta[1]
            delta_z = delta[2]

        self.poses = self._calibrate_container_with_delta(
            self.poses,
            container,
            delta_x,
            delta_y,
            delta_z,
            save
        )

        self.max_deck_height.cache_clear()
277936
public double[] calculate(IAtomContainer container, IAtom atom) {
        int length = (int) ((cutoff - startCutoff) / resolution) + 1;
        logger.debug("Creating RDF of length ", length);

        // the next we need for Gaussian smoothing
        int binsToFillOnEachSide = (int) (peakWidth * 3.0 / resolution);
        double sigmaSquare = Math.pow(peakWidth, 2.0);
        // factors is only half a Gaussian, taking advantage of being symmetrical!
        double[] factors = new double[binsToFillOnEachSide];
        double totalArea = 0.0;
        if (factors.length > 0) {
            factors[0] = 1;
            for (int binCounter = 1; binCounter < factors.length; binCounter++) {
                double height = Math.exp(-1.0 * (Math.pow(((double) binCounter) * resolution, 2.0)) / sigmaSquare);
                factors[binCounter] = height;
                totalArea += height;
            }
            // normalize the Gaussian to unit area
            for (int binCounter = 0; binCounter < factors.length; binCounter++) {
                factors[binCounter] = factors[binCounter] / totalArea;
            }
        }

        // this we need always
        double[] rdf = new double[length];
        double distance = 0.0;
        int index = 0;

        Point3d atomPoint = atom.getPoint3d();
        Iterator<IAtom> atomsInContainer = container.atoms().iterator();
        while (atomsInContainer.hasNext()) {
            IAtom atomInContainer = (IAtom) atomsInContainer.next();
            if (atomInContainer.equals(atom)) continue; // don't include the central atom
            distance = atomPoint.distance(atomInContainer.getPoint3d());
            index = (int) ((distance - startCutoff) / this.resolution);
            double weight = 1.0;
            if (weightFunction != null) {
                weight = weightFunction.calculate(atom, atomInContainer);
            }
            if (factors.length > 0) {
                // apply Gaussian smoothing
                rdf[index] += weight * factors[0];
                for (int binCounter = 1; binCounter < factors.length; binCounter++) {
                    double diff = weight * factors[binCounter];
                    if ((index - binCounter) >= 0) {
                        rdf[index - binCounter] += diff;
                    }
                    if ((index + binCounter) < length) {
                        rdf[index + binCounter] += diff;
                    }
                }
            } else {
                rdf[index] += weight; // unweighted
            }
        }
        return rdf;
    }
143136
function calcultateDepths(depths, callback) {
    if (depths.parentDepth) {
        // if a depth of the links doesn't exist : assign the parehtDepth +1
        // if not, this link has been already found in the past => don't update its depth
        if (! depths.linkDepth) {
            depths.linkDepth = depths.parentDepth + 1;
        }
    }
    else {
        depths.parentDepth = 0;
        depths.linkDepth = 1;
    }
    callback(null, depths);
}
847779
public static void orthoM(float[] m, int mOffset,
        float left, float right, float bottom, float top,
        float near, float far) {
        if (left == right) {
            throw new IllegalArgumentException("left == right");
        }
        if (bottom == top) {
            throw new IllegalArgumentException("bottom == top");
        }
        if (near == far) {
            throw new IllegalArgumentException("near == far");
        }

        final float r_width  = 1.0f / (right - left);
        final float r_height = 1.0f / (top - bottom);
        final float r_depth  = 1.0f / (far - near);
        final float x =  2.0f * (r_width);
        final float y =  2.0f * (r_height);
        final float z = -2.0f * (r_depth);
        final float tx = -(right + left) * r_width;
        final float ty = -(top + bottom) * r_height;
        final float tz = -(far + near) * r_depth;
        m[mOffset + 0] = x;
        m[mOffset + 5] = y;
        m[mOffset +10] = z;
        m[mOffset +12] = tx;
        m[mOffset +13] = ty;
        m[mOffset +14] = tz;
        m[mOffset +15] = 1.0f;
        m[mOffset + 1] = 0.0f;
        m[mOffset + 2] = 0.0f;
        m[mOffset + 3] = 0.0f;
        m[mOffset + 4] = 0.0f;
        m[mOffset + 6] = 0.0f;
        m[mOffset + 7] = 0.0f;
        m[mOffset + 8] = 0.0f;
        m[mOffset + 9] = 0.0f;
        m[mOffset + 11] = 0.0f;
    }
5254
def calibrate(self, data, calibration):
        """"""
        tic = datetime.now()

        if calibration == 'counts':
            return data
        elif calibration == 'radiance':
            raise NotImplementedError("Can't calibrate to radiance.")
        else:
            cal = self.calibration_table
            res = data.data.map_blocks(self._interp, cal, dtype=cal[:, 0].dtype)
            res = xr.DataArray(res,
                               dims=data.dims, attrs=data.attrs,
                               coords=data.coords)
        res = res.where(data > 0)
        logger.debug("Calibration time " + str(datetime.now() - tic))
        return res
1089744
def determine_2(self, container_name, container_alias, meta, val):
        """""""
        if container_alias is not NotSpecified:
            return container_alias
        return container_name[container_name.rfind(":")+1:].replace('/', '-')
536483
function () {
            var first = Math.max(0, Math.min(this.value[0], this.value[1], 1));
            var second = Math.min(1, Math.max(this.value[0], this.value[1], 0));
            this._savedX1 = Math.floor(first * this._railWidth);
            this._savedX2 = Math.ceil(second * this._railWidth + this._firstWidth);
        }
793519
def _build_wells(self) -> List[Well]:
        
        return [
            Well(
                self._well_definition[well],
                Location(self._calibrated_offset, self),
                "{} of {}".format(well, self._display_name),
                self.is_tiprack)
            for well in self._ordering]
470368
def process_calibration(self, save=False):
        """"""
        
        if not self.save_data:
            raise Exception("Runner must be set to save when run, to be able to process")

        vfunc = np.vectorize(calc_db, self.mphonesens, self.mphonedb)

        if USE_FFT:
            peaks = np.mean(abs(self.datafile.get_data(self.current_dataset_name + '/fft_peaks')), axis=1)
        else:
            peaks = np.mean(abs(self.datafile.get_data(self.current_dataset_name + '/vamp')), axis=1)

        # print 'calibration frequencies', self.calibration_frequencies
        # cal_index = self.calibration_indexes[self.calibration_frequencies.index(self.calf)]
        # cal_peak = peaks[cal_index]
        # cal_vmax = vmaxes[cal_index]

        # print 'vfunc inputs', vmaxes, self.caldb, cal_vmax

        resultant_dB = vfunc(peaks, self.calpeak) * -1 #db attenuation

        print 'calibration frequences', self.calibration_frequencies, 'indexes', self.calibration_indexes
        print 'attenuations', resultant_dB

        calibration_vector = resultant_dB[self.calibration_indexes].squeeze()
        # Not currenly saving resultant intensity

        return resultant_dB, '', self.calf
268498
def calibrate(self, data, dsid):
        """"""
        tic = datetime.now()

        data15hdr = self.header['15_DATA_HEADER']
        calibration = dsid.calibration
        channel = dsid.name

        # even though all the channels may not be present in the file,
        # the header does have calibration coefficients for all the channels
        # hence, this channel index needs to refer to full channel list
        i = list(CHANNEL_NAMES.values()).index(channel)

        if calibration == 'counts':
            return data

        if calibration in ['radiance', 'reflectance', 'brightness_temperature']:
            # determine the required calibration coefficients to use
            # for the Level 1.5 Header
            if (self.calib_mode.upper() != 'GSICS' and self.calib_mode.upper() != 'NOMINAL'):
                raise NotImplementedError(
                    'Unknown Calibration mode : Please check')

            # NB GSICS doesn't have calibration coeffs for VIS channels
            if (self.calib_mode.upper() != 'GSICS' or channel in VIS_CHANNELS):
                coeffs = data15hdr[
                    'RadiometricProcessing']['Level15ImageCalibration']
                gain = coeffs['CalSlope'][i]
                offset = coeffs['CalOffset'][i]
            else:
                coeffs = data15hdr[
                    'RadiometricProcessing']['MPEFCalFeedback']
                gain = coeffs['GSICSCalCoeff'][i]
                offset = coeffs['GSICSOffsetCount'][i]
                offset = offset * gain
            res = self._convert_to_radiance(data, gain, offset)

        if calibration == 'reflectance':
            solar_irradiance = CALIB[self.platform_id][channel]["F"]
            res = self._vis_calibrate(res, solar_irradiance)

        elif calibration == 'brightness_temperature':
            cal_type = data15hdr['ImageDescription'][
                'Level15ImageProduction']['PlannedChanProcessing'][i]
            res = self._ir_calibrate(res, channel, cal_type)

        logger.debug("Calibration time " + str(datetime.now() - tic))
        return res
817446
def _position_for_aspirate(self, location=None, clearance=1.0):
        

        placeable = None
        if location:
            placeable, _ = unpack_location(location)
            # go to top of source, if not already there
            if placeable != self.previous_placeable:
                self.move_to(placeable.top())
        else:
            placeable = self.previous_placeable

        # if pipette is currently empty, ensure the plunger is at "bottom"
        if self.current_volume == 0:
            pos, _, _ = pose_tracker.absolute(
                self.robot.poses, self.instrument_actuator)
            if pos != self._get_plunger_position('bottom'):
                # move to top of well to avoid touching liquid
                if placeable:
                    self.move_to(placeable.top())
                self.instrument_actuator.set_active_current(
                    self._plunger_current)
                self.robot.poses = self.instrument_actuator.move(
                    self.robot.poses,
                    x=self._get_plunger_position('bottom')
                )

        # then go inside the location
        if location:
            if isinstance(location, Placeable):
                location = location.bottom(min(location.z_size(), clearance))
            self.move_to(location, strategy='direct')
403762
public void recalculateScale() throws SlickException {
		targetWidth = container.getWidth();
		targetHeight = container.getHeight();
		
		if (maintainAspect) {
			boolean normalIsWide = (normalWidth / normalHeight > 1.6 ? true : false);
			boolean containerIsWide = ((float) targetWidth / (float) targetHeight > 1.6 ? true : false);
			float wScale = targetWidth / normalWidth;
			float hScale = targetHeight / normalHeight;

			if (normalIsWide & containerIsWide) {
				float scale = (wScale < hScale ? wScale : hScale);
				targetWidth = (int) (normalWidth * scale);
				targetHeight = (int) (normalHeight * scale);
			} else if (normalIsWide & !containerIsWide) {
				targetWidth = (int) (normalWidth * wScale);
				targetHeight = (int) (normalHeight * wScale);
			} else if (!normalIsWide & containerIsWide) {
				targetWidth = (int) (normalWidth * hScale);
				targetHeight = (int) (normalHeight * hScale);
			} else {
				float scale = (wScale < hScale ? wScale : hScale);
				targetWidth = (int) (normalWidth * scale);
				targetHeight = (int) (normalHeight * scale);
			}

		} 
		
		if (held instanceof InputListener) {
			container.getInput().addListener((InputListener) held);
		}
		container.getInput().setScale(normalWidth / targetWidth,
									  normalHeight / targetHeight);
		

		int yoffset = 0;
		int xoffset = 0;
		
		if (targetHeight < container.getHeight()) {
			yoffset = (container.getHeight() - targetHeight) / 2;
		}
		if (targetWidth < container.getWidth()) {
			xoffset = (container.getWidth() - targetWidth) / 2;
		}
		container.getInput().setOffset(-xoffset / (targetWidth / normalWidth), 
									   -yoffset / (targetHeight / normalHeight));
		
	}
355009
def re_general(Vel, Area, PerimWetted, Nu):
    """"""
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([Vel, ">=0", "Velocity"], [Nu, ">0", "Nu"])
    return 4 * radius_hydraulic_general(Area, PerimWetted).magnitude * Vel / Nu
1276475
private void calchillshade( WritableRaster pitWR, WritableRaster hillshadeWR, WritableRaster gradientWR, double dx ) {

        pAzimuth = Math.toRadians(pAzimuth);
        pElev = Math.toRadians(pElev);

        double[] sunVector = calcSunVector();
        double[] normalSunVector = calcNormalSunVector(sunVector);
        double[] inverseSunVector = calcInverseSunVector(sunVector);
        int rows = pitWR.getHeight();
        int cols = pitWR.getWidth();
        WritableRaster sOmbraWR = calculateFactor(rows, cols, sunVector, inverseSunVector, normalSunVector, pitWR, dx);
        pm.beginTask(msg.message("hillshade.calculating"), rows * cols);
        for( int j = 1; j < rows - 1; j++ ) {
            for( int i = 1; i < cols - 1; i++ ) {

                double[] ng = gradientWR.getPixel(i, j, new double[3]);
                double cosinc = scalarProduct(sunVector, ng);
                if (cosinc < 0) {
                    sOmbraWR.setSample(i, j, 0, 0);
                }
                hillshadeWR.setSample(i, j, 0, (int) (212.5 * (cosinc * sOmbraWR.getSample(i, j, 0) + pMinDiffuse)));
                pm.worked(1);
            }
        }
        pm.done();
    }
993369
private static void adjustCalibrated(FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight,
										 FMatrixRMaj rectifyK,
										 RectangleLength2D_F32 bound, float scale) {
		// translation
		float deltaX = -bound.x0*scale;
		float deltaY = -bound.y0*scale;

		// adjustment matrix
		SimpleMatrix A = new SimpleMatrix(3,3,true,new float[]{scale,0,deltaX,0,scale,deltaY,0,0,1});
		SimpleMatrix rL = SimpleMatrix.wrap(rectifyLeft);
		SimpleMatrix rR = SimpleMatrix.wrap(rectifyRight);
		SimpleMatrix K = SimpleMatrix.wrap(rectifyK);

		// remove previous calibration matrix
		SimpleMatrix K_inv = K.invert();
		rL = K_inv.mult(rL);
		rR = K_inv.mult(rR);

		// compute new calibration matrix and apply it
		K = A.mult(K);

		rectifyK.set(K.getFDRM());
		rectifyLeft.set(K.mult(rL).getFDRM());
		rectifyRight.set(K.mult(rR).getFDRM());
	}
922246
function calcDirection(start, end) {
  var direction = new Vec2(end);
  direction.subtract(start);
  direction.normalize();
  return direction;
}
578177
def adapt(delta, numpoints, firsttime)
      delta = firsttime ? (delta / DAMP) : (delta >> 1)
      delta += (delta / numpoints)

      k = 0
      while delta > (((BASE - TMIN) * TMAX) / 2)
        delta /= BASE - TMIN
        k += BASE
      end
      k + (BASE - TMIN + 1) * delta / (delta + SKEW)
    end