well-log-toolkit 0.1.124__py3-none-any.whl → 0.1.126__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1510,7 +1510,8 @@ class WellDataManager:
1510
1510
  path: Optional[Union[str, Path]] = None,
1511
1511
  sampled: bool = False,
1512
1512
  combine: Optional[str] = None,
1513
- source_name: Optional[str] = None
1513
+ source_name: Optional[str] = None,
1514
+ silent: bool = False
1514
1515
  ) -> 'WellDataManager':
1515
1516
  """
1516
1517
  Load LAS file(s), auto-create well if needed.
@@ -1538,6 +1539,9 @@ class WellDataManager:
1538
1539
  Name for combined source when combine is specified. If not specified,
1539
1540
  uses 'combined_match', 'combined_resample', or 'combined_concat'.
1540
1541
  When files span multiple wells, the well name is prepended automatically.
1542
+ silent : bool, default False
1543
+ If True, suppress debug output showing which sources were loaded.
1544
+ Useful when loading many files programmatically.
1541
1545
 
1542
1546
  Returns
1543
1547
  -------
@@ -1633,16 +1637,17 @@ class WellDataManager:
1633
1637
  )
1634
1638
 
1635
1639
  # Print debug output
1636
- print("Loaded sources:")
1637
- for well_name, src_name, file_count in loaded_sources:
1638
- print(f" - Well {well_name}: {src_name} ({file_count} file{'s' if file_count > 1 else ''} combined)")
1640
+ if not silent:
1641
+ print("Loaded sources:")
1642
+ for well_name, src_name, file_count in loaded_sources:
1643
+ print(f" - Well {well_name}: {src_name} ({file_count} file{'s' if file_count > 1 else ''} combined)")
1639
1644
 
1640
1645
  return self
1641
1646
 
1642
1647
  # No combine - load each file separately
1643
1648
  loaded_sources = []
1644
1649
  for file_path in file_paths:
1645
- # Read well name and source name before loading
1650
+ # Read well name before loading
1646
1651
  las = LasFile(file_path)
1647
1652
  if las.well_name is None:
1648
1653
  raise LasFileError(
@@ -1650,18 +1655,28 @@ class WellDataManager:
1650
1655
  "Cannot determine which well to load into."
1651
1656
  )
1652
1657
  well_name = las.well_name
1653
- source_name_from_file = las.source_name
1658
+ sanitized_name = sanitize_well_name(well_name)
1659
+ well_key = f"well_{sanitized_name}"
1660
+
1661
+ # Track existing sources before loading
1662
+ existing_sources = set()
1663
+ if well_key in self._wells:
1664
+ existing_sources = set(self._wells[well_key].sources)
1654
1665
 
1655
1666
  # Load the file
1656
1667
  self.load_las(file_path, path=None, sampled=sampled, combine=None, source_name=None)
1657
1668
 
1658
- # Track what was loaded
1659
- loaded_sources.append((well_name, source_name_from_file))
1669
+ # Find new sources that were added
1670
+ if well_key in self._wells:
1671
+ new_sources = set(self._wells[well_key].sources) - existing_sources
1672
+ for src_name in new_sources:
1673
+ loaded_sources.append((well_name, src_name))
1660
1674
 
1661
1675
  # Print debug output
1662
- print("Loaded sources:")
1663
- for well_name, src_name in loaded_sources:
1664
- print(f" - Well {well_name}: {src_name}")
1676
+ if not silent and loaded_sources:
1677
+ print("Loaded sources:")
1678
+ for well_name, src_name in loaded_sources:
1679
+ print(f" - Well {well_name}: {src_name}")
1665
1680
 
1666
1681
  return self
1667
1682
 
@@ -1681,12 +1696,15 @@ class WellDataManager:
1681
1696
  "Cannot determine which well to load into."
1682
1697
  )
1683
1698
 
1684
- source_name_from_file = las.source_name
1685
1699
  sanitized_name = sanitize_well_name(well_name)
1686
1700
  # Use well_ prefix for dictionary key (attribute access)
1687
1701
  well_key = f"well_{sanitized_name}"
1688
1702
 
1689
- if well_key not in self._wells:
1703
+ # Track existing sources before loading
1704
+ existing_sources = set()
1705
+ if well_key in self._wells:
1706
+ existing_sources = set(self._wells[well_key].sources)
1707
+ else:
1690
1708
  # Create new well
1691
1709
  self._wells[well_key] = Well(
1692
1710
  name=well_name,
@@ -1698,9 +1716,14 @@ class WellDataManager:
1698
1716
  # Load into well
1699
1717
  self._wells[well_key].load_las(las, sampled=sampled)
1700
1718
 
1719
+ # Find new sources that were added
1720
+ new_sources = set(self._wells[well_key].sources) - existing_sources
1721
+
1701
1722
  # Print debug output
1702
- print("Loaded sources:")
1703
- print(f" - Well {well_name}: {source_name_from_file}")
1723
+ if not silent and new_sources:
1724
+ print("Loaded sources:")
1725
+ for src_name in new_sources:
1726
+ print(f" - Well {well_name}: {src_name}")
1704
1727
 
1705
1728
  return self # Enable chaining
1706
1729
 
@@ -2324,7 +2347,7 @@ class WellDataManager:
2324
2347
  las_files = list(base_path.glob("*.las"))
2325
2348
  if las_files:
2326
2349
  for las_file in las_files:
2327
- self.load_las(las_file)
2350
+ self.load_las(las_file, silent=True)
2328
2351
  return self
2329
2352
 
2330
2353
  # Load from well folders
@@ -2332,7 +2355,7 @@ class WellDataManager:
2332
2355
  # Find all LAS files in this folder
2333
2356
  las_files = sorted(well_folder.glob("*.las"))
2334
2357
  for las_file in las_files:
2335
- self.load_las(las_file)
2358
+ self.load_las(las_file, silent=True)
2336
2359
 
2337
2360
  return self
2338
2361
 
well_log_toolkit/well.py CHANGED
@@ -457,27 +457,49 @@ class Well:
457
457
  las_files = las
458
458
 
459
459
  # Load all files as separate sources
460
+ # Track sources before and after to identify what was loaded
460
461
  loaded_sources = []
462
+
461
463
  for las_file in las_files:
464
+ # Track sources before this file
465
+ sources_before = set(self.sources)
466
+
462
467
  # Recursively call load_las for each file (without merge or combine, path already prepended)
463
468
  self.load_las(las_file, path=None, sampled=sampled, resample_method=resample_method, merge=False, combine=None)
464
- # Get the source name that was just created
465
- loaded_sources.append(self.sources[-1])
469
+
470
+ # Find which source was added or modified
471
+ sources_after = set(self.sources)
472
+ new_or_modified = sources_after - sources_before
473
+
474
+ if new_or_modified:
475
+ # New source was added
476
+ loaded_sources.append(list(new_or_modified)[0])
477
+ else:
478
+ # Source was overwritten - find it by checking which source is newest
479
+ # Since we don't know which one, we'll use the last one in the list
480
+ # This handles the overwrite case
481
+ if self.sources:
482
+ loaded_sources.append(self.sources[-1])
466
483
 
467
484
  # Combine if requested
468
485
  if combine in {'match', 'resample', 'concat'}:
469
486
  # Determine combined source name
470
487
  combined_source_name = source_name or f'combined_{combine}'
471
488
 
472
- # Merge all loaded sources
473
- self.merge(
474
- method=combine,
475
- sources=loaded_sources,
476
- source_name=combined_source_name
477
- )
489
+ # Merge all loaded sources (only ones that exist)
490
+ sources_to_merge = [s for s in loaded_sources if s in self._sources]
491
+
492
+ if sources_to_merge:
493
+ self.merge(
494
+ method=combine,
495
+ sources=sources_to_merge,
496
+ source_name=combined_source_name
497
+ )
478
498
 
479
- # Remove original sources
480
- self.remove_source(loaded_sources)
499
+ # Remove original sources (only ones that exist)
500
+ sources_to_remove = [s for s in sources_to_merge if s in self._sources]
501
+ if sources_to_remove:
502
+ self.remove_source(sources_to_remove)
481
503
 
482
504
  return self
483
505
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: well-log-toolkit
3
- Version: 0.1.124
3
+ Version: 0.1.126
4
4
  Summary: Fast LAS file processing with lazy loading and filtering for well log analysis
5
5
  Author-email: Kristian dF Kollsgård <kkollsg@gmail.com>
6
6
  License: MIT
@@ -1,15 +1,15 @@
1
1
  well_log_toolkit/__init__.py,sha256=ilJAIIhh68pYfD9I3V53juTEJpoMN8oHpcpEFNpuXAQ,3793
2
2
  well_log_toolkit/exceptions.py,sha256=X_fzC7d4yaBFO9Vx74dEIB6xmI9Agi6_bTU3MPxn6ko,985
3
3
  well_log_toolkit/las_file.py,sha256=Tj0mRfX1aX2s6uug7BBlY1m_mu3G50EGxHGzD0eEedE,53876
4
- well_log_toolkit/manager.py,sha256=oz67-IZvMEP7T_JEY7JMzeXWAvG1FmFSk8NKBif7yFI,108220
4
+ well_log_toolkit/manager.py,sha256=STXkr5qxvxDJ9nqgAKTnZjIZ8RYgFUYdGKiCrYi5mlY,109307
5
5
  well_log_toolkit/operations.py,sha256=z8j8fGBOwoJGUQFy-Vawjq9nm3OD_dUt0oaNh8yuG7o,18515
6
6
  well_log_toolkit/property.py,sha256=WOzoNQcmHCQ8moIKsnSyLgVC8s4LBu2x5IBXtFzmMe8,76236
7
7
  well_log_toolkit/regression.py,sha256=7D3oI-1XVlFb-mOoHTxTTtUHERFyvQSBAzJzAGVoZnk,25192
8
8
  well_log_toolkit/statistics.py,sha256=_huPMbv2H3o9ezunjEM94mJknX5wPK8V4nDv2lIZZRw,16814
9
9
  well_log_toolkit/utils.py,sha256=O2KPq4htIoUlL74V2zKftdqqTjRfezU9M-568zPLme0,6866
10
10
  well_log_toolkit/visualization.py,sha256=xb870FG5FghU2gEkqdn1b2NbWNu07oDmFDN1Cx1HIi0,157280
11
- well_log_toolkit/well.py,sha256=kIN3Zr0sI3Zt3DeHbxDXADbQfWnVxXCQrHZ4UEMyeqI,103343
12
- well_log_toolkit-0.1.124.dist-info/METADATA,sha256=CfWF9CRjoyY3ZmsZ1CkKOSsuVUMg3yY3_XZE3B_lwf4,59810
13
- well_log_toolkit-0.1.124.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- well_log_toolkit-0.1.124.dist-info/top_level.txt,sha256=BMOo7OKLcZEnjo0wOLMclwzwTbYKYh31I8RGDOGSBdE,17
15
- well_log_toolkit-0.1.124.dist-info/RECORD,,
11
+ well_log_toolkit/well.py,sha256=7RzbC7zud5M53zZ8FmuQP0GPhUP5Y6RiFjTuf4_oMWE,104419
12
+ well_log_toolkit-0.1.126.dist-info/METADATA,sha256=gI9Y9FEF-4TcwgLTybyf67Su2pfqg-texJfiJEvpKAM,59810
13
+ well_log_toolkit-0.1.126.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ well_log_toolkit-0.1.126.dist-info/top_level.txt,sha256=BMOo7OKLcZEnjo0wOLMclwzwTbYKYh31I8RGDOGSBdE,17
15
+ well_log_toolkit-0.1.126.dist-info/RECORD,,