Load a Survey Simulator model file as an array of ephem EllipticalBody objects.
    @param model_file:
    @return:
777136
def _kbos_from_survey_sym_model_input_file(model_file):
    
    lines = storage.open_vos_or_local(model_file).read().split('\n')
    kbos = []
    for line in lines:
        if len(line) == 0 or line[0] == '#':  # skip initial column descriptors and the final blank line
            continue
        kbo = ephem.EllipticalBody()
        values = line.split()
        kbo.name = values[8]
        kbo.j = values[9]
        kbo.k = values[10]
        kbo._a = float(values[0])
        kbo._e = float(values[1])
        kbo._inc = float(values[2])
        kbo._Om = float(values[3])
        kbo._om = float(values[4])
        kbo._M = float(values[5])
        kbo._H = float(values[6])
        epoch = ephem.date(2453157.50000 - ephem.julian_date(0))
        kbo._epoch_M = epoch
        kbo._epoch = epoch
        kbos.append(kbo)
    return kbos
1163896
def load_riskmodel(self):
        # to be called before read_exposure
        # NB: this is called even if there is no risk model
        
        logging.info('Reading the risk model if present')
        self.riskmodel = readinput.get_risk_model(self.oqparam)
        if not self.riskmodel:
            parent = self.datastore.parent
            if 'risk_model' in parent:
                self.riskmodel = riskinput.CompositeRiskModel.read(parent)
            return
        if self.oqparam.ground_motion_fields and not self.oqparam.imtls:
            raise InvalidFile('No intensity_measure_types specified in %s' %
                              self.oqparam.inputs['job_ini'])
        self.save_params()
177113
def playback_trajectory(env, ep_dir):
    

    # first reload the model from the xml
    xml_path = os.path.join(ep_dir, "model.xml")
    with open(xml_path, "r") as f:
        env.reset_from_xml_string(f.read())

    state_paths = os.path.join(ep_dir, "state_*.npz")

    # read states back, load them one by one, and render
    t = 0
    for state_file in sorted(glob(state_paths)):
        print(state_file)
        dic = np.load(state_file)
        states = dic["states"]
        for state in states:
            env.sim.set_state_from_flattened(state)
            env.sim.forward()
            env.render()
            t += 1
            if t % 100 == 0:
                print(t)
65914
def snapshot(model, filename, pytest_args, exclusive, skip, solver,
             experimental, custom_tests, custom_config):
    
    model_obj, sbml_ver, notifications = api.validate_model(
        model)
    if model_obj is None:
        LOGGER.critical(
            "The model could not be loaded due to the following SBML errors.")
        utils.stdout_notifications(notifications)
        api.validation_report(model, notifications, filename)
        sys.exit(1)
    if not any(a.startswith("--tb") for a in pytest_args):
        pytest_args = ["--tb", "no"] + pytest_args
    # Add further directories to search for tests.
    pytest_args.extend(custom_tests)
    config = ReportConfiguration.load()
    # Update the default test configuration with custom ones (if any).
    for custom in custom_config:
        config.merge(ReportConfiguration.load(custom))
    model_obj.solver = solver
    _, results = api.test_model(model_obj, sbml_version=sbml_ver, results=True,
                                pytest_args=pytest_args, skip=skip,
                                exclusive=exclusive, experimental=experimental)
    with open(filename, "w", encoding="utf-8") as file_handle:
        LOGGER.info("Writing snapshot report to '%s'.", filename)
        file_handle.write(api.snapshot_report(results, config))
1363201
def internal_model_from_file(
            self, file_name, encoding='utf-8', debug=None,
            pre_ref_resolution_callback=None, is_main_model=True):
        
        model = None
        callback = pre_ref_resolution_callback

        if hasattr(self, "_tx_model_repository"):
            # metamodel has a global repo
            if not callback:
                def _pre_ref_resolution_callback(other_model):
                    from textx.scoping import GlobalModelRepository
                    filename = other_model._tx_filename
                    assert filename
                    # print("METAMODEL PRE-CALLBACK{}".format(filename))
                    other_model._tx_model_repository = GlobalModelRepository(
                        self._tx_model_repository.all_models)
                    self._tx_model_repository.all_models\
                        .filename_to_model[filename] = other_model

                callback = _pre_ref_resolution_callback
            if self._tx_model_repository.all_models.has_model(file_name):
                model = self._tx_model_repository.all_models\
                    .filename_to_model[file_name]

        if not model:
            # model not present (from global repo) -> load it
            model = self._parser_blueprint.clone().get_model_from_file(
                file_name, encoding, debug=debug,
                pre_ref_resolution_callback=callback,
                is_main_model=is_main_model)

        for p in self._model_processors:
            p(model, self)
        return model
