datasets['reported.maxt'].update(data_attrs) datasets['reported.mint'].update(data_attrs) # time attributes used by date grid handlers to access data by date time_attrs = factory.tool.datasets.time.attrs datasets['reported.maxt'].update(time_attrs) datasets['reported.mint'].update(time_attrs) # time attributes used by date grid handlers to access provenance by date provenance_attrs = factory.tool.datasets.provenance.attrs # copy frost temperature file to frapple build directory reader = Hdf5DateGridFileReader(frost_filepath) season_dates['last_valid_date'] = \ reader.datasetAttribute('reported.maxt', 'last_valid_date') season_dates['last_obs_date'] = season_dates['last_valid_date'] print 'Copying : ', reader.filepath manager = Hdf5DateGridFileManager(tool_filepath, mode='a') print 'To : ', manager.filepath copyHdf5DategridFile(reader, manager, factory.tool.fileattrs.attrs, datasets, exclusions) del reader manager.open('a') manager.move('reported', 'temps') manager.close() # copy forecast tempratures to the build file if add_forecast: fcast_reader = factory.sourceFileReader(source, fcast_year, region, 'temps', filepath=shared_filepath)
def _loadManagerAttributes_(self): Hdf5DateGridFileManager._loadManagerAttributes_(self) self._loadProjectFileAttributes_()
def __init__(self, filepath, registry=None, mode='r'): if registry is None: self._preInitProject_(REGBASE) else: self._preInitProject_(registry) Hdf5DateGridFileManager.__init__(self, filepath, mode) hdf5ReaderPatch(self) self._postInitProject_()
def __init__(self, filepath, registry, mode='r'): self._preInitProject_(registry) Hdf5DateGridFileManager.__init__(self, filepath, mode) hdf5ReaderPatch(self) self._postInitProject_()
frost_filepath = os.path.join(frost_dirpath, frost_filename) template = CONFIG.filenames.tempext build_filename = template % template_args build_dirpath = \ os.path.join(dirpaths.build, region_dirpath, source_dirpath, 'temps') build_filepath = os.path.join(build_dirpath, build_filename) if not (os.path.exists(build_dirpath)): os.makedirs(build_dirpath) elif os.path.exists(build_filepath): os.remove(build_filepath) #reader = FrostTempFileReader(target_year, filepath=frost_filepath) reader = Hdf5DateGridFileReader(frost_filepath) print 'Copying : ', reader.filepath #manager = FrostTempFileManager(target_year, mode='a', filepath=build_filepath) manager = Hdf5DateGridFileManager(build_filepath, mode='a') print 'To : ', manager.filepath manager.setFileAttributes(**dict(reader.getFileAttributes())) manager.close() for name in reader.group_names: if name != 'forecast': attrs = reader.getGroupAttributes(name) if debug: print "creating '%s' group" % name manager.open('a') manager.createGroup(name) manager.setGroupAttributes(name, **attrs) manager.close() for name in reader.dataset_names:
datasets['gdd.L43H86.daily'] = deepcopy(data_attrs) provenance_attrs = factory.tool.datasets.provenance.attrs datasets['Carolina.provenance'] = deepcopy(provenance_attrs) datasets['gdd.L43H86.provenance'] = deepcopy(provenance_attrs) # time attributes used by date grid handlers to access data by date time_attrs = factory.tool.datasets.time.attrs datasets['Carolina.accumulated'].update(time_attrs) datasets['Carolina.daily'].update(time_attrs) datasets['Carolina.provenance'].update(time_attrs) datasets['gdd.L43H86.daily'].update(time_attrs) datasets['gdd.L43H86.provenance'].update(time_attrs) # copy frost chill file to frapple build directory reader = Hdf5DateGridFileReader(frost_filepath) print 'Copying : ', reader.filepath builder = Hdf5DateGridFileManager(chill_filepath, mode='a') print 'To : ', builder.filepath copyHdf5DategridFile(reader, builder, factory.tool.fileattrs.attrs, datasets, exclusions) builder.close() del builder, reader # set last obs date in relevant datasets builder = AppleChillGridManager(target_year, mode='a', filepath=chill_filepath) for name in builder.dataset_names: builder.open('a') attrs = builder.getDatasetAttributes(name) if 'last_valid_date' in attrs: builder.setDatasetAttribute(name, 'last_obs_date', attrs['last_valid_date']) builder.close()