GNSS-VEL-95CI 1.0.3
A Python program for calculating the 95 percent CI for GNSS derived site velocities
Requires Python: >=3.6

# GNSS_VEL_95CI
A Python program for calculating the 95%CI for GNSS-derived site velocities, by B. Cornelison and G. Wang. The GNSS_Vel_95CI.py is a Python module for the calculation of the site velocity and its 95%CI for GNSS-derived daily displacement time series.
## Dependancies
You may need to install "statsmodels" on your computer if you have not used it before, which is the only dependency not in standard Python library.

**Install statsmodel example**:
```bash
pip install statsmodels
```
## Important Links
GitHub repositories: [GitHub1](https://github.com/bob-Github-2020), [Github2](https://github.com/BCornel)

**This module has two submodules which can be called as**:
```python
import GNSS-VEL-95CI.GNSS_VEL_95CI
import GNSS-VEL-95CI.Main_cal_95CI
```

GNSS_VEL_95CI is the main function for processing the GNSS data. Main_cal_95CI will search for all .col files in a directory and compute the data automatically. Plots and txt file outputs can be controlled in the function calls.
## Installation
Use the package manager [pip](https://pypi.org/project/GNSS-VEL-95CI/) to install GNSS_VEL_95CI
```bash
pip install GNSS_VEL_95CI
```
## Basic usage
### Case 1:
```python
from GNSS_Vel_95CI.Main_cal_95CI import main

# Process all data files in current directory and returns them to an output file
main()
```
### Case 2 (more advanced usage):
```python
import os
import pandas as pd
from GNSS_Vel_95CI.GNSS_Vel_95CI import cal_95CI

directory = './'
# get the pass
xdir = os.getcwd()  

# Check if there is an output directory (if not create one)
outDir = xdir+'/outputs/'   
if os.path.isdir(outDir):
print('Output directory detected')
pass 
else:
print('Making output directory')
os.mkdir(outDir)

for fin in os.listdir(directory):
if fin.endswith("neu_cm.col"):
print(fin)
GNSS = fin[0:4]    # station name, e.g., UH01
ts_enu = []
ts_enu = pd.read_csv (fin, header=0, delim_whitespace=True)
year = ts_enu.iloc[:,0]    # decimal year

dis = ts_enu.iloc[:,1]     # NS
result_NS=cal_95CI(year,dis,GNSS,outDir,DIR='NS',output='on', pltshow='on')
b_NS=round(result_NS[0],2)          # slope, or site velocity
b_NS_95CI=round(result_NS[1],2)      # The 95%CI of slope

dis = ts_enu.iloc[:,2]     # EW
result_EW=cal_95CI(year,dis,GNSS,outDir,DIR='EW',output='on',pltshow='on')
b_EW=round(result_EW[0],2)
b_EW_95CI=round(result_EW[1],2)

dis = ts_enu.iloc[:,3]     # UD
result_UD=cal_95CI(year,dis,GNSS,outDir,DIR='UD',output='on',pltshow='on')
b_UD=round(result_UD[0],2)
b_UD_95CI=round(result_UD[1],2)

else:
continue

```
## Example Figures
![MRHK_UD_ACF](https://user-images.githubusercontent.com/65426380/144933002-c7eeab12-a110-4031-93b2-120011c5340f.png)

![MRHK_UD_Decomposition](https://user-images.githubusercontent.com/65426380/144967345-ca5b2264-c82e-46cf-8eed-a23d8466f6f9.png)
## Detailed Method
[Methods_Vel_95CI.pdf](https://github.com/bob-Github-2020/GNSS_Vel_95CI/files/7664316/Methods_Vel_95CI.pdf)
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate and contact: bscornelison@gmail.com or bob.g.wang@gmail.com
## Citation
If you use GNSS_VEL_95CI in a scientific publication, we would appreciate citations to the following paper.
**Wang, G. (2022). The 95% Confidence Interval for GNSS-Derived Site Velocities, J. Surv. Eng. 2022, 148(1): 04021030. http://doi.org/10.1061/(ASCE)SU.1943-5428.0000390**
## Licence
[GNU](https://opensource.org/licenses/BSD-2-Clause)
```
Copyright (c) 2021 Brendan Cornelison, Guoquan Wang

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.