|
#!/usr/bin/env python
|
|
|
|
import re
|
|
import os
|
|
import sys
|
|
import shutil
|
|
|
|
|
|
|
|
#=====================
|
|
def modifyParamFile(filein, fileout, paramdict):
|
|
f = open(filein, 'r')
|
|
filestring = f.read()
|
|
f.close()
|
|
|
|
for key, value in paramdict.iteritems():
|
|
filestring = re.sub(key, value, filestring)
|
|
|
|
f = open(fileout, 'w')
|
|
f.write(filestring)
|
|
f.close()
|
|
|
|
#=====================
|
|
def createParamDict(params):
|
|
paramdict = { 'AP_windowsize_x':params['windowsize_x'],
|
|
'AP_windowsize_y':params['windowsize_y'],
|
|
'AP_sample': params['sample'],
|
|
'AP_thickness': params['thickness'],
|
|
'AP_cos_alpha': params['cos_alpha'],
|
|
'AP_lp_diam_x': params['lowpass_diameter_x'],
|
|
'AP_lp_diam_y': params['lowpass_diameter_y'],
|
|
'AP_lp_apod_x': params['lowpass_apod_x'],
|
|
'AP_lp_apod_y': params['lowpass_apod_y'],
|
|
'AP_hp_diam_x': params['highpass_diameter_x'],
|
|
'AP_hp_diam_y': params['highpass_diameter_y'],
|
|
'AP_hp_apod_x': params['highpass_apod_x'],
|
|
'AP_hp_apod_y': params['highpass_apod_y'],
|
|
'AP_corr_mode': params['corr_mode'],
|
|
'AP_raw_path': params['raw_path'] }
|
|
|
|
return paramdict
|
|
|
|
|
|
if __name__ == '__main__':
|
|
params = {}
|
|
params['windowsize_x'] = '1200'
|
|
params['windowsize_y'] = '1250'
|
|
params['sample'] = '4'
|
|
params['thickness'] = '800'
|
|
params['cos_alpha'] = '0.4305'
|
|
params['lowpass_diameter_x'] = '0.25'
|
|
params['lowpass_diameter_y'] = '0.25'
|
|
params['lowpass_apod_x'] = '0.05'
|
|
params['lowpass_apod_y'] = '0.05'
|
|
params['highpass_diameter_x'] = '0.001'
|
|
params['highpass_diameter_y'] = '0.001'
|
|
params['highpass_apod_x'] = '0.002'
|
|
params['highpass_apod_y'] = '0.002'
|
|
params['corr_mode'] = 'mcf'
|
|
params['raw_path'] = '/panfs/storage.local/imb/home/sstagg/scratch/11jul20a/s02/raw'
|
|
|
|
print params
|
|
|
|
paramdict = createParamDict(params)
|
|
|
|
modifyParamFile('test.param', 'testout22.param', paramdict)
|
|
|