def calc_model(self): lines = lines_from_f26(self.opt.f26) wa = self.spec[self.i].wa dw = np.median(np.diff(wa)) print 'finding tau' if self.opt.wadiv is not None: dw1 = dw / self.opt.wadiv wa1 = np.arange(wa[0], wa[-1] + 0.5 * dw1, dw1) tau, ticks = find_tau(wa1, lines, self.opt.atom, logNthresh_LL=self.opt.logNthresh_LL) else: tau, ticks = find_tau(wa, lines, self.opt.atom, logNthresh_LL=self.opt.logNthresh_LL) model = np.exp(-tau) # if we want to calculate the optical depth per line, # do it here. if self.opt.wadiv is not None: model, _ = process_Rfwhm(self.opt.Rfwhm, wa1, model, []) else: model, _ = process_Rfwhm(self.opt.Rfwhm, wa, model, []) if self.opt.wadiv is not None: model = np.interp(wa, wa1, model) self.models[self.i] = model self.ticks = ticks self.model = model
def calc_model(self): lines = lines_from_f26(self.opt.f26) lines = [l for l in lines if l[0] not in ('__', '<>')] wa = self.spec[self.i].wa dw = np.median(np.diff(wa)) print('finding tau') if self.opt.wadiv is not None: dw1 = dw / self.opt.wadiv wa1 = np.arange(wa[0], wa[-1] + 0.5 * dw1, dw1) tau, ticks = find_tau(wa1, lines, self.opt.atom, logNthresh_LL=self.opt.logNthresh_LL) else: tau, ticks = find_tau(wa, lines, self.opt.atom, logNthresh_LL=self.opt.logNthresh_LL) model = np.exp(-tau) # if we want to calculate the optical depth per line, # do it here. if self.opt.wadiv is not None: model, _ = process_Rfwhm(self.opt.Rfwhm, wa1, model, []) else: model, _ = process_Rfwhm(self.opt.Rfwhm, wa, model, []) if self.opt.wadiv is not None: model = np.interp(wa, wa1, model) #self.apply_zero_offsets() self.models[self.i] = model self.ticks = ticks self.model = model
def update_model(self): lines = lines_from_f26(self.opt.f26) wa = self.wa if self.opt.wadiv is not None: wa = self.wa1 # first remove models that no longer present in lines for l in set(self.taus).difference(lines): del self.taus[l] del self.models[l] del self.ticks[l] for tr_id in self.artists['models']: self.artists['models'][tr_id][l].remove() del self.artists['models'][tr_id][l] dtype = np.dtype([('name', 'S10'), ('wa', 'f8'), ('z', 'f8'), ('wa0', 'f8'), ('ind', 'i4')]) # now add the new models from lines new_lines = set(lines).difference(self.taus) print len(new_lines), 'new lines' for l in new_lines: #print 'z, logN, b', z, logN, b ion, z, b, logN = l if ion in ('__', '<>', '<<', '>>'): continue maxdv = 20000 if logN > 18 else 500 t, tick = calc_iontau(wa, self.opt.atom[ion], z + 1, logN, b, ticks=True, maxdv=maxdv, logNthresh_LL=self.opt.logNthresh_LL) self.taus[l] = t self.models[l] = np.exp(-t) temp = np.empty(0, dtype=dtype) if tick: ions = [ion] * len(tick) temp = np.rec.fromarrays([ions] + zip(*tick), dtype=dtype) self.ticks[l] = temp self.allticks = [] if len(self.ticks) > 0: self.allticks = np.concatenate([self.ticks[l] for l in self.ticks ]).view(np.recarray) self.allticks.sort(order='wa') tau = np.zeros_like(wa) for line in self.taus: tau += self.taus[line] self.tau = tau self.model = np.exp(-tau)
def update_model(self): lines = lines_from_f26(self.opt.f26) wa = self.wa if self.opt.wadiv is not None: wa = self.wa1 # first remove models that no longer present in lines for l in set(self.taus).difference(lines): del self.taus[l] del self.models[l] del self.ticks[l] for tr_id in self.artists['models']: self.artists['models'][tr_id][l].remove() del self.artists['models'][tr_id][l] dtype = np.dtype([('name', 'S10'), ('wa', 'f8'), ('z', 'f8'), ('wa0', 'f8'), ('ind', 'i4')]) # now add the new models from lines new_lines = set(lines).difference(self.taus) print len(new_lines), 'new lines' for l in new_lines: #print 'z, logN, b', z, logN, b ion, z, b, logN = l if ion in ('__', '<>', '<<', '>>'): continue maxdv = 20000 if logN > 18 else 500 t, tick = calc_iontau(wa, self.opt.atom[ion], z + 1, logN, b, ticks=True, maxdv=maxdv, logNthresh_LL=self.opt.logNthresh_LL) self.taus[l] = t self.models[l] = np.exp(-t) temp = np.empty(0, dtype=dtype) if tick: ions = [ion] * len(tick) temp = np.rec.fromarrays([ions] + zip(*tick), dtype=dtype) self.ticks[l] = temp self.allticks = [] if len(self.ticks) > 0: self.allticks = np.concatenate( [self.ticks[l] for l in self.ticks]).view(np.recarray) self.allticks.sort(order='wa') tau = np.zeros_like(wa) for line in self.taus: tau += self.taus[line] self.tau = tau self.model = np.exp(-tau)