Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions aemworkflow/aemworkflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
from .interpretation import main as interpretation
from .exports import main as exports


@click.group()
def cli():
"""AEM Interpretation Conversion CLI."""
pass


@cli.command()
@click.option("--i", "input_directory", type=click.Path(exists=True), required=True)
@click.option("--o", "output_directory", type=click.Path(), required=True)
Expand All @@ -21,11 +23,12 @@ def cli():
def pre_interpret(input_directory, output_directory, crs, gis="esri_arcmap_0.5", lines=10, lines_increment=30):
try:
pre_interpretation(input_directory, output_directory, crs, gis, lines, lines_increment)
click.echo(f"Completed pre-interpretation")
click.echo("Completed pre-interpretation")
except Exception as e:
click.echo(f"Error: {e}", err=True)
sys.exit(1)


@cli.command()
@click.option("--i", "input_directory", type=click.Path(exists=True), required=True)
@click.option("--o", "output_directory", type=click.Path(), required=True)
Expand All @@ -36,35 +39,38 @@ def pre_interpret(input_directory, output_directory, crs, gis="esri_arcmap_0.5",
def interpret(input_directory, output_directory, crs="28349", gis="esri_arcmap_0.5", lines=10, lines_increment=30):
try:
interpretation(input_directory, output_directory, crs, gis, lines, lines_increment)
click.echo(f"Completed interpretation")
click.echo("Completed interpretation")
except Exception as e:
click.echo(f"Error: {e}", err=True)
sys.exit(1)


@cli.command()
@click.option("--i", "input_directory", type=click.Path(exists=True), required=True)
@click.option("--o", "output_directory", type=click.Path(), required=True)
@click.option("--a", "asud_filename", type=click.Path(exists=True), required=True)
def validate(input_directory, output_directory, asud_filename):
try:
validation(input_directory, output_directory, asud_filename)
click.echo(f"Completed validation")
click.echo("Completed validation")
except Exception as e:
click.echo(f"Error: {e}", err=True)
sys.exit(1)


@cli.command()
@click.option("--i", "input_directory", type=click.Path(exists=True), required=True)
@click.option("--o", "output_directory", type=click.Path(), required=True)
@click.option("--crs", default="28349", help="Coordinate Reference System (default: EPSG:28349)")
def convert(input_directory, output_directory, crs):
try:
conversion(input_directory, output_directory, crs)
click.echo(f"Completed conversion")
click.echo("Completed conversion")
except Exception as e:
click.echo(f"Error: {e}", err=True)
sys.exit(1)


@cli.command()
@click.option("--i", "input_directory", type=click.Path(exists=True), required=True)
@click.option("--o", "output_directory", type=click.Path(), required=True)
Expand All @@ -76,7 +82,7 @@ def convert(input_directory, output_directory, crs):
def export(input_directory, output_directory, boundary_filename, split_filename, mdc, mdch, egs):
try:
exports(input_directory, output_directory, boundary_filename, split_filename, mdc, mdch, egs)
click.echo(f"Completed export")
click.echo("Completed export")
except Exception as e:
click.echo(f"Error: {e}", err=True)
sys.exit(1)
2 changes: 1 addition & 1 deletion aemworkflow/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def conversion_zedfix_gmt_to_srt(wrk_dir: str, path_dir: str, ext_file: str, log
fidd = 0
row = exdf.query("nm == @nm")
y_scale = (row['t_bot'].iloc[0] - row['t_top'].iloc[0]) /\
(row['frame_bot'].iloc[0] - row['frame_top'].iloc[0])
(row['frame_bot'].iloc[0] - row['frame_top'].iloc[0])
p_file = Path(path_dir) / f"{nm}.path.txt"
tdf = pd.read_csv(p_file, sep=r'\s+', names=pcols, header=None, index_col=False)
# pdf_list.append(tdf)
Expand Down
116 changes: 58 additions & 58 deletions aemworkflow/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ def gmtsddd_to_mdch(wrk_dir: str, colors: str, nm_list: List[int]) -> None:
csvwriter.writerow([f"name:{filen[0]}_{segn}_{line[2]}"])
csvwriter.writerow(["*atoms:false"])
csvwriter.writerow(["*line*color: %f %f %f 1" % (r[line[2]] / 256,
g[line[2]] / 256,
b[line[2]] / 256)])
g[line[2]] / 256,
b[line[2]] / 256)])
csvwriter.writerow(["use_feature_color: false"])
csvwriter.writerow(["width: 5"])
csvwriter.writerow([f"*metadata*Line: {filen[0]}"])
Expand Down Expand Up @@ -284,14 +284,14 @@ def gmts_2_egs(wrk_dir: str, alt_colors: str, nm_lst: List[int]) -> None:
sys.exit(0)

