Ejemplo n.º 1
0
    def read(self, geometry):

        f = open(self.filename, 'rb')
        up = xdrlib.Unpacker(f.read())
        f.close()

        self.NHydr = up.unpack_int()
        self.Nelem = up.unpack_int()
        self.moving = up.unpack_int()

        if geometry.type == "ONE_D_PLANE":
            dim1 = [geometry.Ndep]
            dim2 = [geometry.Ndep, self.NHydr]

        elif geometry.type == 'SPHERICAL_SYMMETRIC':
            dim1 = [geometry.Nradius]
            dim2 = [geometry.Nradius, self.NHydr]

        elif geometry.type == 'TWO_D_PLANE':
            dim1 = [geometry.Nx, geometry.Nz]
            dim2 = [geometry.Nx, geometry.Nz, self.NHydr]

        elif geometry.type == 'THREE_D_PLANE':
            dim1 = [geometry.Nx, geometry.Ny, geometry.Nz]
            dim2 = [geometry.Nx, geometry.Ny, geometry.Nz, self.NHydr]

        self.T = read_farray(dim1, up, "double")
        self.n_elec = read_farray(dim1, up, "double")
        self.vturb = read_farray(dim1, up, "double")

        self.nH = read_farray(dim2, up, "double")
        self.ID = read_string(up)

        self.elements = {}
        for n in range(self.Nelem):
            self.elements[n] = element(up)

        if geometry.type != 'SPHERICAL_SYMMETRIC':
            try:
                stokes = up.unpack_int()
            except EOFError or IOError:
                self.stokes = False
                return
            else:
                self.stokes = True

                self.B = read_farray(dim1, up, "double")
                self.gamma_B = read_farray(dim1, up, "double")
                self.chi_B = read_farray(dim1, up, "double")

        up.done()
Ejemplo n.º 2
0
    def read(self, geometry):

        f = open(self.filename, 'rb')
        up = xdrlib.Unpacker(f.read())
        f.close()

        self.active = up.unpack_int()
        self.Nlevel = up.unpack_int()
        self.Nline = up.unpack_int()
        self.Ncont = up.unpack_int()
        self.Nfixed = up.unpack_int()

        self.abund = up.unpack_double()
        self.weight = up.unpack_double()

        self.labels = {}
        for i in range(self.Nlevel):
            self.labels[i] = read_string(up)

        self.atomID = self.labels[0][0:2].strip()

        self.g = read_farray([self.Nlevel], up, "double")
        self.E = read_farray([self.Nlevel], up, "double")
        self.stage = read_farray([self.Nlevel], up, "int")

        Nrad = self.Nline + self.Ncont

        self.transition = {}
        for kr in range(Nrad):
            self.transition[kr] = atoms.transition(up)

        for kr in range(self.Nline, Nrad):
            if self.transition[kr].shape == "HYDROGENIC":
                self.transition[kr].waves = up.unpack_double()
            else:
                self.transition[kr].waves =\
                read_farray([self.transition[kr].Nwave], up, "double")
                self.transition[kr].alpha =\
                read_farray([self.transition[kr].Nwave], up, "double")

        self.fixed = {}
        for kr in range(self.Nfixed):
            self.transition[kr] = atoms.fixed(up)

        up.done()
Ejemplo n.º 3
0
    def read_BRS(self):

        brsfile = '{0}/brs.out'.format(self.rhdir)
        f = open(brsfile, 'rb')
        up = xdrlib.Unpacker(f.read())
        f.close()

        atmosID = read_string(up)
        Nspace = up.unpack_int()

        Nspect = up.unpack_int()

        hasline = read_farray(Nspect, up, "int")
        ispolarized = read_farray(Nspect, up, "int")
        self.backgrflags = backgrflags(hasline, ispolarized)

        if self.atmos.moving or self.atmos.stokes:
            dim = 2 * Nspect * self.geometry.Nrays
        else:
            dim = Nspect

        self.bg_recno = read_farray(dim, up, "int")
        up.done()
Ejemplo n.º 4
0
    def readpops(self, geometry, popsfile):

        f = open(popsfile, 'rb')
        up = xdrlib.Unpacker(f.read())
        f.close()

        atmosID = read_string(up)
        Nlevel = up.unpack_int()
        Nspace = up.unpack_int()

        if geometry.type == "ONE_D_PLANE":
            dim = [geometry.Ndep, self.Nlevel]
        elif geometry.type == 'SPHERICAL_SYMMETRIC':
            dim = [geometry.Nradius, self.Nlevel]
        elif geometry.type == 'TWO_D_PLANE':
            dim = [geometry.Nx, geometry.Nz, self.Nlevel]
        elif geometry.type == 'THREE_D_PLANE':
            dim = [geometry.Nx, geometry.Ny, geometry.Nz, self.Nlevel]

        self.n = read_farray(dim, up, "double")
        self.nstar = read_farray(dim, up, "double")

        up.done()
Ejemplo n.º 5
0
 def read_element(self, up):
     self.ID = read_string(up)
     self.weight = float(up.unpack_double())
     self.abund = float(up.unpack_double())