Compute (alt, az, distance) relative to the observer's horizon.
9583
def _to_altaz(position_au, observer_data, temperature_C, pressure_mbar):
    
    elevation_m = observer_data.elevation_m
    R = observer_data.altaz_rotation

    if (elevation_m is None) or (R is None):
        raise ValueError('to compute an altazimuth position, you must'
                         ' observe from a specific Earth location that'
                         ' you specify using a Topos instance')

    # TODO: wobble

    position_au = einsum('ij...,j...->i...', R, position_au)
    r_au, alt, az = to_polar(position_au)

    if temperature_C is None:
        alt = Angle(radians=alt)
    else:
        if temperature_C == 'standard':
            temperature_C = 10.0
        if pressure_mbar == 'standard':
            pressure_mbar = 1010.0 * exp(-elevation_m / 9.1e3)
        alt = refract(alt * RAD2DEG, temperature_C, pressure_mbar)
        alt = Angle(degrees=alt)

    return alt, Angle(radians=az), Distance(r_au)
244871
def move_towards(self, other, beta, alpha):
        """"""
        self.position += beta * (other.position - self.position)
        self.position += alpha * (np.random.uniform(-0.5, 0.5, len(self.position)))
        self.position = np.minimum(self.position, [b[1] for b in self.bounds])
        self.position = np.maximum(self.position, [b[0] for b in self.bounds])
764926
function(referencePoint, otherPoint) {
    if (this.yDown) {
      if (otherPoint.y > referencePoint.y) {
        otherPoint = {
          x: otherPoint.x,
          y: referencePoint.y - (otherPoint.y - referencePoint.y)
        }
      } else if (otherPoint.y < referencePoint.y) {
        otherPoint = {
          x: otherPoint.x,
          y: referencePoint.y + (referencePoint.y - otherPoint.y)
        }
      }
    }

    var delta = vec2d(otherPoint).minus(vec2d(referencePoint))
    var weird = radiansToWeird(delta.angle())
    var compass = weirdToCompass(weird)

    for (var i = 0; i < this.slices.length; i++) {
      if (this.slices[i].contains(compass)) {
        return this.slices[i].number
      }
    }
  }
1202257
def setup_interpolant(self):
        """"""
        # for computing nearby (z < 1) redshifts
        zs = numpy.linspace(0., 1., num=self.numpoints)
        ds = self.cosmology.luminosity_distance(zs).value
        self.nearby_d2z = interpolate.interp1d(ds, zs, kind='linear',
                                                bounds_error=False)
        # for computing far away (z > 1) redshifts
        zs = numpy.logspace(0, numpy.log10(self.default_maxz),
                            num=self.numpoints)
        ds = self.cosmology.luminosity_distance(zs).value
        self.faraway_d2z = interpolate.interp1d(ds, zs, kind='linear',
                                                 bounds_error=False)
        # store the default maximum distance
        self.default_maxdist = ds.max()
258837
def offset_to_sky(skydir, offset_lon, offset_lat,
                  coordsys='CEL', projection='AIT'):
    """"""

    offset_lon = np.array(offset_lon, ndmin=1)
    offset_lat = np.array(offset_lat, ndmin=1)

    w = create_wcs(skydir, coordsys, projection)
    pixcrd = np.vstack((offset_lon, offset_lat)).T

    return w.wcs_pix2world(pixcrd, 0)
697355
def get_movement_delta(self):
        """"""
        pos = self.pan - self.previous_pos
        self.previous_pos = Vector2(self.pan.X, self.pan.Y)
        return pos
375536
private void computePsiSmooth(GrayF32 ux , GrayF32 uy , GrayF32 vx , GrayF32 vy ,
								  GrayF32 psiSmooth ) {
		int N = derivFlowUX.width * derivFlowUX.height;

		for( int i = 0; i < N; i++ ) {
			float vux = ux.data[i];
			float vuy = uy.data[i];
			float vvx = vx.data[i];
			float vvy = vy.data[i];

			float mu = vux*vux + vuy*vuy;
			float mv = vvx*vvx + vvy*vvy;

			psiSmooth.data[i] = (float)(1.0/(2.0*Math.sqrt(mu + mv + EPSILON*EPSILON)));
		}
	}
473475
def expected_magz(RAW_IMU, ATTITUDE, inclination, declination):
    ''''''
    v = expected_mag(RAW_IMU, ATTITUDE, inclination, declination)
    return v.z
373164
def aitoffSphereToImage(lon, lat):
    
    lon = lon - 360.*(lon>180)
    lon = np.radians(lon)
    lat = np.radians(lat)

    half_lon = lon/2.
    cos_lat = np.cos(lat)
     
    gamma = (180. / np.pi) * np.sqrt(2. / (1. + (cos_lat * np.cos(half_lon))))
    x = 2. * gamma * cos_lat * np.sin(half_lon)
    y = gamma * np.sin(lat)
    return x, y
809149
function takeCurve(pred) {
    for(var i=0, n=horizon.length; i<n; ++i) {
      var c = horizon[i]
      if(pred(c)) {
        horizon[i] = horizon[n-1]
        horizon.pop()
        return c
      }
    }
    return null
  }
