def update_dataset_window_for_complex(self, device_dataset_id='', old_window=None, new_window=None, site_dataset_id=''): if old_window is None or new_window is None: raise BadRequest("Windows must be specified") site_path = self._get_coverage_path(site_dataset_id) extents = self._list_reference_extents(site_dataset_id) if device_dataset_id not in extents: raise BadRequest("Dataset %s does not reference %s at all." % (site_dataset_id, device_dataset_id)) extent_list = extents[device_dataset_id] listings = [] for i, pairing in enumerate(extent_list): if list(pairing.time_extents) == list(old_window): pairing = ReferenceCoverageExtents('', device_dataset_id, time_extents=new_window) listings.append(pairing) cov = ComplexCoverage.load(site_path) cov.set_reference_coverage_extents(device_dataset_id, listings, append=False) cov.close()
def _create_complex_coverage(cls, dataset_id, description, parameter_dict): pdict = ParameterDictionary.load(parameter_dict) file_root = FileSystem.get_url(FS.CACHE, 'datasets') ccov = ComplexCoverage( file_root, dataset_id, 'Complex Coverage for %s' % dataset_id, parameter_dictionary=pdict, complex_type=ComplexCoverageType.TEMPORAL_AGGREGATION) return ccov
def _splice_coverage(cls, dataset_id, scov): file_root = FileSystem.get_url(FS.CACHE,'datasets') vcov = cls._get_coverage(dataset_id,mode='a') scov_pth = scov.persistence_dir if isinstance(vcov.reference_coverage, SimplexCoverage): ccov = ComplexCoverage(file_root, uuid4().hex, 'Complex coverage for %s' % dataset_id, reference_coverage_locs=[vcov.head_coverage_path,], parameter_dictionary=ParameterDictionary(), complex_type=ComplexCoverageType.TEMPORAL_AGGREGATION) log.info('Creating Complex Coverage: %s', ccov.persistence_dir) ccov.append_reference_coverage(scov_pth) ccov_pth = ccov.persistence_dir ccov.close() vcov.replace_reference_coverage(ccov_pth) elif isinstance(vcov.reference_coverage, ComplexCoverage): log.info('Appending simplex coverage to complex coverage') vcov.reference_coverage.append_reference_coverage(scov_pth) vcov.refresh() vcov.close()
def add_dataset_window_to_complex(self, device_dataset_id='', window=None, site_dataset_id=''): ''' Adds target dataset to the complex coverage for the window specified ''' if window is None: raise BadRequest("Window must be specified") site_path = self._get_coverage_path(site_dataset_id) device_path = self._get_coverage_path(device_dataset_id) ccov = ComplexCoverage.load(site_path) ccov.append_reference_coverage(device_path, ReferenceCoverageExtents('', device_dataset_id, time_extents=window)) ccov.close()
def add_dataset_window_to_complex(self, device_dataset_id='', window=None, site_dataset_id=''): ''' Adds target dataset to the complex coverage for the window specified ''' if window is None: raise BadRequest("Window must be specified") device_path = self._get_coverage_path(device_dataset_id) site_path = self._get_coverage_path(site_dataset_id) ccov = ComplexCoverage.load(site_path) ccov.append_reference_coverage( device_path, ReferenceCoverageExtents('', device_dataset_id, time_extents=window)) ccov.close()
def _splice_coverage(cls, dataset_id, scov): file_root = FileSystem.get_url(FS.CACHE, 'datasets') vcov = cls._get_coverage(dataset_id, mode='a') scov_pth = scov.persistence_dir if isinstance(vcov.reference_coverage, SimplexCoverage): ccov = ComplexCoverage( file_root, uuid4().hex, 'Complex coverage for %s' % dataset_id, reference_coverage_locs=[ vcov.head_coverage_path, ], parameter_dictionary=ParameterDictionary(), complex_type=ComplexCoverageType.TEMPORAL_AGGREGATION) log.info('Creating Complex Coverage: %s', ccov.persistence_dir) ccov.append_reference_coverage(scov_pth) ccov_pth = ccov.persistence_dir ccov.close() vcov.replace_reference_coverage(ccov_pth) elif isinstance(vcov.reference_coverage, ComplexCoverage): log.info('Appending simplex coverage to complex coverage') vcov.reference_coverage.append_reference_coverage(scov_pth) vcov.refresh() vcov.close()