-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit_paths.py
98 lines (76 loc) · 3.59 KB
/
init_paths.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
""" Creates empty directory structure for outputs and `atl02v/shared/paths.py`.
Should be run second after `setup.py`.
Author:
C.M. Gsoemeyer, July 2018
To Do:
Add the database setup to this script?
"""
import os
from datetime import datetime
def init_out_dirs():
"""
"""
# Get path for the `atl02v` package.
cwdir = os.getcwd()
# Build path names.
print("You will be prompted to type/paste an absolute path to a directory that will ")
print("hold your verification data and outputs. It will be named 'verification'.")
prompt = '> Absolute path : '
path_to_verification = input(prompt)
path_to_verification = create_dir(path_to_verification.strip(), 'verification')
# Create sub-paths.
path_to_data = create_dir(path_to_verification, 'data')
path_to_docs = create_dir(path_to_verification, 'docs')
path_to_outputs = create_dir(path_to_verification, 'outputs')
path_to_outputs_data = create_dir(path_to_outputs, 'data')
path_to_outputs_reports = create_dir(path_to_outputs, 'reports')
path_to_outputs_vfiles = create_dir(path_to_outputs, 'vfiles')
# Create readme's.
print("Creating readme's...")
readme_verification = open(os.path.join(path_to_verification, 'README.md'), 'w')
readme_verification.write("Directory generated by `init_out_dirs.py` on {}\n".format(datetime.now()))
readme_verification.close()
readme_data = open(os.path.join(path_to_data, 'README.md'), 'w')
readme_data.write("Contains test ATL01s, ATL02s, and calibration files from J. Lee.\n")
readme_data.close()
readme_docs = open(os.path.join(path_to_docs, 'README.md'), 'w')
readme_docs.write("Contains various documents related to verification testing.\n")
readme_docs.close()
readme_outputs = open(os.path.join(path_to_outputs, 'README.md'), 'w')
readme_outputs.write("Contains\n")
readme_outputs.write(" `data`, which holds the HDF5 and pickle files holding my TOD, TOF, TEP, Radiometry, etc. outputs, which are the equivalents to J. Lee's ATL02 file.\n")
readme_outputs.write(" `reports`, which holds the diff plots and statistics from comparing my outputs to J. Lee's.\n")
readme_outputs.write(" `vfiles`, which holds the verification input CSV files.\n")
readme_outputs.close()
# Write paths to atl02v/shared/paths.py
print("Writing paths to `atl02v/shared/paths.py`...")
pathspy = open(os.path.join(cwdir, 'atl02v', 'shared', 'paths.py'), 'a+')
pathspy.write("path_to_verification = '{}'\n".format(path_to_verification))
pathspy.write("path_to_data = '{}'\n".format(path_to_data))
pathspy.write("path_to_outputs = '{}'\n".format(path_to_outputs))
pathspy.write("path_to_atl02v = '{}'\n".format(cwdir))
pathspy.close()
print(" ")
print("Complete.")
print(" ")
print("Next steps (1/4): ")
print("ls {}".format(path_to_verification))
print("more {}".format(os.path.join(cwdir, 'atl02v', 'shared', 'paths.py')))
print(" ")
print("Next steps (2/4): ")
print("Remember to NEVER git commit `paths.py`! (the `.gitignore` is setup to ignore it)")
print(" ")
print("Next steps (3/4): ")
print("Add ATL01, ATL02, and calibration files into subdirectories in {}".format(path_to_data))
print(" ")
print("Next steps (4/4): ")
print("Obtain the ITOS database [TBA].")
def create_dir(basepath, dirname):
fullpath = os.path.join(basepath, dirname)
if not os.path.isdir(fullpath):
os.mkdir(fullpath)
print('Creating {}'.format(fullpath))
return fullpath
if __name__=='__main__':
init_out_dirs()