1062994
def _co_moving2angle(self, x, y, idex):
        
        T_z = self._T_z_list[idex]
        #T_z = self._cosmo_bkg.T_xy(0, z_lens)
        theta_x = x / T_z
        theta_y = y / T_z
        return theta_x, theta_y
1223673
def native(meshes, xs, ys, zs, expose_horizon=False, horizon_method='boolean'):
    

    centers_flat = meshes.get_column_flat('centers')
    vertices_flat = meshes.get_column_flat('vertices')
    triangles_flat = meshes.get_column_flat('triangles')  # should handle offset automatically

    if horizon_method=='boolean':
        normals_flat = meshes.get_column_flat('tnormals')
    elif horizon_method=='linear':
        normals_flat = meshes.get_column_flat('vnormals')
    else:
        raise NotImplementedError

    # viewing_vector is defined as star -> earth
    # NOTE: this will need to flip if we change the convention on the z-direction
    viewing_vector = np.array([0., 0., 1.])


    # we need to send in ALL vertices but only the visible triangle information
    info = libphoebe.mesh_visibility(viewing_vector,
                                     vertices_flat,
                                     triangles_flat,
                                     normals_flat,
                                     tvisibilities=True,
                                     taweights=True,
                                     method=horizon_method,
                                     horizon=expose_horizon)

    visibilities = meshes.unpack_column_flat(info['tvisibilities'], computed_type='triangles')
    weights = meshes.unpack_column_flat(info['taweights'], computed_type='triangles')

    if expose_horizon:
        horizons = info['horizon']

        # TODO: we need to do this per component and somehow return them in
        # a predictable order or as a dictionary a la the other returned quantities
        horizons = [vertices_flat[horizon_i] for horizon_i in horizons]

    else:
        horizons = None

    return visibilities, weights, horizons
724013
def distance(self, other):
        
        return distance((self.separation, self.pa), (other.separation, other.pa))
240261
def _inc_lat(self, latitude, delta):
        """"""
        y = self._convert_latitude(latitude)
        y += delta
        return 360 / pi * atan(
            exp((180 - y * 360 / (2 ** self._zoom) / self._size) * pi / 180)) - 90
571259
def _compute_full_ts(self, data):
        """"""
        # Get results at each desired timestep and spatial point.
        full_ts, dt = self._compute(data)
        # Vertically integrate.
        vert_types = ('vert_int', 'vert_av')
        if self.dtype_out_vert in vert_types and self.var.def_vert:
            dp = self._get_input_data(_DP_VARS[self.dtype_in_vert],
                                      self.start_date, self.end_date)
            full_ts = utils.vertcoord.int_dp_g(full_ts, dp)
            if self.dtype_out_vert == 'vert_av':
                ps = self._get_input_data(utils.vertcoord.ps,
                                          self.start_date, self.end_date)
                full_ts *= (GRAV_EARTH / ps)
        return full_ts, dt
352048
def native_projection_explanation(ax):
    """"""
    ax.set_title('Longitude and Latitude', size=18, y=1.1)

    # Hide the azimuth labels
    ax.set_azimuth_ticklabels([])

    # Make the axis tick labels visible:
    ax.set_xticks(np.radians(np.arange(-80, 90, 10)))
    ax.tick_params(label1On=True)

    ax.set_xlabel('Longitude')

    xlabel_halo(ax)
    return ax
480249
function recomputeDirections(queryModel, relativeLightPosition) {
  // construct a coordinate system relative to eye point
  const v = spherical2Cartesian(
    queryModel.getValue('phi'),
    queryModel.getValue('theta')
  );
  const viewDir = vec3.fromValues(v[0], v[1], v[2]);
  const at = vec3.fromValues(0, 0, 0); // assumption always looking at 0
  const north = vec3.fromValues(0, 0, 1); // assumption, north is always up
  const approxUp = vec3.create();
  vec3.add(approxUp, north, viewDir);
  vec3.normalize(approxUp, approxUp);

  const t0 = vec3.create();
  vec3.subtract(t0, at, viewDir);
  const t1 = vec3.create();
  vec3.subtract(t1, approxUp, viewDir);
  const right = vec3.create();
  vec3.cross(right, t0, t1);
  vec3.normalize(right, right);
  vec3.subtract(t0, right, viewDir);
  vec3.subtract(t1, at, viewDir);
  const up = vec3.create();
  vec3.cross(up, t0, t1);
  vec3.normalize(up, up);
  // scale down so we can alway have room before normalization
  const rm = vec3.create();
  vec3.scale(rm, right, relativeLightPosition.x);
  const um = vec3.create();
  vec3.scale(um, up, relativeLightPosition.y);
  const scaledView = vec3.create();
  vec3.scale(scaledView, viewDir, 0.3);
  const lightDirection = vec3.create();
  vec3.add(lightDirection, scaledView, rm);
  vec3.add(lightDirection, lightDirection, um);
  vec3.normalize(lightDirection, lightDirection);
  return {
    lightDir: lightDirection,
    viewDir,
  };
}