From 2af48b410403214e6ec06e8de846b234b676acd1 Mon Sep 17 00:00:00 2001 From: Cameron Bodine Date: Fri, 12 Jul 2024 14:24:46 -0400 Subject: [PATCH] Specify exact chunk for transect mosaic #110 --- src/class_portstarObj.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/class_portstarObj.py b/src/class_portstarObj.py index 6500158..cb02085 100644 --- a/src/class_portstarObj.py +++ b/src/class_portstarObj.py @@ -404,7 +404,8 @@ def _createMosaicTransect(self, chunks = pd.unique(group[chunkField]) port_transect = [] for chunk in chunks: - img_path = os.path.join(portPath, '*{}.tif'.format(chunk)) + zero = self._addZero(chunk) + img_path = os.path.join(portPath, '*{}{}.tif'.format(zero, chunk)) img = glob(img_path)[0] port_transect.append(img) port.append(port_transect) @@ -419,7 +420,8 @@ def _createMosaicTransect(self, chunks = pd.unique(group[chunkField]) star_transect = [] for chunk in chunks: - img_path = os.path.join(starPath, '*{}.tif'.format(chunk)) + zero = self._addZero(chunk) + img_path = os.path.join(portPath, '*{}{}.tif'.format(zero, chunk)) img = glob(img_path)[0] star_transect.append(img) star.append(star_transect) @@ -438,12 +440,14 @@ def _createMosaicTransect(self, chunks = pd.unique(group[chunkField]) port_transect = [] for chunk in chunks: - try: - img_path = os.path.join(portPath, '*{}.tif'.format(chunk)) - img = glob(img_path)[0] - port_transect.append(img) - except: - pass + # try: + zero = self.port._addZero(chunk) + img_path = os.path.join(portPath, '*{}{}.tif'.format(zero, chunk)) + img = glob(img_path)[0] + print(img_path, img) + port_transect.append(img) + # except: + # pass port.append(port_transect) self.star._loadSonMeta() @@ -456,12 +460,13 @@ def _createMosaicTransect(self, chunks = pd.unique(group[chunkField]) star_transect = [] for chunk in chunks: - try: - img_path = os.path.join(starPath, '*{}.tif'.format(chunk)) - img = glob(img_path)[0] - star_transect.append(img) - except: - pass + # try: + zero = self.star._addZero(chunk) + img_path = os.path.join(portPath, '*{}{}.tif'.format(zero, chunk)) + img = glob(img_path)[0] + star_transect.append(img) + # except: + # pass star.append(star_transect) srcToMosaic = [list(itertools.chain(*i)) for i in zip(port, star)]