Perturb mineral

I wrote a little perturb mineral thing and modified step_3 from the tutorial to example_uncertainties.py to use it. What do you guys think? And what do you think about removing 'err_' from all the uncertainty dictionaries?
Might be fine, but maybe somebody will want to perturb a mineral where
there are nominal zero error bars?


On Sun, Jul 27, 2014 at 10:24 AM, Sanne Cottaar <notifications@github.com>
wrote:

> In burnman/mineral.py:
>
> > @@ -123,6 +123,18 @@ def set_state(self, pressure, temperature):
> >              self.G = float('nan') #nan if there is no G, this should propagate through calculations to the end
> >              warnings.warn(('Warning: G_0 and or Gprime_0 are undefined for ' + self.to_string()))
> >
> > +    def perturb(self,loc=0.0, scale=1.0):
> > +        """
> > +        Computes random perturbations to the mineral paramaters given published uncertain
> > +        """
> > +        if not hasattr(self,'original_params'):
> > +            self.original_params=self.
> params.copy()
> > +        for pert  in self.uncertainties:
> > +            try:
> > +                self.params[pert]=self.original_params[pert]+np.random.normal(loc=loc,scale=scale)*self.uncertainties[pert]
> > +            except:
> > +                print 'Tried to perturb ', pert, ', but failed. Possibly the uncertainty is not following the convention of \'err_?\' or the error bar is zero.'
>
> I assume the cases with a zero error bar are also caught in the
> 'try/except'. Or would you like it more explicit, Ian? I know notice the
> except statement still mentions the 'err_' flag.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/burnman-project/burnman/pull/29/files#r15440371>.
>