forked from sam-dixon/sn_multicollinearity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_sim_scripts.py
37 lines (31 loc) · 1.23 KB
/
gen_sim_scripts.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
import os
import numpy as np
SCRIPT_DIR = os.path.join(os.curdir, 'scripts')
SUBMIT_PATH = os.path.join(SCRIPT_DIR, 'submit_all.sh')
LOG_DIR = os.path.join(os.curdir, 'logs')
os.makedirs(SCRIPT_DIR, exist_ok=True)
os.makedirs(LOG_DIR, exist_ok=True)
os.chmod(SCRIPT_DIR, 0o0755)
os.chmod(LOG_DIR, 0o0755)
TEMPLATE = """#!/bin/bash
#$ -N mc_{alpha}_{beta}
#$ -l h=compute-2-1
#$ -e {curr_dir}/logs
#$ -o {curr_dir}/logs
/home/samdixon/anaconda3/bin/python {curr_dir}/sims.py --alpha {alpha} --beta {beta}"""
alphas = np.linspace(0.05, 0.2, 11)
betas = np.linspace(2.5, 3.5, 11)
for alpha in alphas:
submit_path = os.path.join(SCRIPT_DIR, 'submit_{:03.0f}.sh'.format(alpha*1000))
for beta in betas:
script_fname = '{:03.0f}_{:02.0f}.sh'.format(alpha*1000, beta*10)
script_path = os.path.join(SCRIPT_DIR, script_fname)
with open(script_path, 'w') as f:
props = {'alpha': np.round(alpha, 3),
'beta': np.round(beta, 1),
'curr_dir': os.path.abspath(os.curdir)}
f.write(TEMPLATE.format(**props))
with open(submit_path, 'a') as f:
f.write('qsub {}\n'.format(script_path))
f.write('sleep 0.5\n')
os.chmod(submit_path, 0o755)