This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathquickLook.py
executable file
·130 lines (110 loc) · 4.35 KB
/
quickLook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# -*- coding: utf-8 -*-
"""
author: kristine m. larson
wrapper for the quickLook function code
#
"""
import sys
import os
import numpy as np
import matplotlib.pyplot as plt
# i do not think these are used
#import warnings
#warnings.filterwarnings("ignore")
#import cProfile
import gps as g
import argparse
import scipy.interpolate
import scipy.signal
import read_snr_files as snr
import quickLook_function as quick
# my internal codes for the refraction correction, which are based on
# codes from TU Vienna. currently turned off for quickLook
# import refraction as refr
# i think this is only used for MJD, so turned off in quickLook
# import datetime
# 2019 Sep 24 added error checking on inputs
#
# user inputs the observation file information
parser = argparse.ArgumentParser()
# required arguments
parser.add_argument("station", help="station", type=str)
parser.add_argument("year", help="year", type=int)
parser.add_argument("doy", help="doy", type=int)
parser.add_argument("snrEnd", help="snrEnding", type=int)
# these are the addons (not required)
parser.add_argument("-fr", "--fr", default=None, type=int, help="try -fr 1 for GPS L1 only, or -fr 101 for Glonass L1")
parser.add_argument("-amp", "--amp", default=None, type=float, help="try -amp 10 for minimum spectral amplitude")
parser.add_argument("-e1", "--e1", default=None, type=int, help="lower limit elevation angle")
parser.add_argument("-e2", "--e2", default=None, type=int, help="upper limit elevation angle")
parser.add_argument("-h1", "--h1", default=None, type=float, help="lower limit reflector height (m)")
parser.add_argument("-h2", "--h2", default=None, type=float, help="upper limit reflector height (m)")
parser.add_argument("-sat", "--sat", default=None, type=float, help="satellite")
parser.add_argument("-peak2noise", "--peak2noise", default=None, type=float, help="peak2noise")
args = parser.parse_args()
#
# rename the user inputs as variables
#
station = args.station
year = args.year
doy= args.doy
snr_type = args.snrEnd
plt_screen = 1 # always have a plot come to screen
exitS = g.check_inputs(station,year,doy,snr_type)
if exitS:
sys.exit()
InputFromScreen = True
# peak to noise value is one way of defining that significance (not the only way).
# For snow and ice, 3.5 or greater, tides can be tricky if the water is rough (and thus
# you might go below 3 a bit.
PkNoise = 3.0
# set some reasonable default values for LSP (Reflector Height calculation).
# some of these can be overriden
# at the command line
freqs = [1] # default is to do L1
pele = [5, 30] # polynomial fit limits
Hlimits = [0.5, 6] # RH limits in meters - this is typical for a snow setup
elval = [5,25] # elevation angle limits for estimating LSP
NReg = [0.5, 6] # noise region - again, this is for typical snow setup
# look at the four geographic quadrants to get started - these are azimuth angles
azval = [0, 90, 90,180, 180, 270, 270, 360]
reqAmp = [8] # this is arbitrary - but generally true for L1 instruments
twoDays = False
# if user inputs these, then it overrides the default
if (args.e1 != None):
elval[0] = args.e1
if elval[0] < 5:
print('have to change the polynomial limits because you went below 5 degrees')
print('this restriction is for quickLook only ')
pele[0] = elval[0]
if (args.e2 != None):
elval[1] = args.e2
# elevation angle limit values for the Lomb Scargle
e1 = elval[0]; e2 = elval[1]
print('Start out using elevation angles: ', e1, ' and ', e2)
print('you can change with e1 and e2 if you like')
print('Refraction correction is not used by quickLook code')
if (args.peak2noise != None):
PkNoise = args.peak2noise
if (args.h1 != None):
Hlimits[0] = args.h1
if (args.h2 != None):
Hlimits[1] = args.h2
if (args.sat != None):
sat = int(args.sat)
else:
sat = None
# minimum and maximum LSP limits
minH = Hlimits[0]; maxH = Hlimits[1]
# this is for when you want to run the code with just a single frequency, i.e. input at the console
# rather than using the input restrictions
if args.fr != None:
freqs = [args.fr]
if args.amp != None:
reqAmp[0] = args.amp
print('Using reflector height limits (m) : ', Hlimits[0], ' and ', Hlimits[1], ' and Ampl:', reqAmp[0])
# maybe here call a function
f=freqs[0]
webapp = False
print('calling the function that does everything')
quick.quickLook_function(station, year, doy, snr_type,f,e1,e2,minH,maxH,reqAmp,pele,webapp,sat,PkNoise)