pingmapper 5.0.14__tar.gz → 5.0.15__tar.gz

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.
Files changed (29) hide show
  1. {pingmapper-5.0.14 → pingmapper-5.0.15}/PKG-INFO +1 -1
  2. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/class_portstarObj.py +29 -2
  3. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/funcs_model.py +35 -2
  4. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/gui_main.py +0 -6
  5. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/main_mapSubstrate.py +0 -6
  6. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/main_readFiles.py +78 -42
  7. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/main_rectify.py +0 -6
  8. pingmapper-5.0.15/pingmapper/version.py +1 -0
  9. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper.egg-info/PKG-INFO +1 -1
  10. pingmapper-5.0.14/pingmapper/version.py +0 -1
  11. {pingmapper-5.0.14 → pingmapper-5.0.15}/LICENSE +0 -0
  12. {pingmapper-5.0.14 → pingmapper-5.0.15}/README.md +0 -0
  13. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/__init__.py +0 -0
  14. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/__main__.py +0 -0
  15. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/class_mapSubstrateObj.py +0 -0
  16. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/class_rectObj.py +0 -0
  17. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/class_sonObj.py +0 -0
  18. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/class_sonObj_nadirgaptest.py +0 -0
  19. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/default_params.json +0 -0
  20. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/funcs_common.py +0 -0
  21. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/funcs_rectify.py +0 -0
  22. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/test_PINGMapper.py +0 -0
  23. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper/test_time.py +0 -0
  24. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper.egg-info/SOURCES.txt +0 -0
  25. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper.egg-info/dependency_links.txt +0 -0
  26. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper.egg-info/requires.txt +0 -0
  27. {pingmapper-5.0.14 → pingmapper-5.0.15}/pingmapper.egg-info/top_level.txt +0 -0
  28. {pingmapper-5.0.14 → pingmapper-5.0.15}/setup.cfg +0 -0
  29. {pingmapper-5.0.14 → pingmapper-5.0.15}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pingmapper
3
- Version: 5.0.14
3
+ Version: 5.0.15
4
4
  Summary: Open-source interface for processing recreation-grade side scan sonar datasets and reproducibly mapping benthic habitat
5
5
  Author: Cameron Bodine, Daniel Buscombe
6
6
  Author-email: bodine.cs@gmail.email
@@ -63,10 +63,29 @@ try:
63
63
  from doodleverse_utils.imports import *
64
64
  from doodleverse_utils.model_imports import *
65
65
  from doodleverse_utils.prediction_imports import *
66
- except ImportError:
66
+ except ImportError as e:
67
+ import traceback
68
+ print('\n' + '='*80)
67
69
  print('Could not import Doodleverse Utils. Please install these packages to use PING-Mapper.')
68
70
  print('They are not needed for GhostVision. Trying to continue...')
69
- pass
71
+ print('\nDetailed error information:')
72
+ print('-'*80)
73
+ print(f'Error Type: {type(e).__name__}')
74
+ print(f'Error Message: {str(e)}')
75
+ print('-'*80)
76
+ traceback.print_exc()
77
+ print('='*80 + '\n')
78
+ except Exception as e:
79
+ import traceback
80
+ print('\n' + '='*80)
81
+ print('Unexpected error while importing Doodleverse Utils.')
82
+ print('Detailed error information:')
83
+ print('-'*80)
84
+ print(f'Error Type: {type(e).__name__}')
85
+ print(f'Error Message: {str(e)}')
86
+ print('-'*80)
87
+ traceback.print_exc()
88
+ print('='*80 + '\n')
70
89
 
71
90
  import geopandas as gpd
72
91
 
@@ -874,6 +893,14 @@ class portstarObj(object):
874
893
  --------------------
875
894
  self._depthZheng() or self._depthThreshold()
