From 731910e7f103107a2e23a8786030514176f661e1 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 14:01:31 +0930 Subject: [PATCH 01/98] feat: added SampleSupervisor --- map2loop/m2l_enums.py | 9 + map2loop/project.py | 125 ++++----- map2loop/sample_storage.py | 268 ++++++++++++++++++++ map2loop/thickness_calculator.py | 18 +- tests/sample_storage/test_sample_storage.py | 194 ++++++++++++++ 5 files changed, 547 insertions(+), 67 deletions(-) create mode 100644 map2loop/sample_storage.py create mode 100644 tests/sample_storage/test_sample_storage.py diff --git a/map2loop/m2l_enums.py b/map2loop/m2l_enums.py index f390361a..3d76cade 100644 --- a/map2loop/m2l_enums.py +++ b/map2loop/m2l_enums.py @@ -1,6 +1,15 @@ from enum import IntEnum +class SampleType(IntEnum): + GEOLOGY = 0 + STRUCTURE = 1 + FAULT = 2 + FOLD = 3 + FAULT_ORIENTATION = 4 + CONTACT = 5 + DTM = 6 + class Datatype(IntEnum): GEOLOGY = 0 STRUCTURE = 1 diff --git a/map2loop/project.py b/map2loop/project.py index 02630ebc..7d63ad5e 100644 --- a/map2loop/project.py +++ b/map2loop/project.py @@ -1,7 +1,7 @@ import beartype import pathlib from map2loop.fault_orientation import FaultOrientationNearest -from .m2l_enums import VerboseLevel, ErrorState, Datatype +from .m2l_enums import VerboseLevel, ErrorState, Datatype, SampleType from .mapdata import MapData from .sampler import Sampler, SamplerDecimator, SamplerSpacing from .thickness_calculator import ThicknessCalculator, ThicknessCalculatorAlpha @@ -11,6 +11,7 @@ from .stratigraphic_column import StratigraphicColumn from .deformation_history import DeformationHistory from .map2model_wrapper import Map2ModelWrapper +from .sample_storage import SampleSupervisor import LoopProjectFile as LPF from typing import Union import numpy @@ -134,6 +135,7 @@ def __init__( self.stratigraphic_column = StratigraphicColumn() self.deformation_history = DeformationHistory() + self.sample_supervisor = SampleSupervisor(self) self.fault_orientations = pandas.DataFrame( columns=["ID", "DIPDIR", "DIP", "X", "Y", "Z", "featureId"] ) @@ -370,34 +372,16 @@ def get_minimum_fault_length(self) -> float: """ return self.deformation_history.get_minimum_fault_length() - # Processing functions - def sample_map_data(self): - """ - Use the samplers to extract points along polylines or unit boundaries - """ - self.geology_samples = self.samplers[Datatype.GEOLOGY].sample( - self.map_data.get_map_data(Datatype.GEOLOGY), self.map_data - ) - self.structure_samples = self.samplers[Datatype.STRUCTURE].sample( - self.map_data.get_map_data(Datatype.STRUCTURE), self.map_data - ) - self.fault_samples = self.samplers[Datatype.FAULT].sample( - self.map_data.get_map_data(Datatype.FAULT), self.map_data - ) - self.fold_samples = self.samplers[Datatype.FOLD].sample( - self.map_data.get_map_data(Datatype.FOLD), self.map_data - ) - def extract_geology_contacts(self): """ Use the stratigraphic column, and fault and geology data to extract points along contacts """ # Use stratigraphic column to determine basal contacts self.map_data.extract_basal_contacts(self.stratigraphic_column.column) - self.map_data.sampled_contacts = self.samplers[Datatype.GEOLOGY].sample( - self.map_data.basal_contacts + self.sample_supervisor.process(SampleType.CONTACT) + self.map_data.get_value_from_raster_df( + Datatype.DTM, self.sample_supervisor(SampleType.CONTACT) ) - self.map_data.get_value_from_raster_df(Datatype.DTM, self.map_data.sampled_contacts) def calculate_stratigraphic_order(self, take_best=False): """ @@ -453,7 +437,7 @@ def calculate_unit_thicknesses(self): self.stratigraphic_column.stratigraphicUnits, self.stratigraphic_column.column, self.map_data.basal_contacts, - self.structure_samples, + self.sample_supervisor, self.map_data, ) @@ -484,9 +468,11 @@ def summarise_fault_data(self): """ Use the fault shapefile to make a summary of each fault by name """ - self.map_data.get_value_from_raster_df(Datatype.DTM, self.fault_samples) - self.deformation_history.summarise_data(self.fault_samples) + self.map_data.get_value_from_raster_df( + Datatype.DTM, self.sample_supervisor(SampleType.FAULT) + ) + self.deformation_history.summarise_data(self.sample_supervisor(SampleType.FAULT)) self.deformation_history.faults = self.throw_calculator.compute( self.deformation_history.faults, self.stratigraphic_column.column, @@ -518,7 +504,6 @@ def run_all(self, user_defined_stratigraphic_column=None, take_best=False): # Calculate basal contacts based on stratigraphic column self.extract_geology_contacts() - self.sample_map_data() self.calculate_unit_thicknesses() self.calculate_fault_orientations() self.summarise_fault_data() @@ -642,41 +627,61 @@ def save_into_projectfile(self): LPF.Set(self.loop_filename, "stratigraphicLog", data=stratigraphic_data) # Save contacts - contacts_data = numpy.zeros(len(self.map_data.sampled_contacts), LPF.contactObservationType) - contacts_data["layerId"] = self.map_data.sampled_contacts["ID"] - contacts_data["easting"] = self.map_data.sampled_contacts["X"] - contacts_data["northing"] = self.map_data.sampled_contacts["Y"] - contacts_data["altitude"] = self.map_data.sampled_contacts["Z"] - contacts_data["featureId"] = self.map_data.sampled_contacts["featureId"] - LPF.Set(self.loop_filename, "contacts", data=contacts_data) + contacts_data = numpy.zeros( + len(self.sample_supervisor(SampleType.CONTACT)), LPF.contactObservationType + ) + contacts_data["layerId"] = self.sample_supervisor(SampleType.CONTACT)["ID"] + contacts_data["easting"] = self.sample_supervisor(SampleType.CONTACT)["X"] + contacts_data["northing"] = self.sample_supervisor(SampleType.CONTACT)["Y"] + contacts_data["altitude"] = self.sample_supervisor(SampleType.CONTACT)["Z"] + LPF.Set(self.loop_filename, "contacts", data=contacts_data, verbose=True) # Save fault trace information faults_obs_data = numpy.zeros( - len(self.fault_samples) + len(self.fault_orientations), LPF.faultObservationType + len(self.sample_supervisor(SampleType.FAULT)) + len(self.fault_orientations), + LPF.faultObservationType, ) faults_obs_data["val"] = numpy.nan - faults_obs_data["eventId"][0 : len(self.fault_samples)] = self.fault_samples["ID"] - faults_obs_data["easting"][0 : len(self.fault_samples)] = self.fault_samples["X"] - faults_obs_data["northing"][0 : len(self.fault_samples)] = self.fault_samples["Y"] - faults_obs_data["altitude"][0 : len(self.fault_samples)] = self.fault_samples["Z"] - faults_obs_data["featureId"][0 : len(self.fault_samples)] = self.fault_samples["featureId"] - faults_obs_data["dipDir"][0 : len(self.fault_samples)] = numpy.nan - faults_obs_data["dip"][0 : len(self.fault_samples)] = numpy.nan - faults_obs_data["posOnly"][0 : len(self.fault_samples)] = 1 + faults_obs_data["eventId"][0 : len(self.sample_supervisor(SampleType.FAULT))] = ( + self.sample_supervisor(SampleType.FAULT)["ID"] + ) + faults_obs_data["easting"][0 : len(self.sample_supervisor(SampleType.FAULT))] = ( + self.sample_supervisor(SampleType.FAULT)["X"] + ) + faults_obs_data["northing"][0 : len(self.sample_supervisor(SampleType.FAULT))] = ( + self.sample_supervisor(SampleType.FAULT)["Y"] + ) + faults_obs_data["altitude"][0 : len(self.sample_supervisor(SampleType.FAULT))] = ( + self.sample_supervisor(SampleType.FAULT)["Z"] + ) + faults_obs_data["type"][0 : len(self.sample_supervisor(SampleType.FAULT))] = 0 + faults_obs_data["dipDir"][0 : len(self.sample_supervisor(SampleType.FAULT))] = numpy.nan + faults_obs_data["dip"][0 : len(self.sample_supervisor(SampleType.FAULT))] = numpy.nan + faults_obs_data["posOnly"][0 : len(self.sample_supervisor(SampleType.FAULT))] = 1 faults_obs_data["displacement"] = ( 100 # self.fault_samples["DISPLACEMENT"] #TODO remove note needed ) - faults_obs_data["eventId"][len(self.fault_samples) :] = self.fault_orientations["ID"] - faults_obs_data["easting"][len(self.fault_samples) :] = self.fault_orientations["X"] - faults_obs_data["northing"][len(self.fault_samples) :] = self.fault_orientations["Y"] - faults_obs_data["altitude"][len(self.fault_samples) :] = self.fault_orientations["Z"] - faults_obs_data["featureId"][len(self.fault_samples) :] = self.fault_orientations[ - "featureId" - ] - faults_obs_data["dipDir"][len(self.fault_samples) :] = self.fault_orientations["DIPDIR"] - faults_obs_data["dip"][len(self.fault_samples) :] = self.fault_orientations["DIP"] - faults_obs_data["posOnly"][len(self.fault_samples) :] = 0 + faults_obs_data["eventId"][len(self.sample_supervisor(SampleType.FAULT)) :] = ( + self.fault_orientations["ID"] + ) + faults_obs_data["easting"][len(self.sample_supervisor(SampleType.FAULT)) :] = ( + self.fault_orientations["X"] + ) + faults_obs_data["northing"][len(self.sample_supervisor(SampleType.FAULT)) :] = ( + self.fault_orientations["Y"] + ) + faults_obs_data["altitude"][len(self.sample_supervisor(SampleType.FAULT)) :] = ( + self.fault_orientations["Z"] + ) + faults_obs_data["type"][len(self.sample_supervisor(SampleType.FAULT)) :] = 0 + faults_obs_data["dipDir"][len(self.sample_supervisor(SampleType.FAULT)) :] = ( + self.fault_orientations["DIPDIR"] + ) + faults_obs_data["dip"][len(self.sample_supervisor(SampleType.FAULT)) :] = ( + self.fault_orientations["DIP"] + ) + faults_obs_data["posOnly"][len(self.sample_supervisor(SampleType.FAULT)) :] = 0 LPF.Set(self.loop_filename, "faultObservations", data=faults_obs_data) faults = self.deformation_history.get_faults_for_export() @@ -705,15 +710,17 @@ def save_into_projectfile(self): LPF.Set(self.loop_filename, "faultLog", data=faults_data) # Save structural information - observations = numpy.zeros(len(self.structure_samples), LPF.stratigraphicObservationType) + observations = numpy.zeros( + len(self.sample_supervisor(SampleType.STRUCTURE)), LPF.stratigraphicObservationType + ) observations["layer"] = "s0" - observations["layerId"] = self.structure_samples["layerID"] - observations["easting"] = self.structure_samples["X"] - observations["northing"] = self.structure_samples["Y"] + observations["layerId"] = self.sample_supervisor(SampleType.STRUCTURE)["layerID"] + observations["easting"] = self.sample_supervisor(SampleType.STRUCTURE)["X"] + observations["northing"] = self.sample_supervisor(SampleType.STRUCTURE)["Y"] # observations["altitude"] = self.structure_samples["Z"] - observations["dipDir"] = self.structure_samples["DIPDIR"] - observations["dip"] = self.structure_samples["DIP"] - observations["dipPolarity"] = self.structure_samples["OVERTURNED"] + observations["dipDir"] = self.sample_supervisor(SampleType.STRUCTURE)["DIPDIR"] + observations["dip"] = self.sample_supervisor(SampleType.STRUCTURE)["DIP"] + observations["dipPolarity"] = self.sample_supervisor(SampleType.STRUCTURE)["OVERTURNED"] LPF.Set(self.loop_filename, "stratigraphicObservations", data=observations) if self.map2model.fault_fault_relationships is not None: diff --git a/map2loop/sample_storage.py b/map2loop/sample_storage.py new file mode 100644 index 00000000..6a4611cd --- /dev/null +++ b/map2loop/sample_storage.py @@ -0,0 +1,268 @@ +from abc import ABC, abstractmethod +from .m2l_enums import Datatype, SampleType, StateType +from .sampler import SamplerDecimator, SamplerSpacing, Sampler +import beartype +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from .project import Project + + +class AccessStorage(ABC): + def __init__(self): + self.storage_label = "AccessStorageAbstractClass" + + def type(self): + return self.storage_label + + @beartype.beartype + @abstractmethod + def store(self, sampletype: SampleType, data): + pass + + @beartype.beartype + @abstractmethod + def check_state(self, sampletype: SampleType): + pass + + @abstractmethod + def load(self, sampletype: SampleType): + pass + + @beartype.beartype + @abstractmethod + def process(self, sampletype: SampleType): + pass + + @beartype.beartype + @abstractmethod + def reprocess(self, sampletype: SampleType): + pass + + @beartype.beartype + @abstractmethod + def __call__(self, sampletype: SampleType): + pass + + +class SampleSupervisor(AccessStorage): + """ + The SampleSupervisor class is responsible for managing the samples and samplers in the project. + It extends the AccessStorage abstract base class. + + Attributes: + storage_label (str): The label of the storage. + samples (list): A list of samples. + samplers (list): A list of samplers. + sampler_dirtyflags (list): A list of flags indicating if the sampler has changed. + dirtyflags (list): A list of flags indicating the state of the data, sample or sampler. + project (Project): The project associated with the SampleSupervisor. + map_data (MapData): The map data associated with the project. + """ + + def __init__(self, project: "Project"): + """ + The constructor for the SampleSupervisor class. + + Args: + project (Project): The Project class associated with the SampleSupervisor. + """ + + self.storage_label = "SampleSupervisor" + self.samples = [None] * len(SampleType) + self.samplers = [None] * len(SampleType) + self.sampler_dirtyflags = [True] * len(SampleType) + self.dirtyflags = [True] * len(StateType) + self.set_default_samplers() + self.project = project + self.map_data = project.map_data + + def type(self): + return self.storage_label + + def set_default_samplers(self): + """ + Initialisation function to set or reset the point samplers + """ + self.samplers[SampleType.STRUCTURE] = SamplerDecimator(1) + self.samplers[SampleType.FAULT_ORIENTATION] = SamplerDecimator(1) + self.samplers[SampleType.GEOLOGY] = SamplerSpacing(50.0) + self.samplers[SampleType.FAULT] = SamplerSpacing(50.0) + self.samplers[SampleType.FOLD] = SamplerSpacing(50.0) + self.samplers[SampleType.CONTACT] = SamplerSpacing(50.0) + self.samplers[SampleType.DTM] = SamplerSpacing(50.0) + # dirty flags to false after initialisation + self.sampler_dirtyflags = [False] * len(SampleType) + + @beartype.beartype + def set_sampler(self, sampletype: SampleType, sampler: Sampler): + """ + Set the point sampler for a specific datatype + + Args: + sampletype (Datatype): + The sample type (SampleType) to use this sampler on + sampler (Sampler): + The sampler to use + """ + self.samplers[sampletype] = sampler + # set the dirty flag to True to indicate that the sampler has changed + self.sampler_dirtyflags[sampletype] = True + + @beartype.beartype + def get_sampler(self, sampletype: SampleType): + """ + Get the sampler name being used for a datatype + + Args: + sampletype: The sample type of the sampler + + Returns: + str: The name of the sampler being used on the specified datatype + """ + return self.samplers[sampletype].sampler_label + + @beartype.beartype + def store(self, sampletype: SampleType, data): + """ + Stores the sample data. + + Args: + sampletype (SampleType): The type of the sample. + data: The sample data to store. + """ + + # store the sample data + self.samples[sampletype] = data + self.sampler_dirtyflags[sampletype] = False + + @beartype.beartype + def check_state(self, sampletype: SampleType): + """ + Checks the state of the data, sample and sampler. + + Args: + sampletype (SampleType): The type of the sample. + """ + + self.dirtyflags[StateType.DATA] = self.map_data.dirtyflags[sampletype] + self.dirtyflags[StateType.SAMPLER] = self.sampler_dirtyflags[sampletype] + + @beartype.beartype + def load(self, sampletype: SampleType): + """ + Loads the map data or raster map data based on the sample type. + + Args: + sampletype (SampleType): The type of the sample. + """ + datatype = Datatype(sampletype) + + if datatype == Datatype.DTM: + self.map_data.load_raster_map_data(datatype) + + else: + # load map data + self.map_data.load_map_data(datatype) + + @beartype.beartype + def process(self, sampletype: SampleType): + """ + Processes the sample based on the sample type. + + Args: + sampletype (SampleType): The type of the sample. + """ + + if sampletype == SampleType.CONTACT: + self.store( + SampleType.CONTACT, + self.samplers[SampleType.CONTACT].sample( + self.map_data.basal_contacts, self.map_data + ), + ) + + else: + datatype = Datatype(sampletype) + self.store( + sampletype, + self.samplers[sampletype].sample( + self.map_data.get_map_data(datatype), self.map_data + ), + ) + + @beartype.beartype + def reprocess(self, sampletype: SampleType): + """ + Reprocesses the data based on the sample type. + + Args: + sampletype (SampleType): The type of the sample. + """ + + if sampletype == SampleType.GEOLOGY or sampletype == SampleType.CONTACT: + self.map_data.extract_all_contacts() + + if self.project.stratigraphic_column.column is None: + self.project.calculate_stratigraphic_order() + + else: + self.project.sort_stratigraphic_column() + + self.project.extract_geology_contacts() + self.process(SampleType.GEOLOGY) + + elif sampletype == SampleType.STRUCTURE: + self.process(SampleType.STRUCTURE) + + elif sampletype == SampleType.FAULT: + self.project.calculate_fault_orientations() + self.project.summarise_fault_data() + self.process(SampleType.FAULT) + + elif sampletype == SampleType.FOLD: + self.process(SampleType.FOLD) + + @beartype.beartype + def __call__(self, sampletype: SampleType): + """ + Checks the state of the data, sample and sampler, and returns + the requested sample after reprocessing if necessary. + + Args: + sampletype (SampleType): The type of the sample. + + Returns: + The requested sample. + """ + + # check the state of the data, sample and sampler + self.check_state(sampletype) + + # run the sampler only if no sample was generated before + if self.samples[sampletype] is None: + # if the data is changed, load and reprocess the data and generate a new sample + if self.dirtyflags[StateType.DATA] is True: + self.load(sampletype) + self.reprocess(sampletype) + return self.samples[sampletype] + + if self.dirtyflags[StateType.DATA] is False: + self.process(sampletype) + return self.samples[sampletype] + + # return the requested sample after reprocessing if the data is changed + elif self.samples[sampletype] is not None: + if self.dirtyflags[StateType.DATA] is False: + if self.dirtyflags[StateType.SAMPLER] is True: + self.reprocess(sampletype) + return self.samples[sampletype] + + if self.dirtyflags[StateType.SAMPLER] is False: + return self.samples[sampletype] + + if self.dirtyflags[StateType.DATA] is True: + + self.load(sampletype) + self.reprocess(sampletype) + return self.samples[sampletype] \ No newline at end of file diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index af016800..4b5bb386 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -7,6 +7,7 @@ from statistics import mean from .mapdata import MapData from scipy.interpolate import Rbf +from .sample_storage import SampleSupervisor from .interpolators import DipDipDirectionInterpolator from .utils import ( create_points, @@ -15,7 +16,7 @@ multiline_to_line, find_segment_strike_from_pt, ) -from .m2l_enums import Datatype +from .m2l_enums import Datatype, SampleType from shapely.geometry import Point import shapely import math @@ -51,7 +52,7 @@ def compute( units: pandas.DataFrame, stratigraphic_order: list, basal_contacts: geopandas.GeoDataFrame, - structure_data: pandas.DataFrame, + samples: SampleSupervisor, map_data: MapData, ) -> pandas.DataFrame: """ @@ -93,7 +94,7 @@ def compute( units: pandas.DataFrame, stratigraphic_order: list, basal_contacts: geopandas.GeoDataFrame, - structure_data: pandas.DataFrame, + samples: SampleSupervisor, map_data: MapData, ) -> pandas.DataFrame: """ @@ -200,7 +201,7 @@ def compute( units: pandas.DataFrame, stratigraphic_order: list, basal_contacts: geopandas.GeoDataFrame, - structure_data: pandas.DataFrame, + samples: SampleSupervisor, map_data: MapData, ) -> pandas.DataFrame: """ @@ -242,7 +243,7 @@ def compute( # increase buffer around basal contacts to ensure that the points are included as intersections basal_contacts["geometry"] = basal_contacts["geometry"].buffer(0.01) # get the sampled contacts - contacts = geopandas.GeoDataFrame(map_data.sampled_contacts) + contacts = samples(SampleType.CONTACT) # build points from x and y coordinates geometry2 = contacts.apply(lambda row: Point(row.X, row.Y), axis=1) contacts.set_geometry(geometry2, inplace=True) @@ -259,9 +260,10 @@ def compute( contacts = contacts.sjoin(basal_contacts, how="inner", predicate="intersects") contacts = contacts[["X", "Y", "Z", "geometry", "basal_unit"]].copy() bounding_box = map_data.get_bounding_box() + structural_data = samples(SampleType.STRUCTURE) # Interpolate the dip of the contacts interpolator = DipDipDirectionInterpolator(data_type="dip") - dip = interpolator(bounding_box, structure_data, interpolator=Rbf) + dip = interpolator(bounding_box, structural_data, interpolator=Rbf) # create a GeoDataFrame of the interpolated orientations interpolated_orientations = geopandas.GeoDataFrame() # add the dip and dip direction to the GeoDataFrame @@ -399,7 +401,7 @@ def compute( units: pandas.DataFrame, stratigraphic_order: list, basal_contacts: geopandas.GeoDataFrame, - structure_data: pandas.DataFrame, + samples: SampleSupervisor, map_data: MapData, ) -> pandas.DataFrame: """ @@ -437,7 +439,7 @@ def compute( For the bottom and top units of the stratigraphic sequence, the assigned thickness will also be -1. """ # input sampled data - sampled_structures = structure_data + sampled_structures = samples(SampleType.STRUCTURE) basal_contacts = basal_contacts.copy() # grab geology polygons and calculate bounding boxes for each lithology diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py new file mode 100644 index 00000000..66d699bb --- /dev/null +++ b/tests/sample_storage/test_sample_storage.py @@ -0,0 +1,194 @@ +import pytest +import os +from map2loop.project import Project +from map2loop.m2l_enums import VerboseLevel, SampleType, StateType +from map2loop.sampler import SamplerSpacing, SamplerDecimator +from datetime import datetime +import pandas + +os.system('gdown --folder https://drive.google.com/drive/folders/1ZEJvPN4lpGpvoepjGMZgzYPGaY3mT46p') + + +@pytest.fixture +def sample_supervisor(): + bounding_box = {"minx": 0, "miny": 0, "maxx": 10000, "maxy": 10000, "base": 0, "top": -5000} + + nowtime = datetime.now().isoformat(timespec='minutes') + model_name = nowtime.replace(":", "-").replace("T", "-") + loop_project_filename = os.path.join(model_name, "local_source.loop3d") + project = Project( + geology_filename='./data/lithologies.shp', + fault_filename="./data/faults.shp", + fold_filename="./data/faults.shp", + structure_filename="./data/measurements.shp", + dtm_filename='./data/DEM.tif', + config_filename='./data/example.hjson', + clut_filename='./data/500kibg_colours.csv', + clut_file_legacy=True, + verbose_level=VerboseLevel.NONE, + tmp_path=model_name, + working_projection="EPSG:7854", + bounding_box=bounding_box, + loop_project_filename=loop_project_filename, + ) + + # Or you can run map2loop and pre-specify the stratigraphic column + column = [ + # youngest + 'Litho_A', + 'Litho_B', + 'Litho_C', + 'Litho_D', + # oldest + ] + + project.run_all(user_defined_stratigraphic_column=column) + + return project.sample_supervisor + + +def test_type(sample_supervisor): + assert sample_supervisor.type() == "SampleSupervisor" + + +def test_set_default_samplers(sample_supervisor): + sample_supervisor.set_default_samplers() + assert isinstance(sample_supervisor.samplers[SampleType.GEOLOGY], SamplerSpacing) + assert isinstance(sample_supervisor.samplers[SampleType.FAULT], SamplerSpacing) + assert isinstance(sample_supervisor.samplers[SampleType.FOLD], SamplerSpacing) + assert isinstance(sample_supervisor.samplers[SampleType.FAULT_ORIENTATION], SamplerDecimator) + assert isinstance(sample_supervisor.samplers[SampleType.DTM], SamplerSpacing) + assert isinstance(sample_supervisor.samplers[SampleType.CONTACT], SamplerSpacing) + assert isinstance(sample_supervisor.samplers[SampleType.STRUCTURE], SamplerDecimator) + + +def test_set_sampler(sample_supervisor): + sampler = SamplerSpacing(100.0) + sample_supervisor.set_sampler(SampleType.STRUCTURE, sampler) + assert sample_supervisor.samplers[SampleType.STRUCTURE] == sampler + assert sample_supervisor.sampler_dirtyflags[SampleType.STRUCTURE] is True + + +def test_get_sampler(sample_supervisor): + sampler = SamplerSpacing(100.0) + sample_supervisor.set_sampler(SampleType.STRUCTURE, sampler) + assert sample_supervisor.get_sampler(SampleType.STRUCTURE) == sampler.sampler_label + + +# TODO: test_store to be completed +def test_store(sample_supervisor): + data = pandas.DataFrame() + sample_supervisor.store(SampleType.STRUCTURE, data) + assert isinstance(sample_supervisor.samples[SampleType.STRUCTURE], pandas.DataFrame) + sample_supervisor.store(SampleType.GEOLOGY, data) + assert isinstance(sample_supervisor.samples[SampleType.GEOLOGY], pandas.DataFrame) + sample_supervisor.store(SampleType.FAULT, data) + assert isinstance(sample_supervisor.samples[SampleType.FAULT], pandas.DataFrame) + sample_supervisor.store(SampleType.FOLD, data) + assert isinstance(sample_supervisor.samples[SampleType.FOLD], pandas.DataFrame) + sample_supervisor.store(SampleType.FAULT_ORIENTATION, data) + assert isinstance(sample_supervisor.samples[SampleType.FAULT_ORIENTATION], pandas.DataFrame) + + +def test_check_state(sample_supervisor): + sample_supervisor.check_state(SampleType.STRUCTURE) + assert sample_supervisor.dirtyflags[StateType.DATA] is False + assert sample_supervisor.dirtyflags[StateType.SAMPLER] is False + + +def test_load(sample_supervisor): + sample_supervisor.load(SampleType.STRUCTURE) + sample_supervisor.check_state(SampleType.STRUCTURE) + assert sample_supervisor.dirtyflags[StateType.DATA] is False + sample_supervisor.load(SampleType.GEOLOGY) + sample_supervisor.check_state(SampleType.GEOLOGY) + assert sample_supervisor.dirtyflags[StateType.DATA] is False + sample_supervisor.load(SampleType.FAULT) + sample_supervisor.check_state(SampleType.FAULT) + assert sample_supervisor.dirtyflags[StateType.DATA] is False + sample_supervisor.load(SampleType.FOLD) + sample_supervisor.check_state(SampleType.FOLD) + assert sample_supervisor.dirtyflags[StateType.DATA] is False + sample_supervisor.load(SampleType.FAULT_ORIENTATION) + sample_supervisor.check_state(SampleType.FAULT_ORIENTATION) + assert sample_supervisor.dirtyflags[StateType.DATA] is False + + +def test_process(sample_supervisor): + sample_supervisor.process(SampleType.STRUCTURE) + sample_supervisor.check_state(SampleType.STRUCTURE) + assert sample_supervisor.samples[SampleType.STRUCTURE] is not None + sample_supervisor.process(SampleType.GEOLOGY) + sample_supervisor.check_state(SampleType.GEOLOGY) + assert sample_supervisor.samples[SampleType.GEOLOGY] is not None + sample_supervisor.process(SampleType.FAULT) + sample_supervisor.check_state(SampleType.FAULT) + assert sample_supervisor.samples[SampleType.FAULT] is not None + sample_supervisor.process(SampleType.FOLD) + sample_supervisor.check_state(SampleType.FOLD) + assert sample_supervisor.samples[SampleType.FOLD] is not None + sample_supervisor.process(SampleType.CONTACT) + sample_supervisor.check_state(SampleType.CONTACT) + assert sample_supervisor.samples[SampleType.CONTACT] is not None + + +def test_reprocess(sample_supervisor): + + sample_supervisor.sampler_dirtyflags[SampleType.STRUCTURE] = True + sample_supervisor.reprocess(SampleType.STRUCTURE) + assert sample_supervisor.samples[SampleType.STRUCTURE] is not None + assert isinstance(sample_supervisor.samples[SampleType.STRUCTURE], pandas.DataFrame) + assert sample_supervisor.sampler_dirtyflags[SampleType.STRUCTURE] is False + + sample_supervisor.sampler_dirtyflags[SampleType.GEOLOGY] = True + sample_supervisor.reprocess(SampleType.GEOLOGY) + assert sample_supervisor.samples[SampleType.GEOLOGY] is not None + assert isinstance(sample_supervisor.samples[SampleType.GEOLOGY], pandas.DataFrame) + assert sample_supervisor.sampler_dirtyflags[SampleType.GEOLOGY] is False + + sample_supervisor.sampler_dirtyflags[SampleType.FOLD] = True + sample_supervisor.reprocess(SampleType.FOLD) + assert sample_supervisor.samples[SampleType.FOLD] is not None + assert isinstance(sample_supervisor.samples[SampleType.FOLD], pandas.DataFrame) + assert sample_supervisor.sampler_dirtyflags[SampleType.FOLD] is False + + sample_supervisor.sampler_dirtyflags[SampleType.CONTACT] = True + sample_supervisor.reprocess(SampleType.CONTACT) + assert sample_supervisor.samples[SampleType.CONTACT] is not None + assert isinstance(sample_supervisor.samples[SampleType.CONTACT], pandas.DataFrame) + assert sample_supervisor.sampler_dirtyflags[SampleType.CONTACT] is False + + +def test_call(sample_supervisor): + + sample_supervisor(SampleType.STRUCTURE) + assert sample_supervisor.samples[SampleType.STRUCTURE] is not None + assert isinstance(sample_supervisor.samples[SampleType.STRUCTURE], pandas.DataFrame) + + sample_supervisor.samples[SampleType.STRUCTURE] = None + sample_supervisor(SampleType.STRUCTURE) + assert sample_supervisor.samples[SampleType.STRUCTURE] is not None + assert isinstance(sample_supervisor.samples[SampleType.STRUCTURE], pandas.DataFrame) + + sample_supervisor.set_sampler(SampleType.STRUCTURE, SamplerDecimator(1)) + sample_supervisor(SampleType.STRUCTURE) + assert sample_supervisor.samples[SampleType.STRUCTURE] is not None + assert isinstance(sample_supervisor.samples[SampleType.STRUCTURE], pandas.DataFrame) + + sample_supervisor.samples[SampleType.GEOLOGY] = None + sample_supervisor.map_data.dirtyflags[SampleType.GEOLOGY] = True + sample_supervisor(SampleType.GEOLOGY) + assert sample_supervisor.samples[SampleType.GEOLOGY] is not None + assert isinstance(sample_supervisor.samples[SampleType.GEOLOGY], pandas.DataFrame) + + sample_supervisor(SampleType.FAULT) + assert sample_supervisor.samples[SampleType.FAULT] is not None + assert isinstance(sample_supervisor.samples[SampleType.FAULT], pandas.DataFrame) + + sample_supervisor(SampleType.FOLD) + assert sample_supervisor.samples[SampleType.FOLD] is not None + assert isinstance(sample_supervisor.samples[SampleType.FOLD], pandas.DataFrame) + + sample_supervisor(SampleType.CONTACT) + assert sample_supervisor.samples[SampleType.CONTACT] is not None + assert isinstance(sample_supervisor.samples[SampleType.CONTACT], pandas.DataFrame) \ No newline at end of file From 42a62387ffd333190a2099c06dbd2c72d5ca78e1 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 14:06:29 +0930 Subject: [PATCH 02/98] fix: added StateType enum --- map2loop/m2l_enums.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/map2loop/m2l_enums.py b/map2loop/m2l_enums.py index 3d76cade..2c642d0b 100644 --- a/map2loop/m2l_enums.py +++ b/map2loop/m2l_enums.py @@ -9,7 +9,7 @@ class SampleType(IntEnum): CONTACT = 5 DTM = 6 - + class Datatype(IntEnum): GEOLOGY = 0 STRUCTURE = 1 @@ -39,3 +39,8 @@ class VerboseLevel(IntEnum): NONE = 0 TEXTONLY = 1 ALL = 2 + + +class StateType(IntEnum): + DATA = 0 + SAMPLER = 1 From 8e6652d17cc3f637365fa26f649f6981ad6c0604 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 14:12:48 +0930 Subject: [PATCH 03/98] doc: added libtiff-dev instead of libtiff5 --- docs/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/Dockerfile b/docs/Dockerfile index 86879a31..a24faffa 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -11,7 +11,8 @@ RUN apt-get update -qq && \ make\ libgl1\ libtinfo5\ - libtiff5\ + # libtiff5\ + libtiff-dev\ libgl1-mesa-glx From aca1164f68e81af15c9ca69d5614b0c903e5a8c2 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 14:19:13 +0930 Subject: [PATCH 04/98] fix: updated to align SampleSupervisor --- map2loop/thickness_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index 4b5bb386..f09432c7 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -457,7 +457,7 @@ def compute( # rebuild basal contacts lines based on sampled dataset sampled_basal_contacts = rebuild_sampled_basal_contacts( - basal_contacts, map_data.sampled_contacts + basal_contacts, samples(SampleType.CONTACT) ) # calculate map dimensions From 439c383d15dcb664d272b56372090e421e7bee76 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 14:42:45 +0930 Subject: [PATCH 05/98] fix: fault_obs_data aligned to master branch --- map2loop/project.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/map2loop/project.py b/map2loop/project.py index 7d63ad5e..494bf7a5 100644 --- a/map2loop/project.py +++ b/map2loop/project.py @@ -654,7 +654,7 @@ def save_into_projectfile(self): faults_obs_data["altitude"][0 : len(self.sample_supervisor(SampleType.FAULT))] = ( self.sample_supervisor(SampleType.FAULT)["Z"] ) - faults_obs_data["type"][0 : len(self.sample_supervisor(SampleType.FAULT))] = 0 + faults_obs_data["featureId"][0 : len(self.sample_supervisor(SampleType.FAULT))] = self.sample_supervisor(SampleType.FAULT)["featureId"] faults_obs_data["dipDir"][0 : len(self.sample_supervisor(SampleType.FAULT))] = numpy.nan faults_obs_data["dip"][0 : len(self.sample_supervisor(SampleType.FAULT))] = numpy.nan faults_obs_data["posOnly"][0 : len(self.sample_supervisor(SampleType.FAULT))] = 1 @@ -674,7 +674,9 @@ def save_into_projectfile(self): faults_obs_data["altitude"][len(self.sample_supervisor(SampleType.FAULT)) :] = ( self.fault_orientations["Z"] ) - faults_obs_data["type"][len(self.sample_supervisor(SampleType.FAULT)) :] = 0 + faults_obs_data["featureId"][len(self.sample_supervisor(SampleType.FAULT)) :] = self.fault_orientations[ + "featureId" + ] faults_obs_data["dipDir"][len(self.sample_supervisor(SampleType.FAULT)) :] = ( self.fault_orientations["DIPDIR"] ) From 47a0b69d86f81ba774c47a16d52255b669ec13a4 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 14:55:24 +0930 Subject: [PATCH 06/98] test: updated InterpolatedStructure test --- tests/sample_storage/test_sample_storage.py | 243 +++++++++++++++++--- 1 file changed, 210 insertions(+), 33 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 66d699bb..ee40025d 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -1,50 +1,227 @@ import pytest import os from map2loop.project import Project -from map2loop.m2l_enums import VerboseLevel, SampleType, StateType +from map2loop.m2l_enums import VerboseLevel, SampleType, StateType, Datatype from map2loop.sampler import SamplerSpacing, SamplerDecimator +from map2loop.thickness_calculator import InterpolatedStructure from datetime import datetime import pandas - -os.system('gdown --folder https://drive.google.com/drive/folders/1ZEJvPN4lpGpvoepjGMZgzYPGaY3mT46p') +import geopandas +from osgeo import gdal, osr +import tempfile +import shapely +import pathlib + +# os.system('gdown --folder https://drive.google.com/drive/folders/1ZEJvPN4lpGpvoepjGMZgzYPGaY3mT46p') + +def create_raster(output_path, bbox, epsg, pixel_size, value=100): + minx, miny, maxx, maxy = bbox + cols = int((maxx - minx) / pixel_size) + rows = int((maxy - miny) / pixel_size) + driver = gdal.GetDriverByName('GTiff') + out_raster = driver.Create(output_path, cols, rows, 1, gdal.GDT_Byte) + out_raster.SetGeoTransform([minx, pixel_size, 0, maxy, 0, -pixel_size]) + srs = osr.SpatialReference() + srs.ImportFromEPSG(epsg) + out_raster.SetProjection(srs.ExportToWkt()) + out_band = out_raster.GetRasterBand(1) + out_band.Fill(value) + out_band.FlushCache() + out_raster = None + + +geology = [ + { + 'UNITNAME': 'Litho_E', + 'geometry': 'POLYGON ((9795.91836734694 9931.26849738919, 9860.73785898637 9795.91836734694, 9935.33621028978 9591.836734693878, 9950.618354641661 9387.755102040817, 10000 9210.342095822705, 10000 8757.661313426739, 9957.613263811385 8571.428571428572, 9795.91836734694 8453.228230379065, 9591.836734693878 8459.27180076132, 9387.755102040817 8424.58063242387, 9183.673469387755 8396.186050103635, 8979.591836734695 8375.328219666773, 8775.510204081633 8142.6900746871015, 8533.835897640307 7959.183673469388, 8367.34693877551 7832.006337691327, 8271.702357700893 7755.102040816327, 8163.265306122449 7660.1472192881065, 8074.276982521525 7551.0204081632655, 7959.183673469388 7424.887053820552, 7876.85861392897 7346.938775510204, 7755.102040816327 7225.488935198103, 7672.260829380581 7142.857142857143, 7551.0204081632655 7021.922675930724, 7447.64756183235 6938.775510204082, 7346.938775510204 6858.865387585699, 7149.179419692682 6734.693877551021, 6938.775510204082 6628.052847726005, 6734.693877551021 6533.238936443719, 6530.6122448979595 6522.261950434471, 6326.530612244898 6520.453083271883, 6122.448979591837 6525.756680235571, 5918.367346938776 6543.242785395409, 5714.285714285715 6570.203352947625, 5510.2040816326535 6597.437955895249, 5306.122448979592 6623.455748266104, 5102.040816326531 6558.673625089685, 5021.544086689852 6530.6122448979595, 4897.95918367347 6484.284692881059, 4648.165410878707 6326.530612244898, 4456.931912169165 6122.448979591837, 4285.714285714286 5949.72882952009, 4081.6326530612246 5747.855828732861, 3877.5510204081634 5481.342782779616, 3673.469387755102 5299.687677500199, 3469.387755102041 5113.124847412109, 3233.5997600944675 4897.95918367347, 3061.2244897959185 4761.364995216837, 2978.9564560870735 4693.877551020409, 2857.1428571428573 4509.9974651725925, 2727.7656477324817 4285.714285714286, 2653.061224489796 4194.911256128428, 2620.9440036695833 4081.6326530612246, 2653.061224489796 3834.8668935347578, 2714.296846973653 3673.469387755102, 2767.1924902468313 3469.387755102041, 2857.1428571428573 3316.1486411581236, 2932.2801317487447 3265.3061224489797, 3061.2244897959185 3201.1586792615, 3265.3061224489797 3115.340836194097, 3411.8516104561945 3061.2244897959185, 3469.387755102041 3039.713489766024, 3673.469387755102 2953.3901993109257, 3877.5510204081634 2900.4941667829244, 4081.6326530612246 2919.088869678731, 4285.714285714286 2942.9248887665417, 4489.795918367347 2963.555199759347, 4693.877551020409 2917.314840822804, 4809.648941974251 2857.1428571428573, 4897.95918367347 2811.5255005505624, 5102.040816326531 2712.551039092395, 5243.474220742985 2653.061224489796, 5306.122448979592 2627.6203077666614, 5510.2040816326535 2402.532733216578, 5649.461551588409 2244.8979591836737, 5714.285714285715 2173.8852286825377, 5838.211215272242 2040.8163265306123, 5918.367346938776 1953.0603836993782, 6037.69419144611 1836.734693877551, 6122.448979591837 1756.0881011340084, 6277.958616918448 1632.6530612244899, 6326.530612244898 1595.732338574468, 6532.909626863441 1428.5714285714287, 6734.693877551021 1276.012440117038, 6876.561690349969 1224.4897959183675, 6938.775510204082 1201.8953050885882, 7142.857142857143 1139.765856217365, 7346.938775510204 1082.3855108144332, 7551.0204081632655 1067.0050796197386, 7755.102040816327 1078.0507691052496, 7995.249689841758 1020.4081632653061, 8163.265306122449 949.2362275415538, 8367.34693877551 868.0756238042093, 8499.189882862325 816.3265306122449, 8571.428571428572 789.4330608601473, 8775.510204081633 723.8424554163096, 8902.20797791773 612.2448979591837, 8979.591836734695 360.74278305987923, 8979.591836734695 180.16181430038142, 8858.95553900271 0, 6046.468258728215 0, 5863.85825506431 296.3535950262776, 5435.566874501761 724.6449755888261, 5282.605667157994 908.1984244013456, 4900.202648798577 1122.3441146826208, 4638.256581222377 1168.2324768857502, 4454.703132409856 1154.8483712431703, 4190.845049741858 1118.520084499026, 3988.1714500113685 1181.6165825283297, 3642.0967183960943 1311.6336087705313, 3024.5158437456353 1594.6118423565003, 2573.2802820815227 1816.4055930049626, 2175.581142987729 2107.0318869581197, 1831.4184264642531 2558.267448622232, 1380.1828648001406 2910.078225512896, 531.2481640422343 3177.7603383644882, 0 3187.497507640264, 0 4970.218705429992, 78.1005872863268 5095.511475436967, 303.71836811838307 5355.545527921371, 739.6578090481191 5745.596606647977, 904.0911069426686 5887.085723440961, 1297.9662158528683 6024.750810050351, 1787.4420793529227 6116.527534456612, 2169.8450977123402 6135.647685374583, 2498.711693501439 6185.3600777613065, 3003.4836777358705 6261.84068143319, 3485.311480868737 6430.098009511334, 3798.881955923459 6705.428182730114, 4250.1175175875715 7240.792408433298, 4731.945320720438 7638.491547527093, 5297.901787892375 7982.654264050569, 5802.673772126806 8112.67129029277, 6276.853514892484 8303.87279947248, 6712.79295582222 8609.795214160013, 6896.346404634739 8785.700602605346, 6995.771189408188 8969.254051417865, 6942.234766837869 9206.343922800705, 6766.329378392537 9558.154699691368, 6414.518601501873 9986.446080253916, 6402.234572809949 10000, 9765.614100864956 10000, 9795.91836734694 9931.26849738919))', + 'GROUP': 'A', + 'ID': 0, + }, + { + 'UNITNAME': 'Litho_F', + 'geometry': 'MULTIPOLYGON (((8979.591836734695 360.74278305987923, 8902.20797791773 612.2448979591837, 8775.510204081633 723.8424554163096, 8571.428571428572 789.4330608601473, 8499.189882862325 816.3265306122449, 8367.34693877551 868.0756238042093, 8163.265306122449 949.2362275415538, 7995.249689841758 1020.4081632653061, 7755.102040816327 1078.0507691052496, 7551.0204081632655 1067.0050796197386, 7346.938775510204 1082.3855108144332, 7142.857142857143 1139.765856217365, 6938.775510204082 1201.8953050885882, 6876.561690349969 1224.4897959183675, 6734.693877551021 1276.012440117038, 6532.909626863441 1428.5714285714287, 6326.530612244898 1595.732338574468, 6277.958616918448 1632.6530612244899, 6122.448979591837 1756.0881011340084, 6037.69419144611 1836.734693877551, 5918.367346938776 1953.0603836993782, 5838.211215272242 2040.8163265306123, 5714.285714285715 2173.8852286825377, 5649.461551588409 2244.8979591836737, 5510.2040816326535 2402.532733216578, 5306.122448979592 2627.6203077666614, 5243.474220742985 2653.061224489796, 5102.040816326531 2712.551039092395, 4897.95918367347 2811.5255005505624, 4809.648941974251 2857.1428571428573, 4693.877551020409 2917.314840822804, 4489.795918367347 2963.555199759347, 4285.714285714286 2942.9248887665417, 4081.6326530612246 2919.088869678731, 3877.5510204081634 2900.4941667829244, 3673.469387755102 2953.3901993109257, 3592.122504199657 2987.798639529117, 3469.387755102041 3039.713489766024, 3411.8516104561945 3061.2244897959185, 3265.3061224489797 3115.340836194097, 3061.2244897959185 3201.1586792615, 2932.2801317487447 3265.3061224489797, 2857.1428571428573 3316.1486411581236, 2767.1924902468313 3469.387755102041, 2714.296846973653 3673.469387755102, 2653.061224489796 3834.8668935347578, 2620.9440036695833 4081.6326530612246, 2653.061224489796 4194.911256128428, 2727.7656477324817 4285.714285714286, 2857.1428571428573 4509.9974651725925, 2978.9564560870735 4693.877551020409, 3061.2244897959185 4761.364995216837, 3233.5997600944675 4897.95918367347, 3469.387755102041 5113.124847412109, 3673.469387755102 5299.687677500199, 3877.5510204081634 5481.342782779616, 4081.6326530612246 5747.855828732861, 4285.714285714286 5949.72882952009, 4456.931912169165 6122.448979591837, 4648.165410878707 6326.530612244898, 4897.95918367347 6484.284692881059, 5021.544086689852 6530.6122448979595, 5102.040816326531 6558.673625089685, 5306.122448979592 6623.455748266104, 5510.2040816326535 6597.437955895249, 5714.285714285715 6570.203352947625, 5918.367346938776 6543.242785395409, 6122.448979591837 6525.756680235571, 6326.530612244898 6520.453083271883, 6530.6122448979595 6522.261950434471, 6734.693877551021 6533.238936443719, 6938.775510204082 6628.052847726005, 7149.179419692682 6734.693877551021, 7346.938775510204 6858.865387585699, 7447.64756183235 6938.775510204082, 7551.0204081632655 7021.922675930724, 7672.260829380581 7142.857142857143, 7755.102040816327 7225.488935198103, 7876.85861392897 7346.938775510204, 7959.183673469388 7424.887053820552, 8074.276982521525 7551.0204081632655, 8163.265306122449 7660.1472192881065, 8271.702357700893 7755.102040816327, 8367.34693877551 7832.006337691327, 8533.835897640307 7959.183673469388, 8775.510204081633 8142.6900746871015, 8979.591836734695 8375.328219666773, 9183.673469387755 8396.186050103635, 9387.755102040817 8424.58063242387, 9591.836734693878 8459.27180076132, 9795.91836734694 8453.228230379065, 9957.613263811385 8571.428571428572, 10000 8757.661313426739, 10000 8427.640566256101, 9796.219398903246 8371.275719144232, 9383.517404828015 8331.33681649179, 9143.883988913365 8300.273225539891, 8984.1283783036 8184.894173432836, 8771.120897490577 7976.324348470085, 8398.357806067788 7714.50265330408, 8078.846584848256 7359.490185282376, 7683.89521417411 6951.225847057416, 7209.066038195081 6636.152281688155, 6805.239355820393 6449.77073597676, 6294.908933039194 6432.020112575675, 5984.273023520203 6427.582456725404, 5673.6371140012125 6480.834326928666, 5376.314172033036 6489.709638629209, 5145.556067818929 6445.333080126496, 4910.36030775455 6347.704651420527, 4777.230632246412 6223.450287612931, 4542.034872182033 6063.6946770031645, 4324.58973551874 5824.061261088515, 4129.332878106803 5593.303156874407, 3925.2007089943236 5389.170987761928, 3734.3815074326594 5176.163506948902, 3494.7480915180095 5020.8455521894075, 3263.9899873039026 4830.026350627742, 2993.2929804373534 4554.891687910922, 2846.850337378401 4315.258271996272, 2735.908941121619 4088.937823632436, 2780.285499624332 3840.429096017244, 2842.4126815281297 3560.8567774501525, 2944.4787660843695 3361.162264187944, 3082.0460974427792 3294.5974264338747, 3379.369039410956 3170.343062626279, 3845.322903689442 3028.338075417598, 4013.9538259997507 3037.2133871181404, 4320.15207966847 3032.7757312678687, 4542.034872182035 3028.338075417598, 4684.039859390716 2983.9615169148847, 4897.047340203738 2886.333088208916, 5189.932626321643 2766.5163802515917, 5358.563548631952 2673.3256073958946, 5465.067289038463 2611.198425492096, 5744.639607605554 2273.9365808714774, 6246.09471868621 1776.9191256410927, 6641.046089360355 1435.2196251702035, 6822.989979221478 1324.2782289134211, 6978.307933980974 1275.4640145604371, 7311.13212275132 1195.5862092555535, 7444.261798259459 1168.960274153926, 7666.144590773023 1160.0849624533835, 7870.2767598855025 1155.6473066031122, 8052.220649746626 1093.5201246993138, 8331.792968313717 987.0163842928032, 8460.484987971584 920.4515465387335, 8713.43137143705 845.0113970841217, 8855.43635864573 782.8842151803237, 8975.253066603054 671.9428189235414, 9010.754313405225 565.4390785170299, 9046.255560207395 410.1211237575353, 9068.443839458752 281.4291040996677, 9050.693216057667 179.36301954342798, 9006.316657554953 90.60990253800173, 8972.337944103203 0, 8858.95553900271 0, 8979.591836734695 180.16181430038142, 8979.591836734695 360.74278305987923)), ((9935.33621028978 9591.836734693878, 9860.73785898637 9795.91836734694, 9795.91836734694 9931.26849738919, 9765.614100864956 10000, 9959.7366093588 10000, 10000 9899.990932923472, 10000 9210.342095822705, 9950.618354641661 9387.755102040817, 9935.33621028978 9591.836734693878)))', + 'GROUP': 'A', + 'ID': 1, + }, + { + 'UNITNAME': 'Litho_G', + 'geometry': 'MULTIPOLYGON (((9591.836734693878 7392.409188406808, 9387.755102040817 7366.494159309232, 9183.673469387755 7310.6236360511, 8979.591836734695 7251.495049924267, 8775.510204081633 7185.4665328045285, 8691.716875348773 7142.857142857143, 8571.428571428572 7060.166183783084, 8423.547550123565 6938.775510204082, 8367.34693877551 6891.931806291853, 8163.265306122449 6717.05674151985, 7959.183673469388 6524.418032899195, 7755.102040816327 6316.720222940251, 7530.765922702089 6122.448979591837, 7346.938775510204 5999.901440678811, 7186.986962143256 5918.367346938776, 6938.775510204082 5793.479608029736, 6734.693877551021 5711.484247324418, 6530.6122448979595 5688.577768753987, 6326.530612244898 5674.85692549725, 6122.448979591837 5664.018903459822, 5918.367346938776 5686.95963645468, 5808.41181229572 5714.285714285715, 5714.285714285715 5737.67798287528, 5510.2040816326535 5789.896906638633, 5306.122448979592 5803.500194938816, 5144.4244384765625 5714.285714285715, 4837.004213917013 5510.2040816326535, 4693.877551020409 5412.657990747569, 4564.6032995107225 5306.122448979592, 4489.795918367347 5235.455182133889, 4285.714285714286 4940.409368398238, 4169.117285280811 4693.877551020409, 4290.969225825096 4489.795918367347, 4489.795918367347 4401.180111632056, 4588.951967200454 4285.714285714286, 4693.877551020409 4151.690736108897, 4830.671037946428 3877.5510204081634, 5102.040816326531 3725.3519953513633, 5306.122448979592 3618.5887395119184, 5510.2040816326535 3357.1418450803176, 5714.285714285715 3090.5887058803014, 5921.393024678133 2857.1428571428573, 6122.448979591837 2649.130140032087, 6354.4265591368385 2448.979591836735, 6530.6122448979595 2314.575934896664, 6621.950889120297 2244.8979591836737, 6938.775510204082 2057.7853066580637, 7142.857142857143 1991.364809931541, 7346.938775510204 1953.759679988939, 7551.0204081632655 1939.4851217464525, 7755.102040816327 1938.7210145288584, 7959.183673469388 1951.3825007847379, 8163.265306122449 1964.9159178441885, 8571.428571428572 1920.2366653753788, 8784.97298882932 1836.734693877551, 9174.578141193 1632.6530612244899, 9387.755102040817 1516.645976475307, 9736.033069844148 1224.4897959183675, 10000 887.0183205117985, 10000 0, 8972.337944103203 0, 9006.316657554953 90.60990253800173, 9050.693216057667 179.36301954342798, 9068.443839458752 281.4291040996677, 9046.255560207395 410.1211237575353, 9010.754313405225 565.4390785170299, 8975.253066603054 671.9428189235414, 8855.43635864573 782.8842151803237, 8713.43137143705 845.0113970841217, 8460.484987971584 920.4515465387335, 8331.792968313717 987.0163842928032, 8052.220649746626 1093.5201246993138, 7870.2767598855025 1155.6473066031122, 7666.144590773023 1160.0849624533835, 7444.261798259459 1168.960274153926, 7311.13212275132 1195.5862092555535, 6978.307933980974 1275.4640145604371, 6822.989979221478 1324.2782289134211, 6641.046089360355 1435.2196251702035, 6246.09471868621 1776.9191256410927, 5744.639607605554 2273.9365808714774, 5465.067289038463 2611.198425492096, 5358.563548631952 2673.3256073958946, 5189.932626321643 2766.5163802515917, 4897.047340203738 2886.333088208916, 4684.039859390716 2983.9615169148847, 4542.034872182035 3028.338075417598, 4320.15207966847 3032.7757312678687, 4013.9538259997507 3037.2133871181404, 3845.322903689442 3028.338075417598, 3379.369039410956 3170.343062626279, 3082.0460974427792 3294.5974264338747, 2944.4787660843695 3361.162264187944, 2842.4126815281297 3560.8567774501525, 2780.285499624332 3840.429096017244, 2735.908941121619 4088.937823632436, 2846.850337378401 4315.258271996272, 2993.2929804373534 4554.891687910922, 3263.9899873039026 4830.026350627742, 3494.7480915180095 5020.8455521894075, 3734.3815074326594 5176.163506948902, 3925.2007089943236 5389.170987761928, 4129.332878106803 5593.303156874407, 4324.58973551874 5824.061261088515, 4542.034872182033 6063.6946770031645, 4777.230632246412 6223.450287612931, 4910.36030775455 6347.704651420527, 5145.556067818929 6445.333080126496, 5376.314172033036 6489.709638629209, 5673.6371140012125 6480.834326928666, 5984.273023520203 6427.582456725404, 6294.908933039194 6432.020112575675, 6805.239355820393 6449.77073597676, 7209.066038195081 6636.152281688155, 7683.89521417411 6951.225847057416, 8078.846584848256 7359.490185282376, 8398.357806067788 7714.50265330408, 8771.120897490577 7976.324348470085, 8984.1283783036 8184.894173432836, 9143.883988913365 8300.273225539891, 9383.517404828015 8331.33681649179, 9796.219398903246 8371.275719144232, 10000 8427.640566256101, 10000 7398.084317291527, 9795.91836734694 7385.734246701611, 9591.836734693878 7392.409188406808)), ((10000 10000, 10000 9899.990932923472, 9959.7366093588 10000, 10000 10000)))', + 'GROUP': 'A', + 'ID': 2, + }, +] + +for row in geology: + row['geometry'] = shapely.wkt.loads(row['geometry']) + +geology = geopandas.GeoDataFrame(geology, crs='epsg:7854') + +# build structures file +structures = [ + { + 'x': 2775.287768202244933, + 'y': 4330.15, + 'strike2': 45.00, + 'dip_2': 45.70, + 'id': 147.00, + 'sf': 's0', + }, + { + 'x': 3529.794754080061011, + 'y': 3091.192011237949828, + 'strike2': 288.50, + 'dip_2': 41.70, + 'id': 204.00, + 'sf': 's0', + }, + { + 'x': 7928.315269200518742, + 'y': 7234.561058065713951, + 'strike2': 48.80, + 'dip_2': 41.10, + 'id': 229.00, + 'sf': 's0', + }, + { + 'x': 8003.966104268994968, + 'y': 7421.634268009857806, + 'strike2': 48.80, + 'dip_2': 41.10, + 'id': 235.00, + 'sf': 's0', + }, + { + 'x': 6881.165236574942355, + 'y': 1213.128646564158771, + 'strike2': 299.10, + 'dip_2': 44.70, + 'id': 252.00, + 'sf': 's0', + }, + { + 'x': 3674.015651128655009, + 'y': 5266.677487068354822, + 'strike2': 41.20, + 'dip_2': 40.10, + 'id': 347.00, + 'sf': 's0', + }, + { + 'x': 3970.895076049027921, + 'y': 2944.223069901633608, + 'strike2': 273.00, + 'dip_2': 46.00, + 'id': 408.00, + 'sf': 's0', + }, +] +for row in structures: + row['geometry'] = shapely.Point(row['x'], row['y']) + del row['x'], row['y'] + +structures = geopandas.GeoDataFrame(structures, crs='epsg:7854') + +faults = geopandas.GeoDataFrame(columns=['geometry'], crs='epsg:7854') + +f_path = tempfile.mkdtemp() + +bounding_box = {"minx": 0, "miny": 0, "maxx": 10000, "maxy": 10000, "base": 0, "top": -5000} + +create_raster( + os.path.join(f_path, "DEM.tif"), + (bounding_box['minx'], bounding_box['miny'], bounding_box['maxx'], bounding_box['maxy']), + 7854, + 1000, +) + +geology.to_file(os.path.join(f_path, "geology.shp")) +structures.to_file(os.path.join(f_path, "structures.shp")) +faults.to_file(os.path.join(f_path, "faults.shp")) +loop_project_filename = os.path.join(f_path, "local_source.loop3d") + +config = { + "structure": { + "orientation_type": "strike", + "dipdir_column": "strike2", + "dip_column": "dip_2", + "description_column": "DESCRIPTION", + "bedding_text": "Bed", + "overturned_column": "structypei", + "overturned_text": "BEOI", + "objectid_column": "objectid", + "desciption_column": "feature", + }, + "geology": { + "unitname_column": "UNITNAME", + "alt_unitname_column": "UNITNAME", + "group_column": "GROUP", + "supergroup_column": "supersuite", + "description_column": "descriptn", + "minage_column": "min_age_ma", + "maxage_column": "max_age_ma", + "rocktype_column": "rocktype1", + "alt_rocktype_column": "rocktype2", + "sill_text": "sill", + "intrusive_text": "intrusive", + "volcanic_text": "volcanic", + "objectid_column": "ID", + "ignore_codes": ["cover"], + }, + "fault": { + "structtype_column": "feature", + "fault_text": "Fault", + "dip_null_value": "0", + "dipdir_flag": "num", + "dipdir_column": "dip_dir", + "dip_column": "dip", + "orientation_type": "dip direction", + "dipestimate_column": "dip_est", + "dipestimate_text": "gentle,moderate,steep", + "name_column": "name", + "objectid_column": "objectid", + }, + "fold": { + "structtype_column": "feature", + "fold_text": "Fold axial trace", + "description_column": "type", + "synform_text": "syncline", + "foldname_column": "NAME", + "objectid_column": "objectid", + }, +} + +module_path = os.path.dirname(map2loop.__file__).replace("__init__.py", "") @pytest.fixture def sample_supervisor(): - bounding_box = {"minx": 0, "miny": 0, "maxx": 10000, "maxy": 10000, "base": 0, "top": -5000} - - nowtime = datetime.now().isoformat(timespec='minutes') - model_name = nowtime.replace(":", "-").replace("T", "-") - loop_project_filename = os.path.join(model_name, "local_source.loop3d") - project = Project( - geology_filename='./data/lithologies.shp', - fault_filename="./data/faults.shp", - fold_filename="./data/faults.shp", - structure_filename="./data/measurements.shp", - dtm_filename='./data/DEM.tif', - config_filename='./data/example.hjson', - clut_filename='./data/500kibg_colours.csv', - clut_file_legacy=True, - verbose_level=VerboseLevel.NONE, - tmp_path=model_name, + proj = Project( + geology_filename=os.path.join(f_path, "geology.shp"), + fault_filename=os.path.join(f_path, "faults.shp"), + fold_filename=os.path.join(f_path, "faults.shp"), + structure_filename=os.path.join(f_path, "structures.shp"), + dtm_filename=os.path.join(f_path, 'DEM.tif'), + clut_filename=pathlib.Path(module_path) + / pathlib.Path('_datasets') + / pathlib.Path('clut_files') + / pathlib.Path('WA_clut.csv'), + config_dictionary=config, + clut_file_legacy=False, working_projection="EPSG:7854", bounding_box=bounding_box, loop_project_filename=loop_project_filename, + overwrite_loopprojectfile=True, ) - - # Or you can run map2loop and pre-specify the stratigraphic column - column = [ - # youngest - 'Litho_A', - 'Litho_B', - 'Litho_C', - 'Litho_D', - # oldest - ] - - project.run_all(user_defined_stratigraphic_column=column) - - return project.sample_supervisor + + proj.set_thickness_calculator(InterpolatedStructure()) + + column = ['Litho_G', 'Litho_F', 'Litho_E'] + + proj.set_sampler(Datatype.GEOLOGY, SamplerSpacing(100.0)) + proj.set_sampler(Datatype.STRUCTURE, SamplerDecimator(0)) + proj.run_all(user_defined_stratigraphic_column=column) + + return proj.sample_supervisor def test_type(sample_supervisor): From cff5d39f6c9ce3160da9a9d2ac4389c0187038cb Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 14:56:42 +0930 Subject: [PATCH 07/98] test: add m2l import --- tests/sample_storage/test_sample_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index ee40025d..943d4ce7 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -11,8 +11,8 @@ import tempfile import shapely import pathlib +import map2loop -# os.system('gdown --folder https://drive.google.com/drive/folders/1ZEJvPN4lpGpvoepjGMZgzYPGaY3mT46p') def create_raster(output_path, bbox, epsg, pixel_size, value=100): minx, miny, maxx, maxy = bbox From 06e6b10b9eab5be798047d83a637e933fc83c76a Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 15:04:10 +0930 Subject: [PATCH 08/98] test: changed test data --- tests/sample_storage/test_sample_storage.py | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 943d4ce7..9a885b10 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -61,56 +61,56 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 2775.287768202244933, 'y': 4330.15, - 'strike2': 45.00, - 'dip_2': 45.70, + 'STRIKE': 45.00, + 'DIP': 45.70, 'id': 147.00, 'sf': 's0', }, { 'x': 3529.794754080061011, 'y': 3091.192011237949828, - 'strike2': 288.50, - 'dip_2': 41.70, + 'STRIKE': 288.50, + 'DIP': 41.70, 'id': 204.00, 'sf': 's0', }, { 'x': 7928.315269200518742, 'y': 7234.561058065713951, - 'strike2': 48.80, - 'dip_2': 41.10, + 'STRIKE': 48.80, + 'DIP': 41.10, 'id': 229.00, 'sf': 's0', }, { 'x': 8003.966104268994968, 'y': 7421.634268009857806, - 'strike2': 48.80, - 'dip_2': 41.10, + 'STRIKE': 48.80, + 'DIP': 41.10, 'id': 235.00, 'sf': 's0', }, { 'x': 6881.165236574942355, 'y': 1213.128646564158771, - 'strike2': 299.10, - 'dip_2': 44.70, + 'STRIKE': 299.10, + 'DIP': 44.70, 'id': 252.00, 'sf': 's0', }, { 'x': 3674.015651128655009, 'y': 5266.677487068354822, - 'strike2': 41.20, - 'dip_2': 40.10, + 'STRIKE': 41.20, + 'DIP': 40.10, 'id': 347.00, 'sf': 's0', }, { 'x': 3970.895076049027921, 'y': 2944.223069901633608, - 'strike2': 273.00, - 'dip_2': 46.00, + 'STRIKE': 273.00, + 'DIP': 46.00, 'id': 408.00, 'sf': 's0', }, From f6618cf40f0ca4ff53363a123f82e1cb219bbcec Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 15:05:43 +0930 Subject: [PATCH 09/98] test: fixed structure config for test --- tests/sample_storage/test_sample_storage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 9a885b10..7872bc60 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -142,8 +142,8 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): config = { "structure": { "orientation_type": "strike", - "dipdir_column": "strike2", - "dip_column": "dip_2", + "dipdir_column": "STRIKE", + "dip_column": "DIP", "description_column": "DESCRIPTION", "bedding_text": "Bed", "overturned_column": "structypei", From 4be78bc66b44ce8a5acb9aa442ae264f48a55b5a Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 15:13:47 +0930 Subject: [PATCH 10/98] fix: inplace to false --- map2loop/thickness_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index f09432c7..85e9e869 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -246,7 +246,7 @@ def compute( contacts = samples(SampleType.CONTACT) # build points from x and y coordinates geometry2 = contacts.apply(lambda row: Point(row.X, row.Y), axis=1) - contacts.set_geometry(geometry2, inplace=True) + contacts.set_geometry(geometry2, inplace=False) # set the crs of the contacts to the crs of the units contacts = contacts.set_crs(crs=basal_contacts.crs) From d425b3c460205838233209e3aae7a947b5f6206d Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 15:34:10 +0930 Subject: [PATCH 11/98] fix: fixed set_crs method --- map2loop/thickness_calculator.py | 4 ++-- tests/sample_storage/test_sample_storage.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index 85e9e869..89be30f3 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -243,10 +243,10 @@ def compute( # increase buffer around basal contacts to ensure that the points are included as intersections basal_contacts["geometry"] = basal_contacts["geometry"].buffer(0.01) # get the sampled contacts - contacts = samples(SampleType.CONTACT) + contacts = geopandas.GeoDataFrame(samples(SampleType.CONTACT)) # build points from x and y coordinates geometry2 = contacts.apply(lambda row: Point(row.X, row.Y), axis=1) - contacts.set_geometry(geometry2, inplace=False) + contacts = contacts.set_geometry(geometry2, inplace=False) # set the crs of the contacts to the crs of the units contacts = contacts.set_crs(crs=basal_contacts.crs) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 7872bc60..96148b15 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -252,7 +252,6 @@ def test_get_sampler(sample_supervisor): assert sample_supervisor.get_sampler(SampleType.STRUCTURE) == sampler.sampler_label -# TODO: test_store to be completed def test_store(sample_supervisor): data = pandas.DataFrame() sample_supervisor.store(SampleType.STRUCTURE, data) From 09dd7f36ecd55c28a9dfa42d64c9d67ef72c59fd Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 11:09:43 +1000 Subject: [PATCH 12/98] fix: ensure all dipdir vals < 360 --- map2loop/mapdata.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 1280e883..cd9b49b9 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -723,7 +723,10 @@ def parse_structure_map(self) -> tuple: structure["DIPDIR"] = self.raw_data[Datatype.STRUCTURE][config["dipdir_column"]] else: print(f"Structure map does not contain dipdir_column '{config['dipdir_column']}'") - + + # Ensure all DIPDIR values are within [0, 360] + structure["DIPDIR"] = structure["DIPDIR"] % 360.0 + if config["dip_column"] in self.raw_data[Datatype.STRUCTURE]: structure["DIP"] = self.raw_data[Datatype.STRUCTURE][config["dip_column"]] else: From a37058b08c51e8e7284d332326f263df13f51b12 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 11:35:01 +1000 Subject: [PATCH 13/98] docs: update libtiff version --- docs/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/Dockerfile b/docs/Dockerfile index a24faffa..547af1fb 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -11,8 +11,7 @@ RUN apt-get update -qq && \ make\ libgl1\ libtinfo5\ - # libtiff5\ - libtiff-dev\ + libtiff6\ libgl1-mesa-glx From d3fc6b55e8ce818019939d710a30ba4b3bdf1769 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 12:15:54 +1000 Subject: [PATCH 14/98] fix: add test for all structures less than 360 --- tests/mapdata/test_mapdata.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/mapdata/test_mapdata.py diff --git a/tests/mapdata/test_mapdata.py b/tests/mapdata/test_mapdata.py new file mode 100644 index 00000000..14bcbfe1 --- /dev/null +++ b/tests/mapdata/test_mapdata.py @@ -0,0 +1,35 @@ +import pytest +import geopandas +import shapely +from map2loop.mapdata import MapData +from map2loop.m2l_enums import Datatype + +def test_structures_less_than_360(): + md = MapData() + + md.config.structure_config = { + "dipdir_column": "DIPDIR", + "dip_column": "DIP", + "description_column": "DESCRIPTION", + "bedding_text": "Bedding", + "objectid_column": "ID", + "overturned_column": "facing", + "overturned_text": "DOWN", + "orientation_type": "strike" + } + + data = { + 'geometry': [shapely.Point(1, 1), shapely.Point(2, 2), shapely.Point(3, 3),], + 'DIPDIR': [45.0, 370.0, 420.0], + 'DIP': [30.0, 60.0, 50], + 'OVERTURNED': ["False", "True", "True"], + 'DESCRIPTION': ["Bedding", "Bedding", "Bedidng"], + 'ID': [1, 2, 3] + } + + data = geopandas.GeoDataFrame(data) + + md.raw_data[Datatype.STRUCTURE] = data + md.parse_structure_map() + + assert md.data[Datatype.STRUCTURE]['DIPDIR'].all() < 360, "MapData.STRUCTURE is producing DIPDIRs > 360 degrees" \ No newline at end of file From 9efe63b76b0e590c3696983eab4e080f6550c86c Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 12:22:04 +1000 Subject: [PATCH 15/98] fix: add catchall exception to mapdata_parse_structure & comment code --- tests/mapdata/test_mapdata.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/mapdata/test_mapdata.py b/tests/mapdata/test_mapdata.py index 14bcbfe1..fd3c9881 100644 --- a/tests/mapdata/test_mapdata.py +++ b/tests/mapdata/test_mapdata.py @@ -5,8 +5,11 @@ from map2loop.m2l_enums import Datatype def test_structures_less_than_360(): + + # call the class md = MapData() + # add config definition md.config.structure_config = { "dipdir_column": "DIPDIR", "dip_column": "DIP", @@ -18,6 +21,7 @@ def test_structures_less_than_360(): "orientation_type": "strike" } + # create mock data data = { 'geometry': [shapely.Point(1, 1), shapely.Point(2, 2), shapely.Point(3, 3),], 'DIPDIR': [45.0, 370.0, 420.0], @@ -27,9 +31,18 @@ def test_structures_less_than_360(): 'ID': [1, 2, 3] } + #build geodataframe to hold the data data = geopandas.GeoDataFrame(data) + # set it as the raw_data md.raw_data[Datatype.STRUCTURE] = data - md.parse_structure_map() + # make it parse the structure map and raise exception if error in parse_structure_map + + try: + md.parse_structure_map() + except Exception as e: + pytest.fail(f"parse_structure_map raised an exception: {e}") + + # check if all values below 360 assert md.data[Datatype.STRUCTURE]['DIPDIR'].all() < 360, "MapData.STRUCTURE is producing DIPDIRs > 360 degrees" \ No newline at end of file From 1aa5add70e0414814ec53542c2f6506548f633b7 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 12:33:04 +1000 Subject: [PATCH 16/98] fix: make the templates a bit easier to fill out --- .github/ISSUE_TEMPLATE/bug_report.yml | 15 +++++++-------- .github/ISSUE_TEMPLATE/documentation_request.yml | 9 --------- .github/ISSUE_TEMPLATE/feature_request.yml | 16 +++++++--------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index fa8ebe43..e70de0e0 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -10,14 +10,12 @@ body: Thanks for submitting a bug report to map2loop! Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. - - type: input - id: bug_title + - type: textarea + id: version attributes: - label: "Bug Title" - description: "Provide a concise and descriptive title for the bug report." - placeholder: "Enter the title of the bug" - validations: - required: true + label: Version + description: What version of map2loop and LoopProjectFile are you running? You can find this information by running `import map2loop` and `map2loop.__version__` in your python terminal or jupyter notebook. + placeholder: "Enter map2loop and LoopProjectFile versions" - type: textarea id: bug_description @@ -32,7 +30,7 @@ body: id: steps_to_reproduce attributes: label: "Minimal reproducible example" - description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." + description: "Provide a minimal reproducible example with the code necessary to reproduce the bug. For more guidance, visit: [How to create a minimal complete reproducible example](https://forum.access-hive.org.au/t/how-to-create-a-minimal-complete-reproducible-example/843)" placeholder: "Enter the steps to reproduce the bug" validations: required: true @@ -85,3 +83,4 @@ body: - label: "Critical" validations: required: true + diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml index 22bce023..9d2ce617 100644 --- a/.github/ISSUE_TEMPLATE/documentation_request.yml +++ b/.github/ISSUE_TEMPLATE/documentation_request.yml @@ -11,15 +11,6 @@ body: Please use this template to suggest an improvement or addition to map2loop documentation. Provide as much detail as possible to help us understand and implement your request efficiently - - type: input - id: doc_title - attributes: - label: "Documentation Title" - description: "Provide a concise and descriptive title for the documentation request." - placeholder: "Enter the title of the documentation request" - validations: - required: true - - type: textarea id: doc_details attributes: diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index de3a3215..5d2d409a 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -20,15 +20,6 @@ body: options: - label: Would you like to work on this feature? - - type: input - id: feature_title - attributes: - label: "Feature Title" - description: "Provide a concise and descriptive title for the feature request." - placeholder: "Enter the title of the feature" - validations: - required: true - - type: textarea id: feature_description attributes: @@ -47,6 +38,13 @@ body: validations: required: true + - type: textarea + id: version + attributes: + label: Version + description: What version of map2loop and LoopProjectFile are you running that doesn't have this feature? You can find this information by running `import map2loop` and `map2loop.__version__` in your python terminal or jupyter notebook. + placeholder: "Enter map2loop and LoopProjectFile versions" + - type: textarea id: proposed_solution attributes: From c61e225771d43d4514e8183971b5f5f103b1ebab Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 12:34:29 +1000 Subject: [PATCH 17/98] fix: update question template --- .github/ISSUE_TEMPLATE/question.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 6e43c3e1..ba6b949b 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -11,15 +11,6 @@ body: Please use this template to ask a question about applying map2loop to your data. Provide as much detail as possible to help us understand and answer your question efficiently. - - type: input - id: question_title - attributes: - label: "Question Title" - description: "Provide a concise and descriptive title for your question." - placeholder: "Enter the title of your question" - validations: - required: true - - type: textarea id: question_details attributes: From 8be28c8b863ba4d1f7054081549c9f09bfc57295 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 15:31:06 +1000 Subject: [PATCH 18/98] fix: move location of the PR template --- .github/{ISSUE_TEMPLATE => }/pull_request_template.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ISSUE_TEMPLATE => }/pull_request_template.md (100%) diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.md b/.github/pull_request_template.md similarity index 100% rename from .github/ISSUE_TEMPLATE/pull_request_template.md rename to .github/pull_request_template.md From f7b29c6d457c6608e6f7a4f8b57d424fb79e6e38 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 15:57:57 +1000 Subject: [PATCH 19/98] fix: fix for altitude not being saved properly in LPF --- map2loop/project.py | 2 +- map2loop/sampler.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/map2loop/project.py b/map2loop/project.py index 494bf7a5..fbc03033 100644 --- a/map2loop/project.py +++ b/map2loop/project.py @@ -719,7 +719,7 @@ def save_into_projectfile(self): observations["layerId"] = self.sample_supervisor(SampleType.STRUCTURE)["layerID"] observations["easting"] = self.sample_supervisor(SampleType.STRUCTURE)["X"] observations["northing"] = self.sample_supervisor(SampleType.STRUCTURE)["Y"] - # observations["altitude"] = self.structure_samples["Z"] + observations["altitude"] = self.sample_supervisor(SampleType.STRUCTURE)["Z"] observations["dipDir"] = self.sample_supervisor(SampleType.STRUCTURE)["DIPDIR"] observations["dip"] = self.sample_supervisor(SampleType.STRUCTURE)["DIP"] observations["dipPolarity"] = self.sample_supervisor(SampleType.STRUCTURE)["OVERTURNED"] diff --git a/map2loop/sampler.py b/map2loop/sampler.py index 9d97d73d..daf1ef6e 100644 --- a/map2loop/sampler.py +++ b/map2loop/sampler.py @@ -84,6 +84,7 @@ def sample( data = spatial_data.copy() data["X"] = data.geometry.x data["Y"] = data.geometry.y + map_data.get_value_from_raster_df(Datatype.DTM, data) data["layerID"] = geopandas.sjoin( data, map_data.get_map_data(Datatype.GEOLOGY), how='left' )['index_right'] From 6efdc980aac92dbaa08c602ab37f88974865ef05 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 10:46:07 +1000 Subject: [PATCH 20/98] fix: update tests that depend on server to skip in case server is unavailable --- tests/project/test_plot_hamersley.py | 28 +++++++----- .../test_thickness_StructuralPoint_server.py | 43 +++++++++++-------- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/tests/project/test_plot_hamersley.py b/tests/project/test_plot_hamersley.py index 6300fcc4..1c78bb7b 100644 --- a/tests/project/test_plot_hamersley.py +++ b/tests/project/test_plot_hamersley.py @@ -1,8 +1,12 @@ -import pytest +#internal imports from map2loop.project import Project from map2loop.m2l_enums import VerboseLevel + +#external imports +import pytest from pyproj.exceptions import CRSError import os +import requests bbox_3d = { "minx": 515687.31005864, @@ -23,15 +27,19 @@ def remove_LPF(): def test_project_execution(): - proj = Project( - use_australian_state_data="WA", - working_projection="EPSG:28350", - bounding_box=bbox_3d, - clut_file_legacy=False, - verbose_level=VerboseLevel.NONE, - loop_project_filename=loop_project_filename, - overwrite_loopprojectfile=True, - ) + try: + proj = Project( + use_australian_state_data="WA", + working_projection="EPSG:28350", + bounding_box=bbox_3d, + clut_file_legacy=False, + verbose_level=VerboseLevel.NONE, + loop_project_filename=loop_project_filename, + overwrite_loopprojectfile=True, + ) + except requests.exceptions.ReadTimeout: + pytest.skip("Connection to the server timed out, skipping test") + proj.run_all(take_best=True) assert proj is not None, "Plot Hamersley Basin failed to execute" diff --git a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_server.py b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_server.py index 8eb0e4bc..21ba002e 100644 --- a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_server.py +++ b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_server.py @@ -1,8 +1,12 @@ +#internal imports from map2loop.thickness_calculator import StructuralPoint from map2loop.project import Project from map2loop.m2l_enums import VerboseLevel -import pathlib +#external imports +import pathlib +import pytest +import requests import map2loop @@ -19,23 +23,26 @@ def test_from_aus_state(): loop_project_filename = "wa_output.loop3d" module_path = map2loop.__file__.replace("__init__.py", "") - proj = Project( - use_australian_state_data="WA", - working_projection="EPSG:28350", - bounding_box=bbox_3d, - config_filename=pathlib.Path(module_path) - / pathlib.Path('_datasets') - / pathlib.Path('config_files') - / pathlib.Path('WA.json'), - clut_filename=pathlib.Path(module_path) - / pathlib.Path('_datasets') - / pathlib.Path('clut_files') - / pathlib.Path('WA_clut.csv'), - # clut_file_legacy=False, - verbose_level=VerboseLevel.NONE, - loop_project_filename=loop_project_filename, - overwrite_loopprojectfile=True, - ) + try: + proj = Project( + use_australian_state_data="WA", + working_projection="EPSG:28350", + bounding_box=bbox_3d, + config_filename=pathlib.Path(module_path) + / pathlib.Path('_datasets') + / pathlib.Path('config_files') + / pathlib.Path('WA.json'), + clut_filename=pathlib.Path(module_path) + / pathlib.Path('_datasets') + / pathlib.Path('clut_files') + / pathlib.Path('WA_clut.csv'), + # clut_file_legacy=False, + verbose_level=VerboseLevel.NONE, + loop_project_filename=loop_project_filename, + overwrite_loopprojectfile=True, + ) + except requests.exceptions.ReadTimeout: + pytest.skip("Connection to the server timed out, skipping test") proj.set_thickness_calculator(StructuralPoint()) proj.run_all() From 933130e86e09254215ea44d54074f774fb13775d Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 11:48:11 +1000 Subject: [PATCH 21/98] test: fix for when server not available --- tests/project/test_plot_hamersley.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/project/test_plot_hamersley.py b/tests/project/test_plot_hamersley.py index 1c78bb7b..2ce73241 100644 --- a/tests/project/test_plot_hamersley.py +++ b/tests/project/test_plot_hamersley.py @@ -43,10 +43,7 @@ def test_project_execution(): proj.run_all(take_best=True) assert proj is not None, "Plot Hamersley Basin failed to execute" - -def test_file_creation(): - expected_file = loop_project_filename - assert os.path.exists(expected_file), f"Expected file {expected_file} was not created" + assert os.path.exists(loop_project_filename), f"Expected file {loop_project_filename} was not created" ################################################################### From b4fba5623750f3c00c944f09689f77d731484af1 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 12:55:26 +1000 Subject: [PATCH 22/98] fix: allow 2 minutes for server connection & add add available ga server link --- map2loop/mapdata.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index cd9b49b9..40856fd5 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -466,7 +466,7 @@ def open_http_query(url: str): """ try: request = urllib.Request(url, headers={"Accept-Encoding": "gzip"}) - response = urllib.request.urlopen(request, timeout=30) + response = urllib.request.urlopen(request, timeout=120) if response.info().get("Content-Encoding") == "gzip": return GzipFile(fileobj=BytesIO(response.read())) else: @@ -495,12 +495,14 @@ def __retrieve_tif(self, filename: str): _type_: The open geotiff in a gdal handler """ self.__check_and_create_tmp_path() + # For gdal debugging use exceptions gdal.UseExceptions() bb_ll = tuple(self.bounding_box_polygon.to_crs("EPSG:4326").geometry.total_bounds) - # try: + if filename.lower() == "aus" or filename.lower() == "au": - url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" + url = "http://gaservices.ga.gov.au/site_9/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" + # previous link version: "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" wcs = WebCoverageService(url, version="1.0.0") coverage = wcs.getCoverage( identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 @@ -512,12 +514,14 @@ def __retrieve_tif(self, filename: str): with open(tmp_file, "wb") as fh: fh.write(coverage.read()) tif = gdal.Open(tmp_file) + elif filename == "hawaii": import netCDF4 bbox_str = ( f"[({str(bb_ll[1])}):1:({str(bb_ll[3])})][({str(bb_ll[0])}):1:({str(bb_ll[2])})]" ) + filename = f"https://pae-paha.pacioos.hawaii.edu/erddap/griddap/srtm30plus_v11_land.nc?elev{bbox_str}" f = urllib.request.urlopen(filename) ds = netCDF4.Dataset("in-mem-file", mode="r", memory=f.read()) From 78c5a80b4c5ba6689f44f52d714b134585110ac8 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 14:34:53 +1000 Subject: [PATCH 23/98] fix: add 2 more links to try from GA WCS if timing out & prints out where the DEM was downloaded from --- map2loop/mapdata.py | 66 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 40856fd5..cd8dd5bd 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -17,7 +17,7 @@ from .aus_state_urls import AustraliaStateUrls from .random_colour import random_colours_hex from typing import Union - +import requests class MapData: """ @@ -482,6 +482,40 @@ def __check_and_create_tmp_path(self): if not os.path.isdir(self.tmp_path): os.mkdir(self.tmp_path) + + @beartype.beartype + def get_coverage(self, url: str, bb_ll:tuple): + """ + Retrieves coverage from GA WCS and save it as a GeoTIFF file. + + This method retrieves a coverage from the specified WCS GA URL using the project's bounding box. + The retrieved coverage is saved to a temporary file --> StudidGDALLocalFile.tif + + Args: + url (str): The GA WCS URL from which to retrieve the coverage. + bb_ll (tuple): A tuple containing the bounding box coordinates (minX, minY, maxX, maxY). + + Returns: + gdal.Dataset: The GDAL dataset of the retrieved GeoTIFF file. + """ + + self.__check_and_create_tmp_path() + + wcs = WebCoverageService(url, version="1.0.0") + + coverage = wcs.getCoverage( + identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 + ) + # This is stupid that gdal cannot read a byte stream and has to have a + # file on the local system to open or otherwise create a gdal file + # from scratch with Create + tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") + + with open(tmp_file, "wb") as fh: + fh.write(coverage.read()) + + return gdal.Open(tmp_file) + @beartype.beartype def __retrieve_tif(self, filename: str): """ @@ -494,27 +528,29 @@ def __retrieve_tif(self, filename: str): Returns: _type_: The open geotiff in a gdal handler """ - self.__check_and_create_tmp_path() # For gdal debugging use exceptions gdal.UseExceptions() bb_ll = tuple(self.bounding_box_polygon.to_crs("EPSG:4326").geometry.total_bounds) if filename.lower() == "aus" or filename.lower() == "au": - url = "http://gaservices.ga.gov.au/site_9/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" - # previous link version: "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" - wcs = WebCoverageService(url, version="1.0.0") - coverage = wcs.getCoverage( - identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 - ) - # This is stupid that gdal cannot read a byte stream and has to have a - # file on the local system to open or otherwise create a gdal file - # from scratch with Create - tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") - with open(tmp_file, "wb") as fh: - fh.write(coverage.read()) - tif = gdal.Open(tmp_file) + urls = [ + "http://services.ga.gov.au/gis/se33rvices/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?", # DEM with land and sea! + "http://services.ga.gov.au/gis/ser333ices/DEM_SRTM_1Second/MapServer/WCSServer?", # DEM with land only + "http://services.ga.gov.au/gis/serv33ices/DEM_SRTM_1Second_Hydro_Enforced/MapServer/WCSServer?"] # dem that accounts for lakes + for url in urls: + try: + tif = self.get_coverage(url, bb_ll) + if tif is not None: + print("DEM loaded from {}".format(url)) + return tif + + except Exception: + pass + + raise Exception("All GA URLs failed to retrieve the DEM coverage.") + elif filename == "hawaii": import netCDF4 From 4a057643c6af52cce99a0d29fda8f65118fe2939 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 20:34:46 +1000 Subject: [PATCH 24/98] fix: revert back to original --- map2loop/mapdata.py | 64 +++++++++++---------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index cd8dd5bd..bb019508 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -483,39 +483,7 @@ def __check_and_create_tmp_path(self): os.mkdir(self.tmp_path) - @beartype.beartype - def get_coverage(self, url: str, bb_ll:tuple): - """ - Retrieves coverage from GA WCS and save it as a GeoTIFF file. - - This method retrieves a coverage from the specified WCS GA URL using the project's bounding box. - The retrieved coverage is saved to a temporary file --> StudidGDALLocalFile.tif - - Args: - url (str): The GA WCS URL from which to retrieve the coverage. - bb_ll (tuple): A tuple containing the bounding box coordinates (minX, minY, maxX, maxY). - - Returns: - gdal.Dataset: The GDAL dataset of the retrieved GeoTIFF file. - """ - - self.__check_and_create_tmp_path() - - wcs = WebCoverageService(url, version="1.0.0") - - coverage = wcs.getCoverage( - identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 - ) - # This is stupid that gdal cannot read a byte stream and has to have a - # file on the local system to open or otherwise create a gdal file - # from scratch with Create - tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") - - with open(tmp_file, "wb") as fh: - fh.write(coverage.read()) - - return gdal.Open(tmp_file) - + @beartype.beartype def __retrieve_tif(self, filename: str): """ @@ -532,24 +500,22 @@ def __retrieve_tif(self, filename: str): # For gdal debugging use exceptions gdal.UseExceptions() bb_ll = tuple(self.bounding_box_polygon.to_crs("EPSG:4326").geometry.total_bounds) - + if filename.lower() == "aus" or filename.lower() == "au": - urls = [ - "http://services.ga.gov.au/gis/se33rvices/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?", # DEM with land and sea! - "http://services.ga.gov.au/gis/ser333ices/DEM_SRTM_1Second/MapServer/WCSServer?", # DEM with land only - "http://services.ga.gov.au/gis/serv33ices/DEM_SRTM_1Second_Hydro_Enforced/MapServer/WCSServer?"] # dem that accounts for lakes + url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second/MapServer/WCSServer?" + wcs = WebCoverageService(url, version="1.0.0") - for url in urls: - try: - tif = self.get_coverage(url, bb_ll) - if tif is not None: - print("DEM loaded from {}".format(url)) - return tif - - except Exception: - pass - - raise Exception("All GA URLs failed to retrieve the DEM coverage.") + coverage = wcs.getCoverage( + identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 + ) + # This is stupid that gdal cannot read a byte stream and has to have a + # file on the local system to open or otherwise create a gdal file + # from scratch with Create + + tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") + with open(tmp_file, "wb") as fh: + fh.write(coverage.read()) + tif = gdal.Open(tmp_file) elif filename == "hawaii": import netCDF4 From 024f67f2fdbe94ba1aecc6d5f7c560f19aaa09b2 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 20:41:58 +1000 Subject: [PATCH 25/98] fix: create the tmp file function missing --- map2loop/mapdata.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index bb019508..8ad62882 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -496,12 +496,14 @@ def __retrieve_tif(self, filename: str): Returns: _type_: The open geotiff in a gdal handler """ - + self.__check_and_create_tmp_path() + # For gdal debugging use exceptions gdal.UseExceptions() bb_ll = tuple(self.bounding_box_polygon.to_crs("EPSG:4326").geometry.total_bounds) if filename.lower() == "aus" or filename.lower() == "au": + url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second/MapServer/WCSServer?" wcs = WebCoverageService(url, version="1.0.0") @@ -511,8 +513,9 @@ def __retrieve_tif(self, filename: str): # This is stupid that gdal cannot read a byte stream and has to have a # file on the local system to open or otherwise create a gdal file # from scratch with Create - + tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") + with open(tmp_file, "wb") as fh: fh.write(coverage.read()) tif = gdal.Open(tmp_file) From f6fe37024bbe8725d29b0280fd96e87de28eb55e Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 4 Jun 2024 08:53:43 +1000 Subject: [PATCH 26/98] fix: return just column with new vals instead of inplace modification --- map2loop/sampler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/sampler.py b/map2loop/sampler.py index daf1ef6e..75e5a159 100644 --- a/map2loop/sampler.py +++ b/map2loop/sampler.py @@ -84,7 +84,7 @@ def sample( data = spatial_data.copy() data["X"] = data.geometry.x data["Y"] = data.geometry.y - map_data.get_value_from_raster_df(Datatype.DTM, data) + data["Z"] = map_data.get_value_from_raster_df(Datatype.DTM, data)["Z"] data["layerID"] = geopandas.sjoin( data, map_data.get_map_data(Datatype.GEOLOGY), how='left' )['index_right'] From 7d9e6d7ff7dbbc60b7d7f0c09d0b85dba8e4a4b9 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 4 Jun 2024 09:09:59 +1000 Subject: [PATCH 27/98] fix: use gpd.points_from_xy --- map2loop/thickness_calculator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index 89be30f3..b9aa7ca7 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -245,8 +245,8 @@ def compute( # get the sampled contacts contacts = geopandas.GeoDataFrame(samples(SampleType.CONTACT)) # build points from x and y coordinates - geometry2 = contacts.apply(lambda row: Point(row.X, row.Y), axis=1) - contacts = contacts.set_geometry(geometry2, inplace=False) + geometry2 = geopandas.points_from_xy(contacts['X'], contacts['Y']) + contacts.set_geometry(geometry2, inplace=True) # set the crs of the contacts to the crs of the units contacts = contacts.set_crs(crs=basal_contacts.crs) From f7fd8e8dfd2ce27d876e868af3a0298ac79a9669 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 4 Jun 2024 09:34:55 +1000 Subject: [PATCH 28/98] fix: verbose dipdir 360 test name --- tests/mapdata/test_mapdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mapdata/test_mapdata.py b/tests/mapdata/test_mapdata.py index fd3c9881..2bd9030e 100644 --- a/tests/mapdata/test_mapdata.py +++ b/tests/mapdata/test_mapdata.py @@ -4,7 +4,7 @@ from map2loop.mapdata import MapData from map2loop.m2l_enums import Datatype -def test_structures_less_than_360(): +def test_if_m2l_returns_all_sampled_structures_with_DIPDIR_lower_than_360(): # call the class md = MapData() From 9285be5c82dbb4f11d6359410204a69fd93fbb02 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 6 Jun 2024 14:49:37 +1000 Subject: [PATCH 29/98] fix: revert back to original timeout --- map2loop/mapdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 8ad62882..c4e789af 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -466,7 +466,7 @@ def open_http_query(url: str): """ try: request = urllib.Request(url, headers={"Accept-Encoding": "gzip"}) - response = urllib.request.urlopen(request, timeout=120) + response = urllib.request.urlopen(request, timeout=30) if response.info().get("Content-Encoding") == "gzip": return GzipFile(fileobj=BytesIO(response.read())) else: From 1ade12dd8844b6f7a64ea916da8f94f5e1700c33 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 6 Jun 2024 14:57:06 +1000 Subject: [PATCH 30/98] fix: revert back to original url --- map2loop/mapdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index c4e789af..9986c163 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -504,7 +504,7 @@ def __retrieve_tif(self, filename: str): if filename.lower() == "aus" or filename.lower() == "au": - url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second/MapServer/WCSServer?" + url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" wcs = WebCoverageService(url, version="1.0.0") coverage = wcs.getCoverage( From ca5cb0b295ffc1891923460ea30325585a705a61 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 05:20:25 +0000 Subject: [PATCH 31/98] chore(master): release 3.1.5 --- CHANGELOG.md | 29 +++++++++++++++++++++++++++++ map2loop/version.py | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7d2af82..a9412930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Changelog +## [3.1.5](https://github.com/Loop3D/map2loop/compare/v3.1.4...v3.1.5) (2024-06-06) + + +### Bug Fixes + +* add 2 more links to try from GA WCS if timing out & prints out where the DEM was downloaded from ([92f73a5](https://github.com/Loop3D/map2loop/commit/92f73a55ad998af76fe02fd09702d98492c6e431)) +* add catchall exception to mapdata_parse_structure & comment code ([59c677c](https://github.com/Loop3D/map2loop/commit/59c677c5988c1e411723c61f3482dbd792ed19a7)) +* add test for all structures less than 360 ([f08c42a](https://github.com/Loop3D/map2loop/commit/f08c42a7e455657c0d042e1346fa5ce5fdb98775)) +* allow 2 minutes for server connection & add add available ga server link ([900a50d](https://github.com/Loop3D/map2loop/commit/900a50d34f44e50c508466d617e4ce8d85c0c316)) +* avoid double imports ([3347751](https://github.com/Loop3D/map2loop/commit/334775120d8db88a82e70980f68940d024524687)) +* create the tmp file function missing ([55688fe](https://github.com/Loop3D/map2loop/commit/55688fe85f7aca2678a15160a73a972427a3bf34)) +* ensure all dipdir vals < 360 ([cf21a6b](https://github.com/Loop3D/map2loop/commit/cf21a6ba8cc0c48dfb7cc442d59a6cd63678ab83)) +* fix for altitude not being saved properly in LPF ([b2c6638](https://github.com/Loop3D/map2loop/commit/b2c663866f478752670aca41a188aa195df9c90f)) +* make the templates a bit easier to fill out ([81f54fe](https://github.com/Loop3D/map2loop/commit/81f54fe9f7163dc997219b4fe092c81b6c7b3ca3)) +* move location of the PR template ([9209c25](https://github.com/Loop3D/map2loop/commit/9209c251520bfd993a51b04124ad62a831a58922)) +* return just column with new vals instead of inplace modification ([722b98c](https://github.com/Loop3D/map2loop/commit/722b98cdbcf1f820b9d1a480f09ac59d287f1a04)) +* revert back to original ([6ed00c9](https://github.com/Loop3D/map2loop/commit/6ed00c999901c3236e53fc039930510be9d38570)) +* revert back to original timeout ([301242f](https://github.com/Loop3D/map2loop/commit/301242f931b92ac01c4251ecf9039119d9da49d5)) +* revert back to original url ([26e4971](https://github.com/Loop3D/map2loop/commit/26e497198744c591879fea96c10935d6b79b7d9d)) +* update question template ([8182e50](https://github.com/Loop3D/map2loop/commit/8182e50361852de817e1440adcb278b5f46f4796)) +* update tests that depend on server to skip in case server is unavailable ([646be9e](https://github.com/Loop3D/map2loop/commit/646be9ea06dade92f16208da7e681d6d2b0e6c65)) +* use gpd.points_from_xy ([2f931c5](https://github.com/Loop3D/map2loop/commit/2f931c59025997133aeea9c10f725858613b7f6b)) +* verbose dipdir 360 test name ([6ffe6bf](https://github.com/Loop3D/map2loop/commit/6ffe6bf31ab860ee054bb175a63c00fee7b8a7ff)) + + +### Documentation + +* update libtiff version ([0a99ac8](https://github.com/Loop3D/map2loop/commit/0a99ac8aaf6980196216137f15060c44b2f77cd9)) + ## [3.1.4](https://github.com/Loop3D/map2loop/compare/v3.1.3...v3.1.4) (2024-05-29) diff --git a/map2loop/version.py b/map2loop/version.py index 1fe90f6a..0aff436e 100644 --- a/map2loop/version.py +++ b/map2loop/version.py @@ -1 +1 @@ -__version__ = "3.1.4" +__version__ = "3.1.5" From c323df54c4ea5ddd6ad77e8782e74055a9b563de Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 09:47:27 +0930 Subject: [PATCH 32/98] test: changed STRIKE to DIPDIR --- tests/sample_storage/test_sample_storage.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 96148b15..084d788d 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -61,7 +61,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 2775.287768202244933, 'y': 4330.15, - 'STRIKE': 45.00, + 'DIPDIR': 45.00, 'DIP': 45.70, 'id': 147.00, 'sf': 's0', @@ -69,7 +69,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 3529.794754080061011, 'y': 3091.192011237949828, - 'STRIKE': 288.50, + 'DIPDIR': 288.50, 'DIP': 41.70, 'id': 204.00, 'sf': 's0', @@ -77,7 +77,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 7928.315269200518742, 'y': 7234.561058065713951, - 'STRIKE': 48.80, + 'DIPDIR': 48.80, 'DIP': 41.10, 'id': 229.00, 'sf': 's0', @@ -85,7 +85,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 8003.966104268994968, 'y': 7421.634268009857806, - 'STRIKE': 48.80, + 'DIPDIR': 48.80, 'DIP': 41.10, 'id': 235.00, 'sf': 's0', @@ -93,7 +93,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 6881.165236574942355, 'y': 1213.128646564158771, - 'STRIKE': 299.10, + 'DIPDIR': 299.10, 'DIP': 44.70, 'id': 252.00, 'sf': 's0', @@ -101,7 +101,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 3674.015651128655009, 'y': 5266.677487068354822, - 'STRIKE': 41.20, + 'DIPDIR': 41.20, 'DIP': 40.10, 'id': 347.00, 'sf': 's0', @@ -109,7 +109,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 3970.895076049027921, 'y': 2944.223069901633608, - 'STRIKE': 273.00, + 'DIPDIR': 273.00, 'DIP': 46.00, 'id': 408.00, 'sf': 's0', From 2def0a8be13d187725794812ab943a2c609b39c6 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 09:56:50 +0930 Subject: [PATCH 33/98] fix: Added DIPDIR to dipdir_column --- tests/sample_storage/test_sample_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 084d788d..0bf3aea0 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -142,7 +142,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): config = { "structure": { "orientation_type": "strike", - "dipdir_column": "STRIKE", + "dipdir_column": "DIPDIR", "dip_column": "DIP", "description_column": "DESCRIPTION", "bedding_text": "Bed", From a032a2470d9d82c34968f3632b8cc9b20be2bed2 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 10:27:30 +0930 Subject: [PATCH 34/98] test: samples return sample_supervisor --- .../InterpolatedStructure/test_interpolated_structure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/thickness/InterpolatedStructure/test_interpolated_structure.py b/tests/thickness/InterpolatedStructure/test_interpolated_structure.py index 606556fc..c72ff056 100644 --- a/tests/thickness/InterpolatedStructure/test_interpolated_structure.py +++ b/tests/thickness/InterpolatedStructure/test_interpolated_structure.py @@ -245,7 +245,7 @@ def basal_contacts(project): @pytest.fixture def samples(project): - return project.structure_samples + return project.sample_supervisor @pytest.fixture From 74a35cd69ea9948a6808ac8b8e065acb841acefc Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 10:52:46 +0930 Subject: [PATCH 35/98] fix: remove sample processing from Project class --- map2loop/project.py | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/map2loop/project.py b/map2loop/project.py index fbc03033..77f4e965 100644 --- a/map2loop/project.py +++ b/map2loop/project.py @@ -121,8 +121,6 @@ def __init__( self._error_state = ErrorState.NONE self._error_state_msg = "" self.verbose_level = verbose_level - self.samplers = [SamplerDecimator()] * len(Datatype) - self.set_default_samplers() self.sorter = SorterUseHint() self.thickness_calculator = ThicknessCalculatorAlpha() self.throw_calculator = ThrowCalculatorAlpha() @@ -315,42 +313,6 @@ def get_throw_calculator(self): """ return self.throw_calculator.throw_calculator_label - def set_default_samplers(self): - """ - Initialisation function to set or reset the point samplers - """ - self.samplers[Datatype.STRUCTURE] = SamplerDecimator(1) - self.samplers[Datatype.GEOLOGY] = SamplerSpacing(50.0) - self.samplers[Datatype.FAULT] = SamplerSpacing(50.0) - self.samplers[Datatype.FOLD] = SamplerSpacing(50.0) - self.samplers[Datatype.DTM] = SamplerSpacing(50.0) - - @beartype.beartype - def set_sampler(self, datatype: Datatype, sampler: Sampler): - """ - Set the point sampler for a specific datatype - - Args: - datatype (Datatype): - The datatype to use this sampler on - sampler (Sampler): - The sampler to use - """ - self.samplers[datatype] = sampler - - @beartype.beartype - def get_sampler(self, datatype: Datatype): - """ - Get the sampler name being used for a datatype - - Args: - datatype (Datatype): The datatype of the sampler - - Returns: - str: The name of the sampler being used on the specified datatype - """ - return self.samplers[datatype].sampler_label - @beartype.beartype def set_minimum_fault_length(self, length: float): """ From 47d51f3f147890509a321cf1cdce8853a3297d70 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 10:52:59 +0930 Subject: [PATCH 36/98] test: fixed data error in test --- tests/sample_storage/test_sample_storage.py | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 0bf3aea0..8f2e0cb9 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -61,56 +61,56 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 2775.287768202244933, 'y': 4330.15, - 'DIPDIR': 45.00, - 'DIP': 45.70, + 'strike2': 45.00, + 'dip_2': 45.70, 'id': 147.00, 'sf': 's0', }, { 'x': 3529.794754080061011, 'y': 3091.192011237949828, - 'DIPDIR': 288.50, - 'DIP': 41.70, + 'strike2': 288.50, + 'dip_2': 41.70, 'id': 204.00, 'sf': 's0', }, { 'x': 7928.315269200518742, 'y': 7234.561058065713951, - 'DIPDIR': 48.80, - 'DIP': 41.10, + 'strike2': 48.80, + 'dip_2': 41.10, 'id': 229.00, 'sf': 's0', }, { 'x': 8003.966104268994968, 'y': 7421.634268009857806, - 'DIPDIR': 48.80, - 'DIP': 41.10, + 'strike2': 48.80, + 'dip_2': 41.10, 'id': 235.00, 'sf': 's0', }, { 'x': 6881.165236574942355, 'y': 1213.128646564158771, - 'DIPDIR': 299.10, - 'DIP': 44.70, + 'strike2': 299.10, + 'dip_2': 44.70, 'id': 252.00, 'sf': 's0', }, { 'x': 3674.015651128655009, 'y': 5266.677487068354822, - 'DIPDIR': 41.20, - 'DIP': 40.10, + 'strike2': 41.20, + 'dip_2': 40.10, 'id': 347.00, 'sf': 's0', }, { 'x': 3970.895076049027921, 'y': 2944.223069901633608, - 'DIPDIR': 273.00, - 'DIP': 46.00, + 'strike2': 273.00, + 'dip_2': 46.00, 'id': 408.00, 'sf': 's0', }, @@ -142,8 +142,8 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): config = { "structure": { "orientation_type": "strike", - "dipdir_column": "DIPDIR", - "dip_column": "DIP", + "dipdir_column": "strike2", + "dip_column": "dip_2", "description_column": "DESCRIPTION", "bedding_text": "Bed", "overturned_column": "structypei", @@ -194,7 +194,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): @pytest.fixture -def sample_supervisor(): +def project(): proj = Project( geology_filename=os.path.join(f_path, "geology.shp"), fault_filename=os.path.join(f_path, "faults.shp"), From 8d7e44e576b1d48a1fcfed7a5e8749a3333bfb41 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 11:01:58 +0930 Subject: [PATCH 37/98] test: use SampleSupervisor to set sampler --- tests/sample_storage/test_sample_storage.py | 4 ++-- .../test_thickness_StructuralPoint_local_source.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 8f2e0cb9..d85d2e1a 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -217,8 +217,8 @@ def project(): column = ['Litho_G', 'Litho_F', 'Litho_E'] - proj.set_sampler(Datatype.GEOLOGY, SamplerSpacing(100.0)) - proj.set_sampler(Datatype.STRUCTURE, SamplerDecimator(0)) + proj.sample_supervisor.set_sampler(Datatype.GEOLOGY, SamplerSpacing(100.0)) + proj.sample_supervisor.set_sampler(Datatype.STRUCTURE, SamplerDecimator(0)) proj.run_all(user_defined_stratigraphic_column=column) return proj.sample_supervisor diff --git a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py index 21eae570..cabcfb85 100644 --- a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py +++ b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py @@ -215,8 +215,8 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): proj.set_thickness_calculator(StructuralPoint()) column = ['Litho_G', 'Litho_F', 'Litho_E'] -proj.set_sampler(Datatype.GEOLOGY, SamplerSpacing(100.0)) -proj.set_sampler(Datatype.STRUCTURE, SamplerDecimator(0)) +proj.sample_supervisor.set_sampler(Datatype.GEOLOGY, SamplerSpacing(100.0)) +proj.sample_supervisor.set_sampler(Datatype.STRUCTURE, SamplerDecimator(0)) proj.run_all(user_defined_stratigraphic_column=column) From a9a3a7b3fcfca2d06bc8c0294bfb870bf9661ff0 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 11:07:31 +0930 Subject: [PATCH 38/98] test: use correct type --- tests/sample_storage/test_sample_storage.py | 4 ++-- .../test_thickness_StructuralPoint_local_source.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index d85d2e1a..3414801d 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -217,8 +217,8 @@ def project(): column = ['Litho_G', 'Litho_F', 'Litho_E'] - proj.sample_supervisor.set_sampler(Datatype.GEOLOGY, SamplerSpacing(100.0)) - proj.sample_supervisor.set_sampler(Datatype.STRUCTURE, SamplerDecimator(0)) + proj.sample_supervisor.set_sampler(SampleType.GEOLOGY, SamplerSpacing(100.0)) + proj.sample_supervisor.set_sampler(SampleType.STRUCTURE, SamplerDecimator(0)) proj.run_all(user_defined_stratigraphic_column=column) return proj.sample_supervisor diff --git a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py index cabcfb85..920b44a7 100644 --- a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py +++ b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py @@ -12,7 +12,7 @@ import pathlib from map2loop.sampler import SamplerSpacing, SamplerDecimator from map2loop.project import Project -from map2loop.m2l_enums import Datatype +from map2loop.m2l_enums import SampleType, Datatype import map2loop @@ -215,8 +215,8 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): proj.set_thickness_calculator(StructuralPoint()) column = ['Litho_G', 'Litho_F', 'Litho_E'] -proj.sample_supervisor.set_sampler(Datatype.GEOLOGY, SamplerSpacing(100.0)) -proj.sample_supervisor.set_sampler(Datatype.STRUCTURE, SamplerDecimator(0)) +proj.sample_supervisor.set_sampler(SampleType.GEOLOGY, SamplerSpacing(100.0)) +proj.sample_supervisor.set_sampler(SampleType.STRUCTURE, SamplerDecimator(0)) proj.run_all(user_defined_stratigraphic_column=column) From 138ae154b9eb63829b27d18a78ef2805a6135216 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 11:13:14 +0930 Subject: [PATCH 39/98] test: corrected fixture name --- tests/sample_storage/test_sample_storage.py | 2 +- .../InterpolatedStructure/test_interpolated_structure.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 3414801d..a0cc2731 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -194,7 +194,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): @pytest.fixture -def project(): +def sample_supervisor(): proj = Project( geology_filename=os.path.join(f_path, "geology.shp"), fault_filename=os.path.join(f_path, "faults.shp"), diff --git a/tests/thickness/InterpolatedStructure/test_interpolated_structure.py b/tests/thickness/InterpolatedStructure/test_interpolated_structure.py index c72ff056..0206010c 100644 --- a/tests/thickness/InterpolatedStructure/test_interpolated_structure.py +++ b/tests/thickness/InterpolatedStructure/test_interpolated_structure.py @@ -9,7 +9,7 @@ import tempfile import pathlib from map2loop.sampler import SamplerSpacing, SamplerDecimator -from map2loop.m2l_enums import Datatype +from map2loop.m2l_enums import Datatype, SampleType import map2loop @@ -216,8 +216,8 @@ def project(): column = ['Litho_G', 'Litho_F', 'Litho_E'] - proj.set_sampler(Datatype.GEOLOGY, SamplerSpacing(100.0)) - proj.set_sampler(Datatype.STRUCTURE, SamplerDecimator(0)) + proj.sample_supervisor.set_sampler(SampleType.GEOLOGY, SamplerSpacing(100.0)) + proj.sample_supervisor.set_sampler(SampleType.STRUCTURE, SamplerDecimator(0)) proj.run_all(user_defined_stratigraphic_column=column) return proj From b288446747a1c2c9a2c5f75639f8cf80f6fff7c8 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 11:50:00 +0930 Subject: [PATCH 40/98] test: use correct dipdir column --- tests/sample_storage/test_sample_storage.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index a0cc2731..fba83ca8 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -61,7 +61,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 2775.287768202244933, 'y': 4330.15, - 'strike2': 45.00, + 'DIPDIR': 45.00, 'dip_2': 45.70, 'id': 147.00, 'sf': 's0', @@ -69,7 +69,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 3529.794754080061011, 'y': 3091.192011237949828, - 'strike2': 288.50, + 'DIPDIR': 288.50, 'dip_2': 41.70, 'id': 204.00, 'sf': 's0', @@ -77,7 +77,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 7928.315269200518742, 'y': 7234.561058065713951, - 'strike2': 48.80, + 'DIPDIR': 48.80, 'dip_2': 41.10, 'id': 229.00, 'sf': 's0', @@ -85,7 +85,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 8003.966104268994968, 'y': 7421.634268009857806, - 'strike2': 48.80, + 'DIPDIR': 48.80, 'dip_2': 41.10, 'id': 235.00, 'sf': 's0', @@ -93,7 +93,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 6881.165236574942355, 'y': 1213.128646564158771, - 'strike2': 299.10, + 'DIPDIR': 299.10, 'dip_2': 44.70, 'id': 252.00, 'sf': 's0', @@ -101,7 +101,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 3674.015651128655009, 'y': 5266.677487068354822, - 'strike2': 41.20, + 'DIPDIR': 41.20, 'dip_2': 40.10, 'id': 347.00, 'sf': 's0', @@ -109,7 +109,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): { 'x': 3970.895076049027921, 'y': 2944.223069901633608, - 'strike2': 273.00, + 'DIPDIR': 273.00, 'dip_2': 46.00, 'id': 408.00, 'sf': 's0', @@ -142,7 +142,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): config = { "structure": { "orientation_type": "strike", - "dipdir_column": "strike2", + "dipdir_column": "DIPDIR", "dip_column": "dip_2", "description_column": "DESCRIPTION", "bedding_text": "Bed", From f31c54af032b481b424b4e78ec31c5589475eec0 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 12:31:32 +0930 Subject: [PATCH 41/98] test: changed dip column name --- tests/sample_storage/test_sample_storage.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index fba83ca8..ee35c9e8 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -62,7 +62,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): 'x': 2775.287768202244933, 'y': 4330.15, 'DIPDIR': 45.00, - 'dip_2': 45.70, + 'DIP': 45.70, 'id': 147.00, 'sf': 's0', }, @@ -70,7 +70,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): 'x': 3529.794754080061011, 'y': 3091.192011237949828, 'DIPDIR': 288.50, - 'dip_2': 41.70, + 'DIP': 41.70, 'id': 204.00, 'sf': 's0', }, @@ -78,7 +78,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): 'x': 7928.315269200518742, 'y': 7234.561058065713951, 'DIPDIR': 48.80, - 'dip_2': 41.10, + 'DIP': 41.10, 'id': 229.00, 'sf': 's0', }, @@ -86,7 +86,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): 'x': 8003.966104268994968, 'y': 7421.634268009857806, 'DIPDIR': 48.80, - 'dip_2': 41.10, + 'DIP': 41.10, 'id': 235.00, 'sf': 's0', }, @@ -94,7 +94,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): 'x': 6881.165236574942355, 'y': 1213.128646564158771, 'DIPDIR': 299.10, - 'dip_2': 44.70, + 'DIP': 44.70, 'id': 252.00, 'sf': 's0', }, @@ -102,7 +102,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): 'x': 3674.015651128655009, 'y': 5266.677487068354822, 'DIPDIR': 41.20, - 'dip_2': 40.10, + 'DIP': 40.10, 'id': 347.00, 'sf': 's0', }, @@ -110,7 +110,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): 'x': 3970.895076049027921, 'y': 2944.223069901633608, 'DIPDIR': 273.00, - 'dip_2': 46.00, + 'DIP': 46.00, 'id': 408.00, 'sf': 's0', }, @@ -143,7 +143,7 @@ def create_raster(output_path, bbox, epsg, pixel_size, value=100): "structure": { "orientation_type": "strike", "dipdir_column": "DIPDIR", - "dip_column": "dip_2", + "dip_column": "DIP", "description_column": "DESCRIPTION", "bedding_text": "Bed", "overturned_column": "structypei", From e1d5c25d31fd1f2ea50b6ba5e8882e79105ec4e7 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 12:43:59 +0930 Subject: [PATCH 42/98] test: updated example date used in test --- docs/examples/plot_hamersley.py | 4 +- tests/sample_storage/test_sample_storage.py | 245 ++++---------------- 2 files changed, 41 insertions(+), 208 deletions(-) diff --git a/docs/examples/plot_hamersley.py b/docs/examples/plot_hamersley.py index 5ba4f6c9..a3f92339 100644 --- a/docs/examples/plot_hamersley.py +++ b/docs/examples/plot_hamersley.py @@ -36,8 +36,8 @@ ) # Set the distance between sample points for arial and linestring geometry -proj.set_sampler(Datatype.GEOLOGY, SamplerSpacing(200.0)) -proj.set_sampler(Datatype.FAULT, SamplerSpacing(200.0)) +proj.sample_supervisor.set_sampler(Datatype.GEOLOGY, SamplerSpacing(200.0)) +proj.sample_supervisor.set_sampler(Datatype.FAULT, SamplerSpacing(200.0)) # Choose which stratigraphic sorter to use or run_all with "take_best" flag to run them all proj.set_sorter(SorterAlpha()) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index ee35c9e8..676d35eb 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -3,223 +3,56 @@ from map2loop.project import Project from map2loop.m2l_enums import VerboseLevel, SampleType, StateType, Datatype from map2loop.sampler import SamplerSpacing, SamplerDecimator -from map2loop.thickness_calculator import InterpolatedStructure -from datetime import datetime +from map2loop.sorter import SorterAlpha import pandas -import geopandas -from osgeo import gdal, osr -import tempfile -import shapely -import pathlib -import map2loop - - -def create_raster(output_path, bbox, epsg, pixel_size, value=100): - minx, miny, maxx, maxy = bbox - cols = int((maxx - minx) / pixel_size) - rows = int((maxy - miny) / pixel_size) - driver = gdal.GetDriverByName('GTiff') - out_raster = driver.Create(output_path, cols, rows, 1, gdal.GDT_Byte) - out_raster.SetGeoTransform([minx, pixel_size, 0, maxy, 0, -pixel_size]) - srs = osr.SpatialReference() - srs.ImportFromEPSG(epsg) - out_raster.SetProjection(srs.ExportToWkt()) - out_band = out_raster.GetRasterBand(1) - out_band.Fill(value) - out_band.FlushCache() - out_raster = None - - -geology = [ - { - 'UNITNAME': 'Litho_E', - 'geometry': 'POLYGON ((9795.91836734694 9931.26849738919, 9860.73785898637 9795.91836734694, 9935.33621028978 9591.836734693878, 9950.618354641661 9387.755102040817, 10000 9210.342095822705, 10000 8757.661313426739, 9957.613263811385 8571.428571428572, 9795.91836734694 8453.228230379065, 9591.836734693878 8459.27180076132, 9387.755102040817 8424.58063242387, 9183.673469387755 8396.186050103635, 8979.591836734695 8375.328219666773, 8775.510204081633 8142.6900746871015, 8533.835897640307 7959.183673469388, 8367.34693877551 7832.006337691327, 8271.702357700893 7755.102040816327, 8163.265306122449 7660.1472192881065, 8074.276982521525 7551.0204081632655, 7959.183673469388 7424.887053820552, 7876.85861392897 7346.938775510204, 7755.102040816327 7225.488935198103, 7672.260829380581 7142.857142857143, 7551.0204081632655 7021.922675930724, 7447.64756183235 6938.775510204082, 7346.938775510204 6858.865387585699, 7149.179419692682 6734.693877551021, 6938.775510204082 6628.052847726005, 6734.693877551021 6533.238936443719, 6530.6122448979595 6522.261950434471, 6326.530612244898 6520.453083271883, 6122.448979591837 6525.756680235571, 5918.367346938776 6543.242785395409, 5714.285714285715 6570.203352947625, 5510.2040816326535 6597.437955895249, 5306.122448979592 6623.455748266104, 5102.040816326531 6558.673625089685, 5021.544086689852 6530.6122448979595, 4897.95918367347 6484.284692881059, 4648.165410878707 6326.530612244898, 4456.931912169165 6122.448979591837, 4285.714285714286 5949.72882952009, 4081.6326530612246 5747.855828732861, 3877.5510204081634 5481.342782779616, 3673.469387755102 5299.687677500199, 3469.387755102041 5113.124847412109, 3233.5997600944675 4897.95918367347, 3061.2244897959185 4761.364995216837, 2978.9564560870735 4693.877551020409, 2857.1428571428573 4509.9974651725925, 2727.7656477324817 4285.714285714286, 2653.061224489796 4194.911256128428, 2620.9440036695833 4081.6326530612246, 2653.061224489796 3834.8668935347578, 2714.296846973653 3673.469387755102, 2767.1924902468313 3469.387755102041, 2857.1428571428573 3316.1486411581236, 2932.2801317487447 3265.3061224489797, 3061.2244897959185 3201.1586792615, 3265.3061224489797 3115.340836194097, 3411.8516104561945 3061.2244897959185, 3469.387755102041 3039.713489766024, 3673.469387755102 2953.3901993109257, 3877.5510204081634 2900.4941667829244, 4081.6326530612246 2919.088869678731, 4285.714285714286 2942.9248887665417, 4489.795918367347 2963.555199759347, 4693.877551020409 2917.314840822804, 4809.648941974251 2857.1428571428573, 4897.95918367347 2811.5255005505624, 5102.040816326531 2712.551039092395, 5243.474220742985 2653.061224489796, 5306.122448979592 2627.6203077666614, 5510.2040816326535 2402.532733216578, 5649.461551588409 2244.8979591836737, 5714.285714285715 2173.8852286825377, 5838.211215272242 2040.8163265306123, 5918.367346938776 1953.0603836993782, 6037.69419144611 1836.734693877551, 6122.448979591837 1756.0881011340084, 6277.958616918448 1632.6530612244899, 6326.530612244898 1595.732338574468, 6532.909626863441 1428.5714285714287, 6734.693877551021 1276.012440117038, 6876.561690349969 1224.4897959183675, 6938.775510204082 1201.8953050885882, 7142.857142857143 1139.765856217365, 7346.938775510204 1082.3855108144332, 7551.0204081632655 1067.0050796197386, 7755.102040816327 1078.0507691052496, 7995.249689841758 1020.4081632653061, 8163.265306122449 949.2362275415538, 8367.34693877551 868.0756238042093, 8499.189882862325 816.3265306122449, 8571.428571428572 789.4330608601473, 8775.510204081633 723.8424554163096, 8902.20797791773 612.2448979591837, 8979.591836734695 360.74278305987923, 8979.591836734695 180.16181430038142, 8858.95553900271 0, 6046.468258728215 0, 5863.85825506431 296.3535950262776, 5435.566874501761 724.6449755888261, 5282.605667157994 908.1984244013456, 4900.202648798577 1122.3441146826208, 4638.256581222377 1168.2324768857502, 4454.703132409856 1154.8483712431703, 4190.845049741858 1118.520084499026, 3988.1714500113685 1181.6165825283297, 3642.0967183960943 1311.6336087705313, 3024.5158437456353 1594.6118423565003, 2573.2802820815227 1816.4055930049626, 2175.581142987729 2107.0318869581197, 1831.4184264642531 2558.267448622232, 1380.1828648001406 2910.078225512896, 531.2481640422343 3177.7603383644882, 0 3187.497507640264, 0 4970.218705429992, 78.1005872863268 5095.511475436967, 303.71836811838307 5355.545527921371, 739.6578090481191 5745.596606647977, 904.0911069426686 5887.085723440961, 1297.9662158528683 6024.750810050351, 1787.4420793529227 6116.527534456612, 2169.8450977123402 6135.647685374583, 2498.711693501439 6185.3600777613065, 3003.4836777358705 6261.84068143319, 3485.311480868737 6430.098009511334, 3798.881955923459 6705.428182730114, 4250.1175175875715 7240.792408433298, 4731.945320720438 7638.491547527093, 5297.901787892375 7982.654264050569, 5802.673772126806 8112.67129029277, 6276.853514892484 8303.87279947248, 6712.79295582222 8609.795214160013, 6896.346404634739 8785.700602605346, 6995.771189408188 8969.254051417865, 6942.234766837869 9206.343922800705, 6766.329378392537 9558.154699691368, 6414.518601501873 9986.446080253916, 6402.234572809949 10000, 9765.614100864956 10000, 9795.91836734694 9931.26849738919))', - 'GROUP': 'A', - 'ID': 0, - }, - { - 'UNITNAME': 'Litho_F', - 'geometry': 'MULTIPOLYGON (((8979.591836734695 360.74278305987923, 8902.20797791773 612.2448979591837, 8775.510204081633 723.8424554163096, 8571.428571428572 789.4330608601473, 8499.189882862325 816.3265306122449, 8367.34693877551 868.0756238042093, 8163.265306122449 949.2362275415538, 7995.249689841758 1020.4081632653061, 7755.102040816327 1078.0507691052496, 7551.0204081632655 1067.0050796197386, 7346.938775510204 1082.3855108144332, 7142.857142857143 1139.765856217365, 6938.775510204082 1201.8953050885882, 6876.561690349969 1224.4897959183675, 6734.693877551021 1276.012440117038, 6532.909626863441 1428.5714285714287, 6326.530612244898 1595.732338574468, 6277.958616918448 1632.6530612244899, 6122.448979591837 1756.0881011340084, 6037.69419144611 1836.734693877551, 5918.367346938776 1953.0603836993782, 5838.211215272242 2040.8163265306123, 5714.285714285715 2173.8852286825377, 5649.461551588409 2244.8979591836737, 5510.2040816326535 2402.532733216578, 5306.122448979592 2627.6203077666614, 5243.474220742985 2653.061224489796, 5102.040816326531 2712.551039092395, 4897.95918367347 2811.5255005505624, 4809.648941974251 2857.1428571428573, 4693.877551020409 2917.314840822804, 4489.795918367347 2963.555199759347, 4285.714285714286 2942.9248887665417, 4081.6326530612246 2919.088869678731, 3877.5510204081634 2900.4941667829244, 3673.469387755102 2953.3901993109257, 3592.122504199657 2987.798639529117, 3469.387755102041 3039.713489766024, 3411.8516104561945 3061.2244897959185, 3265.3061224489797 3115.340836194097, 3061.2244897959185 3201.1586792615, 2932.2801317487447 3265.3061224489797, 2857.1428571428573 3316.1486411581236, 2767.1924902468313 3469.387755102041, 2714.296846973653 3673.469387755102, 2653.061224489796 3834.8668935347578, 2620.9440036695833 4081.6326530612246, 2653.061224489796 4194.911256128428, 2727.7656477324817 4285.714285714286, 2857.1428571428573 4509.9974651725925, 2978.9564560870735 4693.877551020409, 3061.2244897959185 4761.364995216837, 3233.5997600944675 4897.95918367347, 3469.387755102041 5113.124847412109, 3673.469387755102 5299.687677500199, 3877.5510204081634 5481.342782779616, 4081.6326530612246 5747.855828732861, 4285.714285714286 5949.72882952009, 4456.931912169165 6122.448979591837, 4648.165410878707 6326.530612244898, 4897.95918367347 6484.284692881059, 5021.544086689852 6530.6122448979595, 5102.040816326531 6558.673625089685, 5306.122448979592 6623.455748266104, 5510.2040816326535 6597.437955895249, 5714.285714285715 6570.203352947625, 5918.367346938776 6543.242785395409, 6122.448979591837 6525.756680235571, 6326.530612244898 6520.453083271883, 6530.6122448979595 6522.261950434471, 6734.693877551021 6533.238936443719, 6938.775510204082 6628.052847726005, 7149.179419692682 6734.693877551021, 7346.938775510204 6858.865387585699, 7447.64756183235 6938.775510204082, 7551.0204081632655 7021.922675930724, 7672.260829380581 7142.857142857143, 7755.102040816327 7225.488935198103, 7876.85861392897 7346.938775510204, 7959.183673469388 7424.887053820552, 8074.276982521525 7551.0204081632655, 8163.265306122449 7660.1472192881065, 8271.702357700893 7755.102040816327, 8367.34693877551 7832.006337691327, 8533.835897640307 7959.183673469388, 8775.510204081633 8142.6900746871015, 8979.591836734695 8375.328219666773, 9183.673469387755 8396.186050103635, 9387.755102040817 8424.58063242387, 9591.836734693878 8459.27180076132, 9795.91836734694 8453.228230379065, 9957.613263811385 8571.428571428572, 10000 8757.661313426739, 10000 8427.640566256101, 9796.219398903246 8371.275719144232, 9383.517404828015 8331.33681649179, 9143.883988913365 8300.273225539891, 8984.1283783036 8184.894173432836, 8771.120897490577 7976.324348470085, 8398.357806067788 7714.50265330408, 8078.846584848256 7359.490185282376, 7683.89521417411 6951.225847057416, 7209.066038195081 6636.152281688155, 6805.239355820393 6449.77073597676, 6294.908933039194 6432.020112575675, 5984.273023520203 6427.582456725404, 5673.6371140012125 6480.834326928666, 5376.314172033036 6489.709638629209, 5145.556067818929 6445.333080126496, 4910.36030775455 6347.704651420527, 4777.230632246412 6223.450287612931, 4542.034872182033 6063.6946770031645, 4324.58973551874 5824.061261088515, 4129.332878106803 5593.303156874407, 3925.2007089943236 5389.170987761928, 3734.3815074326594 5176.163506948902, 3494.7480915180095 5020.8455521894075, 3263.9899873039026 4830.026350627742, 2993.2929804373534 4554.891687910922, 2846.850337378401 4315.258271996272, 2735.908941121619 4088.937823632436, 2780.285499624332 3840.429096017244, 2842.4126815281297 3560.8567774501525, 2944.4787660843695 3361.162264187944, 3082.0460974427792 3294.5974264338747, 3379.369039410956 3170.343062626279, 3845.322903689442 3028.338075417598, 4013.9538259997507 3037.2133871181404, 4320.15207966847 3032.7757312678687, 4542.034872182035 3028.338075417598, 4684.039859390716 2983.9615169148847, 4897.047340203738 2886.333088208916, 5189.932626321643 2766.5163802515917, 5358.563548631952 2673.3256073958946, 5465.067289038463 2611.198425492096, 5744.639607605554 2273.9365808714774, 6246.09471868621 1776.9191256410927, 6641.046089360355 1435.2196251702035, 6822.989979221478 1324.2782289134211, 6978.307933980974 1275.4640145604371, 7311.13212275132 1195.5862092555535, 7444.261798259459 1168.960274153926, 7666.144590773023 1160.0849624533835, 7870.2767598855025 1155.6473066031122, 8052.220649746626 1093.5201246993138, 8331.792968313717 987.0163842928032, 8460.484987971584 920.4515465387335, 8713.43137143705 845.0113970841217, 8855.43635864573 782.8842151803237, 8975.253066603054 671.9428189235414, 9010.754313405225 565.4390785170299, 9046.255560207395 410.1211237575353, 9068.443839458752 281.4291040996677, 9050.693216057667 179.36301954342798, 9006.316657554953 90.60990253800173, 8972.337944103203 0, 8858.95553900271 0, 8979.591836734695 180.16181430038142, 8979.591836734695 360.74278305987923)), ((9935.33621028978 9591.836734693878, 9860.73785898637 9795.91836734694, 9795.91836734694 9931.26849738919, 9765.614100864956 10000, 9959.7366093588 10000, 10000 9899.990932923472, 10000 9210.342095822705, 9950.618354641661 9387.755102040817, 9935.33621028978 9591.836734693878)))', - 'GROUP': 'A', - 'ID': 1, - }, - { - 'UNITNAME': 'Litho_G', - 'geometry': 'MULTIPOLYGON (((9591.836734693878 7392.409188406808, 9387.755102040817 7366.494159309232, 9183.673469387755 7310.6236360511, 8979.591836734695 7251.495049924267, 8775.510204081633 7185.4665328045285, 8691.716875348773 7142.857142857143, 8571.428571428572 7060.166183783084, 8423.547550123565 6938.775510204082, 8367.34693877551 6891.931806291853, 8163.265306122449 6717.05674151985, 7959.183673469388 6524.418032899195, 7755.102040816327 6316.720222940251, 7530.765922702089 6122.448979591837, 7346.938775510204 5999.901440678811, 7186.986962143256 5918.367346938776, 6938.775510204082 5793.479608029736, 6734.693877551021 5711.484247324418, 6530.6122448979595 5688.577768753987, 6326.530612244898 5674.85692549725, 6122.448979591837 5664.018903459822, 5918.367346938776 5686.95963645468, 5808.41181229572 5714.285714285715, 5714.285714285715 5737.67798287528, 5510.2040816326535 5789.896906638633, 5306.122448979592 5803.500194938816, 5144.4244384765625 5714.285714285715, 4837.004213917013 5510.2040816326535, 4693.877551020409 5412.657990747569, 4564.6032995107225 5306.122448979592, 4489.795918367347 5235.455182133889, 4285.714285714286 4940.409368398238, 4169.117285280811 4693.877551020409, 4290.969225825096 4489.795918367347, 4489.795918367347 4401.180111632056, 4588.951967200454 4285.714285714286, 4693.877551020409 4151.690736108897, 4830.671037946428 3877.5510204081634, 5102.040816326531 3725.3519953513633, 5306.122448979592 3618.5887395119184, 5510.2040816326535 3357.1418450803176, 5714.285714285715 3090.5887058803014, 5921.393024678133 2857.1428571428573, 6122.448979591837 2649.130140032087, 6354.4265591368385 2448.979591836735, 6530.6122448979595 2314.575934896664, 6621.950889120297 2244.8979591836737, 6938.775510204082 2057.7853066580637, 7142.857142857143 1991.364809931541, 7346.938775510204 1953.759679988939, 7551.0204081632655 1939.4851217464525, 7755.102040816327 1938.7210145288584, 7959.183673469388 1951.3825007847379, 8163.265306122449 1964.9159178441885, 8571.428571428572 1920.2366653753788, 8784.97298882932 1836.734693877551, 9174.578141193 1632.6530612244899, 9387.755102040817 1516.645976475307, 9736.033069844148 1224.4897959183675, 10000 887.0183205117985, 10000 0, 8972.337944103203 0, 9006.316657554953 90.60990253800173, 9050.693216057667 179.36301954342798, 9068.443839458752 281.4291040996677, 9046.255560207395 410.1211237575353, 9010.754313405225 565.4390785170299, 8975.253066603054 671.9428189235414, 8855.43635864573 782.8842151803237, 8713.43137143705 845.0113970841217, 8460.484987971584 920.4515465387335, 8331.792968313717 987.0163842928032, 8052.220649746626 1093.5201246993138, 7870.2767598855025 1155.6473066031122, 7666.144590773023 1160.0849624533835, 7444.261798259459 1168.960274153926, 7311.13212275132 1195.5862092555535, 6978.307933980974 1275.4640145604371, 6822.989979221478 1324.2782289134211, 6641.046089360355 1435.2196251702035, 6246.09471868621 1776.9191256410927, 5744.639607605554 2273.9365808714774, 5465.067289038463 2611.198425492096, 5358.563548631952 2673.3256073958946, 5189.932626321643 2766.5163802515917, 4897.047340203738 2886.333088208916, 4684.039859390716 2983.9615169148847, 4542.034872182035 3028.338075417598, 4320.15207966847 3032.7757312678687, 4013.9538259997507 3037.2133871181404, 3845.322903689442 3028.338075417598, 3379.369039410956 3170.343062626279, 3082.0460974427792 3294.5974264338747, 2944.4787660843695 3361.162264187944, 2842.4126815281297 3560.8567774501525, 2780.285499624332 3840.429096017244, 2735.908941121619 4088.937823632436, 2846.850337378401 4315.258271996272, 2993.2929804373534 4554.891687910922, 3263.9899873039026 4830.026350627742, 3494.7480915180095 5020.8455521894075, 3734.3815074326594 5176.163506948902, 3925.2007089943236 5389.170987761928, 4129.332878106803 5593.303156874407, 4324.58973551874 5824.061261088515, 4542.034872182033 6063.6946770031645, 4777.230632246412 6223.450287612931, 4910.36030775455 6347.704651420527, 5145.556067818929 6445.333080126496, 5376.314172033036 6489.709638629209, 5673.6371140012125 6480.834326928666, 5984.273023520203 6427.582456725404, 6294.908933039194 6432.020112575675, 6805.239355820393 6449.77073597676, 7209.066038195081 6636.152281688155, 7683.89521417411 6951.225847057416, 8078.846584848256 7359.490185282376, 8398.357806067788 7714.50265330408, 8771.120897490577 7976.324348470085, 8984.1283783036 8184.894173432836, 9143.883988913365 8300.273225539891, 9383.517404828015 8331.33681649179, 9796.219398903246 8371.275719144232, 10000 8427.640566256101, 10000 7398.084317291527, 9795.91836734694 7385.734246701611, 9591.836734693878 7392.409188406808)), ((10000 10000, 10000 9899.990932923472, 9959.7366093588 10000, 10000 10000)))', - 'GROUP': 'A', - 'ID': 2, - }, -] - -for row in geology: - row['geometry'] = shapely.wkt.loads(row['geometry']) - -geology = geopandas.GeoDataFrame(geology, crs='epsg:7854') - -# build structures file -structures = [ - { - 'x': 2775.287768202244933, - 'y': 4330.15, - 'DIPDIR': 45.00, - 'DIP': 45.70, - 'id': 147.00, - 'sf': 's0', - }, - { - 'x': 3529.794754080061011, - 'y': 3091.192011237949828, - 'DIPDIR': 288.50, - 'DIP': 41.70, - 'id': 204.00, - 'sf': 's0', - }, - { - 'x': 7928.315269200518742, - 'y': 7234.561058065713951, - 'DIPDIR': 48.80, - 'DIP': 41.10, - 'id': 229.00, - 'sf': 's0', - }, - { - 'x': 8003.966104268994968, - 'y': 7421.634268009857806, - 'DIPDIR': 48.80, - 'DIP': 41.10, - 'id': 235.00, - 'sf': 's0', - }, - { - 'x': 6881.165236574942355, - 'y': 1213.128646564158771, - 'DIPDIR': 299.10, - 'DIP': 44.70, - 'id': 252.00, - 'sf': 's0', - }, - { - 'x': 3674.015651128655009, - 'y': 5266.677487068354822, - 'DIPDIR': 41.20, - 'DIP': 40.10, - 'id': 347.00, - 'sf': 's0', - }, - { - 'x': 3970.895076049027921, - 'y': 2944.223069901633608, - 'DIPDIR': 273.00, - 'DIP': 46.00, - 'id': 408.00, - 'sf': 's0', - }, -] -for row in structures: - row['geometry'] = shapely.Point(row['x'], row['y']) - del row['x'], row['y'] - -structures = geopandas.GeoDataFrame(structures, crs='epsg:7854') - -faults = geopandas.GeoDataFrame(columns=['geometry'], crs='epsg:7854') - -f_path = tempfile.mkdtemp() - -bounding_box = {"minx": 0, "miny": 0, "maxx": 10000, "maxy": 10000, "base": 0, "top": -5000} - -create_raster( - os.path.join(f_path, "DEM.tif"), - (bounding_box['minx'], bounding_box['miny'], bounding_box['maxx'], bounding_box['maxy']), - 7854, - 1000, -) - -geology.to_file(os.path.join(f_path, "geology.shp")) -structures.to_file(os.path.join(f_path, "structures.shp")) -faults.to_file(os.path.join(f_path, "faults.shp")) -loop_project_filename = os.path.join(f_path, "local_source.loop3d") - -config = { - "structure": { - "orientation_type": "strike", - "dipdir_column": "DIPDIR", - "dip_column": "DIP", - "description_column": "DESCRIPTION", - "bedding_text": "Bed", - "overturned_column": "structypei", - "overturned_text": "BEOI", - "objectid_column": "objectid", - "desciption_column": "feature", - }, - "geology": { - "unitname_column": "UNITNAME", - "alt_unitname_column": "UNITNAME", - "group_column": "GROUP", - "supergroup_column": "supersuite", - "description_column": "descriptn", - "minage_column": "min_age_ma", - "maxage_column": "max_age_ma", - "rocktype_column": "rocktype1", - "alt_rocktype_column": "rocktype2", - "sill_text": "sill", - "intrusive_text": "intrusive", - "volcanic_text": "volcanic", - "objectid_column": "ID", - "ignore_codes": ["cover"], - }, - "fault": { - "structtype_column": "feature", - "fault_text": "Fault", - "dip_null_value": "0", - "dipdir_flag": "num", - "dipdir_column": "dip_dir", - "dip_column": "dip", - "orientation_type": "dip direction", - "dipestimate_column": "dip_est", - "dipestimate_text": "gentle,moderate,steep", - "name_column": "name", - "objectid_column": "objectid", - }, - "fold": { - "structtype_column": "feature", - "fold_text": "Fold axial trace", - "description_column": "type", - "synform_text": "syncline", - "foldname_column": "NAME", - "objectid_column": "objectid", - }, -} -module_path = os.path.dirname(map2loop.__file__).replace("__init__.py", "") +""" +============================ +Hamersley, Western Australia +============================ +""" + +#################################################################### +# Set the region of interest for the project +# ------------------------------------------- +# Define the bounding box for the ROI + +bbox_3d = { + "minx": 515687.31005864, + "miny": 7493446.76593407, + "maxx": 562666.860106543, + "maxy": 7521273.57407786, + "base": -3200, + "top": 3000, +} @pytest.fixture def sample_supervisor(): + # Specify minimum details (which Australian state, projection and bounding box + # and output file) + loop_project_filename = "wa_output.loop3d" proj = Project( - geology_filename=os.path.join(f_path, "geology.shp"), - fault_filename=os.path.join(f_path, "faults.shp"), - fold_filename=os.path.join(f_path, "faults.shp"), - structure_filename=os.path.join(f_path, "structures.shp"), - dtm_filename=os.path.join(f_path, 'DEM.tif'), - clut_filename=pathlib.Path(module_path) - / pathlib.Path('_datasets') - / pathlib.Path('clut_files') - / pathlib.Path('WA_clut.csv'), - config_dictionary=config, - clut_file_legacy=False, - working_projection="EPSG:7854", - bounding_box=bounding_box, + use_australian_state_data="WA", + working_projection="EPSG:28350", + bounding_box=bbox_3d, + verbose_level=VerboseLevel.NONE, loop_project_filename=loop_project_filename, overwrite_loopprojectfile=True, ) - proj.set_thickness_calculator(InterpolatedStructure()) - - column = ['Litho_G', 'Litho_F', 'Litho_E'] - - proj.sample_supervisor.set_sampler(SampleType.GEOLOGY, SamplerSpacing(100.0)) - proj.sample_supervisor.set_sampler(SampleType.STRUCTURE, SamplerDecimator(0)) - proj.run_all(user_defined_stratigraphic_column=column) + # Set the distance between sample points for arial and linestring geometry + proj.sample_supervisor.set_sampler(Datatype.GEOLOGY, SamplerSpacing(200.0)) + proj.sample_supervisor.set_sampler(Datatype.FAULT, SamplerSpacing(200.0)) + + # Choose which stratigraphic sorter to use or run_all with "take_best" flag to run them all + proj.set_sorter(SorterAlpha()) + # proj.set_sorter(SorterAgeBased()) + # proj.set_sorter(SorterUseHint()) + # proj.set_sorter(SorterUseNetworkx()) + # proj.set_sorter(SorterMaximiseContacts()) + # proj.set_sorter(SorterObservationProjections()) + proj.run_all(take_best=True) return proj.sample_supervisor From 692864ac3838564e319d49bad7fd4ffad73dafc0 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Fri, 7 Jun 2024 12:50:52 +0930 Subject: [PATCH 43/98] fix: use correct type for samplers --- docs/examples/plot_hamersley.py | 6 +++--- tests/sample_storage/test_sample_storage.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/examples/plot_hamersley.py b/docs/examples/plot_hamersley.py index a3f92339..16ca3873 100644 --- a/docs/examples/plot_hamersley.py +++ b/docs/examples/plot_hamersley.py @@ -5,7 +5,7 @@ """ from map2loop.project import Project -from map2loop.m2l_enums import VerboseLevel, Datatype +from map2loop.m2l_enums import VerboseLevel, Datatype, SampleType from map2loop.sorter import SorterAlpha from map2loop.sampler import SamplerSpacing @@ -36,8 +36,8 @@ ) # Set the distance between sample points for arial and linestring geometry -proj.sample_supervisor.set_sampler(Datatype.GEOLOGY, SamplerSpacing(200.0)) -proj.sample_supervisor.set_sampler(Datatype.FAULT, SamplerSpacing(200.0)) +proj.sample_supervisor.set_sampler(SampleType.GEOLOGY, SamplerSpacing(200.0)) +proj.sample_supervisor.set_sampler(SampleType.FAULT, SamplerSpacing(200.0)) # Choose which stratigraphic sorter to use or run_all with "take_best" flag to run them all proj.set_sorter(SorterAlpha()) diff --git a/tests/sample_storage/test_sample_storage.py b/tests/sample_storage/test_sample_storage.py index 676d35eb..a22ecc89 100644 --- a/tests/sample_storage/test_sample_storage.py +++ b/tests/sample_storage/test_sample_storage.py @@ -42,8 +42,8 @@ def sample_supervisor(): ) # Set the distance between sample points for arial and linestring geometry - proj.sample_supervisor.set_sampler(Datatype.GEOLOGY, SamplerSpacing(200.0)) - proj.sample_supervisor.set_sampler(Datatype.FAULT, SamplerSpacing(200.0)) + proj.sample_supervisor.set_sampler(SampleType.GEOLOGY, SamplerSpacing(200.0)) + proj.sample_supervisor.set_sampler(SampleType.FAULT, SamplerSpacing(200.0)) # Choose which stratigraphic sorter to use or run_all with "take_best" flag to run them all proj.set_sorter(SorterAlpha()) From 569e6eefbd035466c830f0fdfeeddecaea947569 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 24 May 2024 14:19:16 +1000 Subject: [PATCH 44/98] fix: update dependencies as discussed --- dependencies.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/dependencies.txt b/dependencies.txt index 462fba39..4c52daee 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -1,8 +1,5 @@ -numpy -pandas geopandas shapely -tqdm networkx owslib map2model From bf61bc44b727032014f9191b57ef067ba7d36d95 Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Mon, 20 May 2024 12:08:46 +1000 Subject: [PATCH 45/98] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..dd84ea78 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..bbcbbe7d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. From 980f24ffb292f22d82cf074f677371d47f180530 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Wed, 22 May 2024 15:28:01 +1000 Subject: [PATCH 46/98] feat: added issue_templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 ------------------- .github/ISSUE_TEMPLATE/bug_report.yml | 21 ++++++---- .../ISSUE_TEMPLATE/documentation_request.yml | 15 ++++++-- .github/ISSUE_TEMPLATE/feature_request.md | 20 ---------- .github/ISSUE_TEMPLATE/feature_request.yml | 33 ++++++++-------- .github/ISSUE_TEMPLATE/question.yml | 11 +++++- 6 files changed, 51 insertions(+), 87 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index dd84ea78..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index e70de0e0..8fe9facf 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,4 +1,4 @@ -name: "🐛 Bug Report" +name: "Bug Report" description: "Report a bug or an issue in map2loop" title: "[Bug] - " labels: ["bug"] @@ -10,12 +10,14 @@ body: Thanks for submitting a bug report to map2loop! Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. - - type: textarea - id: version + - type: input + id: bug_title attributes: - label: Version - description: What version of map2loop and LoopProjectFile are you running? You can find this information by running `import map2loop` and `map2loop.__version__` in your python terminal or jupyter notebook. - placeholder: "Enter map2loop and LoopProjectFile versions" + label: "Bug Title" + description: "Provide a concise and descriptive title for the bug report." + placeholder: "Enter the title of the bug" + validations: + required: true - type: textarea id: bug_description @@ -30,7 +32,7 @@ body: id: steps_to_reproduce attributes: label: "Minimal reproducible example" - description: "Provide a minimal reproducible example with the code necessary to reproduce the bug. For more guidance, visit: [How to create a minimal complete reproducible example](https://forum.access-hive.org.au/t/how-to-create-a-minimal-complete-reproducible-example/843)" + description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." placeholder: "Enter the steps to reproduce the bug" validations: required: true @@ -78,9 +80,12 @@ body: description: "Select the severity level of the bug." options: - label: "Low" + value: "low" - label: "Medium" + value: "medium" - label: "High" + value: "high" - label: "Critical" + value: "critical" validations: required: true - diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml index 9d2ce617..6fb074ad 100644 --- a/.github/ISSUE_TEMPLATE/documentation_request.yml +++ b/.github/ISSUE_TEMPLATE/documentation_request.yml @@ -1,4 +1,4 @@ -name: "📓 Documentation Request" +name: "Documentation Request" description: "Help us improve map2loop documentation!" title: "[Documentation] - " labels: ["documentation"] @@ -9,7 +9,16 @@ body: ## Documentation Request Please use this template to suggest an improvement or addition to map2loop documentation. - Provide as much detail as possible to help us understand and implement your request efficiently + Provide as much detail as possible to help us understand and implement your request efficiently. + + - type: input + id: doc_title + attributes: + label: "Documentation Title" + description: "Provide a concise and descriptive title for the documentation request." + placeholder: "Enter the title of the documentation request" + validations: + required: true - type: textarea id: doc_details @@ -24,7 +33,7 @@ body: id: additional_context attributes: label: "Additional Context" - description: "Any other context or information that may be helpful." + description: "Provide any other context or information that may be helpful." placeholder: "Enter any additional context" validations: required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7d..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 5d2d409a..00872c72 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,4 +1,4 @@ -name: "🚀 Feature Request" +name: "Feature Request" description: "Suggest a new feature or enhancement for map2loop" title: "[Feature Request] - " labels: ["enhancement", "feature request"] @@ -10,15 +10,14 @@ body: Please use this template to submit your feature request. Provide as much detail as possible to help us understand and implement your request efficiently. - - type: checkboxes - id: input1 + - type: input + id: feature_title attributes: - label: "💻" - description: | - Check this if you would like to try and implement your vision in a PR. - The map2loop team will help you go through the process - options: - - label: Would you like to work on this feature? + label: "Feature Title" + description: "Provide a concise and descriptive title for the feature request." + placeholder: "Enter the title of the feature" + validations: + required: true - type: textarea id: feature_description @@ -38,18 +37,11 @@ body: validations: required: true - - type: textarea - id: version - attributes: - label: Version - description: What version of map2loop and LoopProjectFile are you running that doesn't have this feature? You can find this information by running `import map2loop` and `map2loop.__version__` in your python terminal or jupyter notebook. - placeholder: "Enter map2loop and LoopProjectFile versions" - - type: textarea id: proposed_solution attributes: label: "Proposed Solution" - description: "Describe how you envision the feature working. Include any specific requirements or details" + description: "Describe how you envision the feature working. Include any specific requirements or details." placeholder: "Explain how the feature should work" validations: required: true @@ -70,9 +62,16 @@ body: description: "Select the areas of the project that this feature request impacts." options: - label: "input data" + value: "input data" - label: "project creation" + value: "project creation" - label: "samplers" + value: "samplers" - label: "sorters" + value: "sorters" - label: "stratigraphic column" + value: "stratigraphic column" - label: "data types" + value: "data types" - label: "Other" + value: "other" diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index ba6b949b..65db9e62 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -1,4 +1,4 @@ -name: "💬 Question" +name: "Question" description: "Ask a question about map2loop!" title: "[Question] - " labels: ["question"] @@ -11,6 +11,15 @@ body: Please use this template to ask a question about applying map2loop to your data. Provide as much detail as possible to help us understand and answer your question efficiently. + - type: input + id: question_title + attributes: + label: "Question Title" + description: "Provide a concise and descriptive title for your question." + placeholder: "Enter the title of your question" + validations: + required: true + - type: textarea id: question_details attributes: From 81a9a0222e10bf88a0cca97c573cd686cc93e994 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 24 May 2024 08:51:38 +1000 Subject: [PATCH 47/98] fix: add pull request template --- .../ISSUE_TEMPLATE/pull_request_template.yml | 18 +++++++++++++ .../pull_request_template/bug_fix_template.md | 24 +++++++++++++++++ .../docs_update_template.md | 23 ++++++++++++++++ .../pull_request_template/feature_template.md | 27 +++++++++++++++++++ .../tests_improvement_template.md | 23 ++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/pull_request_template.yml create mode 100644 .github/pull_request_template/bug_fix_template.md create mode 100644 .github/pull_request_template/docs_update_template.md create mode 100644 .github/pull_request_template/feature_template.md create mode 100644 .github/pull_request_template/tests_improvement_template.md diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.yml b/.github/ISSUE_TEMPLATE/pull_request_template.yml new file mode 100644 index 00000000..f99ce5c0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/pull_request_template.yml @@ -0,0 +1,18 @@ +version: 2 + +pull_request_templates: + - name: Bug Fix Template + description: Use this template for bug fixes. + file: pull_request_template/bug_fix_template.md + + - name: Feature Template + description: Use this template for new features. + file: pull_request_template/feature_template.md + + - name: Documentation Update Template + description: Use this template for documentation updates. + file: pull_request_template/docs_update_template.md + + - name: Test Improvement Template + description: Use this template for adding a new test. + file: pull_request_template/tests_improvement_template.md \ No newline at end of file diff --git a/.github/pull_request_template/bug_fix_template.md b/.github/pull_request_template/bug_fix_template.md new file mode 100644 index 00000000..d6f7f7ad --- /dev/null +++ b/.github/pull_request_template/bug_fix_template.md @@ -0,0 +1,24 @@ +## Description + +Please describe the issue that this pull request addresses and summarize the changes. + +Fixes #(issue) + +## Type of change + +- [ ] Bug fix (non-breaking change which fixes an issue) + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own code +- [ ] My code follows the style guidelines of this project +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md new file mode 100644 index 00000000..247529c3 --- /dev/null +++ b/.github/pull_request_template/docs_update_template.md @@ -0,0 +1,23 @@ +## Description + +Please include a summary of the changes. Include context if relevant. + +Fixes #(issue) + +## Type of change + +- [ ] Documentation update + +## How Has This Been Tested? +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own documentation +- [ ] I have built the documentation locally with make.bat +- [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs +- [ ] My documentation follows the style guidelines of this project +- [ ] I have checked my spelling and grammar diff --git a/.github/pull_request_template/feature_template.md b/.github/pull_request_template/feature_template.md new file mode 100644 index 00000000..29a43a6e --- /dev/null +++ b/.github/pull_request_template/feature_template.md @@ -0,0 +1,27 @@ +## Description + +Please include a summary of the changes and the related issue. Include relevant motivation and context, if appropriate. +List any new dependencies that are required for this change. + +Fixes #(issue) + +## Type of change + +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own code +- [ ] My code follows the style guidelines of this project +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md new file mode 100644 index 00000000..78b3bc70 --- /dev/null +++ b/.github/pull_request_template/tests_improvement_template.md @@ -0,0 +1,23 @@ +## Description + +Please include a summary of the added test. List relevant functions tested. + +Fixes #(issue) + +## Type of change + +- [ ] Test improvement + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own tests +- [ ] My tests follow the style guidelines of this project +- [ ] I have commented my tests, particularly in hard-to-understand areas +- [ ] New and existing unit tests pass locally with my changes From bf129e87d58b6b694a48d8ad01b06f157b100da4 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 24 May 2024 09:01:09 +1000 Subject: [PATCH 48/98] fix: few typos grammar --- .github/ISSUE_TEMPLATE/pull_request_template.yml | 2 +- .github/pull_request_template/bug_fix_template.md | 4 ++-- .github/pull_request_template/tests_improvement_template.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.yml b/.github/ISSUE_TEMPLATE/pull_request_template.yml index f99ce5c0..2fc5462a 100644 --- a/.github/ISSUE_TEMPLATE/pull_request_template.yml +++ b/.github/ISSUE_TEMPLATE/pull_request_template.yml @@ -6,7 +6,7 @@ pull_request_templates: file: pull_request_template/bug_fix_template.md - name: Feature Template - description: Use this template for new features. + description: Use this template for adding new features. file: pull_request_template/feature_template.md - name: Documentation Update Template diff --git a/.github/pull_request_template/bug_fix_template.md b/.github/pull_request_template/bug_fix_template.md index d6f7f7ad..afdc1497 100644 --- a/.github/pull_request_template/bug_fix_template.md +++ b/.github/pull_request_template/bug_fix_template.md @@ -1,6 +1,6 @@ ## Description -Please describe the issue that this pull request addresses and summarize the changes. +Please describe the issue that this pull request addresses and summarize the changes you are implementing. Fixes #(issue) @@ -10,7 +10,7 @@ Fixes #(issue) ## How Has This Been Tested? -Please describe the tests that you ran to verify your changes. +Please describe any tests that you ran to verify your changes. Provide branch name so we can reproduce. ## Checklist: diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md index 78b3bc70..aa56ee86 100644 --- a/.github/pull_request_template/tests_improvement_template.md +++ b/.github/pull_request_template/tests_improvement_template.md @@ -1,6 +1,6 @@ ## Description -Please include a summary of the added test. List relevant functions tested. +Please include a summary of the added or modified test. List relevant functions tested. Fixes #(issue) From fd567fc15733e56d00d13d6bbd00df0bc0968a6b Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 24 May 2024 09:40:33 +1000 Subject: [PATCH 49/98] fix: tests should be with pytest --- .github/pull_request_template/tests_improvement_template.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md index aa56ee86..58fd8b08 100644 --- a/.github/pull_request_template/tests_improvement_template.md +++ b/.github/pull_request_template/tests_improvement_template.md @@ -17,6 +17,7 @@ Provide branch name so we can reproduce. - [ ] This branch is up-to-date with master - [ ] All gh-action checks are passing +- [ ] My tests run with pytest from the map2loop folder - [ ] I have performed a self-review of my own tests - [ ] My tests follow the style guidelines of this project - [ ] I have commented my tests, particularly in hard-to-understand areas From 523ee4bf2bce726c5f247355dc1008530eaf5c78 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Mon, 27 May 2024 12:46:12 +1000 Subject: [PATCH 50/98] Revert "Update issue templates" --- .github/ISSUE_TEMPLATE/bug_report.yml | 91 ------------------- .../ISSUE_TEMPLATE/documentation_request.yml | 39 -------- .github/ISSUE_TEMPLATE/feature_request.yml | 77 ---------------- .../ISSUE_TEMPLATE/pull_request_template.yml | 18 ---- .github/ISSUE_TEMPLATE/question.yml | 48 ---------- .../pull_request_template/bug_fix_template.md | 24 ----- .../docs_update_template.md | 23 ----- .../pull_request_template/feature_template.md | 27 ------ .../tests_improvement_template.md | 24 ----- 9 files changed, 371 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/documentation_request.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml delete mode 100644 .github/ISSUE_TEMPLATE/pull_request_template.yml delete mode 100644 .github/ISSUE_TEMPLATE/question.yml delete mode 100644 .github/pull_request_template/bug_fix_template.md delete mode 100644 .github/pull_request_template/docs_update_template.md delete mode 100644 .github/pull_request_template/feature_template.md delete mode 100644 .github/pull_request_template/tests_improvement_template.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 8fe9facf..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: "Bug Report" -description: "Report a bug or an issue in map2loop" -title: "[Bug] - " -labels: ["bug"] -body: - - type: markdown - attributes: - value: | - ## Bug Report - Thanks for submitting a bug report to map2loop! - Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. - - - type: input - id: bug_title - attributes: - label: "Bug Title" - description: "Provide a concise and descriptive title for the bug report." - placeholder: "Enter the title of the bug" - validations: - required: true - - - type: textarea - id: bug_description - attributes: - label: "Bug Description" - description: "Describe the bug you encountered. Include details on what you expected to happen and what actually happened." - placeholder: "Enter a detailed description of the bug" - validations: - required: true - - - type: textarea - id: steps_to_reproduce - attributes: - label: "Minimal reproducible example" - description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." - placeholder: "Enter the steps to reproduce the bug" - validations: - required: true - - - type: textarea - id: expected_behavior - attributes: - label: "Expected Behavior" - description: "Describe what you expected to happen." - placeholder: "Enter the expected behavior" - validations: - required: true - - - type: textarea - id: actual_behavior - attributes: - label: "Actual Behavior" - description: "Describe what actually happened when you encountered the bug." - placeholder: "Enter the actual behavior" - validations: - required: true - - - type: textarea - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful in understanding and fixing the bug." - placeholder: "Enter any additional context" - validations: - required: false - - - type: input - id: environment - attributes: - label: "Environment" - description: "Specify the environment in which the bug occurred (e.g., operating system, browser, application version)." - placeholder: "Enter the environment details" - validations: - required: true - - - type: checkboxes - id: severity - attributes: - label: "Severity" - description: "Select the severity level of the bug." - options: - - label: "Low" - value: "low" - - label: "Medium" - value: "medium" - - label: "High" - value: "high" - - label: "Critical" - value: "critical" - validations: - required: true diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml deleted file mode 100644 index 6fb074ad..00000000 --- a/.github/ISSUE_TEMPLATE/documentation_request.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: "Documentation Request" -description: "Help us improve map2loop documentation!" -title: "[Documentation] - " -labels: ["documentation"] -body: - - type: markdown - attributes: - value: | - ## Documentation Request - - Please use this template to suggest an improvement or addition to map2loop documentation. - Provide as much detail as possible to help us understand and implement your request efficiently. - - - type: input - id: doc_title - attributes: - label: "Documentation Title" - description: "Provide a concise and descriptive title for the documentation request." - placeholder: "Enter the title of the documentation request" - validations: - required: true - - - type: textarea - id: doc_details - attributes: - label: "Documentation Details" - description: "Describe the documentation you would like to see. Include details on why it is needed and how it should be structured." - placeholder: "Enter a detailed description of the documentation" - validations: - required: true - - - type: textarea - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful." - placeholder: "Enter any additional context" - validations: - required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml deleted file mode 100644 index 00872c72..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: "Feature Request" -description: "Suggest a new feature or enhancement for map2loop" -title: "[Feature Request] - " -labels: ["enhancement", "feature request"] -body: - - type: markdown - attributes: - value: | - ## Feature Request - - Please use this template to submit your feature request. Provide as much detail as possible to help us understand and implement your request efficiently. - - - type: input - id: feature_title - attributes: - label: "Feature Title" - description: "Provide a concise and descriptive title for the feature request." - placeholder: "Enter the title of the feature" - validations: - required: true - - - type: textarea - id: feature_description - attributes: - label: "Feature Description" - description: "Describe the feature you would like to see. Include details on why it is needed and how it should work." - placeholder: "Enter a detailed description of the feature" - validations: - required: true - - - type: textarea - id: current_situation - attributes: - label: "Current Situation" - description: "Describe the current situation and how the absence of this feature affects you." - placeholder: "Explain the current situation and its drawbacks" - validations: - required: true - - - type: textarea - id: proposed_solution - attributes: - label: "Proposed Solution" - description: "Describe how you envision the feature working. Include any specific requirements or details." - placeholder: "Explain how the feature should work" - validations: - required: true - - - type: input - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful in understanding the feature request." - placeholder: "Enter any additional context" - validations: - required: false - - - type: checkboxes - id: affected_areas - attributes: - label: "Affected Areas" - description: "Select the areas of the project that this feature request impacts." - options: - - label: "input data" - value: "input data" - - label: "project creation" - value: "project creation" - - label: "samplers" - value: "samplers" - - label: "sorters" - value: "sorters" - - label: "stratigraphic column" - value: "stratigraphic column" - - label: "data types" - value: "data types" - - label: "Other" - value: "other" diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.yml b/.github/ISSUE_TEMPLATE/pull_request_template.yml deleted file mode 100644 index 2fc5462a..00000000 --- a/.github/ISSUE_TEMPLATE/pull_request_template.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: 2 - -pull_request_templates: - - name: Bug Fix Template - description: Use this template for bug fixes. - file: pull_request_template/bug_fix_template.md - - - name: Feature Template - description: Use this template for adding new features. - file: pull_request_template/feature_template.md - - - name: Documentation Update Template - description: Use this template for documentation updates. - file: pull_request_template/docs_update_template.md - - - name: Test Improvement Template - description: Use this template for adding a new test. - file: pull_request_template/tests_improvement_template.md \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml deleted file mode 100644 index 65db9e62..00000000 --- a/.github/ISSUE_TEMPLATE/question.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: "Question" -description: "Ask a question about map2loop!" -title: "[Question] - " -labels: ["question"] -body: - - type: markdown - attributes: - value: | - ## Question - - Please use this template to ask a question about applying map2loop to your data. - Provide as much detail as possible to help us understand and answer your question efficiently. - - - type: input - id: question_title - attributes: - label: "Question Title" - description: "Provide a concise and descriptive title for your question." - placeholder: "Enter the title of your question" - validations: - required: true - - - type: textarea - id: question_details - attributes: - label: "Question Details" - description: "Describe your question in detail. Include any context or background information that might be helpful." - placeholder: "Enter the details of your question" - validations: - required: true - - - type: textarea - id: relevant_code_snippets - attributes: - label: "Relevant code or data" - description: "If applicable, provide any relevant code snippets or examples related to your question." - placeholder: "Enter any relevant code snippets" - validations: - required: false - - - type: input - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful in answering your question." - placeholder: "Enter any additional context" - validations: - required: false diff --git a/.github/pull_request_template/bug_fix_template.md b/.github/pull_request_template/bug_fix_template.md deleted file mode 100644 index afdc1497..00000000 --- a/.github/pull_request_template/bug_fix_template.md +++ /dev/null @@ -1,24 +0,0 @@ -## Description - -Please describe the issue that this pull request addresses and summarize the changes you are implementing. - -Fixes #(issue) - -## Type of change - -- [ ] Bug fix (non-breaking change which fixes an issue) - -## How Has This Been Tested? - -Please describe any tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] I have performed a self-review of my own code -- [ ] My code follows the style guidelines of this project -- [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I have made corresponding changes to the documentation -- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md deleted file mode 100644 index 247529c3..00000000 --- a/.github/pull_request_template/docs_update_template.md +++ /dev/null @@ -1,23 +0,0 @@ -## Description - -Please include a summary of the changes. Include context if relevant. - -Fixes #(issue) - -## Type of change - -- [ ] Documentation update - -## How Has This Been Tested? -Please describe the tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] I have performed a self-review of my own documentation -- [ ] I have built the documentation locally with make.bat -- [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs -- [ ] My documentation follows the style guidelines of this project -- [ ] I have checked my spelling and grammar diff --git a/.github/pull_request_template/feature_template.md b/.github/pull_request_template/feature_template.md deleted file mode 100644 index 29a43a6e..00000000 --- a/.github/pull_request_template/feature_template.md +++ /dev/null @@ -1,27 +0,0 @@ -## Description - -Please include a summary of the changes and the related issue. Include relevant motivation and context, if appropriate. -List any new dependencies that are required for this change. - -Fixes #(issue) - -## Type of change - -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - -## How Has This Been Tested? - -Please describe the tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] I have performed a self-review of my own code -- [ ] My code follows the style guidelines of this project -- [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I have made corresponding changes to the documentation -- [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md deleted file mode 100644 index 58fd8b08..00000000 --- a/.github/pull_request_template/tests_improvement_template.md +++ /dev/null @@ -1,24 +0,0 @@ -## Description - -Please include a summary of the added or modified test. List relevant functions tested. - -Fixes #(issue) - -## Type of change - -- [ ] Test improvement - -## How Has This Been Tested? - -Please describe the tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] My tests run with pytest from the map2loop folder -- [ ] I have performed a self-review of my own tests -- [ ] My tests follow the style guidelines of this project -- [ ] I have commented my tests, particularly in hard-to-understand areas -- [ ] New and existing unit tests pass locally with my changes From 7929469ee0d0e8b67512ee3e6a806ad6b5267c93 Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Thu, 9 May 2024 15:02:17 +1000 Subject: [PATCH 51/98] fix: trigger build --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f654acc5..9a85e71f 100644 --- a/setup.py +++ b/setup.py @@ -57,4 +57,4 @@ def get_description(): "Topic :: Scientific/Engineering :: GIS", ], python_requires=">=3.8", -) +) From 131b89a348f4524a8695fd88b838354b9688f475 Mon Sep 17 00:00:00 2001 From: lachlangrose Date: Thu, 9 May 2024 05:02:37 +0000 Subject: [PATCH 52/98] style: style fixes by ruff and autoformatting by black --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9a85e71f..f654acc5 100644 --- a/setup.py +++ b/setup.py @@ -57,4 +57,4 @@ def get_description(): "Topic :: Scientific/Engineering :: GIS", ], python_requires=">=3.8", -) +) From 0b38a46c8de82b7db9eca5d7972c2b511c330b4c Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Mon, 20 May 2024 12:08:46 +1000 Subject: [PATCH 53/98] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..dd84ea78 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..bbcbbe7d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. From ec6a020a7d25de3d15e17bc7d2e1994bd7ed3d08 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Wed, 22 May 2024 15:28:01 +1000 Subject: [PATCH 54/98] feat: added issue_templates edit dddf70b chore: added issue_templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 -------- .github/ISSUE_TEMPLATE/bug_report.yml | 91 +++++++++++++++++++ .../ISSUE_TEMPLATE/documentation_request.yml | 39 ++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ---- .github/ISSUE_TEMPLATE/feature_request.yml | 77 ++++++++++++++++ .github/ISSUE_TEMPLATE/question.yml | 48 ++++++++++ 6 files changed, 255 insertions(+), 58 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/documentation_request.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index dd84ea78..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..8fe9facf --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,91 @@ +name: "Bug Report" +description: "Report a bug or an issue in map2loop" +title: "[Bug] - " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + ## Bug Report + Thanks for submitting a bug report to map2loop! + Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. + + - type: input + id: bug_title + attributes: + label: "Bug Title" + description: "Provide a concise and descriptive title for the bug report." + placeholder: "Enter the title of the bug" + validations: + required: true + + - type: textarea + id: bug_description + attributes: + label: "Bug Description" + description: "Describe the bug you encountered. Include details on what you expected to happen and what actually happened." + placeholder: "Enter a detailed description of the bug" + validations: + required: true + + - type: textarea + id: steps_to_reproduce + attributes: + label: "Minimal reproducible example" + description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." + placeholder: "Enter the steps to reproduce the bug" + validations: + required: true + + - type: textarea + id: expected_behavior + attributes: + label: "Expected Behavior" + description: "Describe what you expected to happen." + placeholder: "Enter the expected behavior" + validations: + required: true + + - type: textarea + id: actual_behavior + attributes: + label: "Actual Behavior" + description: "Describe what actually happened when you encountered the bug." + placeholder: "Enter the actual behavior" + validations: + required: true + + - type: textarea + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful in understanding and fixing the bug." + placeholder: "Enter any additional context" + validations: + required: false + + - type: input + id: environment + attributes: + label: "Environment" + description: "Specify the environment in which the bug occurred (e.g., operating system, browser, application version)." + placeholder: "Enter the environment details" + validations: + required: true + + - type: checkboxes + id: severity + attributes: + label: "Severity" + description: "Select the severity level of the bug." + options: + - label: "Low" + value: "low" + - label: "Medium" + value: "medium" + - label: "High" + value: "high" + - label: "Critical" + value: "critical" + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml new file mode 100644 index 00000000..6fb074ad --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation_request.yml @@ -0,0 +1,39 @@ +name: "Documentation Request" +description: "Help us improve map2loop documentation!" +title: "[Documentation] - " +labels: ["documentation"] +body: + - type: markdown + attributes: + value: | + ## Documentation Request + + Please use this template to suggest an improvement or addition to map2loop documentation. + Provide as much detail as possible to help us understand and implement your request efficiently. + + - type: input + id: doc_title + attributes: + label: "Documentation Title" + description: "Provide a concise and descriptive title for the documentation request." + placeholder: "Enter the title of the documentation request" + validations: + required: true + + - type: textarea + id: doc_details + attributes: + label: "Documentation Details" + description: "Describe the documentation you would like to see. Include details on why it is needed and how it should be structured." + placeholder: "Enter a detailed description of the documentation" + validations: + required: true + + - type: textarea + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful." + placeholder: "Enter any additional context" + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7d..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 00000000..00872c72 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,77 @@ +name: "Feature Request" +description: "Suggest a new feature or enhancement for map2loop" +title: "[Feature Request] - " +labels: ["enhancement", "feature request"] +body: + - type: markdown + attributes: + value: | + ## Feature Request + + Please use this template to submit your feature request. Provide as much detail as possible to help us understand and implement your request efficiently. + + - type: input + id: feature_title + attributes: + label: "Feature Title" + description: "Provide a concise and descriptive title for the feature request." + placeholder: "Enter the title of the feature" + validations: + required: true + + - type: textarea + id: feature_description + attributes: + label: "Feature Description" + description: "Describe the feature you would like to see. Include details on why it is needed and how it should work." + placeholder: "Enter a detailed description of the feature" + validations: + required: true + + - type: textarea + id: current_situation + attributes: + label: "Current Situation" + description: "Describe the current situation and how the absence of this feature affects you." + placeholder: "Explain the current situation and its drawbacks" + validations: + required: true + + - type: textarea + id: proposed_solution + attributes: + label: "Proposed Solution" + description: "Describe how you envision the feature working. Include any specific requirements or details." + placeholder: "Explain how the feature should work" + validations: + required: true + + - type: input + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful in understanding the feature request." + placeholder: "Enter any additional context" + validations: + required: false + + - type: checkboxes + id: affected_areas + attributes: + label: "Affected Areas" + description: "Select the areas of the project that this feature request impacts." + options: + - label: "input data" + value: "input data" + - label: "project creation" + value: "project creation" + - label: "samplers" + value: "samplers" + - label: "sorters" + value: "sorters" + - label: "stratigraphic column" + value: "stratigraphic column" + - label: "data types" + value: "data types" + - label: "Other" + value: "other" diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 00000000..65db9e62 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,48 @@ +name: "Question" +description: "Ask a question about map2loop!" +title: "[Question] - " +labels: ["question"] +body: + - type: markdown + attributes: + value: | + ## Question + + Please use this template to ask a question about applying map2loop to your data. + Provide as much detail as possible to help us understand and answer your question efficiently. + + - type: input + id: question_title + attributes: + label: "Question Title" + description: "Provide a concise and descriptive title for your question." + placeholder: "Enter the title of your question" + validations: + required: true + + - type: textarea + id: question_details + attributes: + label: "Question Details" + description: "Describe your question in detail. Include any context or background information that might be helpful." + placeholder: "Enter the details of your question" + validations: + required: true + + - type: textarea + id: relevant_code_snippets + attributes: + label: "Relevant code or data" + description: "If applicable, provide any relevant code snippets or examples related to your question." + placeholder: "Enter any relevant code snippets" + validations: + required: false + + - type: input + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful in answering your question." + placeholder: "Enter any additional context" + validations: + required: false From ff54560d514ac240b35f28a69544a7793bac10bf Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 24 May 2024 08:51:38 +1000 Subject: [PATCH 55/98] fix: add pull request template --- .../ISSUE_TEMPLATE/pull_request_template.yml | 18 +++++++++++++ .../pull_request_template/bug_fix_template.md | 24 +++++++++++++++++ .../docs_update_template.md | 23 ++++++++++++++++ .../pull_request_template/feature_template.md | 27 +++++++++++++++++++ .../tests_improvement_template.md | 23 ++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/pull_request_template.yml create mode 100644 .github/pull_request_template/bug_fix_template.md create mode 100644 .github/pull_request_template/docs_update_template.md create mode 100644 .github/pull_request_template/feature_template.md create mode 100644 .github/pull_request_template/tests_improvement_template.md diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.yml b/.github/ISSUE_TEMPLATE/pull_request_template.yml new file mode 100644 index 00000000..f99ce5c0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/pull_request_template.yml @@ -0,0 +1,18 @@ +version: 2 + +pull_request_templates: + - name: Bug Fix Template + description: Use this template for bug fixes. + file: pull_request_template/bug_fix_template.md + + - name: Feature Template + description: Use this template for new features. + file: pull_request_template/feature_template.md + + - name: Documentation Update Template + description: Use this template for documentation updates. + file: pull_request_template/docs_update_template.md + + - name: Test Improvement Template + description: Use this template for adding a new test. + file: pull_request_template/tests_improvement_template.md \ No newline at end of file diff --git a/.github/pull_request_template/bug_fix_template.md b/.github/pull_request_template/bug_fix_template.md new file mode 100644 index 00000000..d6f7f7ad --- /dev/null +++ b/.github/pull_request_template/bug_fix_template.md @@ -0,0 +1,24 @@ +## Description + +Please describe the issue that this pull request addresses and summarize the changes. + +Fixes #(issue) + +## Type of change + +- [ ] Bug fix (non-breaking change which fixes an issue) + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own code +- [ ] My code follows the style guidelines of this project +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md new file mode 100644 index 00000000..247529c3 --- /dev/null +++ b/.github/pull_request_template/docs_update_template.md @@ -0,0 +1,23 @@ +## Description + +Please include a summary of the changes. Include context if relevant. + +Fixes #(issue) + +## Type of change + +- [ ] Documentation update + +## How Has This Been Tested? +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own documentation +- [ ] I have built the documentation locally with make.bat +- [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs +- [ ] My documentation follows the style guidelines of this project +- [ ] I have checked my spelling and grammar diff --git a/.github/pull_request_template/feature_template.md b/.github/pull_request_template/feature_template.md new file mode 100644 index 00000000..29a43a6e --- /dev/null +++ b/.github/pull_request_template/feature_template.md @@ -0,0 +1,27 @@ +## Description + +Please include a summary of the changes and the related issue. Include relevant motivation and context, if appropriate. +List any new dependencies that are required for this change. + +Fixes #(issue) + +## Type of change + +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own code +- [ ] My code follows the style guidelines of this project +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md new file mode 100644 index 00000000..78b3bc70 --- /dev/null +++ b/.github/pull_request_template/tests_improvement_template.md @@ -0,0 +1,23 @@ +## Description + +Please include a summary of the added test. List relevant functions tested. + +Fixes #(issue) + +## Type of change + +- [ ] Test improvement + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own tests +- [ ] My tests follow the style guidelines of this project +- [ ] I have commented my tests, particularly in hard-to-understand areas +- [ ] New and existing unit tests pass locally with my changes From 6f787b92fde7a67e7113eab699ba14185e7e6cd8 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 24 May 2024 09:01:09 +1000 Subject: [PATCH 56/98] fix: few typos grammar --- .github/ISSUE_TEMPLATE/pull_request_template.yml | 2 +- .github/pull_request_template/bug_fix_template.md | 4 ++-- .github/pull_request_template/tests_improvement_template.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.yml b/.github/ISSUE_TEMPLATE/pull_request_template.yml index f99ce5c0..2fc5462a 100644 --- a/.github/ISSUE_TEMPLATE/pull_request_template.yml +++ b/.github/ISSUE_TEMPLATE/pull_request_template.yml @@ -6,7 +6,7 @@ pull_request_templates: file: pull_request_template/bug_fix_template.md - name: Feature Template - description: Use this template for new features. + description: Use this template for adding new features. file: pull_request_template/feature_template.md - name: Documentation Update Template diff --git a/.github/pull_request_template/bug_fix_template.md b/.github/pull_request_template/bug_fix_template.md index d6f7f7ad..afdc1497 100644 --- a/.github/pull_request_template/bug_fix_template.md +++ b/.github/pull_request_template/bug_fix_template.md @@ -1,6 +1,6 @@ ## Description -Please describe the issue that this pull request addresses and summarize the changes. +Please describe the issue that this pull request addresses and summarize the changes you are implementing. Fixes #(issue) @@ -10,7 +10,7 @@ Fixes #(issue) ## How Has This Been Tested? -Please describe the tests that you ran to verify your changes. +Please describe any tests that you ran to verify your changes. Provide branch name so we can reproduce. ## Checklist: diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md index 78b3bc70..aa56ee86 100644 --- a/.github/pull_request_template/tests_improvement_template.md +++ b/.github/pull_request_template/tests_improvement_template.md @@ -1,6 +1,6 @@ ## Description -Please include a summary of the added test. List relevant functions tested. +Please include a summary of the added or modified test. List relevant functions tested. Fixes #(issue) From 84764ce02562295d224391c409317a256196c94b Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 24 May 2024 09:40:33 +1000 Subject: [PATCH 57/98] fix: tests should be with pytest --- .github/pull_request_template/tests_improvement_template.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md index aa56ee86..58fd8b08 100644 --- a/.github/pull_request_template/tests_improvement_template.md +++ b/.github/pull_request_template/tests_improvement_template.md @@ -17,6 +17,7 @@ Provide branch name so we can reproduce. - [ ] This branch is up-to-date with master - [ ] All gh-action checks are passing +- [ ] My tests run with pytest from the map2loop folder - [ ] I have performed a self-review of my own tests - [ ] My tests follow the style guidelines of this project - [ ] I have commented my tests, particularly in hard-to-understand areas From 28f437b2b15d806a481f74545d1f0819aca35586 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Mon, 27 May 2024 12:46:12 +1000 Subject: [PATCH 58/98] Revert "Update issue templates" --- .github/ISSUE_TEMPLATE/bug_report.yml | 91 ------------------- .../ISSUE_TEMPLATE/documentation_request.yml | 39 -------- .github/ISSUE_TEMPLATE/feature_request.yml | 77 ---------------- .../ISSUE_TEMPLATE/pull_request_template.yml | 18 ---- .github/ISSUE_TEMPLATE/question.yml | 48 ---------- .../pull_request_template/bug_fix_template.md | 24 ----- .../docs_update_template.md | 23 ----- .../pull_request_template/feature_template.md | 27 ------ .../tests_improvement_template.md | 24 ----- 9 files changed, 371 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/documentation_request.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml delete mode 100644 .github/ISSUE_TEMPLATE/pull_request_template.yml delete mode 100644 .github/ISSUE_TEMPLATE/question.yml delete mode 100644 .github/pull_request_template/bug_fix_template.md delete mode 100644 .github/pull_request_template/docs_update_template.md delete mode 100644 .github/pull_request_template/feature_template.md delete mode 100644 .github/pull_request_template/tests_improvement_template.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 8fe9facf..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: "Bug Report" -description: "Report a bug or an issue in map2loop" -title: "[Bug] - " -labels: ["bug"] -body: - - type: markdown - attributes: - value: | - ## Bug Report - Thanks for submitting a bug report to map2loop! - Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. - - - type: input - id: bug_title - attributes: - label: "Bug Title" - description: "Provide a concise and descriptive title for the bug report." - placeholder: "Enter the title of the bug" - validations: - required: true - - - type: textarea - id: bug_description - attributes: - label: "Bug Description" - description: "Describe the bug you encountered. Include details on what you expected to happen and what actually happened." - placeholder: "Enter a detailed description of the bug" - validations: - required: true - - - type: textarea - id: steps_to_reproduce - attributes: - label: "Minimal reproducible example" - description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." - placeholder: "Enter the steps to reproduce the bug" - validations: - required: true - - - type: textarea - id: expected_behavior - attributes: - label: "Expected Behavior" - description: "Describe what you expected to happen." - placeholder: "Enter the expected behavior" - validations: - required: true - - - type: textarea - id: actual_behavior - attributes: - label: "Actual Behavior" - description: "Describe what actually happened when you encountered the bug." - placeholder: "Enter the actual behavior" - validations: - required: true - - - type: textarea - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful in understanding and fixing the bug." - placeholder: "Enter any additional context" - validations: - required: false - - - type: input - id: environment - attributes: - label: "Environment" - description: "Specify the environment in which the bug occurred (e.g., operating system, browser, application version)." - placeholder: "Enter the environment details" - validations: - required: true - - - type: checkboxes - id: severity - attributes: - label: "Severity" - description: "Select the severity level of the bug." - options: - - label: "Low" - value: "low" - - label: "Medium" - value: "medium" - - label: "High" - value: "high" - - label: "Critical" - value: "critical" - validations: - required: true diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml deleted file mode 100644 index 6fb074ad..00000000 --- a/.github/ISSUE_TEMPLATE/documentation_request.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: "Documentation Request" -description: "Help us improve map2loop documentation!" -title: "[Documentation] - " -labels: ["documentation"] -body: - - type: markdown - attributes: - value: | - ## Documentation Request - - Please use this template to suggest an improvement or addition to map2loop documentation. - Provide as much detail as possible to help us understand and implement your request efficiently. - - - type: input - id: doc_title - attributes: - label: "Documentation Title" - description: "Provide a concise and descriptive title for the documentation request." - placeholder: "Enter the title of the documentation request" - validations: - required: true - - - type: textarea - id: doc_details - attributes: - label: "Documentation Details" - description: "Describe the documentation you would like to see. Include details on why it is needed and how it should be structured." - placeholder: "Enter a detailed description of the documentation" - validations: - required: true - - - type: textarea - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful." - placeholder: "Enter any additional context" - validations: - required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml deleted file mode 100644 index 00872c72..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: "Feature Request" -description: "Suggest a new feature or enhancement for map2loop" -title: "[Feature Request] - " -labels: ["enhancement", "feature request"] -body: - - type: markdown - attributes: - value: | - ## Feature Request - - Please use this template to submit your feature request. Provide as much detail as possible to help us understand and implement your request efficiently. - - - type: input - id: feature_title - attributes: - label: "Feature Title" - description: "Provide a concise and descriptive title for the feature request." - placeholder: "Enter the title of the feature" - validations: - required: true - - - type: textarea - id: feature_description - attributes: - label: "Feature Description" - description: "Describe the feature you would like to see. Include details on why it is needed and how it should work." - placeholder: "Enter a detailed description of the feature" - validations: - required: true - - - type: textarea - id: current_situation - attributes: - label: "Current Situation" - description: "Describe the current situation and how the absence of this feature affects you." - placeholder: "Explain the current situation and its drawbacks" - validations: - required: true - - - type: textarea - id: proposed_solution - attributes: - label: "Proposed Solution" - description: "Describe how you envision the feature working. Include any specific requirements or details." - placeholder: "Explain how the feature should work" - validations: - required: true - - - type: input - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful in understanding the feature request." - placeholder: "Enter any additional context" - validations: - required: false - - - type: checkboxes - id: affected_areas - attributes: - label: "Affected Areas" - description: "Select the areas of the project that this feature request impacts." - options: - - label: "input data" - value: "input data" - - label: "project creation" - value: "project creation" - - label: "samplers" - value: "samplers" - - label: "sorters" - value: "sorters" - - label: "stratigraphic column" - value: "stratigraphic column" - - label: "data types" - value: "data types" - - label: "Other" - value: "other" diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.yml b/.github/ISSUE_TEMPLATE/pull_request_template.yml deleted file mode 100644 index 2fc5462a..00000000 --- a/.github/ISSUE_TEMPLATE/pull_request_template.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: 2 - -pull_request_templates: - - name: Bug Fix Template - description: Use this template for bug fixes. - file: pull_request_template/bug_fix_template.md - - - name: Feature Template - description: Use this template for adding new features. - file: pull_request_template/feature_template.md - - - name: Documentation Update Template - description: Use this template for documentation updates. - file: pull_request_template/docs_update_template.md - - - name: Test Improvement Template - description: Use this template for adding a new test. - file: pull_request_template/tests_improvement_template.md \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml deleted file mode 100644 index 65db9e62..00000000 --- a/.github/ISSUE_TEMPLATE/question.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: "Question" -description: "Ask a question about map2loop!" -title: "[Question] - " -labels: ["question"] -body: - - type: markdown - attributes: - value: | - ## Question - - Please use this template to ask a question about applying map2loop to your data. - Provide as much detail as possible to help us understand and answer your question efficiently. - - - type: input - id: question_title - attributes: - label: "Question Title" - description: "Provide a concise and descriptive title for your question." - placeholder: "Enter the title of your question" - validations: - required: true - - - type: textarea - id: question_details - attributes: - label: "Question Details" - description: "Describe your question in detail. Include any context or background information that might be helpful." - placeholder: "Enter the details of your question" - validations: - required: true - - - type: textarea - id: relevant_code_snippets - attributes: - label: "Relevant code or data" - description: "If applicable, provide any relevant code snippets or examples related to your question." - placeholder: "Enter any relevant code snippets" - validations: - required: false - - - type: input - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful in answering your question." - placeholder: "Enter any additional context" - validations: - required: false diff --git a/.github/pull_request_template/bug_fix_template.md b/.github/pull_request_template/bug_fix_template.md deleted file mode 100644 index afdc1497..00000000 --- a/.github/pull_request_template/bug_fix_template.md +++ /dev/null @@ -1,24 +0,0 @@ -## Description - -Please describe the issue that this pull request addresses and summarize the changes you are implementing. - -Fixes #(issue) - -## Type of change - -- [ ] Bug fix (non-breaking change which fixes an issue) - -## How Has This Been Tested? - -Please describe any tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] I have performed a self-review of my own code -- [ ] My code follows the style guidelines of this project -- [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I have made corresponding changes to the documentation -- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md deleted file mode 100644 index 247529c3..00000000 --- a/.github/pull_request_template/docs_update_template.md +++ /dev/null @@ -1,23 +0,0 @@ -## Description - -Please include a summary of the changes. Include context if relevant. - -Fixes #(issue) - -## Type of change - -- [ ] Documentation update - -## How Has This Been Tested? -Please describe the tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] I have performed a self-review of my own documentation -- [ ] I have built the documentation locally with make.bat -- [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs -- [ ] My documentation follows the style guidelines of this project -- [ ] I have checked my spelling and grammar diff --git a/.github/pull_request_template/feature_template.md b/.github/pull_request_template/feature_template.md deleted file mode 100644 index 29a43a6e..00000000 --- a/.github/pull_request_template/feature_template.md +++ /dev/null @@ -1,27 +0,0 @@ -## Description - -Please include a summary of the changes and the related issue. Include relevant motivation and context, if appropriate. -List any new dependencies that are required for this change. - -Fixes #(issue) - -## Type of change - -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - -## How Has This Been Tested? - -Please describe the tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] I have performed a self-review of my own code -- [ ] My code follows the style guidelines of this project -- [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I have made corresponding changes to the documentation -- [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md deleted file mode 100644 index 58fd8b08..00000000 --- a/.github/pull_request_template/tests_improvement_template.md +++ /dev/null @@ -1,24 +0,0 @@ -## Description - -Please include a summary of the added or modified test. List relevant functions tested. - -Fixes #(issue) - -## Type of change - -- [ ] Test improvement - -## How Has This Been Tested? - -Please describe the tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] My tests run with pytest from the map2loop folder -- [ ] I have performed a self-review of my own tests -- [ ] My tests follow the style guidelines of this project -- [ ] I have commented my tests, particularly in hard-to-understand areas -- [ ] New and existing unit tests pass locally with my changes From 3bfffb8d97421835eb2eac7a672b20bc75ac7721 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 28 May 2024 11:16:23 +1000 Subject: [PATCH 59/98] fix: add issue templates back --- .github/ISSUE_TEMPLATE/bug_report.yml | 87 +++++++++++++++++++ .../ISSUE_TEMPLATE/documentation_request.yml | 37 ++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 69 +++++++++++++++ .../ISSUE_TEMPLATE/pull_request_template.yml | 18 ++++ .github/ISSUE_TEMPLATE/question.yml | 46 ++++++++++ .../pull_request_template/bug_fix_remplate.md | 24 +++++ .../docs_update_template.md | 23 +++++ .../pull_request_template/feature_template.md | 27 ++++++ .../test_improvement_template.md | 24 +++++ 9 files changed, 355 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/documentation_request.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/ISSUE_TEMPLATE/pull_request_template.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml create mode 100644 .github/pull_request_template/bug_fix_remplate.md create mode 100644 .github/pull_request_template/docs_update_template.md create mode 100644 .github/pull_request_template/feature_template.md create mode 100644 .github/pull_request_template/test_improvement_template.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..b96a5204 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,87 @@ +name: "Bug Report" +description: "Report a bug or an issue in map2loop" +title: "[Bug] - " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + ## Bug Report + Thanks for submitting a bug report to map2loop! + Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. + + - type: input + id: bug_title + attributes: + label: "Bug Title" + description: "Provide a concise and descriptive title for the bug report." + placeholder: "Enter the title of the bug" + validations: + required: true + + - type: textarea + id: bug_description + attributes: + label: "Bug Description" + description: "Describe the bug you encountered. Include details on what you expected to happen and what actually happened." + placeholder: "Enter a detailed description of the bug" + validations: + required: true + + - type: textarea + id: steps_to_reproduce + attributes: + label: "Minimal reproducible example" + description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." + placeholder: "Enter the steps to reproduce the bug" + validations: + required: true + + - type: textarea + id: expected_behavior + attributes: + label: "Expected Behavior" + description: "Describe what you expected to happen." + placeholder: "Enter the expected behavior" + validations: + required: true + + - type: textarea + id: actual_behavior + attributes: + label: "Actual Behavior" + description: "Describe what actually happened when you encountered the bug." + placeholder: "Enter the actual behavior" + validations: + required: true + + - type: textarea + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful in understanding and fixing the bug." + placeholder: "Enter any additional context" + validations: + required: false + + - type: input + id: environment + attributes: + label: "Environment" + description: "Specify the environment in which the bug occurred (e.g., operating system, browser, application version)." + placeholder: "Enter the environment details" + validations: + required: true + + - type: checkboxes + id: severity + attributes: + label: "Severity" + description: "Select the severity level of the bug." + options: + - label: "Low" + - label: "Medium" + - label: "High" + - label: "Critical" + validations: + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml new file mode 100644 index 00000000..d275cc6c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation_request.yml @@ -0,0 +1,37 @@ +name: "Documentation Request" +description: "Help us improve map2loop documentation!" +title: "[Documentation] - " +labels: ["documentation"] +body: + - type: markdown + attributes: + value: | + ## Documentation Request + Please use this template to suggest an improvement or addition to map2loop documentation. + Provide as much detail as possible to help us understand and implement your request efficiently. + - type: input + id: doc_title + attributes: + label: "Documentation Title" + description: "Provide a concise and descriptive title for the documentation request." + placeholder: "Enter the title of the documentation request" + validations: + required: true + + - type: textarea + id: doc_details + attributes: + label: "Documentation Details" + description: "Describe the documentation you would like to see. Include details on why it is needed and how it should be structured." + placeholder: "Enter a detailed description of the documentation" + validations: + required: true + + - type: textarea + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful." + placeholder: "Enter any additional context" + validations: + required: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 00000000..c18daa34 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,69 @@ +name: "Feature Request" +description: "Suggest a new feature or enhancement for map2loop" +title: "[Feature Request] - " +labels: ["enhancement", "feature request"] +body: + - type: markdown + attributes: + value: | + ## Feature Request + Please use this template to submit your feature request. Provide as much detail as possible to help us understand and implement your request efficiently. + - type: input + id: feature_title + attributes: + label: "Feature Title" + description: "Provide a concise and descriptive title for the feature request." + placeholder: "Enter the title of the feature" + validations: + required: true + + - type: textarea + id: feature_description + attributes: + label: "Feature Description" + description: "Describe the feature you would like to see. Include details on why it is needed and how it should work." + placeholder: "Enter a detailed description of the feature" + validations: + required: true + + - type: textarea + id: current_situation + attributes: + label: "Current Situation" + description: "Describe the current situation and how the absence of this feature affects you." + placeholder: "Explain the current situation and its drawbacks" + validations: + required: true + + - type: textarea + id: proposed_solution + attributes: + label: "Proposed Solution" + description: "Describe how you envision the feature working. Include any specific requirements or details." + placeholder: "Explain how the feature should work" + validations: + required: true + + - type: input + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful in understanding the feature request." + placeholder: "Enter any additional context" + validations: + required: false + + - type: checkboxes + id: affected_areas + attributes: + label: "Affected Areas" + description: "Select the areas of the project that this feature request impacts." + options: + - label: "input data" + - label: "project creation" + - label: "samplers" + - label: "sorters" + - label: "stratigraphic column" + - label: "data types" + - label: "faults" + - label: "Other" \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.yml b/.github/ISSUE_TEMPLATE/pull_request_template.yml new file mode 100644 index 00000000..bba4e8d7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/pull_request_template.yml @@ -0,0 +1,18 @@ +version: 2 + +pull_request_templates: + - name: Bug Fix Template + description: Use this template for bug fixes. + file: pull_request_template/bug_fix_template.md + + - name: Feature Template + description: Use this template for adding new features. + file: pull_request_template/feature_template.md + + - name: Documentation Update Template + description: Use this template for documentation updates. + file: pull_request_template/docs_update_template.md + + - name: Test Improvement Template + description: Use this template for adding a new test. + file: pull_request_template/tests_improvement_template.md diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 00000000..1348b55c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,46 @@ +name: "Question" +description: "Ask a question about map2loop!" +title: "[Question] - " +labels: ["question"] +body: + - type: markdown + attributes: + value: | + ## Question + Please use this template to ask a question about applying map2loop to your data. + Provide as much detail as possible to help us understand and answer your question efficiently. + - type: input + id: question_title + attributes: + label: "Question Title" + description: "Provide a concise and descriptive title for your question." + placeholder: "Enter the title of your question" + validations: + required: true + + - type: textarea + id: question_details + attributes: + label: "Question Details" + description: "Describe your question in detail. Include any context or background information that might be helpful." + placeholder: "Enter the details of your question" + validations: + required: true + + - type: textarea + id: relevant_code_snippets + attributes: + label: "Relevant code or data" + description: "If applicable, provide any relevant code snippets or examples related to your question." + placeholder: "Enter any relevant code snippets" + validations: + required: false + + - type: input + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful in answering your question." + placeholder: "Enter any additional context" + validations: + required: false \ No newline at end of file diff --git a/.github/pull_request_template/bug_fix_remplate.md b/.github/pull_request_template/bug_fix_remplate.md new file mode 100644 index 00000000..afdc1497 --- /dev/null +++ b/.github/pull_request_template/bug_fix_remplate.md @@ -0,0 +1,24 @@ +## Description + +Please describe the issue that this pull request addresses and summarize the changes you are implementing. + +Fixes #(issue) + +## Type of change + +- [ ] Bug fix (non-breaking change which fixes an issue) + +## How Has This Been Tested? + +Please describe any tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own code +- [ ] My code follows the style guidelines of this project +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md new file mode 100644 index 00000000..99c76ba5 --- /dev/null +++ b/.github/pull_request_template/docs_update_template.md @@ -0,0 +1,23 @@ +## Description + +Please include a summary of the changes. Include context if relevant. + +Fixes #(issue) + +## Type of change + +- [ ] Documentation update + +## How Has This Been Tested? +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own documentation +- [ ] I have built the documentation locally with make.bat +- [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs +- [ ] My documentation follows the style guidelines of this project +- [ ] I have checked my spelling and grammar \ No newline at end of file diff --git a/.github/pull_request_template/feature_template.md b/.github/pull_request_template/feature_template.md new file mode 100644 index 00000000..29a43a6e --- /dev/null +++ b/.github/pull_request_template/feature_template.md @@ -0,0 +1,27 @@ +## Description + +Please include a summary of the changes and the related issue. Include relevant motivation and context, if appropriate. +List any new dependencies that are required for this change. + +Fixes #(issue) + +## Type of change + +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own code +- [ ] My code follows the style guidelines of this project +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/test_improvement_template.md b/.github/pull_request_template/test_improvement_template.md new file mode 100644 index 00000000..0be02d03 --- /dev/null +++ b/.github/pull_request_template/test_improvement_template.md @@ -0,0 +1,24 @@ +## Description + +Please include a summary of the added or modified test. List relevant functions tested. + +Fixes #(issue) + +## Type of change + +- [ ] Test improvement + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] My tests run with pytest from the map2loop folder +- [ ] I have performed a self-review of my own tests +- [ ] My tests follow the style guidelines of this project +- [ ] I have commented my tests, particularly in hard-to-understand areas +- [ ] New and existing unit tests pass locally with my changes \ No newline at end of file From 7605c77144a6986fc5dcd9013dedf5cd4d2e093e Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 28 May 2024 11:40:57 +1000 Subject: [PATCH 60/98] fix: correct grammar for clarity --- .github/pull_request_template/bug_fix_remplate.md | 4 ++-- .github/pull_request_template/docs_update_template.md | 4 ++-- .github/pull_request_template/feature_template.md | 4 ++-- .github/pull_request_template/test_improvement_template.md | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/pull_request_template/bug_fix_remplate.md b/.github/pull_request_template/bug_fix_remplate.md index afdc1497..f2e4c85b 100644 --- a/.github/pull_request_template/bug_fix_remplate.md +++ b/.github/pull_request_template/bug_fix_remplate.md @@ -15,8 +15,8 @@ Provide branch name so we can reproduce. ## Checklist: -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing +- [ ] This branch is up-to-date with the master branch +- [ ] All github-action checks are passing - [ ] I have performed a self-review of my own code - [ ] My code follows the style guidelines of this project - [ ] I have commented my code, particularly in hard-to-understand areas diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md index 99c76ba5..a1c43359 100644 --- a/.github/pull_request_template/docs_update_template.md +++ b/.github/pull_request_template/docs_update_template.md @@ -14,8 +14,8 @@ Provide branch name so we can reproduce. ## Checklist: -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing +- [ ] This branch is up-to-date with the master branch +- [ ] All github-action checks are passing - [ ] I have performed a self-review of my own documentation - [ ] I have built the documentation locally with make.bat - [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs diff --git a/.github/pull_request_template/feature_template.md b/.github/pull_request_template/feature_template.md index 29a43a6e..3b6e6313 100644 --- a/.github/pull_request_template/feature_template.md +++ b/.github/pull_request_template/feature_template.md @@ -17,8 +17,8 @@ Provide branch name so we can reproduce. ## Checklist: -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing +- [ ] This branch is up-to-date with the master branch +- [ ] All github-action checks are passing - [ ] I have performed a self-review of my own code - [ ] My code follows the style guidelines of this project - [ ] I have commented my code, particularly in hard-to-understand areas diff --git a/.github/pull_request_template/test_improvement_template.md b/.github/pull_request_template/test_improvement_template.md index 0be02d03..56e082bc 100644 --- a/.github/pull_request_template/test_improvement_template.md +++ b/.github/pull_request_template/test_improvement_template.md @@ -13,10 +13,10 @@ Fixes #(issue) Please describe the tests that you ran to verify your changes. Provide branch name so we can reproduce. -## Checklist: +## Checklist: -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing +- [ ] This branch is up-to-date with the master branch +- [ ] All github-action checks are passing - [ ] My tests run with pytest from the map2loop folder - [ ] I have performed a self-review of my own tests - [ ] My tests follow the style guidelines of this project From 00cea8f3365a21775b685247457a171c8799c258 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Wed, 29 May 2024 16:18:09 +1000 Subject: [PATCH 61/98] fix: avoid double imports --- map2loop/thickness_calculator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index b9aa7ca7..becc861a 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -254,7 +254,7 @@ def compute( contacts = map_data.get_value_from_raster_df(Datatype.DTM, contacts) # update the geometry of the contact points to include the Z value contacts["geometry"] = contacts.apply( - lambda row: Point(row.geometry.x, row.geometry.y, row["Z"]), axis=1 + lambda row: shapely.Point(row.geometry.x, row.geometry.y, row["Z"]), axis=1 ) # spatial join the contact points with the basal contacts to get the unit for each contact point contacts = contacts.sjoin(basal_contacts, how="inner", predicate="intersects") @@ -281,7 +281,7 @@ def compute( interpolated = map_data.get_value_from_raster_df(Datatype.DTM, interpolated_orientations) # update the geometry of the interpolated points to include the Z value interpolated["geometry"] = interpolated.apply( - lambda row: Point(row.geometry.x, row.geometry.y, row["Z"]), axis=1 + lambda row: shapely.Point(row.geometry.x, row.geometry.y, row["Z"]), axis=1 ) # for each interpolated point, assign name of unit using spatial join units = map_data.get_map_data(Datatype.GEOLOGY) From ae11ebe6499de4e95d1bec5bd2ae4758f8c25ec3 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 12:15:54 +1000 Subject: [PATCH 62/98] fix: add test for all structures less than 360 --- tests/mapdata/test_mapdata.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tests/mapdata/test_mapdata.py b/tests/mapdata/test_mapdata.py index 2bd9030e..14bcbfe1 100644 --- a/tests/mapdata/test_mapdata.py +++ b/tests/mapdata/test_mapdata.py @@ -4,12 +4,9 @@ from map2loop.mapdata import MapData from map2loop.m2l_enums import Datatype -def test_if_m2l_returns_all_sampled_structures_with_DIPDIR_lower_than_360(): - - # call the class +def test_structures_less_than_360(): md = MapData() - # add config definition md.config.structure_config = { "dipdir_column": "DIPDIR", "dip_column": "DIP", @@ -21,7 +18,6 @@ def test_if_m2l_returns_all_sampled_structures_with_DIPDIR_lower_than_360(): "orientation_type": "strike" } - # create mock data data = { 'geometry': [shapely.Point(1, 1), shapely.Point(2, 2), shapely.Point(3, 3),], 'DIPDIR': [45.0, 370.0, 420.0], @@ -31,18 +27,9 @@ def test_if_m2l_returns_all_sampled_structures_with_DIPDIR_lower_than_360(): 'ID': [1, 2, 3] } - #build geodataframe to hold the data data = geopandas.GeoDataFrame(data) - # set it as the raw_data md.raw_data[Datatype.STRUCTURE] = data + md.parse_structure_map() - # make it parse the structure map and raise exception if error in parse_structure_map - - try: - md.parse_structure_map() - except Exception as e: - pytest.fail(f"parse_structure_map raised an exception: {e}") - - # check if all values below 360 assert md.data[Datatype.STRUCTURE]['DIPDIR'].all() < 360, "MapData.STRUCTURE is producing DIPDIRs > 360 degrees" \ No newline at end of file From e94dcebfd59a16f050ffc1796e58a663b4c37d88 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 12:22:04 +1000 Subject: [PATCH 63/98] fix: add catchall exception to mapdata_parse_structure & comment code --- tests/mapdata/test_mapdata.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/mapdata/test_mapdata.py b/tests/mapdata/test_mapdata.py index 14bcbfe1..fd3c9881 100644 --- a/tests/mapdata/test_mapdata.py +++ b/tests/mapdata/test_mapdata.py @@ -5,8 +5,11 @@ from map2loop.m2l_enums import Datatype def test_structures_less_than_360(): + + # call the class md = MapData() + # add config definition md.config.structure_config = { "dipdir_column": "DIPDIR", "dip_column": "DIP", @@ -18,6 +21,7 @@ def test_structures_less_than_360(): "orientation_type": "strike" } + # create mock data data = { 'geometry': [shapely.Point(1, 1), shapely.Point(2, 2), shapely.Point(3, 3),], 'DIPDIR': [45.0, 370.0, 420.0], @@ -27,9 +31,18 @@ def test_structures_less_than_360(): 'ID': [1, 2, 3] } + #build geodataframe to hold the data data = geopandas.GeoDataFrame(data) + # set it as the raw_data md.raw_data[Datatype.STRUCTURE] = data - md.parse_structure_map() + # make it parse the structure map and raise exception if error in parse_structure_map + + try: + md.parse_structure_map() + except Exception as e: + pytest.fail(f"parse_structure_map raised an exception: {e}") + + # check if all values below 360 assert md.data[Datatype.STRUCTURE]['DIPDIR'].all() < 360, "MapData.STRUCTURE is producing DIPDIRs > 360 degrees" \ No newline at end of file From 7e25622d366a646ec3d0bb4c5607e17832e9a5e9 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 12:33:04 +1000 Subject: [PATCH 64/98] fix: make the templates a bit easier to fill out --- .github/ISSUE_TEMPLATE/bug_report.yml | 19 ++++++++------- .../ISSUE_TEMPLATE/documentation_request.yml | 10 +------- .github/ISSUE_TEMPLATE/feature_request.yml | 23 +++++++++++++------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index b96a5204..1909ba79 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -9,15 +9,13 @@ body: ## Bug Report Thanks for submitting a bug report to map2loop! Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. - - - type: input - id: bug_title + + - type: textarea + id: version attributes: - label: "Bug Title" - description: "Provide a concise and descriptive title for the bug report." - placeholder: "Enter the title of the bug" - validations: - required: true + label: Version + description: What version of map2loop and LoopProjectFile are you running? You can find this information by running `import map2loop` and `map2loop.__version__` in your python terminal or jupyter notebook. + placeholder: "Enter map2loop and LoopProjectFile versions" - type: textarea id: bug_description @@ -32,7 +30,7 @@ body: id: steps_to_reproduce attributes: label: "Minimal reproducible example" - description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." + description: "Provide a minimal reproducible example with the code necessary to reproduce the bug. For more guidance, visit: [How to create a minimal complete reproducible example](https://forum.access-hive.org.au/t/how-to-create-a-minimal-complete-reproducible-example/843)" placeholder: "Enter the steps to reproduce the bug" validations: required: true @@ -84,4 +82,5 @@ body: - label: "High" - label: "Critical" validations: - required: true \ No newline at end of file + required: true + diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml index d275cc6c..f202e2a5 100644 --- a/.github/ISSUE_TEMPLATE/documentation_request.yml +++ b/.github/ISSUE_TEMPLATE/documentation_request.yml @@ -8,15 +8,7 @@ body: value: | ## Documentation Request Please use this template to suggest an improvement or addition to map2loop documentation. - Provide as much detail as possible to help us understand and implement your request efficiently. - - type: input - id: doc_title - attributes: - label: "Documentation Title" - description: "Provide a concise and descriptive title for the documentation request." - placeholder: "Enter the title of the documentation request" - validations: - required: true + Provide as much detail as possible to help us understand and implement your request efficiently - type: textarea id: doc_details diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index c18daa34..1fd8719a 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -8,14 +8,16 @@ body: value: | ## Feature Request Please use this template to submit your feature request. Provide as much detail as possible to help us understand and implement your request efficiently. - - type: input - id: feature_title + + - type: checkboxes + id: input1 attributes: - label: "Feature Title" - description: "Provide a concise and descriptive title for the feature request." - placeholder: "Enter the title of the feature" - validations: - required: true + label: "💻" + description: | + Check this if you would like to try and implement your vision in a PR. + The map2loop team will help you go through the process + options: + - label: Would you like to work on this feature? - type: textarea id: feature_description @@ -35,6 +37,13 @@ body: validations: required: true + - type: textarea + id: version + attributes: + label: Version + description: What version of map2loop and LoopProjectFile are you running that doesn't have this feature? You can find this information by running `import map2loop` and `map2loop.__version__` in your python terminal or jupyter notebook. + placeholder: "Enter map2loop and LoopProjectFile versions" + - type: textarea id: proposed_solution attributes: From 7dff3b4c4bd989f5fc8b3e4a74800b961f428f49 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 12:34:29 +1000 Subject: [PATCH 65/98] fix: update question template --- .github/ISSUE_TEMPLATE/question.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 1348b55c..6e17cc06 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -9,14 +9,6 @@ body: ## Question Please use this template to ask a question about applying map2loop to your data. Provide as much detail as possible to help us understand and answer your question efficiently. - - type: input - id: question_title - attributes: - label: "Question Title" - description: "Provide a concise and descriptive title for your question." - placeholder: "Enter the title of your question" - validations: - required: true - type: textarea id: question_details From d2109145e7aa6d0d81df15b37c1c7d2aaa0a548e Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 15:57:57 +1000 Subject: [PATCH 66/98] fix: fix for altitude not being saved properly in LPF --- map2loop/sampler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/sampler.py b/map2loop/sampler.py index 75e5a159..daf1ef6e 100644 --- a/map2loop/sampler.py +++ b/map2loop/sampler.py @@ -84,7 +84,7 @@ def sample( data = spatial_data.copy() data["X"] = data.geometry.x data["Y"] = data.geometry.y - data["Z"] = map_data.get_value_from_raster_df(Datatype.DTM, data)["Z"] + map_data.get_value_from_raster_df(Datatype.DTM, data) data["layerID"] = geopandas.sjoin( data, map_data.get_map_data(Datatype.GEOLOGY), how='left' )['index_right'] From 9f7ddab6e063251c2754ce04d772bc1cf6fe5e3a Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 12:55:26 +1000 Subject: [PATCH 67/98] fix: allow 2 minutes for server connection & add add available ga server link --- map2loop/mapdata.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 9986c163..7089d748 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -466,7 +466,7 @@ def open_http_query(url: str): """ try: request = urllib.Request(url, headers={"Accept-Encoding": "gzip"}) - response = urllib.request.urlopen(request, timeout=30) + response = urllib.request.urlopen(request, timeout=120) if response.info().get("Content-Encoding") == "gzip": return GzipFile(fileobj=BytesIO(response.read())) else: @@ -497,14 +497,14 @@ def __retrieve_tif(self, filename: str): _type_: The open geotiff in a gdal handler """ self.__check_and_create_tmp_path() - + # For gdal debugging use exceptions gdal.UseExceptions() bb_ll = tuple(self.bounding_box_polygon.to_crs("EPSG:4326").geometry.total_bounds) - + if filename.lower() == "aus" or filename.lower() == "au": - - url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" + url = "http://gaservices.ga.gov.au/site_9/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" + # previous link version: "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" wcs = WebCoverageService(url, version="1.0.0") coverage = wcs.getCoverage( @@ -519,7 +519,7 @@ def __retrieve_tif(self, filename: str): with open(tmp_file, "wb") as fh: fh.write(coverage.read()) tif = gdal.Open(tmp_file) - + elif filename == "hawaii": import netCDF4 @@ -527,6 +527,7 @@ def __retrieve_tif(self, filename: str): f"[({str(bb_ll[1])}):1:({str(bb_ll[3])})][({str(bb_ll[0])}):1:({str(bb_ll[2])})]" ) + filename = f"https://pae-paha.pacioos.hawaii.edu/erddap/griddap/srtm30plus_v11_land.nc?elev{bbox_str}" f = urllib.request.urlopen(filename) ds = netCDF4.Dataset("in-mem-file", mode="r", memory=f.read()) From 02a6835777f4e74ce31ea53638f974c1e3d5174e Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 14:34:53 +1000 Subject: [PATCH 68/98] fix: add 2 more links to try from GA WCS if timing out & prints out where the DEM was downloaded from --- map2loop/mapdata.py | 66 +++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 7089d748..a31d3a79 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -18,6 +18,7 @@ from .random_colour import random_colours_hex from typing import Union import requests +import requests class MapData: """ @@ -483,7 +484,39 @@ def __check_and_create_tmp_path(self): os.mkdir(self.tmp_path) - + @beartype.beartype + def get_coverage(self, url: str, bb_ll:tuple): + """ + Retrieves coverage from GA WCS and save it as a GeoTIFF file. + + This method retrieves a coverage from the specified WCS GA URL using the project's bounding box. + The retrieved coverage is saved to a temporary file --> StudidGDALLocalFile.tif + + Args: + url (str): The GA WCS URL from which to retrieve the coverage. + bb_ll (tuple): A tuple containing the bounding box coordinates (minX, minY, maxX, maxY). + + Returns: + gdal.Dataset: The GDAL dataset of the retrieved GeoTIFF file. + """ + + self.__check_and_create_tmp_path() + + wcs = WebCoverageService(url, version="1.0.0") + + coverage = wcs.getCoverage( + identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 + ) + # This is stupid that gdal cannot read a byte stream and has to have a + # file on the local system to open or otherwise create a gdal file + # from scratch with Create + tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") + + with open(tmp_file, "wb") as fh: + fh.write(coverage.read()) + + return gdal.Open(tmp_file) + @beartype.beartype def __retrieve_tif(self, filename: str): """ @@ -496,30 +529,29 @@ def __retrieve_tif(self, filename: str): Returns: _type_: The open geotiff in a gdal handler """ - self.__check_and_create_tmp_path() # For gdal debugging use exceptions gdal.UseExceptions() bb_ll = tuple(self.bounding_box_polygon.to_crs("EPSG:4326").geometry.total_bounds) if filename.lower() == "aus" or filename.lower() == "au": - url = "http://gaservices.ga.gov.au/site_9/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" - # previous link version: "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" - wcs = WebCoverageService(url, version="1.0.0") + urls = [ + "http://services.ga.gov.au/gis/se33rvices/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?", # DEM with land and sea! + "http://services.ga.gov.au/gis/ser333ices/DEM_SRTM_1Second/MapServer/WCSServer?", # DEM with land only + "http://services.ga.gov.au/gis/serv33ices/DEM_SRTM_1Second_Hydro_Enforced/MapServer/WCSServer?"] # dem that accounts for lakes - coverage = wcs.getCoverage( - identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 - ) - # This is stupid that gdal cannot read a byte stream and has to have a - # file on the local system to open or otherwise create a gdal file - # from scratch with Create - - tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") - - with open(tmp_file, "wb") as fh: - fh.write(coverage.read()) - tif = gdal.Open(tmp_file) + for url in urls: + try: + tif = self.get_coverage(url, bb_ll) + if tif is not None: + print("DEM loaded from {}".format(url)) + return tif + + except Exception: + pass + raise Exception("All GA URLs failed to retrieve the DEM coverage.") + elif filename == "hawaii": import netCDF4 From ccee81785ea8e8bc423aacae80526b3dcd97f05b Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 20:34:46 +1000 Subject: [PATCH 69/98] fix: revert back to original --- map2loop/mapdata.py | 64 +++++++++++---------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index a31d3a79..d9200e5a 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -484,39 +484,7 @@ def __check_and_create_tmp_path(self): os.mkdir(self.tmp_path) - @beartype.beartype - def get_coverage(self, url: str, bb_ll:tuple): - """ - Retrieves coverage from GA WCS and save it as a GeoTIFF file. - - This method retrieves a coverage from the specified WCS GA URL using the project's bounding box. - The retrieved coverage is saved to a temporary file --> StudidGDALLocalFile.tif - - Args: - url (str): The GA WCS URL from which to retrieve the coverage. - bb_ll (tuple): A tuple containing the bounding box coordinates (minX, minY, maxX, maxY). - - Returns: - gdal.Dataset: The GDAL dataset of the retrieved GeoTIFF file. - """ - - self.__check_and_create_tmp_path() - - wcs = WebCoverageService(url, version="1.0.0") - - coverage = wcs.getCoverage( - identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 - ) - # This is stupid that gdal cannot read a byte stream and has to have a - # file on the local system to open or otherwise create a gdal file - # from scratch with Create - tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") - - with open(tmp_file, "wb") as fh: - fh.write(coverage.read()) - - return gdal.Open(tmp_file) - + @beartype.beartype def __retrieve_tif(self, filename: str): """ @@ -533,24 +501,22 @@ def __retrieve_tif(self, filename: str): # For gdal debugging use exceptions gdal.UseExceptions() bb_ll = tuple(self.bounding_box_polygon.to_crs("EPSG:4326").geometry.total_bounds) - + if filename.lower() == "aus" or filename.lower() == "au": - urls = [ - "http://services.ga.gov.au/gis/se33rvices/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?", # DEM with land and sea! - "http://services.ga.gov.au/gis/ser333ices/DEM_SRTM_1Second/MapServer/WCSServer?", # DEM with land only - "http://services.ga.gov.au/gis/serv33ices/DEM_SRTM_1Second_Hydro_Enforced/MapServer/WCSServer?"] # dem that accounts for lakes + url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second/MapServer/WCSServer?" + wcs = WebCoverageService(url, version="1.0.0") - for url in urls: - try: - tif = self.get_coverage(url, bb_ll) - if tif is not None: - print("DEM loaded from {}".format(url)) - return tif - - except Exception: - pass - - raise Exception("All GA URLs failed to retrieve the DEM coverage.") + coverage = wcs.getCoverage( + identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 + ) + # This is stupid that gdal cannot read a byte stream and has to have a + # file on the local system to open or otherwise create a gdal file + # from scratch with Create + + tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") + with open(tmp_file, "wb") as fh: + fh.write(coverage.read()) + tif = gdal.Open(tmp_file) elif filename == "hawaii": import netCDF4 From 17aa2b363fb6a9d169bf87ee9ff330b1e68f96cd Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 20:41:58 +1000 Subject: [PATCH 70/98] fix: create the tmp file function missing --- map2loop/mapdata.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index d9200e5a..c3f94c21 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -497,12 +497,14 @@ def __retrieve_tif(self, filename: str): Returns: _type_: The open geotiff in a gdal handler """ - + self.__check_and_create_tmp_path() + # For gdal debugging use exceptions gdal.UseExceptions() bb_ll = tuple(self.bounding_box_polygon.to_crs("EPSG:4326").geometry.total_bounds) if filename.lower() == "aus" or filename.lower() == "au": + url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second/MapServer/WCSServer?" wcs = WebCoverageService(url, version="1.0.0") @@ -512,8 +514,9 @@ def __retrieve_tif(self, filename: str): # This is stupid that gdal cannot read a byte stream and has to have a # file on the local system to open or otherwise create a gdal file # from scratch with Create - + tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") + with open(tmp_file, "wb") as fh: fh.write(coverage.read()) tif = gdal.Open(tmp_file) From dac2a902ca056ffe9bad72037b534032a102a0e5 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 4 Jun 2024 08:53:43 +1000 Subject: [PATCH 71/98] fix: return just column with new vals instead of inplace modification --- map2loop/sampler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/sampler.py b/map2loop/sampler.py index daf1ef6e..75e5a159 100644 --- a/map2loop/sampler.py +++ b/map2loop/sampler.py @@ -84,7 +84,7 @@ def sample( data = spatial_data.copy() data["X"] = data.geometry.x data["Y"] = data.geometry.y - map_data.get_value_from_raster_df(Datatype.DTM, data) + data["Z"] = map_data.get_value_from_raster_df(Datatype.DTM, data)["Z"] data["layerID"] = geopandas.sjoin( data, map_data.get_map_data(Datatype.GEOLOGY), how='left' )['index_right'] From 4e042e54ccdb13ae73b7e8392abee99c836bb8cd Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 4 Jun 2024 09:34:55 +1000 Subject: [PATCH 72/98] fix: verbose dipdir 360 test name --- tests/mapdata/test_mapdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mapdata/test_mapdata.py b/tests/mapdata/test_mapdata.py index fd3c9881..2bd9030e 100644 --- a/tests/mapdata/test_mapdata.py +++ b/tests/mapdata/test_mapdata.py @@ -4,7 +4,7 @@ from map2loop.mapdata import MapData from map2loop.m2l_enums import Datatype -def test_structures_less_than_360(): +def test_if_m2l_returns_all_sampled_structures_with_DIPDIR_lower_than_360(): # call the class md = MapData() From 3978108eff5d3bf1fe00410541494bfcc4a58b19 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 6 Jun 2024 14:49:37 +1000 Subject: [PATCH 73/98] fix: revert back to original timeout --- map2loop/mapdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index c3f94c21..3556c497 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -467,7 +467,7 @@ def open_http_query(url: str): """ try: request = urllib.Request(url, headers={"Accept-Encoding": "gzip"}) - response = urllib.request.urlopen(request, timeout=120) + response = urllib.request.urlopen(request, timeout=30) if response.info().get("Content-Encoding") == "gzip": return GzipFile(fileobj=BytesIO(response.read())) else: From 9a193731646cb94e35971d6925a79b37425938e7 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 6 Jun 2024 14:57:06 +1000 Subject: [PATCH 74/98] fix: revert back to original url --- map2loop/mapdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 3556c497..3118c7a7 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -505,7 +505,7 @@ def __retrieve_tif(self, filename: str): if filename.lower() == "aus" or filename.lower() == "au": - url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second/MapServer/WCSServer?" + url = "http://services.ga.gov.au/gis/services/DEM_SRTM_1Second_over_Bathymetry_Topography/MapServer/WCSServer?" wcs = WebCoverageService(url, version="1.0.0") coverage = wcs.getCoverage( From 11d507fbee313ad93e1957701060cd4281142edb Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 20:42:03 +1000 Subject: [PATCH 75/98] fix: remove matplotlib & assign random colors & tidy up imports --- map2loop/mapdata.py | 36 ++++++++++++++++--------- map2loop/project.py | 17 ++++++------ map2loop/random.py | 3 --- map2loop/random_colour.py | 23 ---------------- map2loop/sampler.py | 7 +++-- map2loop/thickness_calculator.py | 19 +++++++++++--- map2loop/utils.py | 45 ++++++++++++++++++++++++++++++-- 7 files changed, 96 insertions(+), 54 deletions(-) delete mode 100644 map2loop/random.py delete mode 100644 map2loop/random_colour.py diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 3118c7a7..e580b9dc 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -1,3 +1,10 @@ +#internal imports +from .m2l_enums import Datatype, Datastate, VerboseLevel +from .config import Config +from .aus_state_urls import AustraliaStateUrls +from .utils import generate_random_hex_colors + +#external imports import geopandas import pandas import numpy @@ -11,11 +18,6 @@ import beartype import os from io import BytesIO -from .m2l_enums import Datatype, Datastate -from .m2l_enums import VerboseLevel -from .config import Config -from .aus_state_urls import AustraliaStateUrls -from .random_colour import random_colours_hex from typing import Union import requests import requests @@ -291,7 +293,7 @@ def set_ignore_codes(self, codes: list): @beartype.beartype def get_ignore_codes(self) -> list: """ - Get the list of codes to ingnore + Get the list of codes to ignore Returns: list: The list of strings to ignore @@ -1456,7 +1458,7 @@ def extract_basal_contacts(self, stratigraphic_column: list, save_contacts=True) return basal_contacts @beartype.beartype - def colour_units(self, stratigraphic_units: pandas.DataFrame, random: bool = False): + def colour_units(self, stratigraphic_units: pandas.DataFrame, random: bool = False) -> pandas.DataFrame: """ Add a colour column to the units in the stratigraphic units structure @@ -1471,10 +1473,20 @@ def colour_units(self, stratigraphic_units: pandas.DataFrame, random: bool = Fal """ colour_lookup = pandas.DataFrame(columns=["UNITNAME", "colour"]) - try: - colour_lookup = pandas.read_csv(self.colour_filename, sep=",") - except FileNotFoundError: - print(f"Colour Lookup file {self.colour_filename} not found") + + if self.colour_filename is not None: + try: + colour_lookup = pandas.read_csv(self.colour_filename, sep=",") + except FileNotFoundError: + print(f"Colour Lookup file {self.colour_filename} not found. Assigning random colors to units") + self.colour_filename = None + + if self.colour_filename is None: + print("No colour configuration file found. Assigning random colors to units") + missing_colour_n = len(stratigraphic_units["colour"]) + stratigraphic_units.loc[stratigraphic_units["colour"].isna(), ["colour"]] = ( + generate_random_hex_colors(missing_colour_n) + ) colour_lookup["colour"] = colour_lookup["colour"].str.upper() if "UNITNAME" in colour_lookup.columns and "colour" in colour_lookup.columns: @@ -1486,7 +1498,7 @@ def colour_units(self, stratigraphic_units: pandas.DataFrame, random: bool = Fal how="left", ) stratigraphic_units.loc[stratigraphic_units["colour"].isna(), ["colour"]] = ( - random_colours_hex(stratigraphic_units["colour"].isna().sum()) + generate_random_hex_colors(int(stratigraphic_units["colour"].isna().sum())) ) stratigraphic_units.drop(columns=["UNITNAME", "colour_old"], inplace=True) else: diff --git a/map2loop/project.py b/map2loop/project.py index 77f4e965..afa93cbd 100644 --- a/map2loop/project.py +++ b/map2loop/project.py @@ -1,6 +1,6 @@ -import beartype -import pathlib +# internal imports from map2loop.fault_orientation import FaultOrientationNearest +from .utils import hex_to_rgba from .m2l_enums import VerboseLevel, ErrorState, Datatype, SampleType from .mapdata import MapData from .sampler import Sampler, SamplerDecimator, SamplerSpacing @@ -11,19 +11,20 @@ from .stratigraphic_column import StratigraphicColumn from .deformation_history import DeformationHistory from .map2model_wrapper import Map2ModelWrapper + +#external imports from .sample_storage import SampleSupervisor import LoopProjectFile as LPF from typing import Union +from osgeo import gdal +import geopandas +import beartype +import pathlib import numpy import pandas -import geopandas import os import re -from matplotlib.colors import to_rgba -from osgeo import gdal - - class Project(object): """ The main entry point into using map2loop @@ -718,7 +719,7 @@ def draw_geology_map(self, points: pandas.DataFrame = None, overlay: str = ""): ) geol = self.map_data.get_map_data(Datatype.GEOLOGY).copy() geol["colour"] = geol.apply(lambda row: colour_lookup[row.UNITNAME], axis=1) - geol["colour_rgba"] = geol.apply(lambda row: to_rgba(row["colour"], 1.0), axis=1) + geol["colour_rgba"] = geol.apply(lambda row: hex_to_rgba(row["colour"], 1.0), axis=1) if points is None and overlay == "": geol.plot(color=geol["colour_rgba"]) return diff --git a/map2loop/random.py b/map2loop/random.py deleted file mode 100644 index 0fb00ca2..00000000 --- a/map2loop/random.py +++ /dev/null @@ -1,3 +0,0 @@ -import numpy as np - -rng = np.random.default_rng() diff --git a/map2loop/random_colour.py b/map2loop/random_colour.py deleted file mode 100644 index 8d2b8891..00000000 --- a/map2loop/random_colour.py +++ /dev/null @@ -1,23 +0,0 @@ -from .random import rng - - -def random_colours_hex(n): - """ - Generate n random colours in hex format. - """ - rgb = rng.random((n, 3)) - return rgb_to_hex(rgb) - - -def rgb_to_hex(rgb): - """ - Convert rgb values in the range [0,1] to hex format. - """ - return [rgb_to_hex_single(r, g, b) for r, g, b in rgb] - - -def rgb_to_hex_single(r, g, b): - """ - Convert rgb values in the range [0,1] to hex format. - """ - return "#%02x%02x%02x" % (int(r * 255), int(g * 255), int(b * 255)) diff --git a/map2loop/sampler.py b/map2loop/sampler.py index 75e5a159..d369fea5 100644 --- a/map2loop/sampler.py +++ b/map2loop/sampler.py @@ -1,11 +1,14 @@ +# internal imports +from .m2l_enums import Datatype +from .mapdata import MapData + +# external imports from abc import ABC, abstractmethod import beartype import geopandas import pandas import shapely import numpy -from .m2l_enums import Datatype -from .mapdata import MapData from typing import Optional diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index becc861a..526cd61a 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -1,3 +1,5 @@ +# internal imports +import scipy.interpolate from abc import ABC, abstractmethod import beartype import numpy @@ -6,7 +8,6 @@ import geopandas from statistics import mean from .mapdata import MapData -from scipy.interpolate import Rbf from .sample_storage import SampleSupervisor from .interpolators import DipDipDirectionInterpolator from .utils import ( @@ -17,7 +18,17 @@ find_segment_strike_from_pt, ) from .m2l_enums import Datatype, SampleType -from shapely.geometry import Point +from .interpolators import DipDipDirectionInterpolator +from .mapdata import MapData + +#external imports +from abc import ABC, abstractmethod +import beartype +import numpy +import scipy +import pandas +import geopandas +from statistics import mean import shapely import math @@ -263,7 +274,7 @@ def compute( structural_data = samples(SampleType.STRUCTURE) # Interpolate the dip of the contacts interpolator = DipDipDirectionInterpolator(data_type="dip") - dip = interpolator(bounding_box, structural_data, interpolator=Rbf) + dip = interpolator(bounding_box, structure_data, interpolator=scipy.interpolate.Rbf) # create a GeoDataFrame of the interpolated orientations interpolated_orientations = geopandas.GeoDataFrame() # add the dip and dip direction to the GeoDataFrame @@ -339,7 +350,7 @@ def compute( # get the elevation Z of the end point p2 p2[2] = map_data.get_value_from_raster(Datatype.DTM, p2[0], p2[1]) # calculate the length of the shortest line - line_length = euclidean(p1, p2) + line_length = scipy.spatial.distance.euclidean(p1, p2) # find the indices of the points that are within 5% of the length of the shortest line indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) # get the dip of the points that are within diff --git a/map2loop/utils.py b/map2loop/utils.py index f71941dc..855e98bd 100644 --- a/map2loop/utils.py +++ b/map2loop/utils.py @@ -5,7 +5,7 @@ import beartype from typing import Union import pandas - +import random @beartype.beartype def generate_grid(bounding_box: dict, grid_resolution: int = None) -> tuple: @@ -116,7 +116,7 @@ def normal_vector_to_dipdirection_dip(normal_vector: numpy.ndarray) -> numpy.nda @beartype.beartype -def create_points(xy: Union[list, tuple, numpy.ndarray]): +def create_points(xy: Union[list, tuple, numpy.ndarray])-> shapely.points: """ Creates a list of shapely Point objects from a list, tuple, or numpy array of coordinates. @@ -300,3 +300,44 @@ def rebuild_sampled_basal_contacts( ) return sampled_basal_contacts + +@beartype.beartype +def generate_random_hex_colors(n: int) -> list: + """ + Generate a list of random hex color codes. + + Args: + n (int): The number of random hex color codes to generate. + + Returns: + list: A list of randomly generated hex color codes as strings. + + Example: + >>> generate_random_hex_colors(3) + ['#1a2b3c', '#4d5e6f', '#7f8e9d'] + """ + return ["#{:06x}".format(random.randint(0, 0xFFFFFF)) for _ in range(n)] + +@beartype.beartype +def hex_to_rgba(hex_color: str, alpha: float = 1.0) -> tuple: + """ + Convert a hex color code to an RGBA tuple. + + Args: + hex_color (str): The hex color code (e.g., "#RRGGBB" or "#RGB"). + alpha (float, optional): The alpha value (opacity) for the color. Defaults to 1.0. + + Returns: + tuple: A tuple (r, g, b, a) where r, g, b are in the range 0-1 and a is in the range 0-1. + """ + hex_color = hex_color.lstrip('#') + + # Handle short hex code (e.g., "#RGB") + if len(hex_color) == 3: + hex_color = ''.join([c*2 for c in hex_color]) + + r = int(hex_color[0:2], 16) / 255.0 + g = int(hex_color[2:4], 16) / 255.0 + b = int(hex_color[4:6], 16) / 255.0 + + return (r, g, b, alpha) \ No newline at end of file From 6a8197dbeee733a586784721bb368aa5a16b13b4 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 30 May 2024 23:46:31 +0000 Subject: [PATCH 76/98] style: style fixes by ruff and autoformatting by black --- map2loop/mapdata.py | 13 +++++++++---- map2loop/project.py | 3 ++- map2loop/thickness_calculator.py | 2 +- map2loop/utils.py | 9 ++++++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index e580b9dc..0d9175eb 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -1,10 +1,10 @@ -#internal imports +# internal imports from .m2l_enums import Datatype, Datastate, VerboseLevel from .config import Config from .aus_state_urls import AustraliaStateUrls from .utils import generate_random_hex_colors -#external imports +# external imports import geopandas import pandas import numpy @@ -22,6 +22,7 @@ import requests import requests + class MapData: """ A data structure containing all the map data loaded from map files @@ -1458,7 +1459,9 @@ def extract_basal_contacts(self, stratigraphic_column: list, save_contacts=True) return basal_contacts @beartype.beartype - def colour_units(self, stratigraphic_units: pandas.DataFrame, random: bool = False) -> pandas.DataFrame: + def colour_units( + self, stratigraphic_units: pandas.DataFrame, random: bool = False + ) -> pandas.DataFrame: """ Add a colour column to the units in the stratigraphic units structure @@ -1478,7 +1481,9 @@ def colour_units(self, stratigraphic_units: pandas.DataFrame, random: bool = Fal try: colour_lookup = pandas.read_csv(self.colour_filename, sep=",") except FileNotFoundError: - print(f"Colour Lookup file {self.colour_filename} not found. Assigning random colors to units") + print( + f"Colour Lookup file {self.colour_filename} not found. Assigning random colors to units" + ) self.colour_filename = None if self.colour_filename is None: diff --git a/map2loop/project.py b/map2loop/project.py index afa93cbd..2d2d1485 100644 --- a/map2loop/project.py +++ b/map2loop/project.py @@ -12,7 +12,7 @@ from .deformation_history import DeformationHistory from .map2model_wrapper import Map2ModelWrapper -#external imports +# external imports from .sample_storage import SampleSupervisor import LoopProjectFile as LPF from typing import Union @@ -25,6 +25,7 @@ import os import re + class Project(object): """ The main entry point into using map2loop diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index 526cd61a..33489d72 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -21,7 +21,7 @@ from .interpolators import DipDipDirectionInterpolator from .mapdata import MapData -#external imports +# external imports from abc import ABC, abstractmethod import beartype import numpy diff --git a/map2loop/utils.py b/map2loop/utils.py index 855e98bd..b1f87b1f 100644 --- a/map2loop/utils.py +++ b/map2loop/utils.py @@ -7,6 +7,7 @@ import pandas import random + @beartype.beartype def generate_grid(bounding_box: dict, grid_resolution: int = None) -> tuple: """ @@ -116,7 +117,7 @@ def normal_vector_to_dipdirection_dip(normal_vector: numpy.ndarray) -> numpy.nda @beartype.beartype -def create_points(xy: Union[list, tuple, numpy.ndarray])-> shapely.points: +def create_points(xy: Union[list, tuple, numpy.ndarray]) -> shapely.points: """ Creates a list of shapely Point objects from a list, tuple, or numpy array of coordinates. @@ -301,6 +302,7 @@ def rebuild_sampled_basal_contacts( return sampled_basal_contacts + @beartype.beartype def generate_random_hex_colors(n: int) -> list: """ @@ -318,6 +320,7 @@ def generate_random_hex_colors(n: int) -> list: """ return ["#{:06x}".format(random.randint(0, 0xFFFFFF)) for _ in range(n)] + @beartype.beartype def hex_to_rgba(hex_color: str, alpha: float = 1.0) -> tuple: """ @@ -334,10 +337,10 @@ def hex_to_rgba(hex_color: str, alpha: float = 1.0) -> tuple: # Handle short hex code (e.g., "#RGB") if len(hex_color) == 3: - hex_color = ''.join([c*2 for c in hex_color]) + hex_color = ''.join([c * 2 for c in hex_color]) r = int(hex_color[0:2], 16) / 255.0 g = int(hex_color[2:4], 16) / 255.0 b = int(hex_color[4:6], 16) / 255.0 - return (r, g, b, alpha) \ No newline at end of file + return (r, g, b, alpha) From 51f878df982f5a714f8b2fde090eecb470d96fd5 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 10:03:59 +1000 Subject: [PATCH 77/98] fix: assign the right beartype output in create_points --- map2loop/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/utils.py b/map2loop/utils.py index b1f87b1f..360c3d92 100644 --- a/map2loop/utils.py +++ b/map2loop/utils.py @@ -117,7 +117,7 @@ def normal_vector_to_dipdirection_dip(normal_vector: numpy.ndarray) -> numpy.nda @beartype.beartype -def create_points(xy: Union[list, tuple, numpy.ndarray]) -> shapely.points: +def create_points(xy: Union[list, tuple, numpy.ndarray]) -> numpy.ndarray: """ Creates a list of shapely Point objects from a list, tuple, or numpy array of coordinates. From 437e47d57b6c3130efaf89a48698e81c0a8e861c Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 6 Jun 2024 16:18:57 +1000 Subject: [PATCH 78/98] fix: add invalid hex input handling --- map2loop/utils.py | 21 +++++++++--- tests/utils/test_rgb_and_hex_functions.py | 41 +++++++++++++++++++++++ 2 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 tests/utils/test_rgb_and_hex_functions.py diff --git a/map2loop/utils.py b/map2loop/utils.py index 360c3d92..4c3d54e1 100644 --- a/map2loop/utils.py +++ b/map2loop/utils.py @@ -325,22 +325,33 @@ def generate_random_hex_colors(n: int) -> list: def hex_to_rgba(hex_color: str, alpha: float = 1.0) -> tuple: """ Convert a hex color code to an RGBA tuple. - Args: hex_color (str): The hex color code (e.g., "#RRGGBB" or "#RGB"). alpha (float, optional): The alpha value (opacity) for the color. Defaults to 1.0. - Returns: tuple: A tuple (r, g, b, a) where r, g, b are in the range 0-1 and a is in the range 0-1. """ + if not isinstance(hex_color, str) or not hex_color.startswith('#'): + raise ValueError("Invalid hex color code. Must start with '#'.") + hex_color = hex_color.lstrip('#') + if len(hex_color) not in [3, 6]: + raise ValueError("Invalid hex color code. Must be 3 or 6 characters long after '#'.") + # Handle short hex code (e.g., "#RGB") if len(hex_color) == 3: hex_color = ''.join([c * 2 for c in hex_color]) - r = int(hex_color[0:2], 16) / 255.0 - g = int(hex_color[2:4], 16) / 255.0 - b = int(hex_color[4:6], 16) / 255.0 + try: + r = int(hex_color[0:2], 16) / 255.0 + g = int(hex_color[2:4], 16) / 255.0 + b = int(hex_color[4:6], 16) / 255.0 + + except ValueError as e: + raise ValueError( + "Invalid hex color code. Contains non-hexadecimal characters." + ) from e return (r, g, b, alpha) + diff --git a/tests/utils/test_rgb_and_hex_functions.py b/tests/utils/test_rgb_and_hex_functions.py new file mode 100644 index 00000000..c807f5fe --- /dev/null +++ b/tests/utils/test_rgb_and_hex_functions.py @@ -0,0 +1,41 @@ +import pytest +import re +from map2loop.utils import generate_random_hex_colors, hex_to_rgba # Replace 'your_module' with the actual module name + +#does it return the right number of colors? +def test_generate_random_hex_colors_length(): + n = 5 + colors = generate_random_hex_colors(n) + assert len(colors) == n, f"utils function generate_random_hex_colors not returning the right number of hex codes.Expected {n} colors, got {len(colors)}" + +# are the returned hex strings the right format? +def test_generate_random_hex_colors_format(): + n = 10 + hex_pattern = re.compile(r'^#[0-9A-Fa-f]{6}$') + colors = generate_random_hex_colors(n) + for color in colors: + assert hex_pattern.match(color), f"utils function generate_random_hex_colors not returning hex strings in the right format. Got {color} instead." + +# is hex conversion to rgba working as expected? +def test_hex_to_rgba_long_hex(): + hex_color = "#1a2b3c" # long hex versions + expected_output = (0.10196078431372549, 0.16862745098039217, 0.23529411764705882, 1.0) + assert hex_to_rgba(hex_color) == expected_output, f"utils function hex_to_rgba not doing hex to rgba conversion correctly. Expected {expected_output}, got {hex_to_rgba(hex_color)}" + + +def test_hex_to_rgba_short_hex(): + hex_color = "#abc" # short hex versions + expected_output = (0.6666666666666666, 0.7333333333333333, 0.8, 1.0) + assert hex_to_rgba(hex_color) == expected_output + +# does it handle alpha values correctly? +def test_hex_to_rgba_with_alpha(): + hex_color = "#1a2b3c" + alpha = 0.5 + expected_output = (0.10196078431372549, 0.16862745098039217, 0.23529411764705882, alpha) + assert hex_to_rgba(hex_color, alpha) == expected_output, f"utils function hex_to_rgba not handling alpha values correctly. Expected {expected_output}, got {hex_to_rgba(hex_color, alpha)}" + +# does it handle invalid inputs correctly? +def test_hex_to_rgba_invalid_hex(): + with pytest.raises(ValueError): + hex_to_rgba("12FF456"), "utils function hex_to_rgba is expected to raise a ValueError when an invalid hex string is passed, but it did not." \ No newline at end of file From 27e14a8dfc8066cd0014212ef7da687db97add4b Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 6 Jun 2024 16:22:11 +1000 Subject: [PATCH 79/98] fix: comment the code --- map2loop/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/map2loop/utils.py b/map2loop/utils.py index 4c3d54e1..c5bbd5cb 100644 --- a/map2loop/utils.py +++ b/map2loop/utils.py @@ -331,11 +331,14 @@ def hex_to_rgba(hex_color: str, alpha: float = 1.0) -> tuple: Returns: tuple: A tuple (r, g, b, a) where r, g, b are in the range 0-1 and a is in the range 0-1. """ + # if input not string or starts with '#', raise error if not isinstance(hex_color, str) or not hex_color.startswith('#'): raise ValueError("Invalid hex color code. Must start with '#'.") + # Remove '#' from the hex color code hex_color = hex_color.lstrip('#') + # check if hex color code is the right length if len(hex_color) not in [3, 6]: raise ValueError("Invalid hex color code. Must be 3 or 6 characters long after '#'.") @@ -343,6 +346,7 @@ def hex_to_rgba(hex_color: str, alpha: float = 1.0) -> tuple: if len(hex_color) == 3: hex_color = ''.join([c * 2 for c in hex_color]) + # Convert the hex color code to an RGBA tuple// if it fails, return error try: r = int(hex_color[0:2], 16) / 255.0 g = int(hex_color[2:4], 16) / 255.0 From c1fcfdad92c296603db9b2a555c77629b1b90788 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 6 Jun 2024 17:17:57 +1000 Subject: [PATCH 80/98] tests: add test for mapdata.colour_units --- map2loop/mapdata.py | 4 +- ..._mapdata_assign_random_colours_to_units.py | 60 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 tests/mapdata/test_mapdata_assign_random_colours_to_units.py diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 0d9175eb..055b84e1 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -1489,7 +1489,7 @@ def colour_units( if self.colour_filename is None: print("No colour configuration file found. Assigning random colors to units") missing_colour_n = len(stratigraphic_units["colour"]) - stratigraphic_units.loc[stratigraphic_units["colour"].isna(), ["colour"]] = ( + stratigraphic_units.loc[stratigraphic_units["colour"].isna(), "colour"] = ( generate_random_hex_colors(missing_colour_n) ) @@ -1502,7 +1502,7 @@ def colour_units( suffixes=("_old", ""), how="left", ) - stratigraphic_units.loc[stratigraphic_units["colour"].isna(), ["colour"]] = ( + stratigraphic_units.loc[stratigraphic_units["colour"].isna(), "colour"] = ( generate_random_hex_colors(int(stratigraphic_units["colour"].isna().sum())) ) stratigraphic_units.drop(columns=["UNITNAME", "colour_old"], inplace=True) diff --git a/tests/mapdata/test_mapdata_assign_random_colours_to_units.py b/tests/mapdata/test_mapdata_assign_random_colours_to_units.py new file mode 100644 index 00000000..544e74db --- /dev/null +++ b/tests/mapdata/test_mapdata_assign_random_colours_to_units.py @@ -0,0 +1,60 @@ +import pytest +import pandas as pd +from map2loop.mapdata import MapData + +# are random colours being assigned to stratigraphic units in cases where no clut file is provided? +def test_colour_units_no_clut_file(): + # Create a sample DataFrame with missing 'colour' values + data = { + "name": ["Unit1", "Unit2", "Unit3"], + "colour": [None, None, None] + } + stratigraphic_units = pd.DataFrame(data) + + # Instantiate the class and call the method + md = MapData() + md.colour_filename = None # Ensure no file is used + result = md.colour_units(stratigraphic_units) + + # Check that the 'colour' column has been assigned random colors + assert len(result["colour"].dropna()) == 3, "function MapData.colour_units not assigning the right len of random colours" + + # are the generated colours valid hex colours? + colours = result["colour"] + + assert colours.apply(isinstance, args=(str,)).all(), "function MapData.colour_units without clut file not assigning random hex colours as str" + assert colours.str.startswith("#").all(), "function MapData.colour_units without clut file not generating the right hex codes with # at the start" + assert colours.str.len().isin([7, 4]).all(), "function MapData.colour_units without clut file not generating the right hex codes with 7 or 4 characters" + + +def test_colour_units_with_colour_file(tmp_path): + # Create a strati units df with missing 'colour' values + data = { + "name": ["Unit1", "Unit2", "Unit3"], + "colour": [None, None, None] + } + stratigraphic_units = pd.DataFrame(data) + + # Create a temp clut file + colour_data = { + "UNITNAME": ["Unit1", "Unit2"], + "colour": ["#112233", "#445566"] + } + colour_lookup_df = pd.DataFrame(colour_data) + colour_filename = tmp_path / "colour_lookup.csv" + colour_lookup_df.to_csv(colour_filename, index=False) + + # Instantiate the class and call the method + md = MapData() + md.colour_filename = str(colour_filename) + result = md.colour_units(stratigraphic_units) + + # Check that the 'colour' column has been merged correctly and missing colors are assigned + expected_colors = ["#112233", "#445566"] + assert result["colour"].iloc[0] == expected_colors[0], "function MapData.colour_units with clut file not assigning the right colour from the lookup file" + assert result["colour"].iloc[1] == expected_colors[1], "function MapData.colour_units with clut file not assigning the right colour from the lookup file" + assert isinstance(result["colour"].iloc[2], str) , "function MapData.colour_units with clut file not assigning random hex colours as str" + assert result["colour"].iloc[2].startswith("#"), "function MapData.colour_units with clut file not generating the right hex codes with # at the start" + assert len(result["colour"].iloc[2]) in {7,4}, "function MapData.colour_units with clut file not generating the right hex codes with 7 or 4 characters" + + From 072bb348d1a8d31eb4648f5cecdca61c41207a7f Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 6 Jun 2024 17:18:36 +1000 Subject: [PATCH 81/98] tests: reorganise tests --- tests/mapdata/{test_mapdata.py => test_mapdata_dipdir.py} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename tests/mapdata/{test_mapdata.py => test_mapdata_dipdir.py} (95%) diff --git a/tests/mapdata/test_mapdata.py b/tests/mapdata/test_mapdata_dipdir.py similarity index 95% rename from tests/mapdata/test_mapdata.py rename to tests/mapdata/test_mapdata_dipdir.py index 2bd9030e..c35ab432 100644 --- a/tests/mapdata/test_mapdata.py +++ b/tests/mapdata/test_mapdata_dipdir.py @@ -45,4 +45,6 @@ def test_if_m2l_returns_all_sampled_structures_with_DIPDIR_lower_than_360(): pytest.fail(f"parse_structure_map raised an exception: {e}") # check if all values below 360 - assert md.data[Datatype.STRUCTURE]['DIPDIR'].all() < 360, "MapData.STRUCTURE is producing DIPDIRs > 360 degrees" \ No newline at end of file + assert md.data[Datatype.STRUCTURE]['DIPDIR'].all() < 360, "MapData.STRUCTURE is producing DIPDIRs > 360 degrees" + +# From c2c8f1ebc0aa37e6a1a13a6e40476d301cdf4a47 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 6 Jun 2024 17:51:58 +1000 Subject: [PATCH 82/98] fix: make sure all colours are unique --- map2loop/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/map2loop/utils.py b/map2loop/utils.py index c5bbd5cb..886b2865 100644 --- a/map2loop/utils.py +++ b/map2loop/utils.py @@ -306,7 +306,7 @@ def rebuild_sampled_basal_contacts( @beartype.beartype def generate_random_hex_colors(n: int) -> list: """ - Generate a list of random hex color codes. + Generate a list of unique random hex color codes. Args: n (int): The number of random hex color codes to generate. @@ -318,7 +318,11 @@ def generate_random_hex_colors(n: int) -> list: >>> generate_random_hex_colors(3) ['#1a2b3c', '#4d5e6f', '#7f8e9d'] """ - return ["#{:06x}".format(random.randint(0, 0xFFFFFF)) for _ in range(n)] + colors = set() # set prevents duplicates + while len(colors) < n: + color = "#{:06x}".format(random.randint(0, 0xFFFFFF)) + colors.add(color) + return list(colors) @beartype.beartype From 40b30429b77ed2a523f81d1153421e80dc720799 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 7 Jun 2024 12:56:06 +1000 Subject: [PATCH 83/98] fix: small fixes - double check for integer & add test information at the beginning of the test scripts --- map2loop/utils.py | 3 +++ .../mapdata/test_mapdata_assign_random_colours_to_units.py | 4 ++++ tests/mapdata/test_mapdata_dipdir.py | 4 ++++ tests/project/test_plot_hamersley.py | 2 ++ .../InterpolatedStructure/test_interpolated_structure.py | 7 +++++++ .../test_thickness_StructuralPoint_local_source.py | 2 ++ .../test_thickness_StructuralPoint_server.py | 7 +++++++ tests/utils/test_rgb_and_hex_functions.py | 4 +++- 8 files changed, 32 insertions(+), 1 deletion(-) diff --git a/map2loop/utils.py b/map2loop/utils.py index 886b2865..eac742bd 100644 --- a/map2loop/utils.py +++ b/map2loop/utils.py @@ -318,6 +318,9 @@ def generate_random_hex_colors(n: int) -> list: >>> generate_random_hex_colors(3) ['#1a2b3c', '#4d5e6f', '#7f8e9d'] """ + if not isinstance(n, int): + raise TypeError("n of colours must be an integer") ## not sure if necessary as beartype should handle this + colors = set() # set prevents duplicates while len(colors) < n: color = "#{:06x}".format(random.randint(0, 0xFFFFFF)) diff --git a/tests/mapdata/test_mapdata_assign_random_colours_to_units.py b/tests/mapdata/test_mapdata_assign_random_colours_to_units.py index 544e74db..a4c1d63a 100644 --- a/tests/mapdata/test_mapdata_assign_random_colours_to_units.py +++ b/tests/mapdata/test_mapdata_assign_random_colours_to_units.py @@ -1,7 +1,11 @@ +### This file tests the function colour_units() in map2loop/mapdata.py +### Two main test cases are considered: cases in which there is clut file and cases in which there is no clut file + import pytest import pandas as pd from map2loop.mapdata import MapData + # are random colours being assigned to stratigraphic units in cases where no clut file is provided? def test_colour_units_no_clut_file(): # Create a sample DataFrame with missing 'colour' values diff --git a/tests/mapdata/test_mapdata_dipdir.py b/tests/mapdata/test_mapdata_dipdir.py index c35ab432..68f45b47 100644 --- a/tests/mapdata/test_mapdata_dipdir.py +++ b/tests/mapdata/test_mapdata_dipdir.py @@ -1,3 +1,7 @@ +### This file tests the function parse_structure_map() in map2loop/mapdata.py +### at the moment only tests for DIPDIR values lower than 360 degrees +### TODO: add more tests for this function + import pytest import geopandas import shapely diff --git a/tests/project/test_plot_hamersley.py b/tests/project/test_plot_hamersley.py index 2ce73241..027d285a 100644 --- a/tests/project/test_plot_hamersley.py +++ b/tests/project/test_plot_hamersley.py @@ -1,3 +1,5 @@ +### This file tests the overall behavior of project.py. Runs from LoopServer. + #internal imports from map2loop.project import Project from map2loop.m2l_enums import VerboseLevel diff --git a/tests/thickness/InterpolatedStructure/test_interpolated_structure.py b/tests/thickness/InterpolatedStructure/test_interpolated_structure.py index 0206010c..ae0268ad 100644 --- a/tests/thickness/InterpolatedStructure/test_interpolated_structure.py +++ b/tests/thickness/InterpolatedStructure/test_interpolated_structure.py @@ -1,3 +1,10 @@ +# This test runs on a portion of the dataset in https://github.com/Loop3D/m2l3_examples/tree/main/Laurent2016_V2_variable_thicknesses (only for lithologies E, F, and G) +# structures are confined to litho_F, and the test confirms if the StructuralPoint thickness is calculated, for all lithologies, if the thickness is correct for F (~90 m), and top/bottom units are assigned -1 +# this creates a temp folder in Appdata to store the data to run the proj, checks the thickness, and then deletes the temp folder +# this was done to avoid overflow of file creation in the tests folder + +### This file tests the function InterpolatedStructure thickness calculator + import pytest import pandas as pd from map2loop.thickness_calculator import InterpolatedStructure diff --git a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py index 920b44a7..fbca23ca 100644 --- a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py +++ b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_local_source.py @@ -3,6 +3,8 @@ # this creates a temp folder in Appdata to store the data to run the proj, checks the thickness, and then deletes the temp folder # this was done to avoid overflow of file creation in the tests folder +# this tests the thickness calculator Structural Point from local source + from map2loop.thickness_calculator import StructuralPoint from osgeo import gdal, osr import os diff --git a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_server.py b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_server.py index 21ba002e..3cadeb3d 100644 --- a/tests/thickness/StructurePoint/test_thickness_StructuralPoint_server.py +++ b/tests/thickness/StructurePoint/test_thickness_StructuralPoint_server.py @@ -1,3 +1,10 @@ +# This test runs on a portion of the dataset in https://github.com/Loop3D/m2l3_examples/tree/main/Laurent2016_V2_variable_thicknesses (only for lithologies E, F, and G) +# structures are confined to litho_F, and the test confirms if the StructuralPoint thickness is calculated, for all lithologies, if the thickness is correct for F (~90 m), and top/bottom units are assigned -1 +# this creates a temp folder in Appdata to store the data to run the proj, checks the thickness, and then deletes the temp folder +# this was done to avoid overflow of file creation in the tests folder + +# this tests the thickness calculator Structural Point from a server + #internal imports from map2loop.thickness_calculator import StructuralPoint from map2loop.project import Project diff --git a/tests/utils/test_rgb_and_hex_functions.py b/tests/utils/test_rgb_and_hex_functions.py index c807f5fe..b6e417ed 100644 --- a/tests/utils/test_rgb_and_hex_functions.py +++ b/tests/utils/test_rgb_and_hex_functions.py @@ -1,6 +1,8 @@ +### This file tests the function generate_random_hex_colors() and hex_to_rgba() in map2loop/utils.py + import pytest import re -from map2loop.utils import generate_random_hex_colors, hex_to_rgba # Replace 'your_module' with the actual module name +from map2loop.utils import generate_random_hex_colors, hex_to_rgba #does it return the right number of colors? def test_generate_random_hex_colors_length(): From 049f00ccd45fbeaf5d1cb0661a93e5a4b9d33462 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 7 Jun 2024 14:27:26 +1000 Subject: [PATCH 84/98] fix: fix for duplicate units --- map2loop/mapdata.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 055b84e1..4c866be9 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -1494,6 +1494,9 @@ def colour_units( ) colour_lookup["colour"] = colour_lookup["colour"].str.upper() + # if there are duplicates in the clut file, drop. + colour_lookup = colour_lookup.drop_duplicates(subset=["UNITNAME"]) + if "UNITNAME" in colour_lookup.columns and "colour" in colour_lookup.columns: stratigraphic_units = stratigraphic_units.merge( colour_lookup, From 9e637329208475e889300ffc0df9f58edce839fb Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 7 Jun 2024 14:27:56 +1000 Subject: [PATCH 85/98] tests: add tests for duplicate units in colour_units() --- tests/mapdata/test_mapdata_assign_random_colours_to_units.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/mapdata/test_mapdata_assign_random_colours_to_units.py b/tests/mapdata/test_mapdata_assign_random_colours_to_units.py index a4c1d63a..19aded4f 100644 --- a/tests/mapdata/test_mapdata_assign_random_colours_to_units.py +++ b/tests/mapdata/test_mapdata_assign_random_colours_to_units.py @@ -20,6 +20,9 @@ def test_colour_units_no_clut_file(): md.colour_filename = None # Ensure no file is used result = md.colour_units(stratigraphic_units) + # check that there are no duplicates in the 'unit' column + assert result['name'].duplicated().all() is False, "colour_units() in mapdata.py producing duplicate units" + # Check that the 'colour' column has been assigned random colors assert len(result["colour"].dropna()) == 3, "function MapData.colour_units not assigning the right len of random colours" From afe4d5ac85f4a79afc19c89d79e8a1f631556177 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 7 Jun 2024 14:35:33 +1000 Subject: [PATCH 86/98] tests: rephrase the unit must be unique assertion in colour_unit_tests --- tests/mapdata/test_mapdata_assign_random_colours_to_units.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/mapdata/test_mapdata_assign_random_colours_to_units.py b/tests/mapdata/test_mapdata_assign_random_colours_to_units.py index 19aded4f..125caff8 100644 --- a/tests/mapdata/test_mapdata_assign_random_colours_to_units.py +++ b/tests/mapdata/test_mapdata_assign_random_colours_to_units.py @@ -21,7 +21,7 @@ def test_colour_units_no_clut_file(): result = md.colour_units(stratigraphic_units) # check that there are no duplicates in the 'unit' column - assert result['name'].duplicated().all() is False, "colour_units() in mapdata.py producing duplicate units" + assert result['name'].is_unique, "colour_units() in mapdata.py producing duplicate units" # Check that the 'colour' column has been assigned random colors assert len(result["colour"].dropna()) == 3, "function MapData.colour_units not assigning the right len of random colours" @@ -56,6 +56,9 @@ def test_colour_units_with_colour_file(tmp_path): md.colour_filename = str(colour_filename) result = md.colour_units(stratigraphic_units) + # check that there are no duplicates in the 'unit' column + assert result['name'].is_unique, "colour_units() in mapdata.py producing duplicate units" + # Check that the 'colour' column has been merged correctly and missing colors are assigned expected_colors = ["#112233", "#445566"] assert result["colour"].iloc[0] == expected_colors[0], "function MapData.colour_units with clut file not assigning the right colour from the lookup file" From 5c87e5dbb166e635f35b4a43b8ba448d99319645 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 13 Jun 2024 16:58:19 +1000 Subject: [PATCH 87/98] fix: add the suggestions --- map2loop/project.py | 2 +- map2loop/utils.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/map2loop/project.py b/map2loop/project.py index 2d2d1485..31421bc7 100644 --- a/map2loop/project.py +++ b/map2loop/project.py @@ -720,7 +720,7 @@ def draw_geology_map(self, points: pandas.DataFrame = None, overlay: str = ""): ) geol = self.map_data.get_map_data(Datatype.GEOLOGY).copy() geol["colour"] = geol.apply(lambda row: colour_lookup[row.UNITNAME], axis=1) - geol["colour_rgba"] = geol.apply(lambda row: hex_to_rgba(row["colour"], 1.0), axis=1) + geol["colour_rgba"] = geol.apply(lambda row: hex_to_rgb(row["colour"]), axis=1) if points is None and overlay == "": geol.plot(color=geol["colour_rgba"]) return diff --git a/map2loop/utils.py b/map2loop/utils.py index eac742bd..b48ba36a 100644 --- a/map2loop/utils.py +++ b/map2loop/utils.py @@ -304,7 +304,7 @@ def rebuild_sampled_basal_contacts( @beartype.beartype -def generate_random_hex_colors(n: int) -> list: +def generate_random_hex_colors(n: int, seed: int = None) -> list: """ Generate a list of unique random hex color codes. @@ -321,15 +321,21 @@ def generate_random_hex_colors(n: int) -> list: if not isinstance(n, int): raise TypeError("n of colours must be an integer") ## not sure if necessary as beartype should handle this + if seed is not None: + rng = numpy.random.default_rng(seed) + else: + rng = numpy.random.default_rng(123456) + colors = set() # set prevents duplicates + while len(colors) < n: - color = "#{:06x}".format(random.randint(0, 0xFFFFFF)) + color = "#{:06x}".format(rng.integers(0, 0xFFFFFF)) colors.add(color) return list(colors) @beartype.beartype -def hex_to_rgba(hex_color: str, alpha: float = 1.0) -> tuple: +def hex_to_rgb(hex_color: str) -> tuple: """ Convert a hex color code to an RGBA tuple. Args: @@ -352,7 +358,8 @@ def hex_to_rgba(hex_color: str, alpha: float = 1.0) -> tuple: # Handle short hex code (e.g., "#RGB") if len(hex_color) == 3: hex_color = ''.join([c * 2 for c in hex_color]) - + + alpha = 1.0 # Convert the hex color code to an RGBA tuple// if it fails, return error try: r = int(hex_color[0:2], 16) / 255.0 From fad1f3c2069d98f84371fd2b61b14ad69eaad4fa Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 13 Jun 2024 17:06:09 +1000 Subject: [PATCH 88/98] fix: update the tests for new function names (hex_to_rgb) --- tests/utils/test_rgb_and_hex_functions.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/tests/utils/test_rgb_and_hex_functions.py b/tests/utils/test_rgb_and_hex_functions.py index b6e417ed..cce2059b 100644 --- a/tests/utils/test_rgb_and_hex_functions.py +++ b/tests/utils/test_rgb_and_hex_functions.py @@ -2,7 +2,7 @@ import pytest import re -from map2loop.utils import generate_random_hex_colors, hex_to_rgba +from map2loop.utils import generate_random_hex_colors, hex_to_rgb #does it return the right number of colors? def test_generate_random_hex_colors_length(): @@ -22,22 +22,15 @@ def test_generate_random_hex_colors_format(): def test_hex_to_rgba_long_hex(): hex_color = "#1a2b3c" # long hex versions expected_output = (0.10196078431372549, 0.16862745098039217, 0.23529411764705882, 1.0) - assert hex_to_rgba(hex_color) == expected_output, f"utils function hex_to_rgba not doing hex to rgba conversion correctly. Expected {expected_output}, got {hex_to_rgba(hex_color)}" + assert hex_to_rgb(hex_color) == expected_output, f"utils function hex_to_rgba not doing hex to rgba conversion correctly. Expected {expected_output}, got {hex_to_rgb(hex_color)}" def test_hex_to_rgba_short_hex(): hex_color = "#abc" # short hex versions expected_output = (0.6666666666666666, 0.7333333333333333, 0.8, 1.0) - assert hex_to_rgba(hex_color) == expected_output - -# does it handle alpha values correctly? -def test_hex_to_rgba_with_alpha(): - hex_color = "#1a2b3c" - alpha = 0.5 - expected_output = (0.10196078431372549, 0.16862745098039217, 0.23529411764705882, alpha) - assert hex_to_rgba(hex_color, alpha) == expected_output, f"utils function hex_to_rgba not handling alpha values correctly. Expected {expected_output}, got {hex_to_rgba(hex_color, alpha)}" + assert hex_to_rgb(hex_color) == expected_output # does it handle invalid inputs correctly? def test_hex_to_rgba_invalid_hex(): with pytest.raises(ValueError): - hex_to_rgba("12FF456"), "utils function hex_to_rgba is expected to raise a ValueError when an invalid hex string is passed, but it did not." \ No newline at end of file + hex_to_rgb("12FF456"), "utils function hex_to_rgba is expected to raise a ValueError when an invalid hex string is passed, but it did not." \ No newline at end of file From d5726f3d5dfd598dda544a30f046b1efb21d71d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 07:37:00 +0000 Subject: [PATCH 89/98] chore(master): release 3.1.6 --- CHANGELOG.md | 13 +++++++++++++ map2loop/version.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9412930..ec818224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [3.1.6](https://github.com/Loop3D/map2loop/compare/v3.1.5...v3.1.6) (2024-06-13) + + +### Bug Fixes + +* add invalid hex input handling ([40028a8](https://github.com/Loop3D/map2loop/commit/40028a87b06c7610095edb0b78ec451838ff85a6)) +* add the suggestions ([dc85b2e](https://github.com/Loop3D/map2loop/commit/dc85b2e5d89475511904275fc482d3bfd3f33fd8)) +* comment the code ([6e064b1](https://github.com/Loop3D/map2loop/commit/6e064b1a3cb53af1fa92ea51faa4917d2c50663c)) +* fix for duplicate units ([4052eca](https://github.com/Loop3D/map2loop/commit/4052eca85825a8ddd9d3c2f6c57c3f838ae2dd3e)) +* make sure all colours are unique ([f90159a](https://github.com/Loop3D/map2loop/commit/f90159a83691278ee7cfca07c3aba64a144816c8)) +* small fixes - double check for integer & add test information at the beginning of the test scripts ([a916343](https://github.com/Loop3D/map2loop/commit/a916343fba5ec59602fab9892b7d67f86702723b)) +* update the tests for new function names (hex_to_rgb) ([e1778b7](https://github.com/Loop3D/map2loop/commit/e1778b734ca13d4c422daacd29de41c505f92fea)) + ## [3.1.5](https://github.com/Loop3D/map2loop/compare/v3.1.4...v3.1.5) (2024-06-06) diff --git a/map2loop/version.py b/map2loop/version.py index 0aff436e..a5761891 100644 --- a/map2loop/version.py +++ b/map2loop/version.py @@ -1 +1 @@ -__version__ = "3.1.5" +__version__ = "3.1.6" From 975863de2866c63dffb3bc69afc705b219d421d9 Mon Sep 17 00:00:00 2001 From: rabii-chaarani Date: Mon, 3 Jun 2024 14:01:31 +0930 Subject: [PATCH 90/98] feat: added SampleSupervisor --- map2loop/thickness_calculator.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index 33489d72..dfc318b4 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -1,3 +1,13 @@ +from abc import ABC, abstractmethod +import beartype +import numpy +from scipy.spatial.distance import euclidean +import pandas +import geopandas +from statistics import mean +from .mapdata import MapData +from .sample_storage import SampleSupervisor +from .interpolators import DipDipDirectionInterpolator # internal imports import scipy.interpolate from abc import ABC, abstractmethod From eb42ed512cef0cd926d0803c410c931805ecf7e7 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Wed, 22 May 2024 15:28:01 +1000 Subject: [PATCH 91/98] feat: added issue_templates --- .github/ISSUE_TEMPLATE/bug_report.yml | 19 ++++++++----- .../ISSUE_TEMPLATE/documentation_request.yml | 11 +++++++- .github/ISSUE_TEMPLATE/feature_request.yml | 27 +++++++++---------- .github/ISSUE_TEMPLATE/question.yml | 9 +++++++ 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 1909ba79..8fe9facf 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -10,12 +10,14 @@ body: Thanks for submitting a bug report to map2loop! Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. - - type: textarea - id: version + - type: input + id: bug_title attributes: - label: Version - description: What version of map2loop and LoopProjectFile are you running? You can find this information by running `import map2loop` and `map2loop.__version__` in your python terminal or jupyter notebook. - placeholder: "Enter map2loop and LoopProjectFile versions" + label: "Bug Title" + description: "Provide a concise and descriptive title for the bug report." + placeholder: "Enter the title of the bug" + validations: + required: true - type: textarea id: bug_description @@ -30,7 +32,7 @@ body: id: steps_to_reproduce attributes: label: "Minimal reproducible example" - description: "Provide a minimal reproducible example with the code necessary to reproduce the bug. For more guidance, visit: [How to create a minimal complete reproducible example](https://forum.access-hive.org.au/t/how-to-create-a-minimal-complete-reproducible-example/843)" + description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." placeholder: "Enter the steps to reproduce the bug" validations: required: true @@ -78,9 +80,12 @@ body: description: "Select the severity level of the bug." options: - label: "Low" + value: "low" - label: "Medium" + value: "medium" - label: "High" + value: "high" - label: "Critical" + value: "critical" validations: required: true - diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml index f202e2a5..6304632d 100644 --- a/.github/ISSUE_TEMPLATE/documentation_request.yml +++ b/.github/ISSUE_TEMPLATE/documentation_request.yml @@ -8,7 +8,16 @@ body: value: | ## Documentation Request Please use this template to suggest an improvement or addition to map2loop documentation. - Provide as much detail as possible to help us understand and implement your request efficiently + Provide as much detail as possible to help us understand and implement your request efficiently. + + - type: input + id: doc_title + attributes: + label: "Documentation Title" + description: "Provide a concise and descriptive title for the documentation request." + placeholder: "Enter the title of the documentation request" + validations: + required: true - type: textarea id: doc_details diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 1fd8719a..93585a56 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -9,15 +9,14 @@ body: ## Feature Request Please use this template to submit your feature request. Provide as much detail as possible to help us understand and implement your request efficiently. - - type: checkboxes - id: input1 + - type: input + id: feature_title attributes: - label: "💻" - description: | - Check this if you would like to try and implement your vision in a PR. - The map2loop team will help you go through the process - options: - - label: Would you like to work on this feature? + label: "Feature Title" + description: "Provide a concise and descriptive title for the feature request." + placeholder: "Enter the title of the feature" + validations: + required: true - type: textarea id: feature_description @@ -37,13 +36,6 @@ body: validations: required: true - - type: textarea - id: version - attributes: - label: Version - description: What version of map2loop and LoopProjectFile are you running that doesn't have this feature? You can find this information by running `import map2loop` and `map2loop.__version__` in your python terminal or jupyter notebook. - placeholder: "Enter map2loop and LoopProjectFile versions" - - type: textarea id: proposed_solution attributes: @@ -69,10 +61,15 @@ body: description: "Select the areas of the project that this feature request impacts." options: - label: "input data" + value: "input data" - label: "project creation" + value: "project creation" - label: "samplers" + value: "samplers" - label: "sorters" + value: "sorters" - label: "stratigraphic column" + value: "stratigraphic column" - label: "data types" - label: "faults" - label: "Other" \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 6e17cc06..a4b37981 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -10,6 +10,15 @@ body: Please use this template to ask a question about applying map2loop to your data. Provide as much detail as possible to help us understand and answer your question efficiently. + - type: input + id: question_title + attributes: + label: "Question Title" + description: "Provide a concise and descriptive title for your question." + placeholder: "Enter the title of your question" + validations: + required: true + - type: textarea id: question_details attributes: From ca4099165227f28120aff8fe7d9b07ff03966b80 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 24 May 2024 08:51:38 +1000 Subject: [PATCH 92/98] fix: add pull request template --- .../pull_request_template/bug_fix_template.md | 24 +++++++++++++++++++ .../docs_update_template.md | 6 ++--- .../tests_improvement_template.md | 23 ++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/pull_request_template/bug_fix_template.md create mode 100644 .github/pull_request_template/tests_improvement_template.md diff --git a/.github/pull_request_template/bug_fix_template.md b/.github/pull_request_template/bug_fix_template.md new file mode 100644 index 00000000..d6f7f7ad --- /dev/null +++ b/.github/pull_request_template/bug_fix_template.md @@ -0,0 +1,24 @@ +## Description + +Please describe the issue that this pull request addresses and summarize the changes. + +Fixes #(issue) + +## Type of change + +- [ ] Bug fix (non-breaking change which fixes an issue) + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own code +- [ ] My code follows the style guidelines of this project +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md index a1c43359..247529c3 100644 --- a/.github/pull_request_template/docs_update_template.md +++ b/.github/pull_request_template/docs_update_template.md @@ -14,10 +14,10 @@ Provide branch name so we can reproduce. ## Checklist: -- [ ] This branch is up-to-date with the master branch -- [ ] All github-action checks are passing +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing - [ ] I have performed a self-review of my own documentation - [ ] I have built the documentation locally with make.bat - [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs - [ ] My documentation follows the style guidelines of this project -- [ ] I have checked my spelling and grammar \ No newline at end of file +- [ ] I have checked my spelling and grammar diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md new file mode 100644 index 00000000..78b3bc70 --- /dev/null +++ b/.github/pull_request_template/tests_improvement_template.md @@ -0,0 +1,23 @@ +## Description + +Please include a summary of the added test. List relevant functions tested. + +Fixes #(issue) + +## Type of change + +- [ ] Test improvement + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own tests +- [ ] My tests follow the style guidelines of this project +- [ ] I have commented my tests, particularly in hard-to-understand areas +- [ ] New and existing unit tests pass locally with my changes From e9d3b8b4c722f4f1711374335d3c9a0ea8c16946 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 24 May 2024 09:01:09 +1000 Subject: [PATCH 93/98] fix: few typos grammar --- .github/pull_request_template/bug_fix_template.md | 4 ++-- .github/pull_request_template/tests_improvement_template.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template/bug_fix_template.md b/.github/pull_request_template/bug_fix_template.md index d6f7f7ad..afdc1497 100644 --- a/.github/pull_request_template/bug_fix_template.md +++ b/.github/pull_request_template/bug_fix_template.md @@ -1,6 +1,6 @@ ## Description -Please describe the issue that this pull request addresses and summarize the changes. +Please describe the issue that this pull request addresses and summarize the changes you are implementing. Fixes #(issue) @@ -10,7 +10,7 @@ Fixes #(issue) ## How Has This Been Tested? -Please describe the tests that you ran to verify your changes. +Please describe any tests that you ran to verify your changes. Provide branch name so we can reproduce. ## Checklist: diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md index 78b3bc70..aa56ee86 100644 --- a/.github/pull_request_template/tests_improvement_template.md +++ b/.github/pull_request_template/tests_improvement_template.md @@ -1,6 +1,6 @@ ## Description -Please include a summary of the added test. List relevant functions tested. +Please include a summary of the added or modified test. List relevant functions tested. Fixes #(issue) From eeddac31a148880b936b6b28f0ea69ede60b7a01 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Mon, 27 May 2024 12:46:12 +1000 Subject: [PATCH 94/98] Revert "Update issue templates" --- .github/ISSUE_TEMPLATE/bug_report.yml | 91 ------------------- .../ISSUE_TEMPLATE/documentation_request.yml | 38 -------- .github/ISSUE_TEMPLATE/feature_request.yml | 2 +- .../ISSUE_TEMPLATE/pull_request_template.yml | 18 ---- .github/ISSUE_TEMPLATE/question.yml | 47 ---------- .../pull_request_template/bug_fix_template.md | 24 ----- .../docs_update_template.md | 23 ----- .../pull_request_template/feature_template.md | 27 ------ .../tests_improvement_template.md | 23 ----- 9 files changed, 1 insertion(+), 292 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/documentation_request.yml delete mode 100644 .github/ISSUE_TEMPLATE/pull_request_template.yml delete mode 100644 .github/ISSUE_TEMPLATE/question.yml delete mode 100644 .github/pull_request_template/bug_fix_template.md delete mode 100644 .github/pull_request_template/docs_update_template.md delete mode 100644 .github/pull_request_template/feature_template.md delete mode 100644 .github/pull_request_template/tests_improvement_template.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 8fe9facf..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: "Bug Report" -description: "Report a bug or an issue in map2loop" -title: "[Bug] - " -labels: ["bug"] -body: - - type: markdown - attributes: - value: | - ## Bug Report - Thanks for submitting a bug report to map2loop! - Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. - - - type: input - id: bug_title - attributes: - label: "Bug Title" - description: "Provide a concise and descriptive title for the bug report." - placeholder: "Enter the title of the bug" - validations: - required: true - - - type: textarea - id: bug_description - attributes: - label: "Bug Description" - description: "Describe the bug you encountered. Include details on what you expected to happen and what actually happened." - placeholder: "Enter a detailed description of the bug" - validations: - required: true - - - type: textarea - id: steps_to_reproduce - attributes: - label: "Minimal reproducible example" - description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." - placeholder: "Enter the steps to reproduce the bug" - validations: - required: true - - - type: textarea - id: expected_behavior - attributes: - label: "Expected Behavior" - description: "Describe what you expected to happen." - placeholder: "Enter the expected behavior" - validations: - required: true - - - type: textarea - id: actual_behavior - attributes: - label: "Actual Behavior" - description: "Describe what actually happened when you encountered the bug." - placeholder: "Enter the actual behavior" - validations: - required: true - - - type: textarea - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful in understanding and fixing the bug." - placeholder: "Enter any additional context" - validations: - required: false - - - type: input - id: environment - attributes: - label: "Environment" - description: "Specify the environment in which the bug occurred (e.g., operating system, browser, application version)." - placeholder: "Enter the environment details" - validations: - required: true - - - type: checkboxes - id: severity - attributes: - label: "Severity" - description: "Select the severity level of the bug." - options: - - label: "Low" - value: "low" - - label: "Medium" - value: "medium" - - label: "High" - value: "high" - - label: "Critical" - value: "critical" - validations: - required: true diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml deleted file mode 100644 index 6304632d..00000000 --- a/.github/ISSUE_TEMPLATE/documentation_request.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: "Documentation Request" -description: "Help us improve map2loop documentation!" -title: "[Documentation] - " -labels: ["documentation"] -body: - - type: markdown - attributes: - value: | - ## Documentation Request - Please use this template to suggest an improvement or addition to map2loop documentation. - Provide as much detail as possible to help us understand and implement your request efficiently. - - - type: input - id: doc_title - attributes: - label: "Documentation Title" - description: "Provide a concise and descriptive title for the documentation request." - placeholder: "Enter the title of the documentation request" - validations: - required: true - - - type: textarea - id: doc_details - attributes: - label: "Documentation Details" - description: "Describe the documentation you would like to see. Include details on why it is needed and how it should be structured." - placeholder: "Enter a detailed description of the documentation" - validations: - required: true - - - type: textarea - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful." - placeholder: "Enter any additional context" - validations: - required: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 93585a56..013f2ede 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -72,4 +72,4 @@ body: value: "stratigraphic column" - label: "data types" - label: "faults" - - label: "Other" \ No newline at end of file + - label: "Other" diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.yml b/.github/ISSUE_TEMPLATE/pull_request_template.yml deleted file mode 100644 index bba4e8d7..00000000 --- a/.github/ISSUE_TEMPLATE/pull_request_template.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: 2 - -pull_request_templates: - - name: Bug Fix Template - description: Use this template for bug fixes. - file: pull_request_template/bug_fix_template.md - - - name: Feature Template - description: Use this template for adding new features. - file: pull_request_template/feature_template.md - - - name: Documentation Update Template - description: Use this template for documentation updates. - file: pull_request_template/docs_update_template.md - - - name: Test Improvement Template - description: Use this template for adding a new test. - file: pull_request_template/tests_improvement_template.md diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml deleted file mode 100644 index a4b37981..00000000 --- a/.github/ISSUE_TEMPLATE/question.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: "Question" -description: "Ask a question about map2loop!" -title: "[Question] - " -labels: ["question"] -body: - - type: markdown - attributes: - value: | - ## Question - Please use this template to ask a question about applying map2loop to your data. - Provide as much detail as possible to help us understand and answer your question efficiently. - - - type: input - id: question_title - attributes: - label: "Question Title" - description: "Provide a concise and descriptive title for your question." - placeholder: "Enter the title of your question" - validations: - required: true - - - type: textarea - id: question_details - attributes: - label: "Question Details" - description: "Describe your question in detail. Include any context or background information that might be helpful." - placeholder: "Enter the details of your question" - validations: - required: true - - - type: textarea - id: relevant_code_snippets - attributes: - label: "Relevant code or data" - description: "If applicable, provide any relevant code snippets or examples related to your question." - placeholder: "Enter any relevant code snippets" - validations: - required: false - - - type: input - id: additional_context - attributes: - label: "Additional Context" - description: "Provide any other context or information that may be helpful in answering your question." - placeholder: "Enter any additional context" - validations: - required: false \ No newline at end of file diff --git a/.github/pull_request_template/bug_fix_template.md b/.github/pull_request_template/bug_fix_template.md deleted file mode 100644 index afdc1497..00000000 --- a/.github/pull_request_template/bug_fix_template.md +++ /dev/null @@ -1,24 +0,0 @@ -## Description - -Please describe the issue that this pull request addresses and summarize the changes you are implementing. - -Fixes #(issue) - -## Type of change - -- [ ] Bug fix (non-breaking change which fixes an issue) - -## How Has This Been Tested? - -Please describe any tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] I have performed a self-review of my own code -- [ ] My code follows the style guidelines of this project -- [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I have made corresponding changes to the documentation -- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md deleted file mode 100644 index 247529c3..00000000 --- a/.github/pull_request_template/docs_update_template.md +++ /dev/null @@ -1,23 +0,0 @@ -## Description - -Please include a summary of the changes. Include context if relevant. - -Fixes #(issue) - -## Type of change - -- [ ] Documentation update - -## How Has This Been Tested? -Please describe the tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] I have performed a self-review of my own documentation -- [ ] I have built the documentation locally with make.bat -- [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs -- [ ] My documentation follows the style guidelines of this project -- [ ] I have checked my spelling and grammar diff --git a/.github/pull_request_template/feature_template.md b/.github/pull_request_template/feature_template.md deleted file mode 100644 index 3b6e6313..00000000 --- a/.github/pull_request_template/feature_template.md +++ /dev/null @@ -1,27 +0,0 @@ -## Description - -Please include a summary of the changes and the related issue. Include relevant motivation and context, if appropriate. -List any new dependencies that are required for this change. - -Fixes #(issue) - -## Type of change - -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - -## How Has This Been Tested? - -Please describe the tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with the master branch -- [ ] All github-action checks are passing -- [ ] I have performed a self-review of my own code -- [ ] My code follows the style guidelines of this project -- [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I have made corresponding changes to the documentation -- [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/pull_request_template/tests_improvement_template.md b/.github/pull_request_template/tests_improvement_template.md deleted file mode 100644 index aa56ee86..00000000 --- a/.github/pull_request_template/tests_improvement_template.md +++ /dev/null @@ -1,23 +0,0 @@ -## Description - -Please include a summary of the added or modified test. List relevant functions tested. - -Fixes #(issue) - -## Type of change - -- [ ] Test improvement - -## How Has This Been Tested? - -Please describe the tests that you ran to verify your changes. -Provide branch name so we can reproduce. - -## Checklist: - -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing -- [ ] I have performed a self-review of my own tests -- [ ] My tests follow the style guidelines of this project -- [ ] I have commented my tests, particularly in hard-to-understand areas -- [ ] New and existing unit tests pass locally with my changes From 1eff1154d85c10d4f47a363c66497f6ef0439763 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Wed, 22 May 2024 15:28:01 +1000 Subject: [PATCH 95/98] feat: added issue_templates edit dddf70b chore: added issue_templates --- .github/ISSUE_TEMPLATE/bug_report.yml | 91 +++++++++++++++++++ .../ISSUE_TEMPLATE/documentation_request.yml | 39 ++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 4 +- .github/ISSUE_TEMPLATE/question.yml | 48 ++++++++++ 4 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/documentation_request.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..8fe9facf --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,91 @@ +name: "Bug Report" +description: "Report a bug or an issue in map2loop" +title: "[Bug] - " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + ## Bug Report + Thanks for submitting a bug report to map2loop! + Please use this template to report a bug. Please provide as much detail as possible to help us reproduce and fix the issue efficiently. + + - type: input + id: bug_title + attributes: + label: "Bug Title" + description: "Provide a concise and descriptive title for the bug report." + placeholder: "Enter the title of the bug" + validations: + required: true + + - type: textarea + id: bug_description + attributes: + label: "Bug Description" + description: "Describe the bug you encountered. Include details on what you expected to happen and what actually happened." + placeholder: "Enter a detailed description of the bug" + validations: + required: true + + - type: textarea + id: steps_to_reproduce + attributes: + label: "Minimal reproducible example" + description: "Provide a minimal reproducible example with the code and data necessary to reproduce the bug." + placeholder: "Enter the steps to reproduce the bug" + validations: + required: true + + - type: textarea + id: expected_behavior + attributes: + label: "Expected Behavior" + description: "Describe what you expected to happen." + placeholder: "Enter the expected behavior" + validations: + required: true + + - type: textarea + id: actual_behavior + attributes: + label: "Actual Behavior" + description: "Describe what actually happened when you encountered the bug." + placeholder: "Enter the actual behavior" + validations: + required: true + + - type: textarea + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful in understanding and fixing the bug." + placeholder: "Enter any additional context" + validations: + required: false + + - type: input + id: environment + attributes: + label: "Environment" + description: "Specify the environment in which the bug occurred (e.g., operating system, browser, application version)." + placeholder: "Enter the environment details" + validations: + required: true + + - type: checkboxes + id: severity + attributes: + label: "Severity" + description: "Select the severity level of the bug." + options: + - label: "Low" + value: "low" + - label: "Medium" + value: "medium" + - label: "High" + value: "high" + - label: "Critical" + value: "critical" + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml new file mode 100644 index 00000000..6fb074ad --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation_request.yml @@ -0,0 +1,39 @@ +name: "Documentation Request" +description: "Help us improve map2loop documentation!" +title: "[Documentation] - " +labels: ["documentation"] +body: + - type: markdown + attributes: + value: | + ## Documentation Request + + Please use this template to suggest an improvement or addition to map2loop documentation. + Provide as much detail as possible to help us understand and implement your request efficiently. + + - type: input + id: doc_title + attributes: + label: "Documentation Title" + description: "Provide a concise and descriptive title for the documentation request." + placeholder: "Enter the title of the documentation request" + validations: + required: true + + - type: textarea + id: doc_details + attributes: + label: "Documentation Details" + description: "Describe the documentation you would like to see. Include details on why it is needed and how it should be structured." + placeholder: "Enter a detailed description of the documentation" + validations: + required: true + + - type: textarea + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful." + placeholder: "Enter any additional context" + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 013f2ede..00872c72 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -7,6 +7,7 @@ body: attributes: value: | ## Feature Request + Please use this template to submit your feature request. Provide as much detail as possible to help us understand and implement your request efficiently. - type: input @@ -71,5 +72,6 @@ body: - label: "stratigraphic column" value: "stratigraphic column" - label: "data types" - - label: "faults" + value: "data types" - label: "Other" + value: "other" diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 00000000..65db9e62 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,48 @@ +name: "Question" +description: "Ask a question about map2loop!" +title: "[Question] - " +labels: ["question"] +body: + - type: markdown + attributes: + value: | + ## Question + + Please use this template to ask a question about applying map2loop to your data. + Provide as much detail as possible to help us understand and answer your question efficiently. + + - type: input + id: question_title + attributes: + label: "Question Title" + description: "Provide a concise and descriptive title for your question." + placeholder: "Enter the title of your question" + validations: + required: true + + - type: textarea + id: question_details + attributes: + label: "Question Details" + description: "Describe your question in detail. Include any context or background information that might be helpful." + placeholder: "Enter the details of your question" + validations: + required: true + + - type: textarea + id: relevant_code_snippets + attributes: + label: "Relevant code or data" + description: "If applicable, provide any relevant code snippets or examples related to your question." + placeholder: "Enter any relevant code snippets" + validations: + required: false + + - type: input + id: additional_context + attributes: + label: "Additional Context" + description: "Provide any other context or information that may be helpful in answering your question." + placeholder: "Enter any additional context" + validations: + required: false From 78e5c58bc6374aa199d4ac0f1de8079f1ece1e09 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 28 May 2024 11:16:23 +1000 Subject: [PATCH 96/98] fix: add issue templates back --- .../ISSUE_TEMPLATE/pull_request_template.yml | 18 +++++++++++++ .../docs_update_template.md | 23 ++++++++++++++++ .../pull_request_template/feature_template.md | 27 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/pull_request_template.yml create mode 100644 .github/pull_request_template/docs_update_template.md create mode 100644 .github/pull_request_template/feature_template.md diff --git a/.github/ISSUE_TEMPLATE/pull_request_template.yml b/.github/ISSUE_TEMPLATE/pull_request_template.yml new file mode 100644 index 00000000..bba4e8d7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/pull_request_template.yml @@ -0,0 +1,18 @@ +version: 2 + +pull_request_templates: + - name: Bug Fix Template + description: Use this template for bug fixes. + file: pull_request_template/bug_fix_template.md + + - name: Feature Template + description: Use this template for adding new features. + file: pull_request_template/feature_template.md + + - name: Documentation Update Template + description: Use this template for documentation updates. + file: pull_request_template/docs_update_template.md + + - name: Test Improvement Template + description: Use this template for adding a new test. + file: pull_request_template/tests_improvement_template.md diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md new file mode 100644 index 00000000..99c76ba5 --- /dev/null +++ b/.github/pull_request_template/docs_update_template.md @@ -0,0 +1,23 @@ +## Description + +Please include a summary of the changes. Include context if relevant. + +Fixes #(issue) + +## Type of change + +- [ ] Documentation update + +## How Has This Been Tested? +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own documentation +- [ ] I have built the documentation locally with make.bat +- [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs +- [ ] My documentation follows the style guidelines of this project +- [ ] I have checked my spelling and grammar \ No newline at end of file diff --git a/.github/pull_request_template/feature_template.md b/.github/pull_request_template/feature_template.md new file mode 100644 index 00000000..29a43a6e --- /dev/null +++ b/.github/pull_request_template/feature_template.md @@ -0,0 +1,27 @@ +## Description + +Please include a summary of the changes and the related issue. Include relevant motivation and context, if appropriate. +List any new dependencies that are required for this change. + +Fixes #(issue) + +## Type of change + +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) + +## How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. +Provide branch name so we can reproduce. + +## Checklist: + +- [ ] This branch is up-to-date with master +- [ ] All gh-action checks are passing +- [ ] I have performed a self-review of my own code +- [ ] My code follows the style guidelines of this project +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes From 80826a7053f698e6905ed2c2acb2e295cb2a0707 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 28 May 2024 11:40:57 +1000 Subject: [PATCH 97/98] fix: correct grammar for clarity --- .github/pull_request_template/docs_update_template.md | 4 ++-- .github/pull_request_template/feature_template.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/pull_request_template/docs_update_template.md b/.github/pull_request_template/docs_update_template.md index 99c76ba5..a1c43359 100644 --- a/.github/pull_request_template/docs_update_template.md +++ b/.github/pull_request_template/docs_update_template.md @@ -14,8 +14,8 @@ Provide branch name so we can reproduce. ## Checklist: -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing +- [ ] This branch is up-to-date with the master branch +- [ ] All github-action checks are passing - [ ] I have performed a self-review of my own documentation - [ ] I have built the documentation locally with make.bat - [ ] I have built this documentation in docker, following the docker configuration in map2loop/docs diff --git a/.github/pull_request_template/feature_template.md b/.github/pull_request_template/feature_template.md index 29a43a6e..3b6e6313 100644 --- a/.github/pull_request_template/feature_template.md +++ b/.github/pull_request_template/feature_template.md @@ -17,8 +17,8 @@ Provide branch name so we can reproduce. ## Checklist: -- [ ] This branch is up-to-date with master -- [ ] All gh-action checks are passing +- [ ] This branch is up-to-date with the master branch +- [ ] All github-action checks are passing - [ ] I have performed a self-review of my own code - [ ] My code follows the style guidelines of this project - [ ] I have commented my code, particularly in hard-to-understand areas From 4f299b922b67af27e9a45d1bbc87ffd0d303f889 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Fri, 31 May 2024 14:34:53 +1000 Subject: [PATCH 98/98] fix: add 2 more links to try from GA WCS if timing out & prints out where the DEM was downloaded from --- map2loop/mapdata.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/map2loop/mapdata.py b/map2loop/mapdata.py index 4c866be9..97138b39 100644 --- a/map2loop/mapdata.py +++ b/map2loop/mapdata.py @@ -20,7 +20,6 @@ from io import BytesIO from typing import Union import requests -import requests class MapData: @@ -487,7 +486,39 @@ def __check_and_create_tmp_path(self): os.mkdir(self.tmp_path) - + @beartype.beartype + def get_coverage(self, url: str, bb_ll:tuple): + """ + Retrieves coverage from GA WCS and save it as a GeoTIFF file. + + This method retrieves a coverage from the specified WCS GA URL using the project's bounding box. + The retrieved coverage is saved to a temporary file --> StudidGDALLocalFile.tif + + Args: + url (str): The GA WCS URL from which to retrieve the coverage. + bb_ll (tuple): A tuple containing the bounding box coordinates (minX, minY, maxX, maxY). + + Returns: + gdal.Dataset: The GDAL dataset of the retrieved GeoTIFF file. + """ + + self.__check_and_create_tmp_path() + + wcs = WebCoverageService(url, version="1.0.0") + + coverage = wcs.getCoverage( + identifier="1", bbox=bb_ll, format="GeoTIFF", crs=4326, width=2048, height=2048 + ) + # This is stupid that gdal cannot read a byte stream and has to have a + # file on the local system to open or otherwise create a gdal file + # from scratch with Create + tmp_file = os.path.join(self.tmp_path, "StupidGDALLocalFile.tif") + + with open(tmp_file, "wb") as fh: + fh.write(coverage.read()) + + return gdal.Open(tmp_file) + @beartype.beartype def __retrieve_tif(self, filename: str): """