calculate paleoinclination from latitude using dipole formula: tan(I) = 2tan(lat)
    Parameters
    ________________

    lat : either a single value or an array of latitudes

    Returns
    -------

    array of inclinations
966806
def pinc(lat):
    
    tanl = np.tan(np.radians(lat))
    inc = np.arctan(2. * tanl)
    return np.degrees(inc)
392713
def latitude(self):
        ''''''
        sd = dm_to_sd(self.lat)
        if self.lat_dir == 'N':
            return +sd
        elif self.lat_dir == 'S':
            return -sd
        else:
            return 0.
142926
def EarthDistance((lat1, lon1), (lat2, lon2)):
    ""
    x1 = CalcRad(lat1) * math.cos(Deg2Rad(lon1)) * math.sin(Deg2Rad(90-lat1))
    x2 = CalcRad(lat2) * math.cos(Deg2Rad(lon2)) * math.sin(Deg2Rad(90-lat2))
    y1 = CalcRad(lat1) * math.sin(Deg2Rad(lon1)) * math.sin(Deg2Rad(90-lat1))
    y2 = CalcRad(lat2) * math.sin(Deg2Rad(lon2)) * math.sin(Deg2Rad(90-lat2))
    z1 = CalcRad(lat1) * math.cos(Deg2Rad(90-lat1))
    z2 = CalcRad(lat2) * math.cos(Deg2Rad(90-lat2))
    a = (x1*x2 + y1*y2 + z1*z2)/pow(CalcRad((lat1+lat2)/2), 2)
    # a should be in [1, -1] but can sometimes fall outside it by
    # a very small amount due to rounding errors in the preceding
    # calculations (this is prone to happen when the argument points
    # are very close together).  Thus we constrain it here.
    if abs(a) > 1: a = 1
    elif a < -1: a = -1
    return CalcRad((lat1+lat2) / 2) * math.acos(a)
343535
def earth_orientation(date):
    

    x_p, y_p, s_prime = np.deg2rad(_earth_orientation(date))
    return rot3(-s_prime) @ rot2(x_p) @ rot1(y_p)
901764
def lonlat2xyz(lon, lat):
    """"""
    lat = xu.deg2rad(lat)
    lon = xu.deg2rad(lon)
    x = xu.cos(lat) * xu.cos(lon)
    y = xu.cos(lat) * xu.sin(lon)
    z = xu.sin(lat)
    return x, y, z
837177
def _prepare_coords(lons1, lats1, lons2, lats2):
    
    lons1 = numpy.radians(lons1)
    lats1 = numpy.radians(lats1)
    assert lons1.shape == lats1.shape
    lons2 = numpy.radians(lons2)
    lats2 = numpy.radians(lats2)
    assert lons2.shape == lats2.shape
    return lons1, lats1, lons2, lats2
825582
def haversine(lat1: float, lon1: float, lat2: float, lon2: float) -> float:
    """"""
    lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])

    # haversine formula
    dlon = lon2 - lon1
    dlat = lat2 - lat1
    calc_a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2
    calc_c = 2 * asin(sqrt(calc_a))

    return 6371 * calc_c
1037641
def _loglr(self):
        
        """
        # calculate <d-h|d-h> = <h|h> - 2<h|d> + <d|d> up to a constant
        p = self.current_params.copy()
        p.update(self.static_params)

        if self.time is None:
            self.time = p['tc']

        shloglr = hhloglr = 0
        for ifo in self.sh:
            fp, fc = self.det[ifo].antenna_pattern(p['ra'], p['dec'],
                                                   p['polarization'],
                                                   self.time)
            dt = self.det[ifo].time_delay_from_earth_center(p['ra'],
                                                            p['dec'],
                                                            self.time)
            ip = numpy.cos(p['inclination'])
            ic = 0.5 * (1.0 + ip * ip)
            htf = (fp * ip + 1.0j * fc * ic) / p['distance']

            sh = self.sh[ifo].at_time(p['tc'] + dt) * htf
            shloglr += sh
            hhloglr += self.hh[ifo] * abs(htf) ** 2.0

        vloglr = numpy.log(scipy.special.i0e(abs(shloglr)))
        vloglr += abs(shloglr) + hhloglr

        return float(vloglr)
482675
function _haversineCalculation(coordinateOne, coordinateTwo) {
// Credits
// https://www.movable-type.co.uk/scripts/latlong.html
// https://en.wikipedia.org/wiki/Haversine_formula
  let latitudeOneRadians = _convertDegreesToRadians(coordinateOne.latitude);
  let latitudeTwoRadians = _convertDegreesToRadians(coordinateTwo.latitude);

  let longitudeOneRadians = _convertDegreesToRadians(coordinateOne.longitude);
  let longitudeTwoRadians = _convertDegreesToRadians(coordinateTwo.longitude);

  let differenceOfLatitude = latitudeOneRadians - latitudeTwoRadians;
  let differenceOfLongitude = longitudeOneRadians - longitudeTwoRadians;

  // The square of half the chord length between the points
  let a = Math.sin(differenceOfLatitude / 2) * Math.sin(differenceOfLatitude / 2)
    + Math.sin(differenceOfLongitude / 2) * Math.sin(differenceOfLongitude / 2)
    * Math.cos(latitudeOneRadians) * Math.cos(latitudeTwoRadians);

  let angularDistanceInRadians = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));

  let distanceBetweenKM = EARTH_RADIUS_KM * angularDistanceInRadians;

  return distanceBetweenKM;
}
1221958
def dim_dtau(self, pars):
        
        """
        self._set_parameters(pars)
        # term 1
        num1 = -self.m * (self.w ** self.c) * self.c\
            * (self.tau ** (self.c - 1)) * np.sin(self.ang)
        term1 = self.sigmai * num1 / self.denom

        # term 2
        num2a = -self.m * self.otc * np.sin(self.ang)
        num2b = 2 * (self.w ** 2.0) * self.c * (self.tau ** (self.c - 1)) *\
            np.cos(self.ang)
        num2c = 2 * self.c * (self.w ** (self.c * 2)) *\
            (self.tau ** (2 * self.c - 1))
        term2 = self.sigma0 * num2a * (num2b + num2c) / (self.denom ** 2)

        result = term1 + term2

        return result