876
895
  '''
896
+
897
+ # Check if depth detection dependencies are available
898
+ if not DEPTH_DETECTION_AVAILABLE:
899
+ raise ImportError(
900
+ "TensorFlow, Transformers, and/or Doodleverse Utils are not installed. "
901
+ "These packages are required for automatic depth detection. "
902
+ "Please install them using: pip install tensorflow transformers doodleverse-utils"
903
+ )
877
904
 
878
905
  # Open model configuration file
879
906
  with open(self.configfile) as f:
@@ -59,6 +59,9 @@ import itertools
59
59
  # from doodleverse_utils.model_imports import *
60
60
  # from doodleverse_utils.prediction_imports import *
61
61
 
62
+ # Flag to track if depth detection dependencies are available
63
+ DEPTH_DETECTION_AVAILABLE = False
64
+
62
65
  try:
63
66
  import tensorflow as tf
64
67
  import tensorflow.keras.backend as K
@@ -74,10 +77,33 @@ try:
74
77
  from doodleverse_utils.imports import *
75
78
  from doodleverse_utils.model_imports import *
76
79
  from doodleverse_utils.prediction_imports import *
77
- except ImportError:
80
+
81
+ DEPTH_DETECTION_AVAILABLE = True
82
+ except ImportError as e:
83
+ import traceback
84
+ print('\n' + '='*80)
78
85
  print('Could not import Tensorflow and/or Transformers. Please install these packages to use PING-Mapper.')
79
86
  print('They are not needed for GhostVision. Trying to continue...')
80
- pass
87
+ print('\nDetailed error information:')
88
+ print('-'*80)
89
+ print(f'Error Type: {type(e).__name__}')
90
+ print(f'Error Message: {str(e)}')
91
+ print('-'*80)
92
+ traceback.print_exc()
93
+ print('='*80 + '\n')
94
+ DEPTH_DETECTION_AVAILABLE = False
95
+ except Exception as e:
96
+ import traceback
97
+ print('\n' + '='*80)
98
+ print('Unexpected error while importing depth detection dependencies.')
99
+ print('Detailed error information:')
100
+ print('-'*80)
101
+ print(f'Error Type: {type(e).__name__}')
102
+ print(f'Error Message: {str(e)}')
103
+ print('-'*80)
104
+ traceback.print_exc()
105
+ print('='*80 + '\n')
106
+ DEPTH_DETECTION_AVAILABLE = False
81
107
 
82
108
  ################################################################################
83
109
  # model_imports.py from segmentation_gym #
@@ -113,6 +139,13 @@ def initModel(weights, configfile, USE_GPU=False):
113
139
  --------------------
114
140
  self._detectDepth()
115
141
  '''
142
+
143
+ if not DEPTH_DETECTION_AVAILABLE:
144
+ raise ImportError(
145
+ "TensorFlow, Transformers, and/or Doodleverse Utils are not installed. "
146
+ "These packages are required for automatic depth detection. "
147
+ "Please install them using: pip install tensorflow transformers doodleverse-utils"
148
+ )
116
149
 
117
150
  SEED=42
118
151
  np.random.seed(SEED)
@@ -10,12 +10,6 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
10
10
  PACKAGE_DIR = os.path.dirname(SCRIPT_DIR)
11
11
  sys.path.append(PACKAGE_DIR)
12
12
 
13
- # # For Debug
14
- # from funcs_common import *
15
- # from main_readFiles import read_master_func
16
- # from main_rectify import rectify_master_func
17
- # from main_mapSubstrate import map_master_func
18
-
19
13
  from pingmapper.funcs_common import *
20
14
  from pingmapper.main_readFiles import read_master_func
21
15
  from pingmapper.main_rectify import rectify_master_func
@@ -35,12 +35,6 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
35
35
  PACKAGE_DIR = os.path.dirname(SCRIPT_DIR)
36
36
  sys.path.append(PACKAGE_DIR)
37
37
 
38
- # # For debug
39
- # from funcs_common import *
40
- # from class_mapSubstrateObj import mapSubObj
41
- # from class_portstarObj import portstarObj
42
- # from funcs_model import *
43
-
44
38
  from pingmapper.funcs_common import *
45
39
  from pingmapper.class_mapSubstrateObj import mapSubObj
46
40
  from pingmapper.class_portstarObj import portstarObj
@@ -36,12 +36,8 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
36
36
  PACKAGE_DIR = os.path.dirname(SCRIPT_DIR)
37
37
  sys.path.append(PACKAGE_DIR)
38
38
 
39
- # # For debug
40
- # from funcs_common import *
41
- # from class_sonObj import sonObj
42
- # from class_portstarObj import portstarObj
43
-
44
39
  from pingmapper.funcs_common import *
40
+ from pingmapper.funcs_model import DEPTH_DETECTION_AVAILABLE
45
41
  from pingmapper.class_sonObj import sonObj
46
42
  from pingmapper.class_portstarObj import portstarObj
47
43
 
@@ -49,10 +45,29 @@ import shutil
49
45
 
50
46
  try:
51
47
  from doodleverse_utils.imports import *
52
- except ImportError:
48
+ except ImportError as e:
49
+ import traceback
50
+ print('\n' + '='*80)
53
51
  print('Could not import Doodleverse Utils. Please install these packages to use PING-Mapper.')
54
52
  print('They are not needed for GhostVision. Trying to continue...')
