本文整理汇总了Python中pychron.experiment.utilities.identifier.make_runid函数的典型用法代码示例。如果您正苦于以下问题:Python make_runid函数的具体用法?Python make_runid怎么用?Python make_runid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_runid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _do_syn_extract
def _do_syn_extract(self, spec, script, post_script):
self.debug('Executing SynExtraction mode="{}"'.format(spec.mode))
#modify the persister. the original persister for the automated run is saved at self.persister
#arun.persister reset to original when syn extraction stops
identifier=spec.identifier
last_aq=self.arun.persister.get_last_aliquot(identifier)
if last_aq is None:
self.warning('invalid identifier "{}". Does not exist in database'.format(identifier))
else:
runid=make_runid(identifier, last_aq+1)
self.arun.info('Starting SynExtraction run {}'.format(runid))
self.arun.persister.trait_set(use_secondary_database=False,
runid=runid,
uuid=str(uuid.uuid4()))
if self.arun.do_measurement(script=script, use_post_on_fail=False):
if post_script:
self.debug('starting post measurement')
if not self.arun.do_post_measurement(script=post_script):
return
self.debug('delay between syn extractions {}'.format(spec.delay_between))
self.arun.wait(spec.delay_between)
return True
示例2: _sync_meas_analysis_attributes
def _sync_meas_analysis_attributes(self, meas_analysis):
# copy meas_analysis attrs
nocast = lambda x: x
attrs = [
('labnumber', 'labnumber', lambda x: x.identifier),
('aliquot', 'aliquot', int),
('step', 'step', str),
# ('status', 'status', int),
('comment', 'comment', str),
('uuid', 'uuid', str),
('rundate', 'analysis_timestamp', nocast),
('timestamp', 'analysis_timestamp',
lambda x: time.mktime(x.timetuple())
),
]
for key, attr, cast in attrs:
v = getattr(meas_analysis, attr)
setattr(self, key, cast(v))
self.record_id = make_runid(self.labnumber, self.aliquot, self.step)
tag = meas_analysis.tag
if tag:
tag = meas_analysis.tag_item
self.set_tag(tag)
示例3: _modify_secondary
def _modify_secondary(self, ans, new_ans):
self.info('modifying analyses in secondary db. dry={}'.format(self.dry))
db = self.secondary_db
if not db.connect():
self.debug('Not connected to secondary db')
return
with db.session_ctx(commit=not self.dry):
for ai, ni in zip(ans, new_ans):
rid = ai.record_id
dban = db.get_analysis_rid(rid)
if dban:
ident = ni.identifier
dbirradpos = db.get_irradiation_position(ident)
if dbirradpos:
dban.RID = make_runid(ident, ni.aliquot, ni.step)
self.debug('setting {} to {}'.format(ident, dban.RID))
dban.Aliquot = '{:02d}'.format(int(ni.aliquot))
dban.Increment = ni.step
dban.Aliquot_pychron = ni.aliquot
dban.IrradPosition = ident
dban.RedundantSampleID = dbirradpos.SampleID
else:
self.unique_warning('Labnumber {} does not exist in Secondary DB'.format(ident))
else:
self.warning('Analysis {} does not exist in Secondary DB'.format(rid))
示例4: __init__
def __init__(self, dbrecord):
self.uuid = dbrecord.uuid
ln = dbrecord.labnumber
labnumber = str(ln.identifier)
aliquot = dbrecord.aliquot
step = dbrecord.step
self.record_id = make_runid(labnumber, aliquot, step)
self.rundate = dbrecord.analysis_timestamp
self.timestamp = time.mktime(self.rundate.timetuple())
self.tag = dbrecord.tag or ''
self.is_plateau_step = False
meas = dbrecord.measurement
if meas is not None:
if meas.analysis_type:
self.analysis_type = meas.analysis_type.name
if meas.mass_spectrometer:
self.mass_spectrometer = meas.mass_spectrometer.name
sam = ln.sample
if sam:
self.sample = sam.name
if sam.project:
self.project = sam.project.name.lower()
示例5: _make
def _make(self, ep):
project = "Minna Bluff"
db = self.db
with db.session_ctx():
prj = db.get_project(project)
Ar40, Ar39, Ar38, Ar37, Ar36 = [], [], [], [], []
for dev in (("Eurotherm", "Furnace"), ("CO2")):
for si in prj.samples:
for li in si.labnumbers:
self.debug("blanks for {},{}".format(si.name, li.identifier))
for ai in li.analyses:
if ai.extraction.extraction_device.name in dev:
bs = self._extract_blanks(ai)
if bs is not None:
r = make_runid(li.identifier, ai.aliquot, ai.step)
# self.debug('blanks for {} {}'.format(r,bs))
Ar40.append(bs[0])
Ar39.append(bs[1])
Ar38.append(bs[2])
Ar37.append(bs[3])
Ar36.append(bs[4])
reg = WeightedMeanRegressor()
print "blanks for {}".format(dev)
for iso in (Ar40, Ar39, Ar38, Ar37, Ar36):
ys, es = zip(*iso)
reg.trait_set(ys=ys, yserr=es)
print reg.predict()
示例6: _make_labnumber
def _make_labnumber(self, li, root, options, prog):
#make dir for labnumber
ident = li.identifier
ln_root = os.path.join(root, ident)
r_mkdir(ln_root)
prog.change_message('Making {} for {}'.format(self._tag, ident))
#filter invalid analyses
ans=filter(lambda x: not x.tag=='invalid', li.analyses)
#group by stepheat vs fusion
pred = lambda x: bool(x.step)
ans = sorted(ans, key=pred)
stepheat, fusion = map(list, partition(ans, pred))
apred = lambda x: x.aliquot
stepheat = sorted(stepheat, key=apred)
project='Minna Bluff'
li = li.identifier
if stepheat:
key=lambda x: x.aliquot
stepheat=sorted(stepheat, key=key)
for aliquot, ais in groupby(stepheat, key=key):
name=make_runid(li, aliquot, '')
self._make_editor(ais, 'step_heat', options, prog, False,
(ln_root, name, name, project, (li,)))
if fusion:
self._make_editor(fusion, 'fusion', options, prog, False,
(ln_root, li, li, project, (li,)))
示例7: create
def create(self, dbrecord, fast_load=False):
# print 'asdfsadfsdaf', dbrecord, dbrecord.labnumber, dbrecord.uuid
try:
if dbrecord is None or not dbrecord.labnumber:
return
ln = dbrecord.labnumber
self.labnumber = str(ln.identifier)
self.identifier = self.labnumber
self.aliquot = dbrecord.aliquot
self.step = dbrecord.step
self.record_id = make_runid(self.labnumber, self.aliquot, self.step)
self.uuid = dbrecord.uuid
self.tag = dbrecord.tag or ''
self.rundate = dbrecord.analysis_timestamp
sam = ln.sample
if sam:
self.sample = sam.name
if sam.project:
if isinstance(sam.project, (str, unicode)):
self.project = sam.project.lower()
else:
self.project = sam.project.name.lower()
irp = ln.irradiation_position
if irp is not None:
irl = irp.level
ir = irl.irradiation
self.irradiation_info = '{}{} {}'.format(ir.name, irl.name, irp.position)
try:
self.mass_spectrometer = dbrecord.mass_spectrometer
except AttributeError:
pass
meas = dbrecord.measurement
if meas:
self.mass_spectrometer = meas.mass_spectrometer.name.lower()
try:
self.analysis_type = meas.analysis_type.name
except AttributeError, e:
pass
# print 'IsotopeRecord create meas 1 {}'.format(e)
ext = dbrecord.extraction
if ext:
self.extract_value = ext.extract_value
self.cleanup = ext.cleanup_duration
self.duration = ext.extract_duration
try:
if ext.extraction_device:
self.extract_device = ext.extraction_device.name
except AttributeError, e:
pass
示例8: create
def create(self, dbrecord):
# print 'asdfsadfsdaf', dbrecord, dbrecord.labnumber, dbrecord.uuid
try:
if dbrecord is None or not dbrecord.labnumber:
return
ln = dbrecord.labnumber
self.labnumber = str(ln.identifier)
self.identifier = self.labnumber
self.aliquot = dbrecord.aliquot
self.step = dbrecord.step
self.uuid = dbrecord.uuid
self.tag = dbrecord.tag or ''
self.rundate = dbrecord.analysis_timestamp
self.timestamp = time.mktime(self.rundate.timetuple())
self.record_id = make_runid(self.labnumber, self.aliquot, self.step)
# print self.record_id, self.uuid
if ln.sample:
self.sample = ln.sample.name
if dbrecord.labnumber.sample:
self.sample = dbrecord.labnumber.sample.name
irp = ln.irradiation_position
if irp is not None:
irl = irp.level
ir = irl.irradiation
self.irradiation_info = '{}{} {}'.format(ir.name, irl.name, irp.position)
else:
self.irradiation_info = ''
meas = dbrecord.measurement
if meas is not None:
self.mass_spectrometer = meas.mass_spectrometer.name.lower()
if meas.analysis_type:
self.analysis_type = meas.analysis_type.name
ext = dbrecord.extraction
if ext:
if ext.extraction_device:
self.extract_device = ext.extraction_device.name
self.flux_fit_status = self._get_flux_fit_status(dbrecord)
self.blank_fit_status = self._get_selected_history_item(dbrecord, 'selected_blanks_id')
self.ic_fit_status = self._get_selected_history_item(dbrecord, 'selected_det_intercal_id')
self.iso_fit_status = self._get_selected_history_item(dbrecord, 'selected_fits_id')
return True
except Exception, e:
import traceback
traceback.print_exc()
print e
示例9: make_summary
def make_summary(self):
s = 'Pr'
f = self.fit
if f:
if not f in INTERPOLATE_TYPES:
f = f[:1].upper()
s = '{}{}'.format(self.isotope, f)
if self.preceding_id:
p = self.preceding_analysis
rid = make_runid(p.labnumber.identifier, p.aliquot, p.step)
s = '{} ({})'.format(s, rid)
return s
示例10: _construct_analysis
def _construct_analysis(self, rec, prog, calculate_age=True, unpack=False, load_changes=False):
atype = None
if isinstance(rec, meas_AnalysisTable):
rid = make_runid(rec.labnumber.identifier, rec.aliquot, rec.step)
atype = rec.measurement.analysis_type.name
elif hasattr(rec, 'record_id'):
rid = rec.record_id
else:
rid = id(rec)
graph_id = 0
group_id = 0
if hasattr(rec, 'group_id'):
group_id = rec.group_id
if hasattr(rec, 'graph_id'):
graph_id = rec.graph_id
if atype is None:
atype = rec.analysis_type
if prog:
show_age = calculate_age and atype in ('unknown', 'cocktail')
m = 'calculating age' if show_age else ''
msg = 'loading {}. {}'.format(rid, m)
prog.change_message(msg)
meas_analysis = self.db.get_analysis_uuid(rec.uuid)
klass=DBAnalysis if not self.use_vcs else VCSAnalysis
ai = klass(group_id=group_id,
graph_id=graph_id)
# if not self.use_vcs:
synced=False
if atype in ('unknown', 'cocktail'):
if calculate_age:
ai.sync(meas_analysis, load_changes=load_changes)
ai.calculate_age(force=not self.use_vcs)
synced=True
if not synced:
ai.sync(meas_analysis, unpack=unpack, load_changes=load_changes)
return ai
示例11: add_analysis
def add_analysis(self, spec, commit=True):
db = self.db
# for i in range(3):
with db.session_ctx(use_parent_session=False) as session:
irradpos = spec.irradpos
rid = spec.runid
trid = rid.lower()
identifier = spec.labnumber
if trid.startswith('b'):
runtype = 'Blank'
irradpos = -1
elif trid.startswith('a'):
runtype = 'Air'
irradpos = -2
elif trid.startswith('c'):
runtype = 'Unknown'
identifier = irradpos = self.get_identifier(spec)
else:
runtype = 'Unknown'
rid = make_runid(identifier, spec.aliquot, spec.step)
self._analysis = None
db.reraise = True
try:
ret = self._add_analysis(session, spec, irradpos, rid, runtype)
db.commit()
return ret
except Exception as e:
import traceback
self.debug('Mass Spec save exception. {}'.format(e))
tb = traceback.format_exc()
self.debug(tb)
self.message('Could not save spec. runid={} rid={} to MassSpec DB.\n{}'.format(spec.runid, rid, tb))
# if i == 2:
# self.message('Could not save spec.runid={} rid={} '
# 'to Mass Spec database.\n {}'.format(spec.runid, rid, tb))
# else:
# self.debug('retry mass spec save')
# # if commit:
# db.rollback()
finally:
self.db.reraise = True
示例12: _set_device_sensitivity
def _set_device_sensitivity(self, s, e, mi, ed, pr, v, err,prog):
"""
get all analyses between s, e
where mass_spectrometer=mi, extract_device=ed, and project=pr
set sensitivity to v +/-1s e
"""
db=self.db
with db.session_ctx():
ans = db.get_analyses_date_range(s, e,
mass_spectrometer=mi,
extract_device=ed,
project=pr)
ans=filter(lambda x: not x.uuid in self._uuids, ans)
self._uuids.extend([ai.uuid for ai in ans])
self.debug('setting {} analyses'.format(len(ans)))
prog.increase_max(len(ans))
for ai in ans:
r = make_runid(ai.labnumber.identifier,
ai.aliquot, ai.step)
prog.change_message('Saving sensitivity for {}'.format(r))
db.set_analysis_sensitivity(ai, v, err)
示例13: _sync
def _sync(self, path, *args, **kw):
self.path = path
yd = self._load_yaml(path)
attrs = ANALYSIS_ATTRS + ()
for attr in attrs:
if isinstance(attr, tuple):
attr, ydattr = attr
else:
attr, ydattr = attr, attr
setattr(self, attr, yd[ydattr])
self.analysis_type = 'unknown'
self.rundate = datetime.fromtimestamp(self.timestamp)
self.set_j(yd['j'], yd['j_err'])
self.record_id = make_runid(self.labnumber, self.aliquot, self.step)
self.interference_corrections = yd['interference_corrections']
self.production_ratios = yd['production_ratios']
self._sync_isotopes(yd)
示例14: add_analysis
def add_analysis(self, spec, commit=True):
with self.db.session_ctx(commit=False) as sess:
irradpos = spec.irradpos
rid = spec.runid
trid = rid.lower()
identifier = spec.labnumber
if trid.startswith("b"):
runtype = "Blank"
irradpos = -1
elif trid.startswith("a"):
runtype = "Air"
irradpos = -2
elif trid.startswith("c"):
runtype = "Unknown"
identifier = irradpos = self.get_identifier(spec)
else:
runtype = "Unknown"
# paliquot = self.db.get_latest_analysis_aliquot(identifier)
# if paliquot is None:
# paliquot=0
#
# rid = '{}-{:02n}'.format(identifier, spec.aliquot, spec.step)
# self.info('Saving analysis {} to database as {}'.format(spec.rid, rid))
rid = make_runid(identifier, spec.aliquot, spec.step)
self._analysis = None
try:
return self._add_analysis(sess, spec, irradpos, rid, runtype)
except Exception, e:
import traceback
tb = traceback.format_exc()
self.message(
"Could not save spec.runid={} rid={} to Mass Spec database.\n {}".format(spec.runid, rid, tb)
)
if commit:
sess.rollback()
示例15: get_isotope_data
def get_isotope_data(self, idx, k):
v = self.get_isotope(idx, k)
i = self.get_identifier(idx)
a = self.get_aliquot(idx)
s = self.get_step(idx)
rid = make_runid(i, a, s)
if isinstance(v, float):
return [], []
else:
parser = self.parser
sh = parser.sheet
def g():
parser.set_sheet(v, header_idx=0)
cx, cy = parser.get_index('{}_xs'.format(k)), parser.get_index('{}_ys'.format(k))
for row in parser.iterblock(0, rid):
yield row[cx].value, row[cy].value
data = list(g())
self.parser.set_sheet(sh)
return map(list, zip(*data))