glitch-average 1.4.3
package containing glitch moving average script for ligo@cnu
Requires Python: >=3.9

# Running the glitch_average, formerly moving_average, script (version 1.4.3)

Once a new bash shell has been opened, log into the LIGO computing cluster and create the Conda environment. You can either clone the Github
repository to your local directory or use pip to install the package. Pip is recommended:<br />
<pre>
&nbsp;&nbsp;&nbsp;pip install glitch-average
</pre>
<br />
By using pip, the script will be available at all times and can be called by `moving-average args` in the terminal. If you instead
decide to clone the repository, you must navigate to the same project folder as __main__.py and run `python __main__.py args`. Before
running the script, however, you will have to give your LIGO credentials in order to retrieve the necessary data. Run the following in your shell:
<pre>
&nbsp;&nbsp;&nbsp;ligo-proxy-init <i>your-ligo-username</i>
</pre>
<br />
You will be prompted for your LIGO password, which after doing will enable you to run the script without encountering an error when retrieving the data.<br />

Below are the required arguments, in order. You can see these in the terminal by entering `glitch-average -h`<br />
&nbsp;&nbsp;&nbsp;`start time (in GPS or UTC)`<br />

&nbsp;&nbsp;&nbsp;`end time (in GPS or UTC)`<br />

There are also several optional arguments:<br />
&nbsp;&nbsp;&nbsp;`-o --output-dir`: output directory for timeseries and plots; defaults to the current directory<br />

&nbsp;&nbsp;&nbsp;`-d --detector`: detector to get omicron glitches from; defaults to 'L1' on Caltech and Livingston clusters and to 'H1' on Hanford cluster<br />

&nbsp;&nbsp;&nbsp;`-f --flag`: analysis flag to filter events by; defaults to "DMT-ANALYSIS_READY:1"<br />

&nbsp;&nbsp;&nbsp;`-al --averaging_length`: number of points to average; defaults to 30<br />

&nbsp;&nbsp;&nbsp;`-s --stride`: stride between created points in seconds; defaults to 60<br />

&nbsp;&nbsp;&nbsp;`-snr --snr_list`: list of snr integer values to use, entered as comma separated values or list notation ('5,6,7' or '[5,6,7]'); defaults to '[5,8,10,20]'<br />

&nbsp;&nbsp;&nbsp;`-g --glitch`: name of specific GravitySpy glitch to query; defaults to None<br />

Example of running the script:<br />
&nbsp;&nbsp;&nbsp;`glitch-average 'April 5, 2019' 'April 6, 2019' -o /home/username/public_html/ -d H1 -al 25 -s 90 -snr 7,9,12`<br />

Say you want a timeseries of the moving average of the rate of scattered light glitches in L1 on December 1 2019. You would input the following command:<br />
&nbsp;&nbsp;&nbsp;`glitch-average 'Dec 1, 2019' 'Dec 2, 2019 ' -o /home/username/public_html/ -al 25 -s 90 -snr 0 -g Scattered_Light`<br />
*Note: it is best to choose an snr of 0 in order to have a higher population to average*<br />

The program should spit out a TimeSeries .gwf, plot.png, and about.txt files at the directory specified by the -o argument. The about file shows the
timespan of the output TimeSeries file and the timespan that was input to the program. The plot.png file is a plot of the final TimeSeries produced.
The TimeSeries .gwf file can be input into the Lasso algorithm like so:<br />
&nbsp;&nbsp;&nbsp;`gwdetchar-lasso-correlation *start time* *end time* -t 0.0001 -o *path to output directory* -i *detector (L1/H1)* -P *any string - NOT IMPORTANT*-f *path to channels file* -pf *path to TimeSeries .gwf file from moving_average.py* -p SNR_0 -T minute -J 16 -j 10`<br />