def output_init(self): '''Initialize netCDF4 output file Creates an empty netCDF4 output file with the necessary dimensions, variables, attributes and coordinate reference system specification (crs). ''' outputfile = self.engine.get_config_value('netcdf', 'outputfile') outputvars = self.engine.get_config_value('netcdf', 'outputvars') attributes = self.engine.get_config_value('netcdf', 'attributes') crs = self.engine.get_config_value('netcdf', 'crs') if outputfile is not None and outputvars is not None: if not self.restart or not os.path.exists(outputfile): logger.debug('Initializing output...') # get dimension names for each variable variables = { v : { 'dimensions' : self.engine.get_dimensions(v) } for v in outputvars } for v in variables.iterkeys(): logger.info('Creating netCDF output for "%s"' % v) netcdf.initialize(outputfile, self.read_dimensions(), variables=variables, attributes=attributes, crs=crs)
def output_init(self): '''Initialize netCDF4 output file Creates an empty netCDF4 output file with the necessary dimensions, variables, attributes and coordinate reference system specification (crs). ''' if self.engine.config.has_key('netcdf'): logger.debug('Initializing output...') cfg = self.engine.config['netcdf'] # get dimension names for each variable variables = { v : { 'dimensions' : self.engine.get_dimensions(v) } for v in cfg['outputvars'] } netcdf.initialize(cfg['outputfile'], self.read_dimensions(), variables=variables, attributes=cfg['attributes'], crs=cfg['crs']) self.iout = 0
def output_init(self): '''Initialize netCDF4 output file Creates an empty netCDF4 output file with the necessary dimensions, variables, attributes and coordinate reference system specification (crs). ''' outputfile = self.engine.get_config_value('netcdf', 'outputfile') outputvars = self.engine.get_config_value('netcdf', 'outputvars') attributes = self.engine.get_config_value('netcdf', 'attributes') crs = self.engine.get_config_value('netcdf', 'crs') # add zb difference variables outputvars.append(u'difference_zb_aeolis') outputvars.append(u'difference_zb_xbeach') if outputfile is not None and outputvars is not None: if not self.restart or not os.path.exists(outputfile): logger.debug('Initializing output...') # get dimension names for each variable variables = { v: {'dimensions': self.engine.get_dimensions(v)} for v in outputvars } # remove from outputvars, later calculated separately: outputvars.remove(u'difference_zb_aeolis') outputvars.remove(u'difference_zb_xbeach') for v in variables.iterkeys(): logger.info('Creating netCDF output for "%s"' % v) netcdf.initialize(outputfile, self.read_dimensions(), variables=variables, attributes=attributes, crs=crs)