-
Notifications
You must be signed in to change notification settings - Fork 39
/
initialize.py
58 lines (47 loc) · 2.07 KB
/
initialize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# REDPy - Repeating Earthquake Detector in Python
# Copyright (C) 2016-2018 Alicia Hotovec-Ellis ([email protected])
# Licensed under GNU GPLv3 (see LICENSE.txt)
import redpy.config
import redpy.table
import argparse
import os
"""
Run this script first to initialize the hdf5 table where everything will be stored.
Warning: Running this script will overwrite an existing table with the same name defined
by filename in the .cfg file.
usage: initialize.py [-h] [-v] [-c CONFIGFILE]
optional arguments:
-h, --help show this help message and exit
-v, --verbose increase written print statements
-c CONFIGFILE, --configfile CONFIGFILE
use configuration file named CONFIGFILE instead of
default settings.cfg
"""
parser = argparse.ArgumentParser(description=
"Initialize hdf5 table using configuration, overwrites existing table defined in config")
parser.add_argument("-v", "--verbose", action="count", default=0,
help="increase written print statements")
parser.add_argument("-c", "--configfile",
help="use configuration file named CONFIGFILE instead of default settings.cfg")
args = parser.parse_args()
if args.configfile:
opt = redpy.config.Options(args.configfile)
if args.verbose: print("Using config file: {}".format(args.configfile))
else:
opt = redpy.config.Options("settings.cfg")
if args.verbose: print("Using config file: settings.cfg")
if args.verbose: print("Writing hdf5 table: {}".format(opt.filename))
redpy.table.initializeTable(opt)
if args.verbose: print("Creating folder to store images '{}{}'".format(opt.outputPath,
opt.groupName))
try:
os.mkdir('{}{}'.format(opt.outputPath,opt.groupName))
except OSError:
print("Folder exists.")
if args.verbose: print("Creating folder to store core images '{}{}/clusters'".format(
opt.outputPath,opt.groupName))
try:
os.mkdir('{}{}/clusters'.format(opt.outputPath,opt.groupName))
except OSError:
print("Folder exists.")
if args.verbose: print("Done")