55
- pass
53
+ print('\nDetailed error information:')
54
+ print('-'*80)
55
+ print(f'Error Type: {type(e).__name__}')
56
+ print(f'Error Message: {str(e)}')
57
+ print('-'*80)
58
+ traceback.print_exc()
59
+ print('='*80 + '\n')
60
+ except Exception as e:
61
+ import traceback
62
+ print('\n' + '='*80)
63
+ print('Unexpected error while importing Doodleverse Utils.')
64
+ print('Detailed error information:')
65
+ print('-'*80)
66
+ print(f'Error Type: {type(e).__name__}')
67
+ print(f'Error Message: {str(e)}')
68
+ print('-'*80)
69
+ traceback.print_exc()
70
+ print('='*80 + '\n')
56
71
 
57
72
  from scipy.signal import savgol_filter
58
73
 
@@ -839,7 +854,7 @@ def read_master_func(logfilename='',
839
854
  elif (att == "inst_dep_m") and (attAvg == 0): # Automatically detect depth if no instrument depth
840
855
  valid=False
841
856
  invalid[son.beam+"."+att] = False
842
- detectDep=0#1
857
+ detectDep=1
843
858
  else:
844
859
  valid=False
845
860
  invalid[son.beam+"."+att] = False
@@ -997,45 +1012,53 @@ def read_master_func(logfilename='',
997
1012
  del son
998
1013
 
999
1014
  chunks = np.unique(chunks).astype(int)
1000
-
1001
1015
  # # Automatically estimate depth
1002
1016
  if detectDep > 0:
1003
- print('\n\nAutomatically estimating depth for', len(chunks), 'chunks:')
1017
+ # Check if depth detection dependencies are available
1018
+ if not DEPTH_DETECTION_AVAILABLE:
1019
+ print('\n\nCannot estimate depth automatically:')
1020
+ print('TensorFlow, Transformers, and/or Doodleverse Utils are not installed.')
1021
+ print('These packages are required for automatic depth detection.')
1022
+ print('Please install them using: pip install tensorflow transformers doodleverse-utils')
1023
+ print('Skipping automatic depth estimation...\n')
1024
+ detectDep = 0
1025
+ else:
1026
+ print('\n\nAutomatically estimating depth for', len(chunks), 'chunks:')
1004
1027
 
1005
- #Dictionary to store chunk : np.array(depth estimate)
1006
- psObj.portDepDetect = {}
1007
- psObj.starDepDetect = {}
1028
+ #Dictionary to store chunk : np.array(depth estimate)
1029
+ psObj.portDepDetect = {}
1030
+ psObj.starDepDetect = {}
1008
1031
 
1009
- # Estimate depth using:
1010
- # Zheng et al. 2021
1011
- # Load model weights and configuration file
1012
- if detectDep == 1:
1032
+ # Estimate depth using:
1033
+ # Zheng et al. 2021
1034
+ # Load model weights and configuration file
1035
+ if detectDep == 1:
1013
1036
 
1014
- # Store configuration file and model weights
1015
- # These were downloaded at the beginning of the script
1016
- depthModelVer = 'Bedpick_Zheng2021_Segmentation_unet_v1.0'
1017
- psObj.configfile = os.path.join(modelDir, depthModelVer, 'config', depthModelVer+'.json')
1018
- psObj.weights = os.path.join(modelDir, depthModelVer, 'weights', depthModelVer+'_fullmodel.h5')
1019
- print('\n\tUsing Zheng et al. 2021 method. Loading model:', os.path.basename(psObj.weights))
1037
+ # Store configuration file and model weights
1038
+ # These were downloaded at the beginning of the script
1039
+ depthModelVer = 'Bedpick_Zheng2021_Segmentation_unet_v1.0'
1040
+ psObj.configfile = os.path.join(modelDir, depthModelVer, 'config', depthModelVer+'.json')
1041
+ psObj.weights = os.path.join(modelDir, depthModelVer, 'weights', depthModelVer+'_fullmodel.h5')
1042
+ print('\n\tUsing Zheng et al. 2021 method. Loading model:', os.path.basename(psObj.weights))
1020
1043
 
1021
- # With binary thresholding
1022
- elif detectDep == 2:
1023
- print('\n\tUsing binary thresholding...')
1044
+ # With binary thresholding
1045
+ elif detectDep == 2:
1046
+ print('\n\tUsing binary thresholding...')
1024
1047
 
1025
- # Parallel estimate depth for each chunk using appropriate method
1026
- r = Parallel(n_jobs=np.min([len(chunks), threadCnt]))(delayed(psObj._detectDepth)(detectDep, int(chunk), USE_GPU, tileFile) for chunk in tqdm(chunks))
1048
+ # Parallel estimate depth for each chunk using appropriate method
1049
+ r = Parallel(n_jobs=np.min([len(chunks), threadCnt]))(delayed(psObj._detectDepth)(detectDep, int(chunk), USE_GPU, tileFile) for chunk in tqdm(chunks))
1027
1050
 
1028
- # store the depth predictions in the class
1029
- for ret in r:
1030
- psObj.portDepDetect[ret[2]] = ret[0]
1031
- psObj.starDepDetect[ret[2]] = ret[1]
1032
- del ret
1033
- del r
1051
+ # store the depth predictions in the class
1052
+ for ret in r:
1053
+ psObj.portDepDetect[ret[2]] = ret[0]
1054
+ psObj.starDepDetect[ret[2]] = ret[1]
1055
+ del ret
1056
+ del r
1034
1057
 
1035
- # Flag indicating depth autmatically estimated
1036
- autoBed = True
1058
+ # Flag indicating depth autmatically estimated
1059
+ autoBed = True
1037
1060
 
1038
- saveDepth = True
1061
+ saveDepth = True
1039
1062
 
1040
1063
  # Don't estimate depth, use instrument depth estimate (sonar derived)
1041
1064
  elif detectDep == 0:
@@ -1067,9 +1090,10 @@ def read_master_func(logfilename='',
1067
1090
 
1068
1091
  sonDF['dep_m_Method'] = 'Instrument Depth'
1069
1092
  sonDF['dep_m_smth'] = False
1070
- sonDF['dep_m_adjBy'] = adjDep
1071
-
1093
+ sonDF['dep_m_adjBy'] = adjDep
1094
+
1072
1095
  dep = sonDF['inst_dep_m']
1096
+
1073
1097
  if smthDep:
1074
1098
  dep = savgol_filter(dep, 51, 3)
1075
1099
 
@@ -1077,11 +1101,23 @@ def read_master_func(logfilename='',
1077
1101
  dep[dep==0] = np.nan
1078
1102
  dep = np.asarray(dep)
1079
1103
  nans = np.isnan(dep)
1080
- dep[nans] = np.interp(np.flatnonzero(nans), np.flatnonzero(~nans), dep[~nans])
1081
1104
 
1082
- sonDF['dep_m'] = dep + adjDep
1105
+ # Only interpolate if there are valid (non-NaN) values
1106
+ if np.any(~nans):
1107
+ # There are some valid values, so we can interpolate
1108
+ dep[nans] = np.interp(np.flatnonzero(nans), np.flatnonzero(~nans), dep[~nans])
1109
+
1110
+ sonDF['dep_m'] = dep + adjDep
1111
+
1112
+ sonDF.to_csv(son.sonMetaFile, index=False, float_format='%.14f')
1113
+ else:
1114
+ # All values are NaN - cannot interpolate
1115
+ print("\nWarning: All instrument depth values are NaN or zero. Cannot interpolate depth.")
1116
+ print("This may indicate missing depth data in the sonar file.")
1117
+
1118
+ # sonDF['dep_m'] = dep + adjDep
1083
1119
 
1084
- sonDF.to_csv(son.sonMetaFile, index=False, float_format='%.14f')
1120
+ # sonDF.to_csv(son.sonMetaFile, index=False, float_format='%.14f')
1085
1121
  del sonDF, son.sonMetaDF
1086
1122
  son._cleanup()
1087
1123
 
@@ -38,12 +38,6 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
38
38
  PACKAGE_DIR = os.path.dirname(SCRIPT_DIR)
39
39
  sys.path.append(PACKAGE_DIR)
40
40
 
41
- # # For Debug
42
- # from funcs_common import *
43
- # from class_rectObj import rectObj
44
- # from class_portstarObj import portstarObj
45
- # from funcs_rectify import smoothTrackline
46
-
47
41
  from pingmapper.funcs_common import *
48
42
  from pingmapper.class_rectObj import rectObj
49
43
  from pingmapper.class_portstarObj import portstarObj
@@ -0,0 +1 @@
1
+ __version__ = '5.0.15'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pingmapper
3
- Version: 5.0.14
3
+ Version: 5.0.15
4
4
  Summary: Open-source interface for processing recreation-grade side scan sonar datasets and reproducibly mapping benthic habitat
5
5
  Author: Cameron Bodine, Daniel Buscombe
6
6
  Author-email: bodine.cs@gmail.email
@@ -1 +0,0 @@
1
- __version__ = '5.0.14'
File without changes
File without changes
File without changes
File without changes