def get_result(self, result, mtype=None, mean=False, base=False, return_mean=True, **calculation_parameter): """ A function that returns a list of all the result calculated from all measurements, that actually have the result Parameters ---------- result: str: the result to be calculated mtype: str or list of str if provided, only results from that mtype are calculated calculation_parameter: dict the calculation parameters to be used mean: bool if true the results are calculated for the mean measuremnets base: bool if true the results are calculated for the base measurements (needs to be a mean measurement) return_mean: bool if true a numpy mean is calculated and returned Returns ------- list of results Note ---- each of the results is a tuple of the actual value and the error if calculated """ # get all measurements that have the result # if mean use only mean measurements if mean: mlist = filter(lambda x: x.has_result(result=result), self.mean_measurements) if base: mlist = [m for mean in mlist for m in mean.base_measurements if m.has_result(result=result)] # if not use all non mean measurements else: mlist = filter(lambda x: x.has_result(result=result), self.measurements) if mtype: mtypes = RockPy3.to_list(mtype) mlist = filter(lambda x: x.mtype in mtypes, mlist) res = [getattr(m, 'result_' + result)(**calculation_parameter) for m in mlist] self.log.debug('Calculating result << {} >> for {} measurements'.format(result, len(res))) if return_mean: res = [(np.mean(res, axis=0)[0], np.std(res, axis=0)[0])] return res
def get_result(self, result, mtype=None, mean=False, base=False, return_mean=True, **calculation_parameter): """ A function that returns a list of all the result calculated from all measurements, that actually have the result Parameters ---------- result: str: the result to be calculated mtype: str or list of str if provided, only results from that mtype are calculated calculation_parameter: dict the calculation parameters to be used mean: bool if true the results are calculated for the mean measuremnets base: bool if true the results are calculated for the base measurements (needs to be a mean measurement) return_mean: bool if true a numpy mean is calculated and returned Returns ------- list of results Note ---- each of the results is a tuple of the actual value and the error if calculated """ # get all measurements that have the result # if mean use only mean measurements if mean: mlist = filter(lambda x: x.has_result(result=result), self.mean_measurements) if base: mlist = [ m for mean in mlist for m in mean.base_measurements if m.has_result(result=result) ] # if not use all non mean measurements else: mlist = filter(lambda x: x.has_result(result=result), self.measurements) if mtype: mtypes = RockPy3.to_list(mtype) mlist = filter(lambda x: x.mtype in mtypes, mlist) res = [ getattr(m, 'result_' + result)(**calculation_parameter) for m in mlist ] self.log.debug( 'Calculating result << {} >> for {} measurements'.format( result, len(res))) if return_mean: res = [(np.mean(res, axis=0)[0], np.std(res, axis=0)[0])] return res