Returns the Eurocode 8 site class dummy variable
498621
def _get_site_dummy_variables(self, vs30):
        
        s_b = np.zeros_like(vs30)
        s_c = np.zeros_like(vs30)
        s_d = np.zeros_like(vs30)
        s_b[np.logical_and(vs30 >= 360., vs30 < 800.)] = 1.0
        s_c[np.logical_and(vs30 >= 180., vs30 < 360.)] = 1.0
        s_d[vs30 < 180] = 1.0
        return s_b, s_c, s_d
1243680
def _compute_site_class_term(self, C, vs30):
        
        # map vs30 value to site class, see table 2, p. 901.
        site_term = np.zeros(len(vs30))

        # hard rock
        site_term[vs30 > 1100.0] = C['CH']

        # rock
        site_term[(vs30 > 600) & (vs30 <= 1100)] = C['C1']

        # hard soil
        site_term[(vs30 > 300) & (vs30 <= 600)] = C['C2']

        # medium soil
        site_term[(vs30 > 200) & (vs30 <= 300)] = C['C3']

        # soft soil
        site_term[vs30 <= 200] = C['C4']

        return site_term
306090
def gwcalctyp(self):
        """"""
        dig0 = str(self._SIGMA_TYPES[self.type])
        dig1 = str(self._SC_MODES[self.sc_mode])
        return dig1.strip() + dig0.strip()
1335870
def subclass(cls, vt_code, vt_args):
        """"""
        from geoid import get_class
        import geoid.census

        parser = get_class(geoid.census, vt_args.strip('/')).parse

        cls = type(vt_code.replace('/', '_'), (cls,), {'vt_code': vt_code, 'parser': parser})
        globals()[cls.__name__] = cls
        assert cls.parser

        return cls
372029
def getLaplaceCovar(self):
        
        assert self.init,        'GP not initialised'
        assert self.fast==False, 'Not supported for fast implementation'
        
        if self.cache['Sigma']==None:
            self.cache['Sigma'] = SP.linalg.inv(self.getHessian())
        return self.cache['Sigma']
535224
function getVariables(spec_c, parent) {
  var spec_js = {};
  var vars = _.find(getChildren(spec_c, 'sectiondef'), function(section) {
    var kind = getAttr(section, 'kind');
    return (kind == 'public-attrib');
  });
  if (vars) {
    _.each(_.filter(vars.children, function(variable) {
      return (getAttr(variable, 'kind') == 'variable');
    }), function(variable) {
      var varName = getText(getChild(variable, 'name'), 'name');
      var varType = getType(getText(getChild(variable, 'type')), parent);
      var varDescription = getText(getChild(variable, 'detaileddescription'));
      spec_js[varName] = {
        type: varType,
        description: varDescription
      }
    });
  }
  return spec_js;
}
148401
def dbg_repr(self):
        

        stack = [ ]
        for i, frame in enumerate(self):
            s = "%d | %s -> %s, returning to %s" % (
                i,
                "None" if frame.call_site_addr is None else "%#x" % frame.call_site_addr,
                "None" if frame.func_addr is None else "%#x" % frame.func_addr,
                "None" if frame.return_target is None else "%#x" % frame.return_target,
            )
            stack.append(s)

        return "\n".join(stack)
1248955
def _get_mechanism(self, rup, C):
        
        Fn, Fr = self._get_fault_type_dummy_variables(rup)
        return (C['f1'] * Fn) + (C['f2'] * Fr)
846079
def get_output_cache_key(self, placeholder_name, instance):
        
        cachekey = self.get_output_cache_base_key(placeholder_name, instance)
        if self.cache_output_per_site:
            cachekey = "{0}-s{1}".format(cachekey, settings.SITE_ID)

        # Append language code
        if self.cache_output_per_language:
            # NOTE: Not using self.language_code, but using the current language instead.
            #       That is what the {% trans %} tags are rendered as after all.
            #       The render_placeholder() code can switch the language if needed.
            user_language = get_language()
            if user_language not in self.cache_supported_language_codes:
                user_language = 'unsupported'
            cachekey = "{0}.{1}".format(cachekey, user_language)

        return cachekey
122274
def _get_site_classification(self, vs30):
        
        site_class = np.ones(vs30.shape, dtype=int)
        idx = {}
        idx[1] = vs30 > 600.
        idx[2] = np.logical_and(vs30 > 300., vs30 <= 600.)
        idx[3] = np.logical_and(vs30 > 200., vs30 <= 300.)
        idx[4] = vs30 <= 200.
        for i in [2, 3, 4]:
            site_class[idx[i]] = i
        return site_class, idx
270545
public static function get_site_identifier() {
        global $CFG;
        if (!is_null(self::$siteidentifier)) {
            return self::$siteidentifier;
        }
        // If site identifier hasn't been collected yet attempt to get it from the cache config.
        $factory = cache_factory::instance();
        // If the factory is initialising then we don't want to try to get it from the config or we risk
        // causing the cache to enter an infinite initialisation loop.
        if (!$factory->is_initialising()) {
            $config = $factory->create_config_instance();
            self::$siteidentifier = $config->get_site_identifier();
        }
        if (is_null(self::$siteidentifier)) {
            // If the site identifier is still null then config isn't aware of it yet.
            // We'll see if the CFG is loaded, and if not we will just use unknown.
            // It's very important here that we don't use get_config. We don't want an endless cache loop!
            if (!empty($CFG->siteidentifier)) {
                self::$siteidentifier = self::update_site_identifier($CFG->siteidentifier);
            } else {
                // It's not being recorded in MUC's config and the config data hasn't been loaded yet.
                // Likely we are initialising.
                return 'unknown';
            }
        }
        return self::$siteidentifier;
    }
1081397
private int getLocalVariableIndex(int i) {
        int index = classMethod.isStatic() ? 0 : 1;
        for (String type : classMethod.getParameters()) {
            if (type.equals(DOUBLE_CLASS_DESCRIPTOR) || type.equals(LONG_CLASS_DESCRIPTOR)) {
                index += 2;
            } else {
                index++;
            }
        }
        return index + i;
    }
556849
def _get_fault_type_dummy_variables(self, rup):
        

        Fn, Fr = 0, 0
        if rup.rake >= -112.5 and rup.rake <= -67.5:
            # normal
            Fn = 1
        elif rup.rake >= 22.5 and rup.rake <= 157.5:
            # Joins both the reverse and reverse-oblique categories
            Fr = 1
        return Fn, Fr
1338100
def _get_mechanism(self, rup, C):
        
        U, SS, NS, RS = self._get_fault_type_dummy_variables(rup)

        return C['f1'] * NS + C['f2'] * RS + C['f3'] * SS
833691
def _get_fault_type_dummy_variables(self, rake):
        
        f_n, f_r = 0, 0
        if rake >= -120 and rake <= -60:
            # normal
            f_n = 1
        elif rake >= 30 and rake <= 150:
            # reverse
            f_r = 1
        return f_n, f_r
945022
def _get_site_amplification(self, sites, coeffs):
        
        is_rock = self.get_site_type_dummy_variables(sites)
        return coeffs['b5']*is_rock
1091579
def class_variables(self):
        
        p = lambda o: isinstance(o, Variable) and self.module._docfilter(o)
        return filter(p, self.doc.values())