def model_overview(grid_file): """ :param grid_file: path to hdf5 grid file :returns formatted string like so:: threedicore version: 0-20180219-587b996-1 has 1d: True has 2d: True has groundwater: False has levees: True """ grid = GridH5Admin(grid_file) _attrs = OrderedDict([ ('model_slug', ''), ('threedicore_version', ''), ('threedi_version', ''), ('has_1d', ''), ('has_2d', ''), ('has_groundwater', ''), ('has_levees', ''), ('has_breaches', ''), ('has_pumpstations', ''), ]) for k in six.iterkeys(_attrs): if not hasattr(grid, k): continue attr = getattr(grid, k) if attr is None: continue _attrs[k] = '{:24} {}'.format(k.replace('_', ' ') + ':', attr) return '\n'.join((v for v in _attrs.values() if v != '')) + '\n'
def __init__(self, gridadmin_file, export_method='to_shape', target_epsg_code=None, destination=None, indent=None): """ :param gridadmin_file: hdf5 file (full path) :param export_method: (str) 'to_shape', 'to_gpkg' or 'to_geojson' :param target_epsg_code: (str) epsg code :param destination: path to folder the export folder, defaults to the same folder as the gridadmin_file """ self.ga = GridH5Admin(gridadmin_file) self._export_method = export_method self._extension = EXPORT_METHOD_TO_EXTENSION_MAP[export_method] if not target_epsg_code: self._epsg = self.ga.epsg_code else: self._epsg = target_epsg_code if not destination: self._dest = os.path.split(gridadmin_file)[0] else: self._dest = destination self._indent = indent
def setUp(self): self.parser = GridH5Admin(grid_admin_h5_file) d = tempfile.mkdtemp() self.f = os.path.join(d, "test_lines.shp")
def setUp(self): self.parser = GridH5Admin(grid_admin_h5_file)