Skip to content

Commit

Permalink
style: style fixes by ruff and autoformatting by black
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlangrose authored and github-actions[bot] committed Feb 8, 2024
1 parent eb4e764 commit c884b90
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 100 deletions.
24 changes: 5 additions & 19 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@
"myst_parser",
]

source_suffix = {
".rst": "restructuredtext",
".txt": "markdown",
".md": "markdown",
}
source_suffix = {".rst": "restructuredtext", ".txt": "markdown", ".md": "markdown"}

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand All @@ -84,18 +80,12 @@
"url": "https://github.com/loop3d/map2loop",
"icon": "fab fa-github-square",
},
{
"name": "Twitter",
"url": "https://twitter.com/loop3d",
"icon": "fab fa-twitter-square",
},
{"name": "Twitter", "url": "https://twitter.com/loop3d", "icon": "fab fa-twitter-square"},
],
# "navbar_start": ["navbar-logo", "navbar-version"],
# "use_edit_page_button": True,
"collapse_navigation": True,
"external_links": [
{"name": "Loop3d", "url": "https://www.loop3d.org"},
],
"external_links": [{"name": "Loop3d", "url": "https://www.loop3d.org"}],
}
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
Expand All @@ -109,18 +99,14 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
autosummary_mock_imports = [
"LoopStructural.interpolators._cython",
]
autosummary_mock_imports = ["LoopStructural.interpolators._cython"]
# Sphinx gallery examples
from LoopStructural.visualisation.sphinx_scraper import Scraper as LoopScraper
from sphinx_gallery.sorting import ExampleTitleSortKey

