Esempio n. 1
0
    def seek(self, date=None, time=None, spc=-1, k=0, chkvar=True):
        """
        Move file cursor to the beginning of the specified record
        see __recordposition for parameter definitions
        """
        spc += 1
        if date is None:
            date = self.start_date
        if time is None:
            time = self.start_time

        if (
            chkvar and
            timediff((self.end_date, self.end_time), (date, time), 24) > 0 or
            timediff((self.start_date, self.start_time), (date, time), 24) < 0
        ):
            raise KeyError(("Gridded emission file includes (%i,%6.1f) " +
                            "thru (%i,%6.1f); you requested (%i,%6.1f)") %
                           (self.start_date, self.start_time,
                            self.end_date, self.end_time, date, time))
        if chkvar and spc < 1 or spc > self.nspec:
            raise KeyError(("Gridded emission file include species 1 thru " +
                            "%i; you requested %i") % (self.nspec, spc))

        # self.rffile._newrecord(self.__recordposition(date,time,1,0))
        # start_date,start_time,end_date,end_time=self.rffile.read("ifif")
        self.rffile._newrecord(self.__recordposition(date, time, spc, k))
Esempio n. 2
0
    def __gettimestep(self):
        """
        Header information provides start and end date, but does not
        indicate the increment between.  This routine reads the first
        and second date/time and initializes variables indicating the
        timestep length and the anticipated number.
        """
        self.rffile._newrecord(
                        self.padded_size
                        )
        d,t=self.start_date,self.start_time
        self.nlayers=0
        while timediff((self.start_date,self.start_time),(d,t))==0:
            t,d=self.rffile.read(self.id_fmt)
            self.nlayers+=1
        self.time_step=timediff((self.start_date,self.start_time),(d,t))

        while True:
            try:
                self.seek(d,t,1,False)
                d,t=timeadd((d,t),(0,self.time_step))
            except:
                break
        self.end_date,self.end_time=timeadd((d,t),(0,-self.time_step))
        self.time_step_count=int(timediff((self.start_date,self.start_time),(self.end_date,self.end_time))/self.time_step)+1
Esempio n. 3
0
    def seek(self, date=None, time=None, k=1, chkvar=True):
        """
        Move file cursor to beginning of specified record
        see __recordposition for a definition of variables
        """
        if date is None:
            date = self.start_date
        if time is None:
            time = self.start_time

        if chkvar:
            chkt1 = timediff((self.end_date, self.end_time), (date, time)) > 0
            chkt2 = timediff((self.start_date, self.start_time),
                             (date, time)) < 0
            if chkt1 or chkt2:
                raise KeyError(("Vertical Diffusivity file includes " +
                                "(%i,%6.1f) thru (%i,%6.1f); you requested " +
                                "(%i,%6.1f)") %
                               (self.start_date, self.start_time,
                                self.end_date, self.end_time, date, time))
            if k < 1 or k > self.nlayers:
                raise KeyError(
                    ("Vertical Diffusivity file include layers 1" +
                     "thru %i; you requested %i") % (self.nlayers, k))
        self.rffile._newrecord(self.__recordposition(date, time, k))
Esempio n. 4
0
    def __gettimestep(self):
        """
        Header information provides start and end date, but does not
        indicate the increment between.  This routine reads the first
        and second date/time and initializes variables indicating the
        timestep length and the anticipated number.
        """
        self.rffile._newrecord(self.padded_size * 2)
        d, t = self.start_date, self.start_time
        self.nlayers = 0
        while timediff((self.start_date, self.start_time), (d, t)) == 0:
            t, d = self.rffile.read(self.id_fmt)
            self.rffile.next()
            self.nlayers += 1
        self.time_step = timediff((self.start_date, self.start_time), (d, t))

        while True:
            try:
                self.seek(d, t, self.nlayers, 1, False)
                d, t = timeadd((d, t), (0, self.time_step))
            except:
                break
        self.end_date, self.end_time = timeadd((d, t), (0, -self.time_step))
        self.time_step_count = int(
            timediff((self.start_date, self.start_time),
                     (self.end_date, self.end_time)) / self.time_step) + 1
