lalframe Cache maker tool using python
lalframe
LALFrame is LAL wrapping of the LIGO/Virgo Frame library and, is necessary to read / write GWF files.
lalframe Chache file structure
K K1_C 1195700000 32 file://localhost/frames/full/11957/K-K1_C-1195700000-32.gwf K K1_C 1195700032 32 file://localhost/frames/full/11957/K-K1_C-1195700032-32.gwf K K1_C 1195700064 32 file://localhost/frames/full/11957/K-K1_C-1195700064-32.gwf K K1_C 1195700096 32 file://localhost/frames/full/11957/K-K1_C-1195700096-32.gwf K K1_C 1195700128 32 file://localhost/frames/full/11957/K-K1_C-1195700128-32.gwf K K1_C 1195700160 32 file://localhost/frames/full/11957/K-K1_C-1195700160-32.gwf . . .
mkCache.py
This code creates the Cache file every 300 seconds.
To use this Python tool continuously in the background, run it in the following way.
$ nohup python -u mkCache.py &
Add the following code, and if you login after the reboot, the program will run.
$ sudo vi ~/.profile (sleep 10 && /usr/local/bin/python /home/detchar/Cache/mkcache.py ) & # Insert this line
BUT, If the latest cache file is not created, re-run mkCache.py using the nohup code above.
Cache file direction in KAGRA k1det1
[detchar@k1det1~]$ cd /home/detchar/Cache [detchar@k1det1 Cache]$ ls K1-Cache.cache mkCache.py nohup.out
Cache file direction in KAGRA seikai
In seikai, only the ikagra data cache is stored.
[user@seikai~]$ cd /home/detchar/Cache/ikagra_cache/ [user@seikai Cache]$ ls ikagra_cachefile.cache mkCache.py
Code of mkCache.py in k1det1
1 # Coded by Jung Pil-Jong :: scilavinka.aptunus@gmail.com
2
3 from os import listdir
4 import time
5
6
7 ########## Making gwf Cache file ##########
8
9 def job() :
10
11 basedir = "/frames/full/"
12
13 ls_out = []
14
15 full_listdir = sorted(listdir(basedir))
16 full_listdir.remove('99999')
17 gwf_listdir = []
18
19 for n in range(len(full_listdir)) :
20 try :
21 if type(int(full_listdir[n])) == int and int(full_listdir[n]) < 99999 :
22 gwf_listdir.append(full_listdir[n])
23 else :
24 pass
25 except ValueError as err :
26 pass
27
28 gwf_listdir.sort()
29
30 for m in range(len(gwf_listdir)) :
31 subdir = basedir + str(gwf_listdir[m])
32 gwf_lists = sorted(listdir(subdir))
33 for i in range(len(gwf_lists)) :
34 if gwf_lists[i][-3:] == 'gwf' :
35 ls_out.append(' '.join( gwf_lists[i].split('.')[0].split('-') ) + ' file://localhost'+subdir+'/'+gwf_lists[i] )
36 else :
37 pass
38 ls_out.sort()
39
40 f = open('./K1-Cache.cache', 'w')
41 f.write('\n'.join(ls_out))
42 f.close()
43
44
45 ########## Auto run cache file maker during 300 second ##########
46
47 if __name__ == '__main__' :
48 while True :
49 job()
50 time.sleep(300)