Exemplo n.º 1
0
    def readline(self, descr):
        words = descr.split()
        self.descr = descr

        self.name = words[0]
        i = 1

        if self.name in ['H2', 'HD', 'CO']:

            if len(words) == 4:
                self.J = -1
                self.nu = -1
            else:
                if len(words) == 6:
                    self.nu = int(words[i])
                    i += 1
                elif len(words) == 5:
                    self.nu = 0
                self.J = int(words[i])
                self.stat = (2 * self.J + 1) * (2 * (self.J % 2) + 1)
                i += 1

        if self.name in ['OI', 'CI', 'SiII']:
            if len(words) == 5:
                self.J = int(words[1])
                i += 1
            else:
                self.J = -1

        self.get_ioniz()
        self.col = a(float(words[i]), float(words[i + 1]), float(words[i + 2]))
Exemplo n.º 2
0
    def readline(self, descr):
        """
        Method to read species data from the line
        Used by reading data from file
        """
        words = descr.split()
        self.descr = descr

        self.name = words[0]
        i = 1

        if self.name in ['H2', 'HD', 'CO']:

            if len(words) == 4:
                self.J = -1
                self.nu = -1
            else:
                if len(words) == 6:
                    self.nu = int(words[i])
                    i += 1
                elif len(words) == 5:
                    self.nu = 0
                self.J = int(words[i])
                self.stat = (2*self.J+1)*(2*(self.J%2)+1)
                i += 1

        if self.name in ['OI', 'CI', 'SiII']:
            if len(words) == 5:
                self.J = int(words[1])
                i += 1
            else:
                self.J = -1

        self.get_ioniz()
        self.col = a(float(words[i]), float(words[i+1]), float(words[i+2]))
Exemplo n.º 3
0
def depletion(element, logN, logNref, ref='Zn', mode=None):
    """
    Return the value of the depletion of element using Asplund 2009 data
    parameters:
            - element     : name of the element
            - logN        : column density of element
            - logNH       : column density of reference element for the depletion
            - ref         : name of the reference element, Zn is default
            - mode        : if mode == 'Solar' include solar uncertainties in result
    """
    element = e(element).get_element_name()
    element_ref = e(ref).get_element_name()
    if isinstance(logN, a) or isinstance(logNref, a):
        if mode == 'Solar':
            return (logN / logNref * a(Asplund2009(element_ref), 'l') / a(Asplund2009(element), 'l')).log()
        else:
            return (logN / logNref * 10 ** (Asplund2009(element_ref)[0] - Asplund2009(element)[0])).log()
Exemplo n.º 4
0
 def __init__(self, name='', col=0, plus=0, minus=0):
     self.name = name
     self.elem = ''
     self.nu = -1
     self.J = -1
     self.stat = -1
     self.col = a(col, plus, minus)
     self.mod = 0
     self.ioniz = 0
     self.descr = self.name
     if col != 0:
         self.descr += ' ' + str(col)
     # for line modeling:
     self.logN = 0
     self.b = 0
     self.b_ind = 0
Exemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        
        # representation name SiII, OI*, HD
        self.name = args[0]
        # short desciprion of element, like Si
        self.el = self.get_element_name()
        
        # set column density:
        if len(args) == 1:
            self.col = a()
        elif len(args) == 2:
            if isinstance(args[1], str):
                self.col = a(args[1])
            elif isinstance(args[1], a):
                self.col = args[1]
            elif isinstance(args[1], (int, float)):
                self.col = a(args[1], 0, 0)
        elif len(args) == 4:
            if 'f' in kwargs.keys():
                self.col = a(args[1], args[2], args[3], kwargs['f'])
            else:
                self.col = a(args[1], args[2], args[3], )
        
        self.nu = None
        self.J = None
        if 'j' in self.name:
            self.J = int(self.name[int(self.name.index('j'))+1:])
        self.b = None
        
        for k in kwargs.items():
            if k[0] == 'b' and isinstance(k[1], (list, tuple)):
                setattr(self, k[0], a(k[1][0], k[1][1], k[1][2], 'd'))
            else:
                setattr(self, k[0], k[1])
        
        # refresh representation for molecules
        self.name = self.__repr__()
        
        self.mend = None
        
        self.fine = self.name.count('*')
        
        self.statw()
        self.ionstate()

        self.lines = []

        # for line modeling:
        self.logN = self.col.val
        if self.b is not None:
            self.b_ = self.b.val
        
        # some additional parameters:        
        self.mod = 0
Exemplo n.º 6
0
def metallicity(element, logN, logNH, mode=None):
    """
    Return the value of the metallicity using Asplund 2009 data
    parameters:
            - element     : name of the element
            - logN        : column density of element
            - logNH       : column density of HI
            - mode        : if mode == 'Solar' include solar uncertainties in result
    """
    element = e(element).get_element_name()
    if isinstance(logN, a) or isinstance(logNH, a):
        if not isinstance(logNH, a):
            logNH = 10**logNH
        if mode == 'Solar':
            return (logN / logNH / a(Asplund2009(element), 'l')).log()
        else:
            return (logN / logNH / 10**(Asplund2009(element)[0])).log()
    
    if isinstance(logN, float) and isinstance(logNH, float):
        return logN - logNH - Asplund2009(element)[0]
Exemplo n.º 7
0
def abundance(element, logNH, me, mode=None):
    """
    Return the value of the abundance of element at specified metallicity using Asplund 2009 data
    parameters:
            - element     : name of the element
            - logNH       : column density of HI
            - me          : metallicity
            - mode        : if mode == 'Solar' include solar uncertainties in result
    return: N
            - N           : abundance of element in log, or a() object
    
    """
    element = e(element).get_element_name()
    if isinstance(me, a) or isinstance(logNH, a):
        if mode == 'Solar':
            return (logNH * me * a(Asplund2009(element), 'l')).log()
        else:
            return (logNH * me * 10**(Asplund2009(element)[0])).log()

    if isinstance(me, float) or isinstance(logNH, float):
        return me + logNH + Asplund2009(element)[0]
Exemplo n.º 8
0
if __name__ == '__main__':
    if 0:
        d = DLAlist.DLA_SDSS()
        d = DLAlist()
        print(d)    
    
    if 0:
        H2 = H2list.Malec(1)  
        for line in H2:
            print(line)
    if 0:
        HI = HIlist.HIset()
        for line in HI:
            print(line, line.l, line.f, line.g)
    if 0:
        N = a('14.47^{+0.09}_{-0.07}', 'l')
        print(N)
        HI = a('19.88^{+0.01}_{-0.01}', 'l')
        print(metallicity('O_I', N, HI))

    if 0:
        HI = a('19.88^{+0.01}_{-0.01}', 'l')
        me = a('-1.2^{+0.1}_{-0.1}', 'l')
        print(abundance('OI', HI, me))

    if 1:
        A = atomicData()
        #A.readCO()
        #print(A.list('SiII'))
        A.makedatabase()
        #A.makedatabase()