Esempio n. 5
0
    def seek(self, date=None, time=None, k=1, hp=0, chkvar=True):
        """
        Move file cursor to specified record
        """
        if date == None:
            date = self.start_date
        if time == None:
            time = self.start_time

        if chkvar and timediff(
            (self.end_date, self.end_time), (date, time)) > 0 or timediff(
                (self.start_date, self.start_time), (date, time)) < 0:
            raise KeyError(
                "Vertical Diffusivity file includes (%i,%6.1f) thru (%i,%6.1f); you requested (%i,%6.1f)"
                % (self.start_date, self.start_time, self.end_date,
                   self.end_time, date, time))
        if chkvar and k < 1 or k > self.nlayers:
            raise KeyError(
                "Vertical Diffusivity file include layers 1 thru %i; you requested %i"
                % (self.nlayers, k))
        if chkvar and hp < 0 or hp > 1:
            raise KeyError(
                "Height pressure or indexed 0 and 1; you requested %i" % (hp))

        self.rffile._newrecord(self.__recordposition(date, time, k, hp))
Esempio n. 6
0
    def __readheader(self):
        """
        __readheader reads the header section of the ipr file
        it initializes each header field (see CAMx Users Manual for a list)
        as properties of the ipr class
        """
        vals = self.rffile.read(self.emiss_hdr_fmt)
        self.name, self.note, ione, self.nspec, self.start_date, self.start_time, self.end_date, self.end_time = vals[
            0:10], vals[10:70], vals[70], vals[71], vals[72], vals[73], vals[
                74], vals[75]
        rdum, rdum, self.iutm, self.xorg, self.yorg, self.delx, self.dely, self.nx, self.ny, self.nz, idum, idum, rdum, rdum, rdum = self.rffile.read(
            self.grid_hdr_fmt)
        if self.nz == 0:
            #Special case of gridded emissions
            #Seems to be same as avrg
            self.nlayers = 1
        else:
            self.nlayers = self.nz
        ione, ione, nx, ny = self.rffile.read(self.cell_hdr_fmt)
        if not (self.nx, self.ny) == (nx, ny):
            raise ValueError(
                "nx, ny defined first as %i, %i and then as %i, %i" %
                (self.nx, self.ny, nx, ny))
        species_temp = self.rffile.read(self.nspec * self.spc_fmt)
        self.spcnames = []
        for i in range(0, self.nspec * 10, 10):
            self.spcnames.append(Int2Asc(species_temp[i:i + 10]))

        ione, self.nstk = self.rffile.read(self.nstk_hdr_fmt)

        stkprms = zeros((self.nstk * len(self.stk_hdr_fmt), ), 'f')
        read_into(self.rffile, stkprms, '')
        self.rffile.next()
        #self.rffile.previous()
        #self.tmplist=self.rffile.read('ffffff'*self.nstk)

        stkprms = stkprms.reshape((self.nstk, len(self.stk_hdr_fmt)))
        for i in range(stkprms.shape[0]):
            if stkprms[i, -1] == array_nan:
                stkprms[i, -1] = float('-nan')
        self.stk_props = stkprms.tolist()
        self.data_start_byte = self.rffile.record_start
        self.start_date, self.start_time, end_date, end_time = self.rffile.read(
            self.time_hdr_fmt)

        self.time_step = timediff((self.start_date, self.start_time),
                                  (end_date, end_time))
        self.end_time += self.time_step
        self.time_step_count = int(
            timediff((self.start_date, self.start_time),
                     (self.end_date, self.end_time),
                     (2400, 24)[int(self.time_step % 2)]) / self.time_step)

        self.stk_time_prop_fmt = "" + ("iiiff" * self.nstk)
        self.padded_stk_time_prop_size = struct.calcsize(
            "ii" + self.stk_time_prop_fmt)

        self.record_fmt = ("i10i") + self.data_fmt * (self.nstk)
        self.record_size = struct.calcsize(self.record_fmt)
        self.padded_size = self.record_size + 8
