Loop3D / map2loop

MIT License
9 stars 9 forks source link

[Bug] - project cannot be run without colour file #92

Closed lachlangrose closed 3 months ago

lachlangrose commented 3 months ago

Bug Title

project cannot be run without colour file

Bug Description

Map colours should not be a requirement to run map2loop. Where colours are not provided randomly assign colours to the units.

Minimal reproducible example

import os from map2loop.project import Project from map2loop.m2l_enums import VerboseLevel from map2loop.m2l_enums import Datatype from map2loop.sampler import SamplerSpacing, SamplerDecimator from map2loop.sorter import SorterUseHint, SorterUseNetworkX, SorterAgeBased, SorterAlpha import time

from datetime import datetime nowtime=datetime.now().isoformat(timespec='minutes')
model_name=nowtime.replace(":","-").replace("T","-") loop_project_filename = os.path.join(model_name, "local_source.loop3d")

t0 = time.time()

Specify the boundary of the region of interest in the appropriate projection coordinates

bounding_box = { "minx": 520000, "miny": 7490000, "maxx": 550000, "maxy": 7510000, "base": -3200, "top": 1200, }

Initialise the project with the shapefiles, dtm, config file

output locations and projection to work in

proj = Project( geology_filename = "./source_data/geol_clip.shp", fault_filename = "./source_data/faults_clip.shp", fold_filename = "./source_data/folds_clip.shp", structure_filename = "./source_data/structure_clip.shp", dtm_filename = './source_data/dtm_rp.tif', config_filename = './source_data/example.hjson',

clut_filename = './source_data/500kibg_colours.csv',

clut_file_legacy = True,
verbose_level = VerboseLevel.NONE,
tmp_path = model_name,
working_projection = "EPSG:28350",
bounding_box = bounding_box,
loop_project_filename = loop_project_filename

)

Remove faults less than 5km

proj.set_minimum_fault_length(5000.0)

Set sampling distance for geology and fault maps to 200m

proj.set_sampler(Datatype.GEOLOGY, SamplerSpacing(200.0)) proj.set_sampler(Datatype.FAULT, SamplerSpacing(200.0))

Set to only take every second orientation observation (0 or 1 means take all observations)

proj.set_sampler(Datatype.STRUCTURE, SamplerDecimator(2))

Set what text is expected for intrusions (contained within the description field)

proj.map_data.config.geology_config["intrusive_text"] = "mafic intrusive" proj.map_data.config.geology_config["sill"] = "oskianoiasfn"

Set specific layers from the geology map to be ignored (commonly "cover" or "water")

proj.set_ignore_codes(["cover", "Fortescue_Group", "A_FO_od"])

Specify which stratigraphic columns sorter to use, other options are

(SorterAlpha, SorterAgeBased, SorterUseHint, SorterUseNetworkX, SorterMaximiseContacts, SorterObservationProjections)

proj.set_sorter(SorterAlpha()) proj.run_all()

Expected Behavior

Map2loop should run and work as expected and generate random colours.

Actual Behavior


ValueError Traceback (most recent call last) Cell In[4], line 4 1 # Specify which stratigraphic columns sorter to use, other options are 2 # (SorterAlpha, SorterAgeBased, SorterUseHint, SorterUseNetworkX, SorterMaximiseContacts, SorterObservationProjections) 3 proj.set_sorter(SorterAlpha()) ----> 4 proj.run_all()

File ~/Documents/repositories/loop/map2loop/map2loop/project.py:525, in Project.run_all(self, user_defined_stratigraphic_column, take_best) 523 self.calculate_fault_orientations() 524 self.summarise_fault_data() --> 525 self.apply_colour_to_units() 526 self.save_into_projectfile()

File ~/Documents/repositories/loop/map2loop/map2loop/project.py:473, in Project.apply_colour_to_units(self) 469 def apply_colour_to_units(self): 470 """ 471 Apply the clut file to the units in the stratigraphic column 472 """ --> 473 self.stratigraphic_column.stratigraphicUnits = self.map_data.colour_units( 474 self.stratigraphic_column.stratigraphicUnits 475 )

File <@beartype(map2loop.mapdata.MapData.colour_units) at 0x7536508fb1c0>:51, in colour_units(beartype_object_110679875684752, beartype_get_violation, __beartype_conf, __beartype_func, *args, **kwargs) ... (...) 479 mode=mode, 480 )

ValueError: Invalid file path or buffer object type: <class 'NoneType'> Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

Additional Context

No response

Environment

???

Severity

AngRodrigues commented 3 months ago

Issue addressed in https://github.com/Loop3D/map2loop/issues/90 Will close this to avoid duplicate tasks