sphinx_gallery_conf = {
"examples_dirs": ["../../examples/"],
"gallery_dirs": [
"_auto_examples/"
], # path to where to save gallery generated output
"gallery_dirs": ["_auto_examples/"], # path to where to save gallery generated output
"image_scrapers": ("matplotlib", LoopScraper()),
"within_subsection_order": ExampleTitleSortKey,
"reference_url": {"LoopStructural": None},
Expand Down
5 changes: 2 additions & 3 deletions examples/plot_hamersley.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
Hamersley, Western Australia
============================
"""

from map2loop.project import Project
from map2loop.m2l_enums import VerboseLevel, Datatype
from map2loop.sorter import (
SorterAlpha,
)
from map2loop.sorter import SorterAlpha
from map2loop.sampler import SamplerSpacing

####################################################################
Expand Down
15 changes: 7 additions & 8 deletions map2loop/aus_state_urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class AustraliaStateUrls:
aus_geology_urls = {
"WA": "http://13.211.217.129:8080/geoserver/loop/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=loop:500k_geol_28350&bbox={BBOX_STR}&srs=EPSG:28350&outputFormat=shape-zip",
Expand All @@ -8,7 +7,7 @@ class AustraliaStateUrls:
"NSW": "http://13.211.217.129:8080/geoserver/NSW/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=NSW:ge_rockunit_lao2&bbox={BBOX_STR}&srs=EPSG:28355&outputFormat=shape-zip",
"ACT": "",
"TAS": "http://13.211.217.129:8080/geoserver/TAS/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=TAS:geol_poly_250_28355&bbox={BBOX_STR}&srs=EPSG:28355&outputFormat=shape-zip",
"NT": ""
"NT": "",
}
aus_structure_urls = {
"WA": "http://13.211.217.129:8080/geoserver/loop/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=loop:waroxi_wa_28350&bbox={BBOX_STR}&srs=EPSG:28350&outputFormat=shape-zip",
Expand All @@ -18,7 +17,7 @@ class AustraliaStateUrls:
"NSW": "http://13.211.217.129:8080/geoserver/NSW/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=NSW:lao_struct_pt&bbox={BBOX_STR}&srs=EPSG:28355&outputFormat=shape-zip",
"ACT": "",
"TAS": "http://13.211.217.129:8080/geoserver/TAS/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=TAS:geol_struc_250_28355&bbox={BBOX_STR}&srs=EPSG:28355&outputFormat=shape-zip",
"NT": ""
"NT": "",
}
aus_fault_urls = {
"WA": "http://13.211.217.129:8080/geoserver/loop/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=loop:500k_faults_28350&bbox={BBOX_STR}&srs=EPSG:28350&outputFormat=shape-zip",
Expand All @@ -28,7 +27,7 @@ class AustraliaStateUrls:
"NSW": "http://13.211.217.129:8080/geoserver/NSW/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=NSW:faults_joined_left_contains_drop_dups&bbox={BBOX_STR}&srs=EPSG:28355&outputFormat=shape-zip",
"ACT": "",
"TAS": "http://13.211.217.129:8080/geoserver/TAS/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=TAS:geol_line_250_28355&bbox={BBOX_STR}&srs=EPSG:28355&outputFormat=shape-zip",
"NT": ""
"NT": "",
}
aus_fold_urls = {
"WA": "http://13.211.217.129:8080/geoserver/loop/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=loop:500k_faults_28350&bbox={BBOX_STR}&srs=EPSG:28350&outputFormat=shape-zip",
Expand All @@ -38,7 +37,7 @@ class AustraliaStateUrls:
"NSW": "http://13.211.217.129:8080/geoserver/NSW/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=NSW:folds_lao&bbox={BBOX_STR}&srs=EPSG:28355&outputFormat=shape-zip",
"ACT": "",
"TAS": "http://13.211.217.129:8080/geoserver/TAS/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=TAS:geol_line_250_28355&bbox={BBOX_STR}&srs=EPSG:28355&outputFormat=shape-zip",
"NT": ""
"NT": "",
}
aus_mindep_loopdata = {
"WA": "http://13.211.217.129:8080/geoserver/loop/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=loop:mindeps_2018_28350&bbox={BBOX_STR}&srs=EPSG:28350&outputFormat=shape-zip",
Expand All @@ -48,7 +47,7 @@ class AustraliaStateUrls:
"NSW": "http://13.211.217.129:8080/geoserver/NSW/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=NSW:nsw_mindeps&bbox={BBOX_STR}&srs=EPSG:28355&outputFormat=shape-zip",
"ACT": "",
"TAS": "http://13.211.217.129:8080/geoserver/VIC/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=VIC:mindeps_2018_28350&bbox={BBOX_STR}&srs=EPSG:28350&outputFormat=shape-zip",
"NT": ""
"NT": "",
}
aus_config_urls = {
"WA": "https://gist.githubusercontent.com/yohanderose/8f843de0dde531f009a3973cbdadcc9f/raw/cad97e91a71b4e4791629a6d384e2700095eb3b6/WA_meta.hjson",
Expand All @@ -58,7 +57,7 @@ class AustraliaStateUrls:
"NSW": "https://gist.githubusercontent.com/markjessell/0bcb02e6f3ae6da9f00f299b5f0a7f77/raw/09c8018e2d92c7f0051a45be4f9e19dc7cd9a30c/NSW.hjson",
"ACT": "",
"TAS": "https://gist.githubusercontent.com/markjessell/e6521f0d0b7a29014deb04996033554f/raw/296c364b618a49654e18eba10196fa3cc2aabd2f/TAS.hjson",
"NT": ""
"NT": "",
}
aus_clut_urls = {
"WA": "https://gist.githubusercontent.com/yohanderose/8f7e2d57db9086fbe1a7c651b9e25996/raw/9144994d162662ec015321699c3658a8dbf57def/WA_clut.csv",
Expand All @@ -68,5 +67,5 @@ class AustraliaStateUrls:
"NSW": "",
"ACT": "",
"TAS": "",
"NT": ""
"NT": "",
}
85 changes: 43 additions & 42 deletions map2loop/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,54 @@ class Config:
fold_config: dict
column names and keywords for fold mappings
"""

def __init__(self):
self.structure_config = {
"orientation_type": "dip direction",
"dipdir_column": "DIPDIR",
"dip_column": "DIP",
"description_column": "DESCRIPTION",
"bedding_text": "bedding",
"overturned_column": "DESCRIPTION",
"overturned_text": "overturned",
"objectid_column": "ID"
}
"orientation_type": "dip direction",
"dipdir_column": "DIPDIR",
"dip_column": "DIP",
"description_column": "DESCRIPTION",
"bedding_text": "bedding",
"overturned_column": "DESCRIPTION",
"overturned_text": "overturned",
"objectid_column": "ID",
}
self.geology_config = {
"unitname_column": "UNITNAME",
"alt_unitname_column": "CODE",
"group_column": "GROUP",
"supergroup_column": "SUPERGROUP",
"description_column": "DESCRIPTION",
"minage_column": "MIN_AGE",
"maxage_column": "MAX_AGE",
"rocktype_column": "ROCKTYPE1",
"alt_rocktype_column": "ROCKTYPE2",
"sill_text": "sill",
"intrusive_text": "intrusive",
"volcanic_text": "volcanic",
"objectid_column": "ID",
"ignore_codes": ["cover"]
}
"unitname_column": "UNITNAME",
"alt_unitname_column": "CODE",
"group_column": "GROUP",
"supergroup_column": "SUPERGROUP",
"description_column": "DESCRIPTION",
"minage_column": "MIN_AGE",
"maxage_column": "MAX_AGE",
"rocktype_column": "ROCKTYPE1",
"alt_rocktype_column": "ROCKTYPE2",
"sill_text": "sill",
"intrusive_text": "intrusive",
"volcanic_text": "volcanic",
"objectid_column": "ID",
"ignore_codes": ["cover"],
}
self.fault_config = {
"structtype_column": "FEATURE",
"fault_text": "fault",
"dip_null_value": "-999",
"dipdir_flag": "num",
"dipdir_column": "DIPDIR",
"dip_column": "DIP",
"dipestimate_column": "DIP_ESTIMATE",
"dipestimate_text": "'NORTH_EAST','NORTH',<rest of cardinals>,'NOT ACCESSED'",
"name_column": "NAME",
"objectid_column": "ID"
}
"structtype_column": "FEATURE",
"fault_text": "fault",
"dip_null_value": "-999",
"dipdir_flag": "num",
"dipdir_column": "DIPDIR",
"dip_column": "DIP",
"dipestimate_column": "DIP_ESTIMATE",
"dipestimate_text": "'NORTH_EAST','NORTH',<rest of cardinals>,'NOT ACCESSED'",
"name_column": "NAME",
"objectid_column": "ID",
}
self.fold_config = {
"structtype_column": "FEATURE",
"fold_text": "fold",
"description_column": "DESCRIPTION",
"synform_text": "syncline",
"foldname_column": "NAME",
"objectid_column": "ID"
}
"structtype_column": "FEATURE",
"fold_text": "fold",
"description_column": "DESCRIPTION",
"synform_text": "syncline",
"foldname_column": "NAME",
"objectid_column": "ID",
}