Esempio n. 7
0
    def __readheader(self):
        """
        __readheader reads the header section of the ipr file
        it initializes each header field (see CAMx Users Manual for a list)
        as properties of the ipr class
        """
        vals = self.rffile.read(self.emiss_hdr_fmt)
        self.name = vals[0:10]
        self.note = vals[10:70]
        ione = vals[70]
        self.nspec = vals[71]
        self.start_date, self.start_time = vals[72], vals[73]
        self.end_date, self.end_time = vals[74], vals[75]

        self.name = Int2Asc(self.name)
        self.note = Int2Asc(self.note)

        vals = self.rffile.read(self.grid_hdr_fmt)
        self.rdum, rdum, self.iutm = vals[0:3]
        self.xorg, self.yorg, self.delx, self.dely = vals[3:7]
        self.nx, self.ny, self.nz = vals[7:10]
        idum, self.idum, rdum, rdum, rdum = vals[10:]

        if self.name == 'EMISSIONS ':
            # Special case of gridded emissions
            # Seems to be same as avrg
            self.nlayers = 1
        else:
            self.nlayers = self.nz
        self.ione, ione, nx, ny = self.rffile.read(self.cell_hdr_fmt)
        if not (self.nx, self.ny) == (nx, ny):
            raise ValueError(("nx, ny defined first as %i, %i and then " +
                              "as %i, %i") % (self.nx, self.ny, nx, ny))
        species_temp = self.rffile.read(self.nspec * self.spc_fmt)
        self.spcnames = []
        for i in range(0, self.nspec * 10, 10):
            self.spcnames.append(Int2Asc(species_temp[i:i + 10]))

        self.data_start_byte = self.rffile.record_start
        start_date, start_time, end_date, end_time = self.rffile.read(
            self.time_hdr_fmt)

        self.time_step = timediff(
            (start_date, start_time), (end_date, end_time))
        mystep = (2400, 24)[int(self.time_step % 2)]
        self.time_step_count = int(timediff((self.start_date, self.start_time),
                                            (self.end_date, self.end_time),
                                            mystep) // self.time_step)
        if self.name == 'AIRQUALITY':
            self.time_step_count = 1
            self.start_date = self.end_date
        self.record_size = self.rffile.record_size
        self.padded_size = self.record_size + 8
        self.cell_count = (self.record_size - struct.calcsize("i10i")
                           ) // struct.calcsize(self.data_fmt)
        self.record_fmt = ("i10i") + self.data_fmt * (self.cell_count)
Esempio n. 8
0
 def __gettimestep(self):
     d,t=date,time=self.start_date,self.start_time
     self.nlayers=-1
     while (d,t)==(date,time):
         self.nlayers+=1
         t,d=self.rffile.read(self.id_fmt)
     self.time_step=timediff((self.start_date,self.start_time),(d,t))
     self.rffile.infile.seek(0,2)
     self.rffile.previous()
     self.end_time,self.end_date=self.rffile.read(self.id_fmt)
     self.time_step_count=int(timediff((self.start_date,self.start_time),(self.end_date,self.end_time))/self.time_step)+1
Esempio n. 9
0
 def __gettimestep(self):
     """
     Header information provides start and end date, but does not
     indicate the increment between.  This routine reads the first
     and second date/time and initializes variables indicating the
     timestep length and the anticipated number.
     """
     self.__rffile.seek(self.__data_start_byte,0)
     temp=fromfile(self.__rffile,dtype=self.__ipr_record_type,count=len(self.dimensions['LAY'])*len(self.dimensions['ROW'])*len(self.dimensions['COL'])+1)
     self.TSTEP=timediff((self.SDATE,self.STIME),(temp[-1]['DATE']+2000000,temp[-1]['TIME']))
     self.NSTEPS=int(timediff((self.SDATE,self.STIME),(self.EDATE,self.ETIME))/self.TSTEP)
Esempio n. 10
0
 def __gettimestep(self):
     d, t = date, time = self.start_date, self.start_time
     self.nlayers = -1
     while (d, t) == (date, time):
         self.nlayers += 1
         t, d = self.rffile.read(self.id_fmt)
     self.time_step = timediff((self.start_date, self.start_time), (d, t))
     self.rffile.infile.seek(0, 2)
     self.rffile.previous()
     self.end_time, self.end_date = self.rffile.read(self.id_fmt)
     self.time_step_count = int(
         timediff((self.start_date, self.start_time),
                  (self.end_date, self.end_time)) // self.time_step) + 1
Esempio n. 11
0
    def __gettimestep(self):
        """
        Header information provides start and end date, but does not
        indicate the increment between.  This routine reads the first
        and second date/time and initializes variables indicating the
        timestep length and the anticipated number.
        """
        # This is a bit of a hack, but should work:
        # Search for the next record that is the same
        # length as self.padded_time_hdr_size
        #
        # This should be the next date record
        # 1) date - startdate = timestep
        # 2) (record_start - self.padded_time_hdr_size)/self.padded_size
        #     = klayers
        self.rffile._newrecord(0)
        self.rffile.next()
        nlayers = 0
        while not self.rffile.record_size == self.time_hdr_size:
            self.rffile.next()
            nlayers += 1

        self.nlayers = (nlayers - 1) // 2

        if self.time_hdr_fmt == "fi":
            time, date = self.rffile.read(self.time_hdr_fmt)
        elif self.time_hdr_fmt == "fii":
            time, date, lstagger = self.rffile.read(self.time_hdr_fmt)

        self.end_time, self.end_date = time, date

        self.time_step = timediff((self.start_date, self.start_time),
                                  (date, time))

        while True:
            try:
                for i in range(self.nlayers * 2 + 1):
                    self.rffile.next()
                if self.rffile.record_size == 8:
                    self.end_time, self.end_date = self.rffile.read("fi")
                elif self.rffile.record_size == 12:
                    self.end_time, self.end_date, lstagger = self.rffile.read(
                        "fii")
                else:
                    raise KeyError()
            except Exception:
                break

        self.time_step_count = int(
            timediff((self.start_date, self.start_time),
                     (self.end_date, self.end_time)) / self.time_step) + 1
Esempio n. 12
0
    def __readheader(self):
        """
        __readheader reads the header section of the ipr file
        it initializes each header field (see CAMx Users Manual for a list)
        as properties of the ipr class
        """
        vals=self.rffile.read(self.emiss_hdr_fmt)
        self.name,self.note,ione,self.nspec,self.start_date,self.start_time,self.end_date,self.end_time=vals[0:10],vals[10:70],vals[70],vals[71],vals[72],vals[73],vals[74],vals[75]
        rdum,rdum,self.iutm,self.xorg,self.yorg,self.delx,self.dely,self.nx,self.ny,self.nz,idum,idum,rdum,rdum,rdum=self.rffile.read(self.grid_hdr_fmt)
        if self.nz==0:
            #Special case of gridded emissions
            #Seems to be same as avrg
            self.nlayers=1
        else:
            self.nlayers=self.nz
        ione,ione,nx,ny=self.rffile.read(self.cell_hdr_fmt)
        if not (self.nx,self.ny)==(nx,ny):
            raise ValueError("nx, ny defined first as %i, %i and then as %i, %i" % (self.nx,self.ny,nx,ny))
        species_temp=self.rffile.read(self.nspec*self.spc_fmt)
        self.spcnames=[]
        for i in range(0,self.nspec*10,10):
            self.spcnames.append(Int2Asc(species_temp[i:i+10]))
        
        ione,self.nstk=self.rffile.read(self.nstk_hdr_fmt)

        stkprms=zeros((self.nstk*len(self.stk_hdr_fmt),),'f')
        read_into(self.rffile,stkprms,'')
        self.rffile.next()
        #self.rffile.previous()
        #self.tmplist=self.rffile.read('ffffff'*self.nstk)
        
        stkprms=stkprms.reshape((self.nstk,len(self.stk_hdr_fmt)))
        for i in range(stkprms.shape[0]):
            if stkprms[i,-1]==array_nan:
                stkprms[i,-1]=float('-nan')
        self.stk_props=stkprms.tolist()
        self.data_start_byte=self.rffile.record_start
        self.start_date,self.start_time,end_date,end_time=self.rffile.read(self.time_hdr_fmt)
        
        self.time_step=timediff((self.start_date,self.start_time),(end_date,end_time))
        self.end_time += self.time_step
        self.time_step_count=int(timediff((self.start_date,self.start_time),(self.end_date,self.end_time),(2400,24)[int(self.time_step % 2)])/self.time_step)
        
        self.stk_time_prop_fmt=""+("iiiff"*self.nstk)
        self.padded_stk_time_prop_size=struct.calcsize("ii"+self.stk_time_prop_fmt)
        
        self.record_fmt=("i10i")+self.data_fmt*(self.nstk)
        self.record_size=struct.calcsize(self.record_fmt)
        self.padded_size=self.record_size+8
Esempio n. 13
0
 def seek(self,date=None,time=None,k=1,chkvar=True):
     """
     Move file cursor to beginning of specified record
     see __recordposition for a definition of variables
     """
     if date==None:
         date=self.start_date
     if time==None:
         time=self.start_time
         
     if chkvar and timediff((self.end_date,self.end_time),(date,time))>0 or timediff((self.start_date,self.start_time),(date,time))<0:
         raise KeyError("Vertical Diffusivity file includes (%i,%6.1f) thru (%i,%6.1f); you requested (%i,%6.1f)" % (self.start_date,self.start_time,self.end_date,self.end_time,date,time))
     if chkvar and k<1 or k>self.nlayers:
         raise KeyError("Vertical Diffusivity file include layers 1 thru %i; you requested %i" % (self.nlayers,k))
     self.rffile._newrecord(self.__recordposition(date,time,k))
Esempio n. 14
0
 def seek(self,date=None,time=None,k=1,uv=1):
     """
     Move file cursor to beginning of specified record
     see __recordposition for a definition of variables
     """
     if date==None:
         date=self.start_date
     if time==None:
         time=self.start_time
     chkvar=True
     if chkvar and timediff((self.end_date,self.end_time),(date,time))>0 or timediff((self.start_date,self.start_time),(date,time))<0:
         raise KeyError("Wind file includes (%i,%6.1f) thru (%i,%6.1f); you requested (%i,%6.1f)" % (self.start_date,self.start_time,self.end_date,self.end_time,date,time))
     if chkvar and uv<0 or uv >2:
         raise KeyError("Wind file includes Date (uv: 0), u velocity (uv: 1) and v velocity (uv: 2); you requested %i" % (uv))
     
     self.rffile._newrecord(self.__recordposition(date,time,k,uv))
Esempio n. 15
0
 def __timerecords(self,dt):
     """
     Calculate the number of records to increment to reach time (d,t)
     """
     d, t = dt
     nsteps=timediff((self.start_date,self.start_time),(d,t),(2400,24)[int(self.time_step % 2)])
     nspec=self.__spcrecords(self.nspec+1)
     return nsteps*(nspec)
Esempio n. 16
0
 def __timerecords(self,dt):
     """
     Calculate the number of records to increment to reach time (d,t)
     """
     dt = d, t
     nsteps=int(timediff((self.start_date,self.start_time),(d,t))/self.time_step)
     nspec=self.__spcrecords(self.nspec+1)
     return nsteps*nspec
Esempio n. 17
0
 def seek(self,date=None,time=None,k=1,hp=0,chkvar=True):
     """
     Move file cursor to specified record
     """
     if date==None:
         date=self.start_date
     if time==None:
         time=self.start_time
         
     if chkvar and timediff((self.end_date,self.end_time),(date,time))>0 or timediff((self.start_date,self.start_time),(date,time))<0:
         raise KeyError("Vertical Diffusivity file includes (%i,%6.1f) thru (%i,%6.1f); you requested (%i,%6.1f)" % (self.start_date,self.start_time,self.end_date,self.end_time,date,time))
     if chkvar and k<1 or k>self.nlayers:
         raise KeyError("Vertical Diffusivity file include layers 1 thru %i; you requested %i" % (self.nlayers,k))
     if chkvar and hp<0 or hp >1:
         raise KeyError("Height pressure or indexed 0 and 1; you requested %i" % (hp))
         
     self.rffile._newrecord(self.__recordposition(date,time,k,hp))
Esempio n. 18
0
 def __timerecords(self,dt):
     """
     Calculate the number of records to increment to reach time (d,t)
     """
     dt = d, t
     nsteps=int(timediff((self.start_date,self.start_time),(d,t))/self.time_step)
     nspec=self.__spcrecords(self.nspec+1)
     return nsteps*nspec
Esempio n. 19
0
 def __gettimestep(self):
     """
     Header information provides start and end date, but does not
     indicate the increment between.  This routine reads the first
     and second date/time and initializes variables indicating the
     timestep length and the anticipated number.
     """
     self.__rffile.seek(self.__data_start_byte, 0)
     rcount = (len(self.dimensions['LAY']) *
               len(self.dimensions['ROW']) *
               len(self.dimensions['COL']) + 1)
     temp = fromfile(self.__rffile,
                     dtype=self.__ipr_record_type,
                     count=rcount)
     self.TSTEP = timediff((self.SDATE, self.STIME),
                           (temp[-1]['DATE'] + 2000000, temp[-1]['TIME']))
     self.NSTEPS = int(timediff((self.SDATE, self.STIME),
                                (self.EDATE, self.ETIME)) / self.TSTEP)
Esempio n. 20
0
 def __timerecords(self, dt):
     """
     Calculate the number of records to increment to reach time (d,t)
     """
     d, t = dt
     nsteps = timediff((self.start_date, self.start_time), (d, t),
                       (2400, 24)[int(self.time_step % 2)])
     nspec = self.__spcrecords(self.nspec + 1)
     return nsteps * (nspec)
Esempio n. 21
0
 def __timerecords(self,dt):
     """
     routine returns the number of records to increment from the
     data start byte to find the first time
     """
     d, t = dt
     nsteps=int(timediff((self.start_date,self.start_time),(d,t))/self.time_step)
     nk=self.__layerrecords(self.nlayers+1)
     return nsteps*nk
Esempio n. 22
0
 def seek(self,date=None,time=None,spc=-1,k=0,chkvar=True):
     """
     Move file cursor to the beginning of the specified record
     see __recordposition for parameter definitions
     """
     spc+=1
     if date==None:
         date=self.start_date
     if time==None:
         time=self.start_time
         
     if chkvar and timediff((self.end_date,self.end_time),(date,time),24)>0 or timediff((self.start_date,self.start_time),(date,time),24)<0:
         raise KeyError("Gridded emission file includes (%i,%6.1f) thru (%i,%6.1f); you requested (%i,%6.1f)" % (self.start_date,self.start_time,self.end_date,self.end_time,date,time))
     if chkvar and spc<1 or spc>self.nspec:
         raise KeyError("Gridded emission file include species 1 thru %i; you requested %i" % (self.nspec,spc))
     
     #self.rffile._newrecord(self.__recordposition(date,time,1,0))
     #start_date,start_time,end_date,end_time=self.rffile.read("ifif")
     self.rffile._newrecord(self.__recordposition(date,time,spc,k))
Esempio n. 23
0
    def __gettimestep(self):
        """
        Header information provides start and end date, but does not
        indicate the increment between.  This routine reads the first
        and second date/time and initializes variables indicating the
        timestep length and the anticipated number.
        """
        #This is a bit of a hack, but should work:
        #Search for the next record that is the same
        #length as self.padded_time_hdr_size
        #
        #This should be the next date record
        #1) date - startdate = timestep
        #2) (record_start - self.padded_time_hdr_size)/self.padded_size = klayers
        self.rffile.next()
        while not self.rffile.record_size==self.time_hdr_size:
            self.rffile.next()
        
        dist_btwn_dates=self.rffile.record_start - self.padded_time_hdr_size
        self.nlayers=(dist_btwn_dates)/self.padded_size/2
        
        if self.time_hdr_fmt=="fi":
            time,date=self.rffile.read(self.time_hdr_fmt)
        elif self.time_hdr_fmt=="fii":
            time,date,lstagger=self.rffile.read(self.time_hdr_fmt)

        self.time_step=timediff((self.start_date,self.start_time),(date,time))
        
        while True:
            try:
                self.rffile._newrecord(self.rffile.record_start+dist_btwn_dates)
                self.rffile.tell()
                if self.time_hdr_fmt=="fi":
                    self.end_time,self.end_date=self.rffile.read(self.time_hdr_fmt)
                elif self.time_hdr_fmt=="fii":
                    self.end_time,self.end_date,lstagger=self.rffile.read(self.time_hdr_fmt)
            except:
                break
        
        self.time_step_count=int(timediff((self.start_date,self.start_time),(self.end_date,self.end_time))/self.time_step)+1
Esempio n. 24
0
    def __readheader(self):
        """
        __readheader reads the header section of the ipr file
        it initializes each header field (see CAMx Users Manual for a list)
        as properties of the ipr class
        """
        vals=self.rffile.read(self.emiss_hdr_fmt)
        self.name,self.note,ione,self.nspec,self.start_date,self.start_time,self.end_date,self.end_time=vals[0:10],vals[10:70],vals[70],vals[71],vals[72],vals[73],vals[74],vals[75]
        
        self.name=Int2Asc(self.name)
        self.note=Int2Asc(self.note)
        self.rdum,rdum,self.iutm,self.xorg,self.yorg,self.delx,self.dely,self.nx,self.ny,self.nz,idum,self.idum,rdum,rdum,rdum=self.rffile.read(self.grid_hdr_fmt)

        if self.name=='EMISSIONS ':
            #Special case of gridded emissions
            #Seems to be same as avrg
            self.nlayers=1
        else:
            self.nlayers=self.nz
        self.ione,ione,nx,ny=self.rffile.read(self.cell_hdr_fmt)
        if not (self.nx,self.ny)==(nx,ny):
            raise ValueError("nx, ny defined first as %i, %i and then as %i, %i" % (self.nx,self.ny,nx,ny))
        species_temp=self.rffile.read(self.nspec*self.spc_fmt)
        self.spcnames=[]
        for i in range(0,self.nspec*10,10):
            self.spcnames.append(Int2Asc(species_temp[i:i+10]))
        
        self.data_start_byte=self.rffile.record_start
        start_date,start_time,end_date,end_time=self.rffile.read(self.time_hdr_fmt)
        self.time_step=timediff((start_date,start_time),(end_date,end_time))
        self.time_step_count=int(timediff((self.start_date,self.start_time),(self.end_date,self.end_time),(2400,24)[int(self.time_step % 2)])//self.time_step)
        if self.name == 'AIRQUALITY':
            self.time_step_count = 1
            self.start_date = self.end_date
        self.record_size=self.rffile.record_size
        self.padded_size=self.record_size+8
        self.cell_count=(self.record_size-struct.calcsize("i10i"))/struct.calcsize(self.data_fmt)
        self.record_fmt=("i10i")+self.data_fmt*(self.cell_count)