710327
def cached_model_file(model_name='anon_model', file=None, model_code=None, cache_dir=None,
                      fit_cachefile=None, include_prefix=False):
    ''' 
    '''
    cache_dir = _get_cache_dir(cache_dir)
    model_name = _sanitize_model_name(model_name)
    ## compute model prefix
    if file:
        model_code = _read_file(file)
    if model_code:
        model_prefix = '.'.join([model_name, _make_digest(dict(model_code=model_code,
                                                               pystan=pystan.__version__,
                                                               cython=Cython.__version__))])
    else: ## handle case where no model code given
        if file is not None:
            logger.info('Note - no model code detected from given file: {}'.format(file))
        else:
            logger.info('Note - no model code detected (neither file nor model_code given)')
    ## parse model_prefix from fit_cachefile if given
    if fit_cachefile:
        # if necessary, impute cache_dir from filepath
        if fit_cachefile != os.path.basename(fit_cachefile):
            cache_dir, fit_cachefile = os.path.split(os.path.abspath(fit_cachefile))
        # if fit_cachefile given, parse to get fit_model_prefix
        fit_model_prefix = re.sub(string=os.path.basename(fit_cachefile), pattern='(.*).stanfit.*', repl='\\1')
        if model_code:
            if fit_model_prefix != model_prefix:
                logger.warning('Computed model prefix does not match that used to estimate model. Using prefix matching fit_cachefile')
        model_prefix = fit_model_prefix
    # compute path to model cachefile
    model_cachefile = '.'.join([model_prefix, 'stanmodel', 'pkl'])
    if include_prefix:
        return model_prefix, model_cachefile
    return model_cachefile
243579
def _xml_for_episode_index(self, ep_ind):
        

        # read the model xml, using the metadata stored in the attribute for this episode
        model_file = self.demo_file["data/{}".format(ep_ind)].attrs["model_file"]
        model_path = os.path.join(self.demo_path, "models", model_file)
        with open(model_path, "r") as model_f:
            model_xml = model_f.read()
        return model_xml
320758
def load(self, mdl_file):
        
        import dill as pickle

        mdl_file_e = op.expanduser(mdl_file)

        sv = pickle.load(open(mdl_file_e, "rb"))
        self.mdl = sv["mdl"]
        # self.mdl[2] = self.mdl[0]
        # try:
        #     eval(sv['fv_extern_src'])
        #     eval("fv_extern_temp_name  = " + sv['fv_extern_src_name'])
        #     sv['fv_extern'] = fv_extern_temp_name
        # except:
        #     print "pomoc,necoje blbe"
        #     pass

        self.modelparams.update(sv["modelparams"])
        logger.debug("loaded model from path: " + mdl_file_e)
690791
def postprocess_model_xml(xml_str):
    

    path = os.path.split(robosuite.__file__)[0]
    path_split = path.split("/")

    # replace mesh and texture file paths
    tree = ET.fromstring(xml_str)
    root = tree
    asset = root.find("asset")
    meshes = asset.findall("mesh")
    textures = asset.findall("texture")
    all_elements = meshes + textures

    for elem in all_elements:
        old_path = elem.get("file")
        if old_path is None:
            continue
        old_path_split = old_path.split("/")
        ind = max(
            loc for loc, val in enumerate(old_path_split) if val == "robosuite"
        )  # last occurrence index
        new_path_split = path_split + old_path_split[ind + 1 :]
        new_path = "/".join(new_path_split)
        elem.set("file", new_path)

    return ET.tostring(root, encoding="utf8").decode("utf8")
337993
def load_morfessor_model(lang="en", version="2"):
  
  src_dir = "morph{}".format(version)
  p = locate_resource(src_dir, lang)
  file_handler = _open(p)
  tmp_file_ = NamedTemporaryFile(delete=False)
  tmp_file_.write(file_handler.read())
  tmp_file_.close()
  io = morfessor.MorfessorIO()
  model = io.read_any_model(tmp_file_.name)
  os.remove(tmp_file_.name)
  return model
1045776
def _loadable_models():
    
    classes = [
        pyphi.Direction,
        pyphi.Network,
        pyphi.Subsystem,
        pyphi.Transition,
        pyphi.labels.NodeLabels,
        pyphi.models.Cut,
        pyphi.models.KCut,
        pyphi.models.NullCut,
        pyphi.models.Part,
        pyphi.models.Bipartition,
        pyphi.models.KPartition,
        pyphi.models.Tripartition,
        pyphi.models.RepertoireIrreducibilityAnalysis,
        pyphi.models.MaximallyIrreducibleCauseOrEffect,
        pyphi.models.MaximallyIrreducibleCause,
        pyphi.models.MaximallyIrreducibleEffect,
        pyphi.models.Concept,
        pyphi.models.CauseEffectStructure,
        pyphi.models.SystemIrreducibilityAnalysis,
        pyphi.models.ActualCut,
        pyphi.models.AcRepertoireIrreducibilityAnalysis,
        pyphi.models.CausalLink,
        pyphi.models.Account,
        pyphi.models.AcSystemIrreducibilityAnalysis
    ]
    return {cls.__name__: cls for cls in classes}
