コード例 #1
0
    def initialize(self, filename, timestep, nx_redu, ny_redu, nz_redu):
        """Call this method to convert a Citcoms Hdf file to a Vtk file"""

        from citcoms_plugins.utils import parsemodel
        (step, modelname, metafile, fullpath) = parsemodel(filename)

        if not fullpath:
            # try to load step=0
            import os.path
            step = 0
            pardir, mfilename = os.path.split(metafile)
            fullpath = os.path.join(pardir, "%s.%d.h5" % (modelname, step))

        #Read meta-inforamtion
        hdf = tables.openFile(metafile, 'r')
        hdf_t = tables.openFile(fullpath, 'r')

        self._nx = int(hdf.root.input._v_attrs.nodex)
        self._ny = int(hdf.root.input._v_attrs.nodey)
        self._nz = int(hdf.root.input._v_attrs.nodez)

        #Clip against boundaries
        if nx_redu >= 0 or nx_redu >= self._nx:
            nx_redu = self._nx - 1
        if ny_redu == 0 or ny_redu >= self._ny:
            ny_redu = self._ny - 1
        if nz_redu == 0 or nz_redu >= self._nz:
            nz_redu = self._nz - 1

        #Make reduction factors global
        self._nx_redu = nx_redu
        self._ny_redu = ny_redu
        self._nz_redu = nz_redu

        #Number of Timesteps in scene
        #self.timesteps = int(hdf.root.time.nrows)

        #Number of caps
        nproc_surf = int(hdf.root.input._v_attrs.nproc_surf)
        #Store the Inner Radius. Import if we want to create a core
        self._radius_inner = self._radius_inner = float(
            hdf.root.input._v_attrs.radius_inner)
        #start computation
        hexgrid = self.__citcom2vtk(hdf, hdf_t, nproc_surf, nx_redu, ny_redu,
                                    nz_redu)

        hdf.close()
        self.progress = -1
        return hexgrid
コード例 #2
0
ファイル: CitcomSHDFUgrid.py プロジェクト: QuLogic/citcoms
    def initialize(self,filename,timestep,nx_redu,ny_redu,nz_redu):
        """Call this method to convert a Citcoms Hdf file to a Vtk file"""
        
        from citcoms_plugins.utils import parsemodel
        (step, modelname, metafile, fullpath) = parsemodel(filename)

        if not fullpath:
            # try to load step=0
            import os.path
            step = 0
            pardir, mfilename = os.path.split(metafile)
            fullpath = os.path.join(pardir, "%s.%d.h5" % (modelname, step))

        
        #Read meta-inforamtion
        hdf = tables.openFile(metafile, 'r')
        hdf_t = tables.openFile(fullpath, 'r')

        self._nx = int(hdf.root.input._v_attrs.nodex)
        self._ny = int(hdf.root.input._v_attrs.nodey)
        self._nz = int(hdf.root.input._v_attrs.nodez)
        

        #Clip against boundaries
        if nx_redu>=0 or nx_redu>=self._nx:
            nx_redu = self._nx-1
        if ny_redu==0 or ny_redu>=self._ny:
            ny_redu = self._ny-1
        if nz_redu==0 or nz_redu>=self._nz:
            nz_redu = self._nz-1
        
        #Make reduction factors global
        self._nx_redu = nx_redu
        self._ny_redu = ny_redu
        self._nz_redu = nz_redu
        
        #Number of Timesteps in scene   
        #self.timesteps = int(hdf.root.time.nrows)

        #Number of caps
        nproc_surf = int(hdf.root.input._v_attrs.nproc_surf)
        #Store the Inner Radius. Import if we want to create a core
        self._radius_inner = self._radius_inner = float(hdf.root.input._v_attrs.radius_inner)
        #start computation
        hexgrid = self.__citcom2vtk(hdf, hdf_t, nproc_surf,nx_redu,ny_redu,nz_redu)
        
        hdf.close()
        self.progress = -1
        return hexgrid 
