def test_reader(self): for (dirpath, dirnames, filenames) in os.walk(self.filepath): print(dirpath) for f in filenames: filepath = os.path.join(dirpath, f) print(filepath) spec = r.read(filepath)
def setUp(self): self.c = c.Collection() self.bbpath = os.path.join(os.path.expanduser("~"), "data/specdal/Big_Bio_2014/20140611/") for f in os.listdir(self.bbpath): spec = r.read(os.path.join(self.bbpath, f)) if spec is not None: self.c.add_spectrum(spec)
def read(self, filepath, measure_type, verbose=False): ''' Read measurement from a file. ''' data, meta = read(filepath, verbose=verbose) self.metadata = meta if measure_type == 'pct_reflect' and 'pct_reflect' not in data: self.measurement = self.get_pct_reflect(data) return assert measure_type in data # TODO: handle this self.measurement = data[measure_type]
args = parser.parse_args() # make output directory outdir = os.path.abspath(args.outdir) figdir = os.path.join(outdir, 'figures') datadir = os.path.join(outdir, 'data') for d in (outdir, figdir, datadir): if not os.path.exists(d): os.makedirs(d) ################################################################################ # read files coll = c.Collection() for f in os.listdir(args.indir): filepath = os.path.join(args.indir, f) spec = r.read(filepath) coll.add_spectrum(spec) # resample if args.resampler: for spec in coll.spectra: spec = res.resample(spec, method=args.resampler) # stitch if args.stitcher: for spec in coll.spectra: spec = sti.stitch(spec, method=args.stitcher) # group by if args.group_by_separator: groups = coll.group_by_separator(*args.group_by_separator)