def fill_data(self, trans, linelist=None, closest=False, verbose=True): """ Fill atomic data and setup analy. Parameters ---------- trans : Quantity or str Either a rest wavelength (e.g. 1215.6700*u.AA) or the name of a transition (e.g. 'CIV 1548'). For an unknown transition use string 'unknown'. linelist : LineList, optional Class of linelist or str setting LineList closest : bool, optional Take the closest line to input wavelength? [False] """ # Deal with LineList if linelist is None: if self.ltype == 'Abs': llist = LineList('ISM') elif self.ltype == 'Em': llist = LineList('Galaxy') else: raise ValueError("Not ready for ltype = {:s}".format( self.ltype)) elif isinstance(linelist, basestring): llist = LineList(linelist) elif isinstance(linelist, LineList): llist = linelist else: raise ValueError('Bad input for linelist') # Closest? llist.closest = closest # Data newline = llist[trans] if newline is None: raise ValueError("Transition {} not found in LineList {:s}".format( trans, llist.list)) try: self.data.update(newline) # Expected to be a LineList dict object except TypeError: raise TypeError("Probably should not be here") # Update if isinstance(self.data, dict): self.wrest = self.data['wrest'] else: self.wrest = self.data['wrest'] * self.data['wrest'].unit self.name = self.data['name'] # self.update() # is this used ?
def fill_data(self, trans, linelist=None, closest=False, verbose=True): """ Fill atomic data and setup analy. Parameters ---------- trans : Quantity or str Either a rest wavelength (e.g. 1215.6700*u.AA) or the name of a transition (e.g. 'CIV 1548'). For an unknown transition use string 'unknown'. linelist : LineList, optional Class of linelist or str setting LineList closest : bool, optional Take the closest line to input wavelength? [False] """ # Deal with LineList if linelist is None: llist = LineList('ISM') elif isinstance(linelist,basestring): llist = LineList(linelist) elif isinstance(linelist,LineList): llist = linelist else: raise ValueError('Bad input for linelist') # Closest? llist.closest = closest # Data newline = llist[trans] try: self.data.update(newline) # Expected to be a LineList dict object except TypeError: pdb.set_trace() # Update self.wrest = self.data['wrest'] self.name = self.data['name'] # self.analy.update( { 'flg_eye': 0, 'flg_limit': 0, # No limit 'datafile': '', 'name': self.data['name'] }) # Additional fundamental attributes for Absorption Line self.attrib.update(abs_attrib.copy())
def fill_data(self, trans, linelist=None, closest=False, verbose=True): """ Fill atomic data and setup analy. Parameters ---------- trans : Quantity or str Either a rest wavelength (e.g. 1215.6700*u.AA) or the name of a transition (e.g. 'CIV 1548'). For an unknown transition use string 'unknown'. linelist : LineList, optional Class of linelist or str setting LineList closest : bool, optional Take the closest line to input wavelength? [False] """ # Deal with LineList if linelist is None: if self.ltype == 'Abs': llist = LineList('ISM') elif self.ltype == 'Em': llist = LineList('Galaxy') else: raise ValueError("Not ready for ltype = {:s}".format(self.ltype)) elif isinstance(linelist,basestring): llist = LineList(linelist) elif isinstance(linelist,LineList): llist = linelist else: raise ValueError('Bad input for linelist') # Closest? llist.closest = closest # Data newline = llist[trans] if newline is None: raise ValueError("Transition {} not found in LineList {:s}".format(trans, llist.list)) try: self.data.update(newline) # Expected to be a LineList dict object except TypeError: raise TypeError("Probably should not be here") # Update self.wrest = self.data['wrest'] self.name = self.data['name'] # self.update() # is this used ?
def fill_data(self, trans, linelist=None, closest=False): """ Fill atomic data and setup analy. Parameters ---------- trans : Quantity or str Either a rest wavelength (e.g. 1215.6700*u.AA) or the name of a transition (e.g. 'CIV 1548'). For an unknown transition use string 'unknown'. linelist : LineList, optional Class of linelist or str setting LineList closest : bool, optional Take the closest line to input wavelength? [False] """ # Deal with LineList if linelist is None: llist = LineList('ISM') elif isinstance(linelist,basestring): llist = LineList(linelist) elif isinstance(linelist,LineList): llist = linelist else: raise ValueError('Bad input for linelist') # Closest? llist.closest = closest # Data newline = llist[trans] self.data.update(newline) # Update self.wrest = self.data['wrest'] self.trans = self.data['name'] # self.analy.update( { 'flg_eye': 0, 'flg_limit': 0, # No limit 'datafile': '', 'name': self.data['name'] }) # Additional attributes for Absorption Line self.attrib.update({'N': 0., 'Nsig': 0., 'flagN': 0, # Column 'b': 0.*u.km/u.s, 'bsig': 0.*u.km/u.s # Doppler } )
def fill_data(self, trans, linelist=None, closest=False, verbose=True, use_CACHE=False, **kwargs): """ Fill atomic data and setup analy. Parameters ---------- trans : Quantity or str Either a rest wavelength (e.g. 1215.6700*u.AA) or the name of a transition (e.g. 'CIV 1548'). For an unknown transition use string 'unknown'. linelist : str or LineList or list of LineList objects, optional Class of linelist or str setting LineList or list of LineList objects closest : bool, optional Take the closest line to input wavelength? [False] """ global CACHE_LLIST # Only cached if LineList is *not* input # Deal with LineList flg_list = False if linelist is None: if use_CACHE and (CACHE_LLIST is not None): llist = CACHE_LLIST else: if self.ltype == 'Abs': llist = LineList('ISM') elif self.ltype == 'Em': llist = LineList('Galaxy') else: raise ValueError("Not ready for ltype = {:s}".format(self.ltype)) elif isinstance(linelist,basestring): llist = LineList(linelist) elif isinstance(linelist,LineList): llist = linelist elif isinstance(linelist,list): llist = linelist[0] flg_list = True else: raise ValueError('Bad input for linelist') # Cache CACHE_LLIST = llist # Closest? llist.closest = closest # Data if flg_list: # Allow for a list of LineList for llist in linelist: llist.closest = closest newline = llist[trans] if newline is not None: break else: newline = llist[trans] # Success? if newline is None: print("Transition {} not found in LineList {:s}".format(trans, llist.list)) raise ValueError("You may need to set clear_CACHE_LLIST=True") try: self.data.update(newline) # Expected to be a LineList dict object except TypeError: raise TypeError("Probably should not be here") # Update if isinstance(self.data, dict): self.wrest = self.data['wrest'] else: self.wrest = self.data['wrest']*self.data['wrest'].unit self.name = self.data['name'] # self.update() # is this used ?
def test_closest(): ism = LineList('ISM') ism.closest=True # line = ism[1250.584*u.AA] # dict with units np.testing.assert_allclose(line['wrest'], 1250.578*u.AA, rtol=1e-7)
def test_closest(): ism = LineList('ISM') ism.closest=True # line = ism[1250.584*u.AA] np.testing.assert_allclose(line['wrest'], 1250.578*u.AA, rtol=1e-7)
def fill_data(self, trans, linelist=None, closest=False, verbose=True, use_CACHE=False, **kwargs): """ Fill atomic data and setup analy. Parameters ---------- trans : Quantity or str Either a rest wavelength (e.g. 1215.6700*u.AA) or the name of a transition (e.g. 'CIV 1548'). For an unknown transition use string 'unknown'. linelist : str or LineList or list of LineList objects, optional Class of linelist or str setting LineList or list of LineList objects closest : bool, optional Take the closest line to input wavelength? [False] """ global CACHE_LLIST # Only cached if LineList is *not* input # Deal with LineList flg_list = False if linelist is None: if use_CACHE and (CACHE_LLIST is not None): llist = CACHE_LLIST else: if self.ltype == 'Abs': llist = LineList('ISM') elif self.ltype == 'Em': llist = LineList('Galaxy') else: raise ValueError("Not ready for ltype = {:s}".format( self.ltype)) elif isinstance(linelist, basestring): llist = LineList(linelist) elif isinstance(linelist, LineList): llist = linelist elif isinstance(linelist, list): llist = linelist[0] flg_list = True else: raise ValueError('Bad input for linelist') # Cache CACHE_LLIST = llist # Closest? llist.closest = closest # Data if flg_list: # Allow for a list of LineList for llist in linelist: llist.closest = closest newline = llist[trans] if newline is not None: break else: newline = llist[trans] # Success? if newline is None: print("Transition {} not found in LineList {:s}".format( trans, llist.list)) raise ValueError("You may need to set clear_CACHE_LLIST=True") try: self.data.update(newline) # Expected to be a LineList dict object except TypeError: raise TypeError("Probably should not be here") # Update if isinstance(self.data, dict): self.wrest = self.data['wrest'] else: self.wrest = self.data['wrest'] * self.data['wrest'].unit self.name = self.data['name'] # self.update() # is this used ?