def apply(source, name, weights, esmf_format, output): from utools.regrid.core_esmf import create_weighted_output log_entry('info', 'Starting weight application for "weights": {}'.format(weights), rank=0) create_weighted_output(esmf_format, source, weights, output, name) log_entry('info', 'Finished weight application for "weights": {}'.format(weights), rank=0)
def merge(catchment_directory, weight_directory, master_path): from utools.regrid.core_ocgis import create_merged_weights weight_files = [] esmf_unstructured = [] def _collect_and_sort_(seq, directory, startswith): for l in os.listdir(directory): if l.startswith(startswith): seq.append(os.path.join(directory, l)) seq.sort() _collect_and_sort_(weight_files, weight_directory, 'weights_') _collect_and_sort_(esmf_unstructured, catchment_directory, 'catchments_esmf_') log_entry('info', 'Started merging netCDF files', rank=0) create_merged_weights(weight_files, esmf_unstructured, master_path) log_entry('info', 'Finished merging netCDF files', rank=0)
def convert(source_uid, source, esmf_format, feature_class, config_path, dest_crs_index, node_threshold, split, debug): from utools.prep.prep_shapefiles import convert_to_esmf_format log_entry('info', 'Started converting to ESMF format: {}'.format(source), rank=0) # Set the feature class name even if it is None. Feature class name is required for a file geodatabase. driver_kwargs = {'feature_class': feature_class} # If there is a destination CRS, read in the value and convert to a spatial reference object for the geometry # manager. if dest_crs_index is not None: log.debug(('dest_crs_index', dest_crs_index)) dest_crs_index = dest_crs_index.split(',') if len(dest_crs_index) == 1: crs_section = None crs_option = dest_crs_index[0] elif len(dest_crs_index) == 2: crs_section, crs_option = dest_crs_index else: raise NotImplementedError(len(dest_crs_index)) sp = SafeConfigParser() sp.read(config_path) crs_wkt = sp.get(crs_section, crs_option) dest_crs = osgeo.osr.SpatialReference() dest_crs.ImportFromWkt(crs_wkt) else: dest_crs = None convert_to_esmf_format(esmf_format, source, source_uid, node_threshold=node_threshold, driver_kwargs=driver_kwargs, debug=debug, dest_crs=dest_crs, split_interiors=split) log_entry('info', 'Finished converting to ESMF format: {}'.format(source), rank=0)