Beispiel #1
0
    def start_from(self, val):
        if val is None:
            self._start_from = val
            return
            
        if '$' in val:
            from pyRSD.rsdfit.parameters.tools import replace_vars
            val = replace_vars(val, {})
        
        import os
        if not os.path.exists(val):
            raise RuntimeError("cannot set `start_from` to `%s`: no such file" %val)
        
        if os.path.isdir(val):
            from glob import glob
            from pyRSD.rsdfit.results import EmceeResults, LBFGSResults
            import operator
            
            pattern = os.path.join(val, "*.npz")
            result_files = glob(pattern)
            if not len(result_files):
                raise RuntimeError("did not find any chain (`.npz`) files matching pattern `%s`" %pattern)
            
            # find the chain file which has the maximum log prob in it and use that
            max_lnprobs = []
            for f in result_files:
                
                try:
                    r = EmceeResults.from_npz(f)
                    max_lnprobs.append(r.max_lnprob)
                except:
                    r = LBFGSResults.from_npz(f)
                    max_lnprobs.append(-r.min_chi2)

            index, value = max(enumerate(max_lnprobs), key=operator.itemgetter(1))
            self._start_from = result_files[index]
        else:
            self._start_from = val
Beispiel #2
0
 def output(self, val):
     if '$' in val:
         from pyRSD.rsdfit.parameters.tools import replace_vars
         val = replace_vars(val, {})
     self._output = val
Beispiel #3
0
 def model_file(self, val):
     
     if '$' in val:
         from pyRSD.rsdfit.parameters.tools import replace_vars
         val = replace_vars(val, {})    
     self._model_file = val