Skip to content

Commit

Permalink
Fix #348
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderJuestel committed Jul 21, 2024
1 parent ed518bd commit 21c0372
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 64 deletions.
1 change: 0 additions & 1 deletion gemgis/download_gemgis_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def download_tutorial_data(filename: str,
create_pooch : Create pooch class to fetch files from a website.
"""
try:
import pooch
from pooch import HTTPDownloader
download = HTTPDownloader(progressbar=False)
except ModuleNotFoundError:
Expand Down
1 change: 0 additions & 1 deletion gemgis/gemgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import numpy as np
# import scooby
import pandas as pd
from pandas.core import frame
import rasterio
import geopandas as gpd
import rasterio.transform
Expand Down
42 changes: 21 additions & 21 deletions gemgis/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def extract_lithologies(geo_model,
raise ModuleNotFoundError(
'Matplotlib package is not installed. Use pip install matplotlib to install the latest version')

# Trying to import gempy but returning error if gempy is not installed
try:
import gempy as gp
except ModuleNotFoundError:
raise ModuleNotFoundError(
'GemPy package is not installed. Use pip install gempy to install the latest version')
## Trying to import gempy but returning error if gempy is not installed
#try:
# import gempy as gp
#except ModuleNotFoundError:
# raise ModuleNotFoundError(
# 'GemPy package is not installed. Use pip install gempy to install the latest version')

shape = geo_model._grid.topography.values_2d[:, :, 2].shape

Expand Down Expand Up @@ -502,11 +502,11 @@ def crop_block_to_topography(geo_model) -> pv.core.pointset.UnstructuredGrid:
"""

# Trying to import GemPy
try:
import gempy as gp
except ModuleNotFoundError:
raise ModuleNotFoundError(
'GemPy package is not installed. Use pip install gempy to install the latest version')
#try:
# import gempy as gp
#except ModuleNotFoundError:
# raise ModuleNotFoundError(
# 'GemPy package is not installed. Use pip install gempy to install the latest version')

# Trying to import PVGeo
try:
Expand Down Expand Up @@ -880,7 +880,7 @@ def save_qgis_qml_file(gdf: gpd.geodataframe.GeoDataFrame,
raise TypeError('gdf must be a GeoDataFrame')

# Checking that the geometry column is present in the gdf
if not 'geometry' in gdf:
if 'geometry' not in gdf:
raise ValueError('geometry column not present in GeoDataFrame')

# Checking that all geometries are Polygons
Expand All @@ -892,15 +892,15 @@ def save_qgis_qml_file(gdf: gpd.geodataframe.GeoDataFrame,
raise TypeError('value column name must be of type string')

# Checking that the value column is present in the gdf
if not value in gdf:
if value not in gdf:
raise ValueError('"%s" not in gdf. Please provide a valid column name.' % value)

# Checking that the color column is of type string
if not isinstance(color, str):
raise TypeError('color column name must be of type string')

# Checking that the value column is present in the gdf
if not color in gdf:
if color not in gdf:
raise ValueError('"%s" not in gdf. Please provide a valid column name.' % color)

# Creating RGBA column from hex colors
Expand Down Expand Up @@ -1058,19 +1058,19 @@ def clip_fault_of_gempy_model(geo_model,
"""
# Trying to import gempy but returning error if gempy is not installed
try:
import gempy as gp
except ModuleNotFoundError:
raise ModuleNotFoundError(
'GemPy package is not installed. Use pip install gempy to install the latest version')
#try:
# import gempy as gp
#except ModuleNotFoundError:
# raise ModuleNotFoundError(
# 'GemPy package is not installed. Use pip install gempy to install the latest version')

# Checking that the fault is provided as string
if not isinstance(fault, str):
raise TypeError('Faults must be provided as one string for one fault ')

# Checking that the fault is a fault of the geo_model
if isinstance(fault, str):
if not fault in geo_model.surfaces.df['surface'][geo_model.surfaces.df['isFault'] == True].tolist():
if fault not in geo_model.surfaces.df['surface'][geo_model.surfaces.df['isFault'] == True].tolist():
raise ValueError('Fault is not part of the GemPy geo_model')

# Getting the fault DataFrames
Expand All @@ -1087,7 +1087,7 @@ def clip_fault_of_gempy_model(geo_model,

# Checking that the correct values are provided for the parameter which
if isinstance(which, str):
if not which in ['first', 'last', 'both']:
if which not in ['first', 'last', 'both']:
raise ValueError('The options for the parameter "which" include "first", "last", or "both"')

# Checking that the i size is of type int or float
Expand Down
3 changes: 1 addition & 2 deletions gemgis/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
import pandas as pd
import geopandas as gpd
from typing import Union, List, Sequence, Optional, Iterable, Dict, Tuple
from rasterio.mask import mask
from shapely.geometry import box, Polygon, LineString
from shapely.geometry import Polygon, LineString
import shapely
from pathlib import Path
import affine
Expand Down
15 changes: 7 additions & 8 deletions gemgis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,11 @@ def show_number_of_data_points(geo_model):
"""

# Trying to import gempy but returning error if gempy is not installed
try:
import gempy as gp
except ModuleNotFoundError:
raise ModuleNotFoundError(
'GemPy package is not installed. Use pip install gempy to install the latest version')
#try:
# import gempy as gp
#except ModuleNotFoundError:
# raise ModuleNotFoundError(
# 'GemPy package is not installed. Use pip install gempy to install the latest version')

# Create empty lists to store values
no_int = []
Expand Down Expand Up @@ -2405,7 +2405,6 @@ def rotate_gempy_input_data(extent: Union[np.ndarray, shapely.geometry.Polygon,
list(extent_polygon.centroid.coords)[0][1]))

# Creating Bounding Box
bbox = box(*extent_rotated.bounds)
extent = [extent_rotated.bounds[0],
extent_rotated.bounds[2],
extent_rotated.bounds[1],
Expand Down Expand Up @@ -2636,7 +2635,7 @@ def get_cdp_linestring_of_seismic_data(path_in: str,
"""
# Trying to import segysak but returning error if segysak is not installed
try:
from segysak.segy import segy_loader, segy_writer
from segysak.segy import segy_loader
except ModuleNotFoundError:
raise ModuleNotFoundError(
'segysak package is not installed. Use pip install segysak to install the latest version')
Expand Down Expand Up @@ -2720,7 +2719,7 @@ def get_cdp_points_of_seismic_data(path_in: str,
"""
# Trying to import segysak but returning error if segysak is not installed
try:
from segysak.segy import segy_loader, segy_writer
from segysak.segy import segy_loader
except ModuleNotFoundError:
raise ModuleNotFoundError(
'segysak package is not installed. Use pip install segysak to install the latest version')
Expand Down
35 changes: 4 additions & 31 deletions gemgis/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def load_wms(url: str,

# Requesting the WMS Service or returning an error if a module may be missing
try:
wms = owslib.wms.WebMapService(url,
version=version)
wms = WebMapService(url,
version=version)

return wms
except requests.exceptions.SSLError:
Expand Down Expand Up @@ -197,11 +197,7 @@ def load_as_map(url: str,

# Trying to import owslib but returning error if owslib is not installed
try:
import owslib
from owslib import util
from owslib.wms import WebMapService
from owslib.wfs import WebFeatureService
from owslib.wcs import WebCoverageService
__all__ = [util]
except ModuleNotFoundError:
raise ModuleNotFoundError(
Expand Down Expand Up @@ -404,11 +400,7 @@ def load_as_array(url: str,

# Trying to import owslib but returning error if owslib is not installed
try:
import owslib
from owslib import util
from owslib.wms import WebMapService
from owslib.wfs import WebFeatureService
from owslib.wcs import WebCoverageService
__all__ = [util]
except ModuleNotFoundError:
raise ModuleNotFoundError(
Expand Down Expand Up @@ -557,9 +549,7 @@ def load_wfs(url: str): # -> owslib.wfs.WebFeatureService:
try:
import owslib
from owslib import util
from owslib.wms import WebMapService
from owslib.wfs import WebFeatureService
from owslib.wcs import WebCoverageService
__all__ = [util]
except ModuleNotFoundError:
raise ModuleNotFoundError(
Expand All @@ -578,7 +568,7 @@ def load_wfs(url: str): # -> owslib.wfs.WebFeatureService:

# Requesting the WMS Service or returning an error if a module may be missing
try:
wfs = owslib.wfs.WebFeatureService(url)
wfs = WebFeatureService(url)

return wfs

Expand Down Expand Up @@ -634,9 +624,6 @@ def load_as_gpd(url: str,
try:
import owslib
from owslib import util
from owslib.wms import WebMapService
from owslib.wfs import WebFeatureService
from owslib.wcs import WebCoverageService
__all__ = [util]
except ModuleNotFoundError:
raise ModuleNotFoundError(
Expand Down Expand Up @@ -731,8 +718,6 @@ def load_wcs(url: str): # -> owslib.wcs.WebCoverageService:
try:
import owslib
from owslib import util
from owslib.wms import WebMapService
from owslib.wfs import WebFeatureService
from owslib.wcs import WebCoverageService
__all__ = [util]
except ModuleNotFoundError:
Expand All @@ -744,7 +729,7 @@ def load_wcs(url: str): # -> owslib.wcs.WebCoverageService:
raise TypeError('URL must be of type string')

# Loading the WCS Layer
wcs = owslib.wcs.WebCoverageService(url)
wcs = WebCoverageService(url)

return wcs

Expand Down Expand Up @@ -810,11 +795,7 @@ def create_request(wcs_url: str,

# Trying to import owslib but returning error if owslib is not installed
try:
import owslib
from owslib import util
from owslib.wms import WebMapService
from owslib.wfs import WebFeatureService
from owslib.wcs import WebCoverageService
__all__ = [util]
except ModuleNotFoundError:
raise ModuleNotFoundError(
Expand Down Expand Up @@ -904,11 +885,7 @@ def load_as_file(url: str,

# Trying to import owslib but returning error if owslib is not installed
try:
import owslib
from owslib import util
from owslib.wms import WebMapService
from owslib.wfs import WebFeatureService
from owslib.wcs import WebCoverageService
__all__ = [util]
except ModuleNotFoundError:
raise ModuleNotFoundError(
Expand Down Expand Up @@ -1018,11 +995,7 @@ def load_as_files(wcs_url: str,

# Trying to import owslib but returning error if owslib is not installed
try:
import owslib
from owslib import util
from owslib.wms import WebMapService
from owslib.wfs import WebFeatureService
from owslib.wcs import WebCoverageService
__all__ = [util]
except ModuleNotFoundError:
raise ModuleNotFoundError(
Expand Down

0 comments on commit 21c0372

Please sign in to comment.