834900
def haversine(lat_lng1, lat_lng2, native=True):
    if native:
        return _native.haversine(lat_lng1, lat_lng2)

    """"""
    lat1, lng1 = lat_lng1
    lat2, lng2 = lat_lng2
    lat1, lng1, lat2, lng2 = map(math.radians, (lat1, lng1, lat2, lng2))
    lat = lat2 - lat1
    lng = lng2 - lng1
    d = math.sin(lat * 0.5) ** 2 \
        + math.cos(lat1) * math.cos(lat2) * math.sin(lng * 0.5) ** 2
    return 2 * _AVG_EARTH_RADIUS * math.asin(math.sqrt(d))
139330
public static double latitudeToMetersY( double latitude ) {
        return EQUATORIALRADIUS * Math.log(Math.tan(Math.PI / 4 + 0.5 * Math.toRadians(latitude)));
    }
1183627
def _earth_orientation(date):
    

    ttt = date.change_scale('TT').julian_century
    # a_a = 0.12
    # a_c = 0.26
    # s_prime = -0.0015 * (a_c ** 2 / 1.2 + a_a ** 2) * ttt
    s_prime = - 0.000047 * ttt

    return date.eop.x / 3600., date.eop.y / 3600., s_prime / 3600
481446
function (latitude) {
                return Math.log(Math.tan(Math.PI / 4 + (latitude * Angle.DEGREES_TO_RADIANS) / 2)) / Math.PI;
            }
548629
function cprNLFunction (lat) {
  if (lat < 0) lat = -lat // Table is simmetric about the equator
  if (lat < 10.47047130) return 59
  if (lat < 14.82817437) return 58
  if (lat < 18.18626357) return 57
  if (lat < 21.02939493) return 56
  if (lat < 23.54504487) return 55
  if (lat < 25.82924707) return 54
  if (lat < 27.93898710) return 53
  if (lat < 29.91135686) return 52
  if (lat < 31.77209708) return 51
  if (lat < 33.53993436) return 50
  if (lat < 35.22899598) return 49
  if (lat < 36.85025108) return 48
  if (lat < 38.41241892) return 47
  if (lat < 39.92256684) return 46
  if (lat < 41.38651832) return 45
  if (lat < 42.80914012) return 44
  if (lat < 44.19454951) return 43
  if (lat < 45.54626723) return 42
  if (lat < 46.86733252) return 41
  if (lat < 48.16039128) return 40
  if (lat < 49.42776439) return 39
  if (lat < 50.67150166) return 38
  if (lat < 51.89342469) return 37
  if (lat < 53.09516153) return 36
  if (lat < 54.27817472) return 35
  if (lat < 55.44378444) return 34
  if (lat < 56.59318756) return 33
  if (lat < 57.72747354) return 32
  if (lat < 58.84763776) return 31
  if (lat < 59.95459277) return 30
  if (lat < 61.04917774) return 29
  if (lat < 62.13216659) return 28
  if (lat < 63.20427479) return 27
  if (lat < 64.26616523) return 26
  if (lat < 65.31845310) return 25
  if (lat < 66.36171008) return 24
  if (lat < 67.39646774) return 23
  if (lat < 68.42322022) return 22
  if (lat < 69.44242631) return 21
  if (lat < 70.45451075) return 20
  if (lat < 71.45986473) return 19
  if (lat < 72.45884545) return 18
  if (lat < 73.45177442) return 17
  if (lat < 74.43893416) return 16
  if (lat < 75.42056257) return 15
  if (lat < 76.39684391) return 14
  if (lat < 77.36789461) return 13
  if (lat < 78.33374083) return 12
  if (lat < 79.29428225) return 11
  if (lat < 80.24923213) return 10
  if (lat < 81.19801349) return 9
  if (lat < 82.13956981) return 8
  if (lat < 83.07199445) return 7
  if (lat < 83.99173563) return 6
  if (lat < 84.89166191) return 5
  if (lat < 85.75541621) return 4
  if (lat < 86.53536998) return 3
  if (lat < 87.00000000) return 2
  else return 1
}
572333
def lon_lat(value):
    
    lon, lat = value.split()
    return longitude(lon), latitude(lat)
276917
def distance(latitude_1, longitude_1, elevation_1, latitude_2, longitude_2, elevation_2,
             haversine=None):
    

    # If points too distant -- compute haversine distance:
    if haversine or (abs(latitude_1 - latitude_2) > .2 or abs(longitude_1 - longitude_2) > .2):
        return haversine_distance(latitude_1, longitude_1, latitude_2, longitude_2)

    coef = math.cos(latitude_1 / 180. * math.pi)
    #pylint: disable=invalid-name
    x = latitude_1 - latitude_2
    y = (longitude_1 - longitude_2) * coef

    distance_2d = math.sqrt(x * x + y * y) * ONE_DEGREE

    if elevation_1 is None or elevation_2 is None or elevation_1 == elevation_2:
        return distance_2d

    return math.sqrt(distance_2d ** 2 + (elevation_1 - elevation_2) ** 2)