header = "Vertex,SegmentID,X,Y,ELEVATION,PixelX," \
"PixelY,AusAEM_DEM,DEPTH,Type,OverAge,UnderAge," \
"BoundConf,ContactTyp,BasisOfInt,OvrStrtUnt," \
"OvrStratNo,OvrConf,UndStrtUnt,UndStratNo," \
"UndConf,WithinStrt,WithinStNo,WithinConf," \
"HydStrtType,HydStrConf,BOMNAFUnt,BOMNAFNo," \
"InterpRef,Comment,Annotation,NewObs,Operator," \
"" \
"Date,SURVEY_LINE\n"
"PixelY,AusAEM_DEM,DEPTH,Type,OverAge,UnderAge," \
"BoundConf,ContactTyp,BasisOfInt,OvrStrtUnt," \
"OvrStratNo,OvrConf,UndStrtUnt,UndStratNo," \
"UndConf,WithinStrt,WithinStNo,WithinConf," \
"HydStrtType,HydStrConf,BOMNAFUnt,BOMNAFNo," \
"InterpRef,Comment,Annotation,NewObs,Operator," \
"" \
"Date,SURVEY_LINE\n"

regex2 = re.compile('[+-]?([0-9]*[.])?[0-9]+')

Expand Down Expand Up @@ -327,9 +327,9 @@ def gmts_2_egs(wrk_dir: str, alt_colors: str, nm_lst: List[int]) -> None:
while regex2.match(line.split()[0]):
los = line.split()
fou.write(f"{los[9]},{los[8]},{los[2]},"
f"{los[3]},{los[4]},{los[0]},"
f"{los[1]},{los[5]},{los[6]},"
f"{met},{nm}\n")
f"{los[3]},{los[4]},{los[0]},"
f"{los[1]},{los[5]},{los[6]},"
f"{met},{nm}\n")
line = lines.pop(0)
except IndexError:
pass
Expand All @@ -355,46 +355,46 @@ def gmts_2_mdc(wrk_dir: str, colors: str, nm_lst: List[int]) -> None:

