-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdocker_inspecz.py
63 lines (46 loc) · 2.18 KB
/
docker_inspecz.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
def inspecz(config):
import os
import sys
from catalog_io import get_catalog, select_sample, check_buffer_version
from verify import Verify
'''
The interactive version of inspecz allows the deletions of previous buffer files,
after ther the selection of the sample has been changed in the configuration file.
This script is adjusted to work within a docker container:
1. no interactive messages in the command line
2. verifies the consistency of the buffer and configuration files
3. inspection parameter 'vstatus' is always _resume_
In order to start a new sample selection, the buffer_* files must be removed manually.
'''
print(f"Sample selection:")
print(f"-verified: {config['view_verified']}")
print(f"-zphot state: {config['vzphot_outlier']}")
print(f"-redshift range: {config['vzmin']}<z<{config['vzmax']}")
print(f"-sampling: {config['vsample_percent']}%")
# resume always on for Docker version
config['vstatus']=='resume'
buffer_name = os.path.join(config['buffer_path'], config['buffer_name'])
buffer_config_name = '.'.join(buffer_name.split('.')[:-1])+'.yaml'
if os.path.exists( buffer_name ):
# Check for consistency between input and buffer selection, if exists
if os.path.exists( buffer_config_name ):
with open(buffer_config_name,'r') as fin:
buffer_config = yaml.load(fin, Loader=yaml.FullLoader)
# ignore vstatus=new/resume from buffer config file during consistency check
buffer_config.pop('vstatus')
resp = check_buffer_version(buffer_config, config)
if resp == 0 :
raise ValueError(f'Inconsistent input and buffer files. Remove previous buffer file:\n{buffer_config_name}')
fcat = get_catalog(config)
s1 = Verify(fcat, config)
s1.verify(show=True)
if __name__ == '__main__':
import sys
import time
import yaml
try:
yaml_file = open(sys.argv[1], 'r')
except:
yaml_file = open("config_files/dockerConfig.yaml", 'r')
config = yaml.load(yaml_file, Loader=yaml.FullLoader)
inspecz(config)