Skip to content

Commit

Permalink
Refs #114. more menaingful output dir name; deal with rare cases where
Browse files Browse the repository at this point in the history
metadata in images are wrong: /HFIR/CG1D/IPTS-20444/raw/ob/Sep_15_sCMOS/20180915_OB_0010_2325.tiff
  • Loading branch information
yxqd committed Sep 21, 2018
1 parent 76ce4fb commit df4efa2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/imars3d/CT_from_TIFF_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def autoreduce(
RunNo = int(meta['RunNo'])
GroupID = int(meta['GroupID'])
GroupSize = int(meta['GroupSize'])
fn = os.path.basename(ct_file_path)
if RunNo < GroupID + GroupSize - 1:
fn = os.path.basename(ct_file_path)
print("%s: Not the last file of the CT. skip" % fn)
return
if RunNo < GroupID + GroupSize - 1:
Expand All @@ -57,7 +57,12 @@ def autoreduce(
import shutil
shutil.rmtree(workdir)
if outdir is None:
outdir = os.path.join(autoreduce_dir, 'CT-group-%s' % GroupID)
fn2 = meta.get('FileNameStr', fn)
tokens = ['CT-group', str(GroupID), fn2]
sample_desc = meta.get('SampleDescStr')
if sample_desc: tokens.append(sample_desc)
outdirname = '-'.join(tokens)
outdir = os.path.join(autoreduce_dir, outdirname)
ct = CT(
ct_file_path,
workdir=workdir, outdir=outdir,
Expand Down Expand Up @@ -145,6 +150,9 @@ def _find_OB_DF_files(self, type, subdir, fail_on_not_found=True):
self.logger.debug("%s file %s is too old" % (type, e))
continue
md = readTIFMetadata(p)
if 'ExposureTime' not in md:
print("missing ExposureTime in %s" % p)
continue
et = float(md['ExposureTime'])
if not np.isclose(et, self.exposure_time):
self.logger.debug("%s file %s was exposed %s seconds, but CT was exposed %s seconds" % (
Expand Down

0 comments on commit df4efa2

Please sign in to comment.