qgis-tem-loader

qgis plugin for loading TEM geophysical inversion XYZ files as 3D objects
git clone git://src.adamsgaard.dk/qgis-tem-loader # fast
git clone https://src.adamsgaard.dk/qgis-tem-loader.git # slow
Log | Files | Refs | README | LICENSE Back to index

commit b89c87f0b053bd9eede7d4049c12f68f35eb6434
parent eea620f476dc695a1f9180003d6611110ea2c5ab
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed,  8 Apr 2026 15:48:27 +0200

chore(python): remove original conversion script

Diffstat:
Dunpivot-xyz.py | 107-------------------------------------------------------------------------------
1 file changed, 0 insertions(+), 107 deletions(-)

diff --git a/unpivot-xyz.py b/unpivot-xyz.py @@ -1,107 +0,0 @@ -#!/usr/bin/env python -from pathlib import Path -import sys -import pandas as pd - -def count_header_lines(path, comment_char='/'): - with open(path, 'r') as f: - for i, line in enumerate(f): - if not line.lstrip().startswith(comment_char): - return i - return 0 - -def unpivot_xyz(path): - skiprows = count_header_lines(path) - df = pd.read_csv(path, sep='\\s+', skiprows=skiprows) - res_cols = [c for c in df.columns if c.startswith("Res_")] - thick_cols = [c for c in df.columns if c.startswith("Thick_")] - model_points = [] - doi_points = [] - model_layers = [] - for _, row in df.iterrows(): - x = row["X"] - y = row["Y"] - z = row["Z"] - doi = row["DOI"] - data_residual = row["DataResidual"] - n_layers = row["NumLayers"] - try: - n_layers = int(n_layers) - except (TypeError, ValueError): - n_layers = None - if pd.isna(n_layers): - n_layers = None - point_wkt = f'POINT Z ({x} {y} {z})' - z_doi = z - doi - doi_wkt = f'POINT Z ({x} {y} {z_doi})' - cum_depth = 0 - model_points.append({ - "X": x, - "Y": y, - "Z": z, - "Line": row["Line"], - "StationNo": row["StationNo"], - "DataResidual": data_residual, - "NumLayers": n_layers, - "Geometry": point_wkt - }) - doi_points.append({ - "X": x, - "Y": y, - "Z": z_doi, - "DOI": doi, - "ZDOI": z_doi, - "Geometry": doi_wkt - }) - layer_cols = list(zip(res_cols, thick_cols)) - if n_layers is not None: - layer_cols = layer_cols[:n_layers] - for i, (res_col, thick_col) in enumerate(layer_cols, 1): - res = row[res_col] - thick = row[thick_col] - if pd.isna(res) or pd.isna(thick): - print( - f'Skipping layer {i} for row {row.name}: ' - f'missing {res_col} or {thick_col}.', - file=sys.stderr - ) - break - depth_top = cum_depth - depth_bottom = cum_depth + thick - z_top = z - depth_top - z_bot = z - depth_bottom - z_mid = (z_top + z_bot) / 2 - cum_depth = depth_bottom - layer_wkt = f'LINESTRING Z ({x} {y} {z_top}, {x} {y} {z_bot})' - model_layers.append({ - "X": x, - "Y": y, - "Z": z, - "ZTop": z_top, - "ZMid": z_mid, - "ZBottom": z_bot, - "DepthTop": depth_top, - "DepthBottom": depth_bottom, - "Resistivity": res, - "Layer": i, - "Geometry": layer_wkt - }) - store_csv(model_layers, path, '.layers.csv') - store_csv(model_points, path, '.points.csv') - store_csv(doi_points, path, '.doi.csv') - -def store_csv(entries, base_path, new_suffix): - df_out = pd.DataFrame(entries) - f = base_path.with_suffix(new_suffix) - df_out.to_csv(f, index=False) - print(f) - -if __name__ == '__main__': - if len(sys.argv) < 2: - raise SystemExit(f'usage: {sys.argv[0]} FILE.xyz ..') - for f in sys.argv[1:]: - path = Path(f) - if path.is_file(): - unpivot_xyz(path) - else: - raise SystemExit(f'{f} not found.')