def __var_get(self, key): units = get_uamiv_units(self.name, key, self._aerosol_names) spcnames = [sn.strip() for sn in self.spcnames] if self.name == 'EMISSIONS ': def constr(spc): return self.getArray( nspec=spcnames.index(spc)).squeeze()[:, newaxis, :, :] def decor(spc): return dict(units=units, var_desc=spc, long_name=spc.ljust(16)) else: ntimes = len(self.dimensions['TSTEP']) nlays = len(self.dimensions['LAY']) nrows = len(self.dimensions['ROW']) ncols = len(self.dimensions['COL']) def constr(spc): return self.getArray(nspec=spcnames.index( spc)).squeeze().reshape(ntimes, nlays, nrows, ncols) def decor(spc): return dict(units=units, var_desc=spc.ljust(16), long_name=spc.ljust(16)) values = constr(key) var = self.createVariable(key, 'f', ('TSTEP', 'LAY', 'ROW', 'COL')) var[:] = values for k, v in decor(key).items(): setattr(var, k, v) return var
def __variables(self,k): spc_index=self.__var_names__.index(k) dimensions=('TSTEP','LAY','ROW','COL') outvals=self.__memmap__[k]['DATA'] units = get_uamiv_units(self.NAME, k) return PseudoIOAPIVariable(self,k,'f',dimensions,values=outvals, units = units)
def __variables(self, k): dimensions = ('TSTEP', 'LAY', 'ROW', 'COL') outvals = self.__memmap__[k]['DATA'] units = get_uamiv_units(self.NAME, k, self._aerosol_names) return PseudoIOAPIVariable(self, k, 'f', dimensions, values=outvals, units=units)
def __variables(self,proc_spc): if proc_spc=='TFLAG': time=self.variables['TIME_%s' % self.spcnames[0][1].strip()] date=self.variables['DATE_%s' % self.spcnames[0][1].strip()] self.variables['TFLAG']=PseudoNetCDFVariable(self,'proc_spc','i',('TSTEP','VAR','DATE-TIME'),values=ConvertCAMxTime(date[:,0,0,0],time[:,0,0,0],len(self.dimensions['VAR']))) return self.variables['TFLAG'] self.variables.clear() for k in self.proc_dict: proc=proc_spc[:len(k)] spc=proc_spc[len(k)+1:] if proc==k and spc.ljust(10) in self.spcnames['SPECIES'].tolist(): spcprocs=self.__readalltime(spc) for p,plong in self.proc_dict.items(): var_name=p+'_'+spc # IPR units are consistent with 'IPR' if p == 'UCNV': units = 'm**3/mol' elif p == 'AVOL': units = 'm**3' else: units = get_uamiv_units('IPR', spc) self.variables[var_name] = PseudoNetCDFVariable(self,var_name,'f',('TSTEP','LAY','ROW','COL'), values=spcprocs[p], units=units, var_desc=(var_name).ljust(16), long_name=(var_name).ljust(16)) del spcprocs return self.variables[proc_spc] raise KeyError("Bad!")
def __variables(self, k): dimensions = ("TSTEP", "LAY", "ROW", "COL") ntimes = len(self.dimensions["TSTEP"]) nx = len(self.dimensions["COL"]) ny = len(self.dimensions["ROW"]) nz = len(self.dimensions["LAY"]) outvals = self.__memmap__[self.CURRENT_GRID][k]["DATA"][:, :, :, :] unit = get_uamiv_units("INSTANT ", k) return PseudoNetCDFVariable(self, k, "f", dimensions, values=outvals, units=unit)
def __variables(self, k): dimensions = ('TSTEP', 'LAY', 'ROW', 'COL') outvals = self.__memmap__[self.CURRENT_GRID][k]['DATA'][:, :, :, :] unit = get_uamiv_units('INSTANT ', k) return PseudoNetCDFVariable(self, k, 'f', dimensions, values=outvals, units=unit)
def __variables(self,k): spc_index=self.__var_names__.index(k) edgename = k.split('_')[0] spcname = k[len(edgename)+1:] if edgename in ('WEST', 'EAST'): dimensions=('TSTEP', 'ROW', 'LAY') else: dimensions=('TSTEP', 'COL', 'LAY') outvals=self.__memmap__[spcname][edgename]['DATA'] units = get_uamiv_units(self.NAME, spcname) return PseudoIOAPIVariable(self,k,'f',dimensions,values=outvals, units = units)
def __decorator(self,name,pncfv): spc = name.split('_')[-1] prc = name.split('_')[0] # IPR units are consistent with 'IPR' if prc == 'UCNV': units = 'm**3/mol' elif prc == 'AVOL': units = 'm**3' else: units = get_uamiv_units('IPR', spc) decor=lambda k: dict(units=units, var_desc=k.ljust(16), long_name=k.ljust(16)) for k,v in decor(name).items(): setattr(pncfv,k,v) return pncfv
def __decorator(self, name, pncfv): spc = name.split('_')[-1] prc = name.split('_')[0] # IPR units are consistent with 'IPR' if prc == 'UCNV': units = 'm**3/mol' elif prc == 'AVOL': units = 'm**3' else: units = get_uamiv_units('IPR', spc) decor = lambda k: dict( units=units, var_desc=k.ljust(16), long_name=k.ljust(16)) for k, v in decor(name).items(): setattr(pncfv, k, v) return pncfv
def __var_get(self,key): units = get_uamiv_units(self.name, key) spcnames = map(str.strip, self.spcnames) if self.name=='EMISSIONS ': constr=lambda spc: self.getArray(nspec=spcnames.index(spc)).squeeze()[:,newaxis,:,:] decor=lambda spc: dict(units=units, var_desc=spc, long_name=spc.ljust(16)) else: constr=lambda spc: self.getArray(nspec=spcnames.index(spc)).squeeze().reshape(map(len, (self.dimensions['TSTEP'],self.dimensions['LAY'],self.dimensions['ROW'],self.dimensions['COL']))) decor=lambda spc: dict(units=units, var_desc=spc.ljust(16), long_name=spc.ljust(16)) values=constr(key) var=self.createVariable(key,'f',('TSTEP','LAY','ROW','COL')) var[:] = values for k,v in decor(key).items(): setattr(var,k,v) return var
def __var_get(self,key): units = get_uamiv_units(self.name, key, self._aerosol_names) spcnames = map(str.strip, self.spcnames) if self.name=='EMISSIONS ': constr=lambda spc: self.getArray(nspec=spcnames.index(spc)).squeeze()[:,newaxis,:,:] decor=lambda spc: dict(units=units, var_desc=spc, long_name=spc.ljust(16)) else: constr=lambda spc: self.getArray(nspec=spcnames.index(spc)).squeeze().reshape(map(len, (self.dimensions['TSTEP'],self.dimensions['LAY'],self.dimensions['ROW'],self.dimensions['COL']))) decor=lambda spc: dict(units=units, var_desc=spc.ljust(16), long_name=spc.ljust(16)) values=constr(key) var=self.createVariable(key,'f',('TSTEP','LAY','ROW','COL')) var[:] = values for k,v in decor(key).items(): setattr(var,k,v) return var
def __variables(self, proc_spc): if proc_spc == 'TFLAG': time = self.variables['TIME_%s' % char.decode(self.spcnames)[0][1].strip()] date = self.variables['DATE_%s' % char.decode(self.spcnames[0])[1].strip()] tmpvals = ConvertCAMxTime(date[:, 0, 0, 0], time[:, 0, 0, 0], len(self.dimensions['VAR'])) tmpvar = pncvar(self, 'proc_spc', 'i', ('TSTEP', 'VAR', 'DATE-TIME'), values=tmpvals) self.variables['TFLAG'] = tmpvar return self.variables['TFLAG'] self.variables.clear() spcstrs = char.decode(self.spcnames['SPECIES']).tolist() for k in self.proc_dict: proc = proc_spc[:len(k)] spc = proc_spc[len(k) + 1:] if proc == k and spc.ljust(10) in spcstrs: spcprocs = self.__readalltime(spc) for p, plong in self.proc_dict.items(): var_name = p + '_' + spc # IPR units are consistent with 'IPR' if p == 'UCNV': units = 'm**3/mol' elif p == 'AVOL': units = 'm**3' else: units = get_uamiv_units('IPR', spc) tmpvar = pncvar(self, var_name, 'f', ('TSTEP', 'LAY', 'ROW', 'COL'), values=spcprocs[p], units=units, var_desc=var_name.ljust(16), long_name=var_name.ljust(16)) self.variables[var_name] = tmpvar del spcprocs return self.variables[proc_spc] raise KeyError("Bad!")