Returns the moment and the moment magnitude
487954
def _get_moment_from_ndk_string(self, ndk_string, exponent):
        
        moment = float(ndk_string[49:56]) * (10. ** exponent)
        version = ndk_string[:3]
        magnitude = utils.moment_magnitude_scalar(moment)
        return moment, version, magnitude
1306179
def get_seconds(value, scale):
  
  scales = {
    'seconds': lambda x: x,
    'minutes': lambda x: x * 60,
    'hours': lambda x: x * 60 * 60,
    'days': lambda x: x * 60 * 60 * 24,
    'weeks': lambda x: x * 60 * 60 * 24 * 7,
    'months': lambda x: x * 60 * 60 * 24 * 30,
    'years': lambda x: x * 60 * 60 * 24 * 365,
  }
  return scales[scale](value)
883047
def dev_moments(self):
        """"""
        return numpy.sum(numpy.abs(self.moments-self.ma.moments))
945602
def values(self):
        
        return np.array([self.mean, self.var, self.min, self.max, self.num])
702893
def magnitude(self):
    

    return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2 + self.w ** 2)
695642
def getBottomRight(self):
        
        return (float(self.get_cx()) + float(self.get_r()), float(self.get_cy()) - float(self.get_r()))
159423
def get_magnitude_term(self, C, rup):
        
        b0, stress_drop = self._get_sof_terms(C, rup.rake)
        if rup.mag <= C["m1"]:
            return b0
        else:
            # Calculate moment (equation 5)
            m_0 = 10.0 ** (1.5 * rup.mag + 16.05)
            # Get stress-drop scaling (equation 6)
            if rup.mag > C["m2"]:
                stress_drop += (C["b2"] * (C["m2"] - self.CONSTANTS["mstar"]) +
                                (C["b3"] * (rup.mag - C["m2"])))
            else:
                stress_drop += (C["b2"] * (rup.mag - self.CONSTANTS["mstar"]))
            stress_drop = np.exp(stress_drop)
            # Get corner frequency (equation 4)
            f0 = 4.9 * 1.0E6 * 3.2 * ((stress_drop / m_0) ** (1. / 3.))
            return 1. / f0
989242
function getRes(unit) {
        var measured,
            begin,
            count = 30,
            divisor = 1e3,
            ns = timer.ns,
            sample = [];

        // Get average smallest measurable time.
        while (count--) {
          if (unit == 'us') {
            divisor = 1e6;
            if (ns.stop) {
              ns.start();
              while (!(measured = ns.microseconds())) {}
            } else {
              begin = ns();
              while (!(measured = ns() - begin)) {}
            }
          }
          else if (unit == 'ns') {
            divisor = 1e9;
            begin = (begin = ns())[0] + (begin[1] / divisor);
            while (!(measured = ((measured = ns())[0] + (measured[1] / divisor)) - begin)) {}
            divisor = 1;
          }
          else if (ns.now) {
            begin = ns.now();
            while (!(measured = ns.now() - begin)) {}
          }
          else {
            begin = new ns().getTime();
            while (!(measured = new ns().getTime() - begin)) {}
          }
          // Check for broken timers.
          if (measured > 0) {
            sample.push(measured);
          } else {
            sample.push(Infinity);
            break;
          }
        }
        // Convert to seconds.
        return getMean(sample) / divisor;
      }
90882
def normalized(self):
    

    magnitude = self.magnitude()
    return Quaternion(
      self.x / magnitude, self.y / magnitude,
      self.z / magnitude, self.w / magnitude)
511003
def magnitude(self):
        """"""
        return math.sqrt(
            reduce(lambda x, y: x + y, [x ** 2 for x in self.to_list()])
        )
1111140
def unit(self):
        """"""
        return Vector(
            (self.x / self.magnitude()),
            (self.y / self.magnitude()),
            (self.z / self.magnitude())
        )
176131
function () {
            if (this._duration) {
                return this._duration;
            }
            if (this._start && this._end) {
                return moment.duration(this._end - this._start);
            }
            else {
                return moment.duration(0);
            }
        }
936458
def _get_magnitude_scaling_term(self, C, mag):
        
        if mag < 6.75:
            return C["a1_lo"] + C["a2_lo"] * mag + C["a3"] *\
                ((8.5 - mag) ** 2.0)
        else:
            return C["a1_hi"] + C["a2_hi"] * mag + C["a3"] *\
                ((8.5 - mag) ** 2.0)
735970
@Override
    public Moment currentTime() {

        if ((this.monotonic || MONOTON_MODE) && LeapSeconds.getInstance().isEnabled()) {
            long nanos = this.utcNanos();
            return Moment.of(Math.floorDiv(nanos, MRD), (int) Math.floorMod(nanos, MRD), TimeScale.UTC);
        } else {
            long millis = System.currentTimeMillis();
            int nanos = ((int) Math.floorMod(millis, 1000)) * MIO;
            return Moment.of(Math.floorDiv(millis, 1000), nanos, TimeScale.POSIX);
        }

    }
1347222
def duration(self):
        
        return units.Quantity(self.span[1] - self.span[0], self.xunit,
                              dtype=float)
1206163
def _total_seconds(t):
    '''
    
    '''
    return sum([
        int(t.days * 86400 + t.seconds),
        int(round(t.microseconds / 1000000.0))
    ])
576122
def _get_magnitude_term(self, C, mag):
        
        f_mag = C["c0"] + C["c1"] * mag
        if (mag > 4.5) and (mag <= 5.5):
            return f_mag + (C["c2"] * (mag - 4.5))
        elif (mag > 5.5) and (mag <= 6.5):
            return f_mag + (C["c2"] * (mag - 4.5)) + (C["c3"] * (mag - 5.5))
        elif mag > 6.5:
            return f_mag + (C["c2"] * (mag - 4.5)) + (C["c3"] * (mag - 5.5)) +\
                (C["c4"] * (mag - 6.5))
        else:
            return f_mag