-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.py
executable file
·51 lines (40 loc) · 1.18 KB
/
make.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
#!/usr/bin/env python
import os
from tqdm import tqdm
from glob import glob
import pandas as pd
from extraction import main as extract
from analysis import (
estimate_darkcount_rate_max_min,
estimate_darkcount_rate_random_charge,
)
out_dir = 'extraction_output'
os.makedirs(out_dir, exist_ok=True)
input_dir = 'observations'
for path in tqdm(glob(input_dir+'/*')):
# my own convention:
# digicamtoy MCs don't have a field named digicam_baseline
# So here we have to estimate the baseline ourselves.
if 'toy' in path:
use_digicam_baseline = False
else:
use_digicam_baseline = True
outpath = path.replace(input_dir, out_dir)+'.h5'
if not os.path.isfile(outpath):
extract(
input_file=path,
output_file=outpath,
use_digicam_baseline=use_digicam_baseline,
)
dfs = []
for path in glob(out_dir+'/*'):
df = estimate_darkcount_rate_max_min(path)
df['method'] = 'max_min'
df['path'] = path
dfs.append(df)
df = estimate_darkcount_rate_random_charge(path)
df['method'] = 'random_charge'
df['path'] = path
dfs.append(df)
df = pd.concat(dfs)
df.to_hdf('results.h5', key='all')