#!/bin/bash

macroframecache="/scratch4/saikat/S3/HLcachev04/H-754180505-754180921.cache"
macrosimcache="/scratch4/saikat/warrenwaveforms/HL-warren_sim-0-32.cache"
macroburstinjfile="HL-INJECTIONS_1_BURST-754180513-400.xml"
macrocalibrationcache="/ldas_outgoing/calibration/cache_files/H1-CAL-V02-751651244-757699245.cache"
macrochannelname="H1:LSC-AS_Q"
macrogpsstarttime="754180513"
macrothreshold="1.0e-35"
macrosimseconds="32"

function datafind() {
	LSCdataFind --gps-start-time ${macrogpsstarttime} --gps-end-time ${macrogpsendtime} --observatory H --type RDS_R_L3 --lal-cache --url-type file --match localhost >${macroframecache}
}

function power() {
     /home/saikat/src/lalapps/src/power/lalapps_power --window-length 32768 --low-freq-cutoff 130.0 --debug-level 65 --bandwidth 1024 --nsigma 2.0 --max-tileduration 0.25 --cluster --psd-average-method useMedian --resample-filter butterworth --event-limit 900 --gps-end-time ${macrogpsendtime} --threshold ${macrothreshold} --gps-start-time ${macrogpsstarttime} --high-pass 120.0 --max-tileband 32.0 --channel-name ${macrochannelname} --frame-cache ${macroframecache} --resample-rate 16384 --ram-limit 512 --gps-end-time-ns 0 --window-shift 8192 --filter-corruption 8192 --user-tag S3 --psd-average-points 548864 --default-alpha 0.5 --window 2 --tile-overlap-factor 2 --min-time-bin 2 --gps-start-time-ns 0 --min-freq-bin 2 --verbose --burstinjection-file ${macroburstinjfile} --calibration-cache ${macrocalibrationcache}
}

#6 seconds
macrogpsendtime="754180913"
#datafind
power

# 477 seconds
#macrogpsendtime="785307732"
#datafind
#power

# 953 seconds
#macrogpsendtime="785308208"
#datafind
#power

# 3809 seconds
#macrogpsendtime="785311064"
#datafind
#power

#echo "--window-length 32768 --gps-end-time ${macrogpsendtime} --low-freq-cutoff 70.0 --nsigma 2.0 --max-tileduration 0.25 --cluster --psd-average-method useMedian --resample-filter butterworth --event-limit 900 --threshold ${macrothreshold} --gps-start-time ${macrogpsstarttime} --psd-average-points 548864 --max-tileband 32.0 --channel-name ${macrochannelname} --frame-cache ${macroframecache} --resample-rate 16384 --ram-limit 512 --gps-end-time-ns 0 --window-shift 8192 --bandwidth 1024 --user-tag S3 --debug-level 65 --default-alpha 0.5 --window 2 --filter-corruption 8192 --min-time-bin 2 --gps-start-time-ns 0 --min-freq-bin 2 --tile-overlap-factor 2 --burstinjection-file ${macrosiminjfile} --calibration-cache ${macrocalibrationfile} --high-pass 60.0 --verbose --printData"