@beartype.beartype
def update_from_dictionary(self, dictionary: dict, lower: bool = False):
Expand Down
47 changes: 31 additions & 16 deletions map2loop/map2model_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re


class Map2ModelWrapper():
class Map2ModelWrapper:
"""
A wrapper around map2model functionality
Expand All @@ -25,6 +25,7 @@ class Map2ModelWrapper():
verbose_level: m2l_enum.VerboseLevel
A selection that defines how much console logging is output
"""

def __init__(self, map_data, verbose_level: VerboseLevel = VerboseLevel.NONE):
"""
The initialiser for the map2model wrapper
Expand Down Expand Up @@ -139,7 +140,7 @@ def run(self, verbose_level: VerboseLevel = None):
self.map_data.get_bounding_box(),
map2model_code_map,
verbose_level == VerboseLevel.NONE,
"None"
"None",
)
if verbose_level == VerboseLevel.ALL:
print("map2model log:")
Expand All @@ -148,21 +149,26 @@ def run(self, verbose_level: VerboseLevel = None):
print("map2model complete")

# Parse units sorted
units_sorted = pandas.read_csv(os.path.join(self.map_data.tmp_path, "map2model_data", "units_sorted.txt"), header=None, sep=' ')
units_sorted = pandas.read_csv(
os.path.join(self.map_data.tmp_path, "map2model_data", "units_sorted.txt"),
header=None,
sep=' ',
)
if units_sorted.shape == 0:
self.sorted_units = []
else:
self.sorted_units = list(units_sorted[5])

# Parse fault intersections
out = []
fault_fault_intersection_filename = os.path.join(self.map_data.tmp_path, "map2model_data", "fault-fault-intersection.txt")
if os.path.isfile(fault_fault_intersection_filename) and os.path.getsize(fault_fault_intersection_filename) > 0:
df = pandas.read_csv(
fault_fault_intersection_filename,
delimiter="{",
header=None,
)
fault_fault_intersection_filename = os.path.join(
self.map_data.tmp_path, "map2model_data", "fault-fault-intersection.txt"
)
if (
os.path.isfile(fault_fault_intersection_filename)
and os.path.getsize(fault_fault_intersection_filename) > 0
):
df = pandas.read_csv(fault_fault_intersection_filename, delimiter="{", header=None)
df[1] = list(df[1].str.replace("}", "", regex=False))
df[1] = [re.findall("\(.*?\)", i) for i in df[1]] # Valid escape for regex
df[0] = list(df[0].str.replace("^[0-9]*, ", "", regex=True))
Expand All @@ -173,15 +179,20 @@ def run(self, verbose_level: VerboseLevel = None):

for _, row in df.iterrows():
for i in numpy.arange(len(row[1])):
out += [[row[0], "Fault_"+row[1][i][0], row[1][i][1], float(row[1][i][2])]]
out += [[row[0], "Fault_" + row[1][i][0], row[1][i][1], float(row[1][i][2])]]

df_out = pandas.DataFrame(columns=["Fault1", "Fault2", "Type", "Angle"], data=out)
self.fault_fault_relationships = df_out

# Parse unit fault relationships
out = []
unit_fault_intersection_filename = os.path.join(self.map_data.tmp_path, "map2model_data", "unit-fault-intersection.txt")
if os.path.isfile(unit_fault_intersection_filename) and os.path.getsize(unit_fault_intersection_filename) > 0:
unit_fault_intersection_filename = os.path.join(
self.map_data.tmp_path, "map2model_data", "unit-fault-intersection.txt"
)
if (
os.path.isfile(unit_fault_intersection_filename)
and os.path.getsize(unit_fault_intersection_filename) > 0
):
df = pandas.read_csv(unit_fault_intersection_filename, header=None, sep='{')
df[1] = list(df[1].str.replace("}", "", regex=False))
df[1] = df[1].astype(str).str.split(", ")
Expand All @@ -190,17 +201,21 @@ def run(self, verbose_level: VerboseLevel = None):

for _, row in df.iterrows():
for i in numpy.arange(len(row[1])):
out += [[row[0], "Fault_"+row[1][i]]]
out += [[row[0], "Fault_" + row[1][i]]]

df_out = pandas.DataFrame(columns=["Unit", "Fault"], data=out)
self.unit_fault_relationships = df_out

# Parse unit unit relationships
units = []
links = []
graph_filename = os.path.join(self.map_data.tmp_path, "map2model_data", "graph_all_None.gml.txt")
graph_filename = os.path.join(
self.map_data.tmp_path, "map2model_data", "graph_all_None.gml.txt"
)
if os.path.isfile(graph_filename) and os.path.getsize(graph_filename) > 0:
with open(os.path.join(self.map_data.tmp_path, "map2model_data", "graph_all_None.gml.txt")) as file:
with open(
os.path.join(self.map_data.tmp_path, "map2model_data", "graph_all_None.gml.txt")
) as file:
contents = file.read()
segments = contents.split("\n\n")
for line in segments[0].split("\n"):
Expand Down
5 changes: 4 additions & 1 deletion map2loop/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Sampler(ABC):
Args:
ABC (ABC): Derived from Abstract Base Class
"""

def __init__(self):
"""
Initialiser of for Sampler
Expand Down Expand Up @@ -49,6 +50,7 @@ class SamplerDecimator(Sampler):
ie. decimation = 10 means take every tenth point
Note: This only works on data frames with lists of points with columns "X" and "Y"
"""

@beartype.beartype
def __init__(self, decimation: int = 1):
"""
Expand Down Expand Up @@ -76,7 +78,7 @@ def sample(self, map_data: geopandas.GeoDataFrame) -> pandas.DataFrame:
data["X"] = data.geometry.x
data["Y"] = data.geometry.y
data.reset_index(drop=True, inplace=True)
return pandas.DataFrame(data[::self.decimation].drop(columns="geometry"))
return pandas.DataFrame(data[:: self.decimation].drop(columns="geometry"))


class SamplerSpacing(Sampler):
Expand All @@ -86,6 +88,7 @@ class SamplerSpacing(Sampler):
ie. spacing = 500 means take a sample every 500 metres
Note: This only works on data frames that contain MultiPolgon, Polygon, MultiLineString and LineString geometry
"""

@beartype.beartype
def __init__(self, spacing: float = 50.0):
"""
Expand Down
Loading

0 comments on commit c884b90

Please sign in to comment.