def _make_analyses(self, records, gid, ggid): return [FileAnalysis(age=nominal_value(ai.age), age_err=std_dev(ai.age), record_id=ai.info_str, group_id=gid, graph_id=ggid) for ai in records]
def gen(): for d in parser.itervalues(): if d['age'] is not None: f = FileAnalysis(age=float(d['age']), age_err=float(d['age_err']), record_id=d['runid'], sample=d.get('sample', ''), aliquot=int(d.get('aliquot', 0)), group_id=int(d.get('group', 0))) yield f
def _refresh_sys_mon_series(self): if globalv.system_monitor_debug: ans = [ FileAnalysis(age=2 * random.random() + 10, aliquot=i, peak_center=ufloat(random.random(), 0.1), timestamp=time.time(), labnumber='{:04d}'.format(3000), age_err=random.random()) for i in range(min(self.search_tool.limit, 50)) ] else: ms = self.conn_spec.system_name ans = self.processor.analysis_series(ms, weeks=self.search_tool.weeks, days=self.search_tool.days, hours=self.search_tool.hours, limit=self.search_tool.limit) ans = self._sort_analyses(ans) self.analyses = ans
def _get_items_from_file(self, parser): from pychron.processing.analyses.file_analysis import FileAnalysis try: ans = [(d.get('group', 0), FileAnalysis(age=float(d['age']), age_err=float(d['age_err']), record_id=d['runid'], sample=d.get('sample', ''), aliquot=int(d.get('aliquot', 0)))) for d in parser.values()] items = [] for i, (gid, aa) in enumerate(groupby_idx(ans, 0)): for _, ai in aa: ai.group_id = i items.append(ai) return items except (TypeError, ValueError) as e: warning(None, 'Invalid values in the import file. Error="{}"'.format(e))
def _get_analyses(self, tool, identifier, aliquot=None, use_date_range=False): if globalv.system_monitor_debug: import numpy as np self._cnt += 1 if self._cnt > 40: return [ FileAnalysis(age=2 * random.random() + 10, aliquot=1, step=ALPHAS[i], k39=2 + random.random() * 10, k39_err=0, timestamp=time.time(), labnumber='{:04d}'.format(2000), age_err=random.random()) for i in range(self._cnt - 4) ] else: np.random.seed(1234567) ages = np.random.random((self._cnt, 2)) return [ FileAnalysis(age=a + 10, aliquot=i, timestamp=time.time(), labnumber='{:04d}'.format( 1000 if self._flag else 2000), age_err=e) for i, (a, e) in enumerate(ages) ] else: db = self.processor.db with db.session_ctx(): if aliquot is not None: def func(a, l): return l.identifier == identifier, a.aliquot == aliquot ans = db.get_analyses(func=func) elif use_date_range: high = datetime.now() low = tool.low if low is None: low = high - timedelta( hours=tool.hours, weeks=tool.weeks, days=tool.days) tool.low = low ans = db.get_analyses_date_range(low, high, labnumber=identifier, order='desc', limit=tool.limit) else: ans, tc = db.get_labnumber_analyses(identifier, order='desc', limit=tool.limit) return self.processor.make_analyses(ans)