try:
fsctn = ("GOCAD PLine 1\n"
"HEADER {{\n"
"name:{}_{}_{}\n"
"*atoms:false\n"
"*line*color:{:.6f} {:.6f} {:.6f} 1\n"
"use_feature_color: false\n"
"width:5\n"
"*metadata*Line: {}\n"
"*metadata*Type: {}\n"
"*metadata*BoundaryNm: {}\n"
"*metadata*BoundConf: {}\n"
"*metadata*BasisOfInt: {}\n"
"*metadata*OvrStrtUnt: {}\n"
"*metadata*OvrStrtCod: {}\n"
"*metadata*OvrConf: {}\n"
"*metadata*UndStrtUnt: {}\n"
"*metadata*UndStrtCod: {}\n"
"*metadata*UndConf: {}\n"
"*metadata*WithinType: {}\n"
"*metadata*WithinStrt: {}\n"
"*metadata*WithinStNo: {}\n"
"*metadata*WithinConf: {}\n"
"*metadata*InterpRef: {}\n"
"*metadata*Comment: {}\n"
"*metadata*Annotation: {}\n"
"*metadata*NewObs: {}\n"
"*metadata*Operator: {}\n"
"*metadata*Organization: Geoscience Australia\n"
"}}\n"
"PROPERTIES px py gl depth\n"
"GOCAD_ORIGINAL_COORDINATE_SYSTEM\n"
'NAME " gocad Local"\n'
'PROJECTION " GDA94 / MGA zone 53"\n'
'DATUM " Mean Sea Level"\n'
"AXIS_NAME X Y Z\n"
"AXIS_UNIT m m m\n"
"ZPOSITIVE Elevation\n"
"END_ORIGINAL_COORDINATE_SYSTEM\n"
"GEOLOGICAL_FEATURE {}\n"
"ILINE\n"
)
"HEADER {{\n"
"name:{}_{}_{}\n"
"*atoms:false\n"
"*line*color:{:.6f} {:.6f} {:.6f} 1\n"
"use_feature_color: false\n"
"width:5\n"
"*metadata*Line: {}\n"
"*metadata*Type: {}\n"
"*metadata*BoundaryNm: {}\n"
"*metadata*BoundConf: {}\n"
"*metadata*BasisOfInt: {}\n"
"*metadata*OvrStrtUnt: {}\n"
"*metadata*OvrStrtCod: {}\n"
"*metadata*OvrConf: {}\n"
"*metadata*UndStrtUnt: {}\n"
"*metadata*UndStrtCod: {}\n"
"*metadata*UndConf: {}\n"
"*metadata*WithinType: {}\n"
"*metadata*WithinStrt: {}\n"
"*metadata*WithinStNo: {}\n"
"*metadata*WithinConf: {}\n"
"*metadata*InterpRef: {}\n"
"*metadata*Comment: {}\n"
"*metadata*Annotation: {}\n"
"*metadata*NewObs: {}\n"
"*metadata*Operator: {}\n"
"*metadata*Organization: Geoscience Australia\n"
"}}\n"
"PROPERTIES px py gl depth\n"
"GOCAD_ORIGINAL_COORDINATE_SYSTEM\n"
'NAME " gocad Local"\n'
'PROJECTION " GDA94 / MGA zone 53"\n'
'DATUM " Mean Sea Level"\n'
"AXIS_NAME X Y Z\n"
"AXIS_UNIT m m m\n"
"ZPOSITIVE Elevation\n"
"END_ORIGINAL_COORDINATE_SYSTEM\n"
"GEOLOGICAL_FEATURE {}\n"
"ILINE\n"
)
fmt = "PVRTX {:0.0f} {:6.1f} {:7.1f} {:.1f} {:.6f} {:.6f} {:.1f} {:.1f}\n"

srt_dir = Path(wrk_dir) / "SORT"
Expand Down Expand Up @@ -429,11 +429,11 @@ def gmts_2_mdc(wrk_dir: str, colors: str, nm_lst: List[int]) -> None:
frst = int(frst)
# segn = int(segn)
fou.write(fsctn.format(nm, segn, met[2],
row['Red'].iloc[0], row['Green'].iloc[0], row['Blue'].iloc[0],
nm,
*met[2:21],
nm
))
row['Red'].iloc[0], row['Green'].iloc[0], row['Blue'].iloc[0],
nm,
*met[2:21],
nm
))
try:
while regex2.match(line.split()[0]):
los = [int(_l) if i == 7 else float(_l) for i, _l in enumerate(line.split())]
Expand Down
2 changes: 1 addition & 1 deletion aemworkflow/pre_interpretation.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def box_elevation(extent_file_path, path_file_path, output_file_path, depth_line
ppt = int(path_fields[1])
py = (y_of - float(path_fields[8])) / y_fact
out_file.write(f"{int(path_fields[1]) - 1} "
f"{round(decimal.Decimal((-py + ypo) - (2 / y_fact)), 4).normalize()}\n")
f"{round(decimal.Decimal((-py + ypo) - (2 / y_fact)), 4).normalize()}\n")
yy.insert(ppt - 1, py * -1)
last = ppt

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ addopts = [

[tool.flake8]
max-line-length = 120
ignore = ["E402"]
ignore = ["E402", "F401", "F841"]
Loading