1309771
def load_b26_file(file_name):
    
    # file_name = "Z:\Lab\Cantilever\Measurements\\tmp_\\a"

    assert os.path.exists(file_name)

    with open(file_name, 'r') as infile:
        data = yaml.safe_load(infile)
    return data
849796
def load_model_data(self, path, model):
        
        if os.path.isdir(path):
            # try find a model data collection
            if os.path.isfile(os.path.join(path, '_all.yml')):
                self.load_model_data_collection(path, model)
            self.load_model_data_from_files(path, model)
            self.session.commit()
839139
def load_model(self, fname):
        
        if isinstance(fname, STRING_TYPES):  # assume file name
            if os.path.exists(fname):
                _LIB.XGBoosterLoadModel(self.handle, c_str(fname))
            else:
                raise ValueError("No such file: {0}".format(fname))
        else:
            buf = fname
            length = ctypes.c_ulong(len(buf))
            ptr = (ctypes.c_char * len(buf)).from_buffer(buf)
            _check_call(_LIB.XGBoosterLoadModelFromBuffer(self.handle, ptr, length))
1311405
def load_data(self):
        
        for m, member in enumerate(self.members):
            mo = ModelOutput(self.ensemble_name, member, self.run_date, self.variable,
                             self.start_date, self.end_date, self.path, self.map_file, self.single_step)
            mo.load_data()
            if self.data is None:
                self.data = np.zeros((len(self.members), mo.data.shape[0], mo.data.shape[1], mo.data.shape[2]),
                                     dtype=np.float32)
            if mo.units == "m":
                self.data[m] = mo.data * 1000
                self.units = "mm"
            else:
                self.data[m] = mo.data
            if self.units == "":
                self.units = mo.units
            del mo.data
            del mo
381496
@Override
    public void loadModel(InputStream modelIs) {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            IOUtils.copy(modelIs, baos);
        } catch (IOException e) {
            LOG.error("Load model err.", e);
        }

        InputStream isForSVMLoad = new ByteArrayInputStream(baos.toByteArray());
        try (ZipInputStream zipInputStream = new ZipInputStream(isForSVMLoad)) {
            ZipEntry entry;
            while ((entry = zipInputStream.getNextEntry()) != null) {
                if (entry.getName().endsWith(".model")) {
                    BufferedReader br = new BufferedReader(new InputStreamReader(zipInputStream, Charset.defaultCharset()));
                    this.model = svm.svm_load_model(br);
                }
            }

        } catch (IOException e) {
            // Do Nothing.
        }

        modelIs = new ByteArrayInputStream(baos.toByteArray());
        try (ZipInputStream zipInputStream = new ZipInputStream(modelIs)) {
            ZipEntry entry;
            while ((entry = zipInputStream.getNextEntry()) != null) {
                if (entry.getName().endsWith(".lbindexer")) {
                    String lbIndexer = IOUtils.toString(zipInputStream, Charset.defaultCharset());
                    this.labelIndexer = new LabelIndexer(new ArrayList<>());
                    this.labelIndexer.readFromSerializedString(lbIndexer);
                }
            }

        } catch (IOException e) {
            LOG.error("Err in load LabelIndexer", e);
        }

    }
1211341
public static <T extends DajlabModelInterface> DajlabModel loadModel(final File file) {

		Gson fxGson = FxGson.fullBuilder().create();
		DajlabModel model = new DajlabModel();
		try {
			JsonParser jsonParser = new JsonParser();
			JsonReader jsonReader = new JsonReader(new FileReader(file));
			jsonReader.beginObject();
			if (jsonReader.hasNext()) {
				jsonReader.nextName();
				JsonObject ob = jsonParser.parse(jsonReader).getAsJsonObject();
				Set<Entry<String, JsonElement>> set = ob.entrySet();
				for (Entry<String, JsonElement> entry : set) {
					String className = entry.getKey();
					JsonElement el = entry.getValue();
					try {
						T obj = (T) fxGson.fromJson(el, Class.forName(className));
						model.put(obj);
					} catch (ClassNotFoundException e) {
						logger.warn("Unable to load model for [{}]", className);
					}
				}
			}
		} catch (Exception e) {
			logger.debug(e.getMessage());
			logger.error("Unable to load model from file [{}]", file.getName());
			ExceptionFactory.throwDaJLabRuntimeException(DaJLabConstants.ERR_LOAD_MODEL);
		}

		return model;
	}