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 direction in KAGRA k1det1
[detchar@k1det1~]$ cd /home/detchar/Cache [detchar@k1det1 Cache]$ ls K1-Cache.cache mkCache.py nohup.out
=== Cache 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 from numpy import arange
5 import time
6
7
8 ########## Making gwf Cache file ##########
9
10 def job() :
11
12 basedir = "/frames/full/"
13
14 ls_out = []
15
16 full_listdir = sorted(listdir(basedir))
17 full_listdir.remove('99999')
18 gwf_listdir = []
19
20 for n in range(len(full_listdir)) :
21 try :
22 if type(int(full_listdir[n])) == int and int(full_listdir[n]) < 99999 :
23 gwf_listdir.append(full_listdir[n])
24 else :
25 pass
26 except ValueError as err :
27 pass
28
29 gwf_listdir.sort()
30
31 for m in range(len(gwf_listdir)) :
32 subdir = basedir + str(gwf_listdir[m])
33 gwf_lists = sorted(listdir(subdir))
34 for i in range(len(gwf_lists)) :
35 if gwf_lists[i][-3:] == 'gwf' :
36 ls_out.append(' '.join( gwf_lists[i].split('.')[0].split('-') ) + ' file://localhost'+subdir+'/'+gwf_lists[i] )
37 else :
38 pass
39 ls_out.sort()
40
41 f = open('./K1-Cache.cache', 'w')
42 f.write('\n'.join(ls_out))
43 f.close()
44
45
46 ########## Auto run cache file maker during 300 second ##########
47
48 if __name__ == '__main__' :
49 while True :
50 job()
51 time.sleep(300)