Convert latitude from degrees,minutes,seconds in string or 3-array
   format to decimal degrees.
556859
def dms2dec(dms):
    
    DEGREE = 360.
    HOUR = 24.
    MINUTE = 60.
    SECOND = 3600.

    # Be careful here, degree needs to be a float so that negative zero
    # can have its signbit set:
    # http://docs.scipy.org/doc/numpy-1.7.0/reference/c-api.coremath.html#NPY_NZERO

    if isstring(dms):
        degree,minute,second = np.array(re.split('[dms]',hms))[:3].astype(float)
    else:
        degree,minute,second = dms.T

    sign = np.copysign(1.0,degree)
    decimal = np.abs(degree) + minute * 1./MINUTE + second * 1./SECOND
    decimal *= sign
    return decimal
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
1244187
String formatLngLat() {
        DecimalFormat df = new DecimalFormat("##0.0###########");

        // Explicitly test for differences less than 1.0e-12 and
        // force them to be zero.  Otherwise you may find a case
        // where two points differ in the less significant bits, but
        // they format as the same number.
        double lng = (Math.abs(m_longitude) < EPSILON) ? 0 : m_longitude;
        double lat = (Math.abs(m_latitude) < EPSILON) ? 0 : m_latitude;
        return df.format(lng) + " " + df.format(lat);
    }
368186
def to_minutes(days=0, hours=0, minutes=0, seconds=0, milliseconds=0,
               round_to_int=True):
    
    total = float(days)*24*60 + float(hours)*60 + float(minutes) + \
        float(seconds)/60 + float(milliseconds)/1000/60
    return int(round(total)) if round_to_int else total
1247140
def _scale_degrees():
    '''
    degrees = ['1', '2', '3',  '4',  '5',  '6', '7',
               '8', '9', '10', '11', '12', '13']
    semitones = [0, 2, 4, 5, 7, 9, 11, 12, 14, 16, 17, 19, 21]
    return dict([(d, s) for d, s in zip(degrees, semitones)])
642540
def parse_coordinate(string_rep, unit):
        
        # explicit radian ('r') value
        if string_rep[-1] == 'r':
            return coordinates.Angle(string_rep[:-1], unit=u.rad)
        # explicit image ('i') and physical ('p') pixels
        elif string_rep[-1] in ['i', 'p']:
            return u.Quantity(string_rep[:-1]) - 1
        # Any ds9 coordinate representation (sexagesimal or degrees)
        elif 'd' in string_rep or 'h' in string_rep:
            return coordinates.Angle(string_rep)
        elif unit is 'hour_or_deg':
            if ':' in string_rep:
                spl = tuple([float(x) for x in string_rep.split(":")])
                return coordinates.Angle(spl, u.hourangle)
            else:
                ang = float(string_rep)
                return coordinates.Angle(ang, u.deg)
        elif unit.is_equivalent(u.deg):
            # return coordinates.Angle(string_rep, unit=unit)
            if ':' in string_rep:
                ang = tuple([float(x) for x in string_rep.split(":")])
            else:
                ang = float(string_rep)
            return coordinates.Angle(ang, u.deg)
        elif unit.is_equivalent(u.dimensionless_unscaled):
            return u.Quantity(float(string_rep), unit) - 1
        else:
            return u.Quantity(float(string_rep), unit)
85460
def _hour_angle_to_hours(times, hourangle, longitude, equation_of_time):
    """"""
    naive_times = times.tz_localize(None)  # naive but still localized
    tzs = 1 / NS_PER_HR * (
        naive_times.astype(np.int64) - times.astype(np.int64))
    hours = (hourangle - longitude - equation_of_time / 4.) / 15. + 12. + tzs
    return np.asarray(hours)
1204967
def get_utm_zone(longitude):
    """"""
    zone = int((math.floor((longitude + 180.0) / 6.0) + 1) % 60)
    if zone == 0:
        zone = 60
    return zone
1229700
def nsamples_to_hourmin(x, pos):
    '''
    '''

    h, m, s = hourminsec(x/16.0)
    return '{:.0f}h {:2.0f}′'.format(h, m+round(s))
1326727
@NotNull
    public static double[] decimalToDegreesMinutesSeconds(double decimal)
    {
        int d = (int)decimal;
        double m = Math.abs((decimal % 1) * 60);
        double s = (m % 1) * 60;
        return new double[] { d, (int)m, s};
    }
865571
def hms_to_seconds(time_string):
    
    s = time_string.split(':')
    hours = int(s[0])
    minutes = int(s[1])
    secs = float(s[2])
    return hours * 3600 + minutes * 60 + secs
168365
def convert_to_xml(cls, degrees):
        
        if degrees < 0.0:
            degrees %= -360
            degrees += 360
        elif degrees > 0.0:
            degrees %= 360

        return str(int(round(degrees * cls.DEGREE_INCREMENTS)))
165675
private long[][] getLatitude( String lat ) {

        float secs = Float.parseFloat("0" + lat.substring(4)) * 60.f;
        long nom = (long) (secs * 1000);

        long[][] latl = new long[][]{{Long.parseLong(lat.substring(0, 2)), 1}, {Long.parseLong(lat.substring(2, 4)), 1},
                {nom, 1000}};

        return latl;
    }
1144970
def _cast_float(temp_dt):
    """"""
    if type(temp_dt) == str:
        fmt = '%Y-%m-%dT%H:%M:00'
        base_dt = temp_dt[0:19]
        tz_offset = eval(temp_dt[19:22])
        temp_dt = datetime.datetime.strptime(base_dt, fmt) - \
                datetime.timedelta(hours=tz_offset)
    return (temp_dt - datetime.datetime(1970, 1, 1)).total_seconds()
31936
def seconds2str(seconds):
    """"""

    if seconds < 0:
        return "{0:.3g}s".format(seconds)
    elif math.isnan(seconds):
        return "NaN"
    elif math.isinf(seconds):
        return "Inf"

    m, s = divmod(seconds, 60)
    h, m = divmod(m, 60)
    if h >= 1:
        return "{0:g}h {1:02g}m {2:.3g}s".format(h, m, s)
    elif m >= 1:
        return "{0:02g}m {1:.3g}s".format(m, s)
    else:
        return "{0:.3g}s".format(s)
781511
def wtime_to_minutes(time_string):
    ''' 

    '''
    hours, mins, seconds = time_string.split(':')
    return int(hours) * 60 + int(mins) + 1
222843
def _get_decimal_from_datetime(time):
    '''
    
    '''

    # Get decimal seconds from seconds + microseconds
    temp_seconds = np.float(time.second) + (np.float(time.microsecond) / 1.0E6)
    return decimal_time(np.array([time.year], dtype=int),
                        np.array([time.month], dtype=int),
                        np.array([time.day], dtype=int),
                        np.array([time.hour], dtype=int),
                        np.array([time.minute], dtype=int),
                        np.array([temp_seconds], dtype=int))