コード例 #3
0
    def __set_pure_state__(self, state):
        z = state.data
        if z:
            d = gunzip_string(z)
            m = re.search('(?<=Filename:)\w+', header)
            file_name = m.group(0)
            m = re.search('(?<=NX:)\w+', d)
            self.nx_redu = int(m.group(0))
            m = re.search('(?<=NX:)\w+', d)
            self.ny_redu = int(m.group(0))
            m = re.search('(?<=NX:)\w+', d)
            self.nz_redu = int(m.group(0))

            if not isfile(file_name):
                msg = 'Could not find file at %s\n' % file_name
                msg += 'Please move the file there and try again.'
                raise IOError, msg

            (step, modelname, metafilepath, filepath) = parsemodel(file_name)
            file_name = metafilepath

            self.filename = file_name

            #self.data = self.citcomshdftougrid.initialize(self.filename,0,0,0,0,False,False)
            f = tables.openFile(file_name, 'r')
            self.nx = int(f.root.input._v_attrs.nodex)
            self.ny = int(f.root.input._v_attrs.nodey)
            self.nz = int(f.root.input._v_attrs.nodez)

            #self.timesteps = int(f.root.time.nrows)

            f.close()
            self.data = self.citcomshdftougrid.initialize(
                self.filename, self.current_timestep, self.nx_redu,
                self.ny_redu, self.nz_redu)
            self.data_changed = True
            self._update_data()
            # Now set the remaining state without touching the children.
            set_state(self, state, ignore=['children', '_file_path'])
            # Setup the children.
            handle_children_state(self.children, state.children)
            # Setup the children's state.
            set_state(self, state, first=['children'], ignore=['*'])
コード例 #4
0
    def __set_pure_state__(self, state):
        z = state.data
        if z:
            d = gunzip_string(z)
            m = re.search('(?<=Filename:)\w+', header)
            file_name = m.group(0)
            m = re.search('(?<=NX:)\w+', d)
            self.nx_redu = int(m.group(0))
            m = re.search('(?<=NX:)\w+', d)
            self.ny_redu = int(m.group(0))
            m = re.search('(?<=NX:)\w+', d)
            self.nz_redu = int(m.group(0))
        
            if not isfile(file_name):
                msg = 'Could not find file at %s\n'%file_name
                msg += 'Please move the file there and try again.'
                raise IOError, msg
            
            (step, modelname, metafilepath, filepath) = parsemodel(file_name)
            file_name = metafilepath
            
            self.filename = file_name
        
            #self.data = self.citcomshdftougrid.initialize(self.filename,0,0,0,0,False,False)
            f = tables.openFile(file_name,'r')
            self.nx = int(f.root.input._v_attrs.nodex)
            self.ny = int(f.root.input._v_attrs.nodey)
            self.nz = int(f.root.input._v_attrs.nodez)
        
            #self.timesteps = int(f.root.time.nrows)

            f.close()
            self.data = self.citcomshdftougrid.initialize(self.filename,self.current_timestep,self.nx_redu,self.ny_redu,self.nz_redu)
            self.data_changed = True
            self._update_data()
            # Now set the remaining state without touching the children.
            set_state(self, state, ignore=['children', '_file_path'])
            # Setup the children.
            handle_children_state(self.children, state.children)
            # Setup the children's state.
            set_state(self, state, first=['children'], ignore=['*'])
コード例 #5
0
    def initialize(self,file_name):
        """This Methods initializes the reader and reads the meta-information from the Hdf file """
        self.filename = file_name
        
        #self.data = self.citcomshdftougrid.initialize(self.filename,0,0,0,0,False,False)
        from citcoms_plugins.utils import parsemodel

        (step, modelname, coordpath, filepath) = parsemodel(file_name)
        if step is None:
            step = 0

        f = tables.openFile(coordpath,'r')
        self.nx = int(f.root.input._v_attrs.nodex)
        self.ny = int(f.root.input._v_attrs.nodey)
        self.nz = int(f.root.input._v_attrs.nodez)
        
        self.nx_redu = self.nx
        self.ny_redu = self.ny
        self.nz_redu = self.nz
        
        self.timestep = step
        #self.timesteps = int(f.root.time.nrows)
        f.close()
コード例 #6
0
    def initialize(self, file_name):
        """This Methods initializes the reader and reads the meta-information from the Hdf file """
        self.filename = file_name

        #self.data = self.citcomshdftougrid.initialize(self.filename,0,0,0,0,False,False)
        from citcoms_plugins.utils import parsemodel

        (step, modelname, coordpath, filepath) = parsemodel(file_name)
        if step is None:
            step = 0

        f = tables.openFile(coordpath, 'r')
        self.nx = int(f.root.input._v_attrs.nodex)
        self.ny = int(f.root.input._v_attrs.nodey)
        self.nz = int(f.root.input._v_attrs.nodez)

        self.nx_redu = self.nx
        self.ny_redu = self.ny
        self.nz_redu = self.nz

        self.timestep = step
        #self.timesteps = int(f.root.time.nrows)
        f.close()