gnssrefl.gps module
- gnssrefl.gps.LSPresult_name(station, year, doy, extension)
makes name for the Lomb Scargle output
- Parameters:
station (str) – 4 ch station name
year (int) – full year
doy (int) – day of year
extension (str) – name of subdirectory for results
- Returns:
filepath1 (str) – where Lomb Scargle output goes
fileexists (bool) – whether output already exists
- gnssrefl.gps.UNR_highrate(station, year, doy)
picks up the 5 minute time series from UNR website for a given station
- Parameters:
station (str) – 4 character station name
year (int) – full year
doy (int) – day of year
- Returns:
filename (str) – output filename
goodDownload (bool) – whether your download was successful
- gnssrefl.gps.arc_scaleF(f, satNu)
calculates LSP scale factor cf , the wavelength divided by 2
- Parameters:
f (integer) – satellite frequency
satNu (integer) – satellite number (1-400)
- Returns:
cf – GNSS wavelength/2 (meters)
- Return type:
float
- gnssrefl.gps.avoid_cddis(year, month, day)
work around for people that can’t use CDDIS ftps this will get multi-GNSS files for GFZ from the IGN hopefully
- Parameters:
year (int) – full year
month (int) – month of the year
day (int) – calendar day
- Returns:
filename (str) – name of the orbit file
fdir (str) – where the orbit file is stored
foundit (bool) – whether it was found or not
- gnssrefl.gps.azimuth_angle(RecSat, East, North)
Given cartesian Receiver-Satellite vectors, and East and North unit vectors, computes azimuth angle
- Parameters:
RecSat (3-vector) – meters
East (3-vector) – unit vector in east direction
North (3-vector) – unit vector in north direction
- Returns:
azangle – azimuth angle in degrees
- Return type:
float
- gnssrefl.gps.back2thefuture(iyear, idoy)
code checks that this is not a day in the future also rejects data before the year 2000
- Parameters:
iyear (int) – full year
idoy (int) – day of year
- Returns:
badDay – whether your day exists (yet)
- Return type:
bool
- gnssrefl.gps.bfg_data(fstation, year, doy, samplerate=30, debug=False)
Picks up a RINEX3 file from BFG network
- Parameters:
fstation (string) – 4 char station ID
year (integer) – year
doy (integer) – day of year
samplerate (integer) – sample rate of the receiver (default is 30)
debug (boolean) – directory file listing provided if true default is false
- gnssrefl.gps.bfg_password()
Picks up BFG userid and password that is stored in a pickle file in your REFL_CODE/Files/passwords area If it does not exist, it asks you to input the values and stores them for you.
- Returns:
userid (str) – BFG username
password (str) – BFG password
- gnssrefl.gps.big_Disk_in_DC_hourly(station, year, month, day, idtag)
Picks up a one hour RINEX file from CORS. and gunzips it
- Parameters:
station (str) – 4 ch station name
year (int) – full year
month (int) – calendar month
day (integer) – day of the month. if zero, it means month is really day of year
idtag (str) – small case letter from a to x; tells the code which hour it is
- gnssrefl.gps.big_Disk_work_hard(station, year, month, day, delete_hourly)
Attempts to pick up subdaily RINEX 2.11 files from the NGS archive creates a single RINEX file
If day is 0, then month is presumed to be the day of year
Requires gfzrnx for merging.
- Parameters:
station (str) – 4 char station name
year (int) – year
month (int) – month
day (integer) – day
delete_hourly (bool) – whether hourly files are deleted
- gnssrefl.gps.binary(string)
changes python string to bytes for use in fortran code using f2py via numpy input is a string, output is bytes with null at the end
- gnssrefl.gps.cdate2nums(col1)
returns fractional year from ch date, e.g. 2012-02-15 if time is blank, return 3000
- Parameters:
col1 (str) – date in yyyyy-mm-dd, 2012-02-15
- Returns:
t – fractional date, year + doy/365.25
- Return type:
float
- gnssrefl.gps.cdate2ydoy(col1)
returns year and day of year from character date, e.g. ‘2012-02-15’
- Parameters:
col1 (str) – date in yyyyy-mm-dd, 2012-02-15
- Returns:
year (int) – full year
doy (int) – day of year
- gnssrefl.gps.cddis_download_2022B(filename, directory)
Nth iteration of download code for CDDIS
- Parameters:
filename (str) – name of the rinex file or orbit file
directory (str) – where the file lives at CDDIS
- gnssrefl.gps.cddis_download_2022B_new(filename, directory)
download code for CDDIS using https and password
- Parameters:
filename (str) – name of the rinex file or orbit file
directory (str) – where the file lives at CDDIS
- gnssrefl.gps.cddis_password()
Picks up cddis userid and password that is stored in a pickle file in your REFL_CODE/Files/passwords area If it does not exist, it asks you to input the values and stores them for you.
- Returns:
userid (str) – cddis username
password (str) – cddis password
- gnssrefl.gps.cddis_restriction(iyear, idoy, archive)
CDDIS has announced a restructuring of their archive. After 6 months files are tarred. It would be ok for the code to accommodate this change, but it will have to come from the community. If six months has passed since you ran the code, a warning will come to the screen and the code will exit.
updated now that i realize BKG does the same thing
- Parameters:
iyear (int) – year you want to download from CDDIS
idoy (int) – day of year you want to download from CDDIS
archive (str) – name of archive
- Returns:
bad_day – if bad_day is true, you cannot access high-rate data from CDDIS or BKG
- Return type:
bool
- gnssrefl.gps.char_month_converter(month)
integer month to 3 character month
- Parameters:
month (int) – integer month (1-12)
- Returns:
month – three char month, uppercase
- Return type:
str
- gnssrefl.gps.checkEGM()
Downloads and stores EGM96 file in REFL_CODE/Files for use in refl_zones
- Returns:
foundfile – whether EGM96 file was found (or installed) on your local machine
- Return type:
bool
- gnssrefl.gps.checkFiles(station, extension)
apparently no one consistently checks for the Files directory existence. this is an attempt to fix that.
- Parameters:
station (str) – 4 ch station ID
extension (str) – subdirectory for results in $REFL_CODE/Files/station
- gnssrefl.gps.check_environ_variables()
Checks to see if you have set the expected environment variables used in gnssrefl
- gnssrefl.gps.check_inputs(station, year, doy, snr_type)
inputs to Lomb Scargle and Rinex translation codes are checked for sensibility. Returns true or false to code can exit.
- Parameters:
station (str) – 4 ch station name
year (int) – full year
doy (int) – day of year
snr_type (int) – snr file type (e.g. 66)
- Returns:
exitSys – whether fatal error is trigger by a bad choice
- Return type:
bool
Check to see if you already have the nav file. Uncompresses it if necessary
- Parameters:
year (int) – full year
month (int) – month or doy if day is zero
day (int) – day of month or 0
- Returns:
foundit – whether nav file has been found
- Return type:
boolean
- gnssrefl.gps.confused_obstimes(tvd)
this will be slow (and should be fixed)
- Parameters:
tvd (numpy array) – results of LSP results
- Returns:
modifiedjulian – modified julian date values
- Return type:
numpy array of floats
- class gnssrefl.gps.constants
Bases:
object
- bei_L2 = 1561.098
- bei_L5 = 1176.45
- bei_L6 = 1268.52
- bei_L7 = 1207.14
- c = 299792458
- fL1 = 1575.42
- fL2 = 1227.6
- fL5 = 1176.45
- gal_L1 = 1575.42
- gal_L5 = 1176.45
- gal_L6 = 1278.7
- gal_L7 = 1207.14
- gal_L8 = 1191.795
- mu = 398600500000000.0
- omegaEarth = 7.2921151467e-05
- wL1 = 0.19029367279836487
- wL2 = 0.24421021342456825
- wL5 = 0.25482804879085386
- wbL2 = 0.19203948631027648
- wbL5 = 0.25482804879085386
- wbL6 = 0.2363324646044209
- wbL7 = 0.2483493695843067
- wgL1 = 0.19029367279836487
- wgL5 = 0.25482804879085386
- wgL6 = 0.23445097208101978
- wgL7 = 0.2483493695843067
- wgL8 = 0.251547000952345
- gnssrefl.gps.dec31(year)
Calculates the day of year for December 31
- Parameters:
input (integer) – year
- Returns:
doy – day of year for December 31
- Return type:
integer
- gnssrefl.gps.define_and_xz_snr(station, year, doy, snr)
finds and checks for existence of a SNR file uncompresses if that is needed (xz or gz)
- Parameters:
station (str) – station name, 4 characters
year (int) – full year
doy (int) – day of year
snr (int) – kind of snr file (66,77, 88 etc)
- Returns:
fname (str) – full name of the SNR file
fname2 (str) – no longer used but kept for backwards capability
snre (bool) – whether the file exists or not
- gnssrefl.gps.define_logdir(station, year, doy)
creates logfile name and directory (for rinex2snr) given a station, year and day of year
- Parameters:
station (str) – 4 ch station name
year (int) – full year
doy (int) – day of year
- gnssrefl.gps.define_quick_filename(station, year, doy, snr)
defines SNR File name
- Parameters:
station (str) – 4 ch station name
year (int) – full year
doy (int) – day of year
snr (int) – snr file type (66,88, etc)
- Returns:
f – SNR filename
- Return type:
str
- gnssrefl.gps.diffraction_correction(el_deg, temp=20.0, press=1013.25)
Computes and return the elevation correction for refraction in the atmosphere such that the elevation of the satellite plus the correction is the observed angle of incidence.
Based on an empirical model by G.G. Bennet. This code was provided by Chalmers Group, Joakim Strandberg and Thomas Hobiger Bennett, G. G. The calculation of astronomical refraction in marine navigation. Journal of Navigation 35.02 (1982): 255-259.
- Parameters:
el_deg (array_like) – A vector of true satellite elevations in degrees for which the correction is calculated.
temp (float, optional) – Air temperature at ground level in degrees celsius, default 20 C.
press (float, optional) – Air pressure at ground level in hPa, default 1013.25 hPa.
- Returns:
corr_el_deg – The elevation correction in degrees.
- Return type:
1d-array
- gnssrefl.gps.doy2ymd(year, doy)
- Parameters:
year (int) –
doy (int) – day of year
- Returns:
d
- Return type:
datetime object
- gnssrefl.gps.elev_angle(up, RecSat)
computes satellite elevation angle
- Parameters:
up (3 vector float) – unit vector in the up direction
RecSat (3 vector numpy) – Cartesian vector pointing from receiver to satellite in meters
- Returns:
angle – elevation angle in radians
- Return type:
float
- gnssrefl.gps.fdoy2mjd(year, fdoy)
calculates modified julian day from year and fractional day of year
- Parameters:
year (int) – full year
fdoy (float) – fractional day of year
- Returns:
mjd – modified julian day
- Return type:
float
- gnssrefl.gps.final_gfz_orbits(year, month, day)
downloads gfz final orbit and stores in $ORBITS
- Parameters:
year (int) – full year
month (int) – month or day of year if day is set to zero
day (int) – day of month
- Returns:
littlename (str) – orbit filename, fdir, foundit
fdir (str) – directory where the orbit file is stored locally
foundit (bool) – whether the file was found
- gnssrefl.gps.findConstell(cc)
determine constellation integer value
- Parameters:
cc (string is one character (from rinex satellite line)) –
- constellation definition:
G : GPS R : Glonass E : Galileo C : Beidou
- Returns:
out – value added to satellite number for our system, 0 for GPS, 100 for Glonass, 200 for Galileo, 300 for everything else
- Return type:
integer
- gnssrefl.gps.find_satlist_wdate(f, snrExist, year, doy)
find satellite list for a given frequency and date
- Parameters:
f (integer) – frequency
snrExist (numpy array, bool) – tells you if a signal is (potentially) legal
year (int) – full year
doy (int) – day of year
- Returns:
satlist (numpy list of integers) – satellites to use
june 24, 2021 (updated for SVN78)
- gnssrefl.gps.freq_out(x, ofac, hifac)
- Parameters:
x (numpy array) – sine(elevation angle)
ofac (float) – oversamping factor
hifac (float) – how far to calculate RH frequencies (in meters)
- Returns:
pd – frequencies
- Return type:
float numpy arrays
- gnssrefl.gps.ftitle(freq)
makes a frequency title for plots
- Parameters:
freq (int) – GNSS frequency
- Returns:
returnf – nice string for the constellation/frequency for the title of a plot
- Return type:
str
- gnssrefl.gps.ga_highrate(station9, year, doy, dec, deleteOld=True)
Attempts to download highrate RINEX 3 files from GA
- Parameters:
station9 (str) – nine character station name appropriate for rinex 3
year (int) – full year
doy (int) – day of year
dec (int) – decimation value. 1 or 0 means no decimation
deleteOld (bool) – whether to delete old rinex 3 files
- Returns:
rinex2 (string) – rinex2 filename created by merging 96 files!
fexist (boolean) – whether a rinex2 file was successfully created
- gnssrefl.gps.gbm_orbits_direct(year, month, day)
downloads gfz multi-gnss orbits, aka gbm orbits, directly from GFZ. thus avoids CDDIS. it first checks to see if you have the files online. both version of the long name.
- Parameters:
year (int) – full year
month (int) – month number or day of year if day is set to zero
day (int) – calendar day of month
- gnssrefl.gps.geoidCorrection(lat, lon)
Calculates the EGM96 geoid correction
- Parameters:
lat (float) – latitude, degrees
lon (float) – longitude, degrees
- Returns:
geoidC – geoid correction in meters
- Return type:
float
- gnssrefl.gps.getMJD(year, month, day, fract_hour)
- Parameters:
year (int) –
month (int) –
day (int) –
fract_hour (float) – hour (fractional)
- Returns:
mjd – modified julian day
- Return type:
float
Tries to download navigation file from CDDIS Renames it to my convention (auto0010.22n)
- Parameters:
navfile (str) – name of GPS broadcast orbit file
cyyyy (str) – 4 char year
cyy (str) – 2 char year
cdoy (str) – 3 char day of year
- Returns:
navfile – full path of the stored navigation file
- Return type:
str
downloads GPS broadcast navigation file from ESA tries both Z and gz compressed
- Parameters:
cyyyy (str) – 4 char year
cdoy (str) – 3 char day of year
- Returns:
fstatus – whether file was found or not
- Return type:
bool
- gnssrefl.gps.get_noaa_obstimes(t)
Needs to be be fixed for new file structure
- Parameters:
t (list of integers) – year, month, day, hour, minute, second
- Returns:
obstimes – datetime format
- Return type:
list
- gnssrefl.gps.get_noaa_obstimes_plus(t, **kwargs)
given a list of time tags (y,m,d,h,m,s), it calculates datetime objects and modified julian days
- Parameters:
t (numpy array) – our water level format where year, month, day, hour, minute, second are in the first columns
- Returns:
obstimes (list of datetime obj) – list of timetags
modjulian (list of floats) – modified julian date
- gnssrefl.gps.get_obstimes(tvd)
Calculates datetime objects for times associated with LSP results file contents, i.e. the variable created when you read in the results file.
- Parameters:
tvd (numpy array) – results of LSP results
- Returns:
obstimes – datetime objects
- Return type:
numpy array
- gnssrefl.gps.get_obstimes_plus(tvd)
send a LSP results file, so the variable created when you read in the results file. return obstimes for matplotlib plotting purposes 2022jun10 - added MJD output
See get_obstimes 2024apr06 too slow because I was using np.append
- Parameters:
tvd (numpy array) – contents of Lomb Scargle data processing
- Returns:
obstimes (list of datetime objects) – times of observations
modjulian (list of floats) – modified julian days
- gnssrefl.gps.get_ofac_hifac(elevAngles, cf, maxH, desiredPrec)
Computes two factors - ofac and hifac - that are inputs to the Lomb-Scargle Periodogram code. We follow the terminology and discussion from Press et al. (1992) in their LSP algorithm description.
- Parameters:
elevAngles (numpy of floats) – vector of satellite elevation angles in degrees
cf (float) – (L-band wavelength/2 ) in meters
maxH (int) – maximum LSP grid frequency in meters
desiredPrec (float) – the LSP frequency grid spacing in meters i.e. how precise you want he LSP reflector height to be estimated
- Returns:
ofac (float) – oversampling factor
hifac (float) – high-frequency factor
- gnssrefl.gps.get_orbits_setexe(year, month, day, orbtype, fortran)
picks up and stores orbits as needed. It also sets executable location for translation (gpsonly vs multignss)
- Parameters:
year (int) – full year
month (int) – calendar month
day (int) – calendar day
orbtype (str) – orbit source, e.g. nav, gps…
fortran (bool) – whether you are using fortran code for translation
- Returns:
foundit (bool) – whether orbit file was found
f (str) – name of the orbit file
orbdir (str) – location of the orbit file
snrexe (str) – location of SNR executable. only relevant for fortran users
downloads navigation file from SOPAC
- Parameters:
navfile (string) – name of GPS broadcast orbit file
cyyyy (string) – 4 char year
cyy (string) – 2 char year
cdoy (string) – 3 char day of year
- Returns:
navfile – should be the same name as input. not logical! I have no idea why i did it this way.
- Return type:
string
downloads navigation file from SOPAC to be used in a cron job
- Parameters:
yyyy (int) – full year
doy (int) – day of year
- Returns:
filefound – whether file is found
- Return type:
bool
- gnssrefl.gps.get_wuhan_orbits(year: int, month: int, day: int) [<class 'str'>, <class 'str'>, <class 'bool'>]
Downloads ultra-rapid Wuhan sp3 file and stores them in $ORBITS
- Parameters:
year (int) – full year
month (int) – month or day of year
day (int) – day or if set to 0, then month is really day of year
- Returns:
unzipped_filename (str) – name of the sp3 orbit file
orbit_dir (str) – name of the file directory where orbit is stored
foundit (bool) – whether file was found
picks up nav file and stores it in the ORBITS directory
- Parameters:
year (int) – full year
month (int) – if day is zero, the month value is really the day of year
day (int) – day of the month
- Returns:
navname (string) – name of navigation file
navdir (string) – location of where the nav file should be stored
foundit (bool) – whether the file was found
picks up nav file from a specific archive and stores it in the ORBITS directory
- Parameters:
year (integer) – full year
month (int) – calendar month, or day of year
day (int) – day of the month, or zero
archive (str) – name of the GNSS archive. currently allow sopac and esa
- Returns:
navname (str) – name of navigation file (should always be auto???0.yyn, so unclear to me why it is sent)
navdir (str) – location of where the file has been stored
foundit (bool) – whether the file was found
- gnssrefl.gps.getseries(site)
originally from brendan crowell. picks up two UNR time series - stores in subdirectory called tseries input is station name (four character, lower case)
- gnssrefl.gps.getsp3file(year, month, day)
retrieves IGS sp3 precise orbit file from CDDIS
- Parameters:
year (integer) – full year
month (integer) – calendar month
day (integer) – calendar day
- Returns:
name (str) – filename for the orbits
fdir (str) – directory for the orbits
- gnssrefl.gps.getsp3file_flex(year, month, day, pCtr)
retrieves sp3files returns the name of the orbit file and its directory from CDDIS only gets the old-style filenames
- Parameters:
year (integer) –
month (integer) –
day (integer) –
pCtr (string) – 3 character orbit processing center
- Returns:
name (str) – filename for the orbits
fdir (str) – directory for the orbits
fexist (bool) – whether the orbit file was successfully found
- gnssrefl.gps.getsp3file_mgex(year, month, day, pCtr)
retrieves MGEX sp3 orbit files
- Parameters:
year (integer) –
month (integer) –
day (integer) –
pCtr (string) – name of the orbit center
- Returns:
name (str) – orbit filename
fdir (str) – file directory
foundit (bool)
- gnssrefl.gps.gfz_version()
Finds location of the gfzrnx executable
- Returns:
gfzv – name/location of gfzrnx executable
- Return type:
str
- gnssrefl.gps.glonass_channels(f, prn)
Retrieves appropriate wavelength for a given Glonass satellite
- Parameters:
f (int) – frequency( 101 or 102)
prn (int) – satellite number
- Returns:
l (float) – wavelength for glonass satellite in meters
logic from Simon Williams
- gnssrefl.gps.gnssSNR_version()
Finds location of the GNSS to SNR executable
- Returns:
gpse – location of gnssSNR executable
- Return type:
str
- gnssrefl.gps.gpsSNR_version()
Finds location of the gps to SNR executable
- Returns:
gpse – location of gpsSNR executable
- Return type:
str
- gnssrefl.gps.hatanaka_version()
Finds the Hatanaka decompression executable
- Returns:
hatanakav – name/location of hatanaka executable
- Return type:
str
- gnssrefl.gps.hatanaka_warning()
- Return type:
warning about missing Hatanaka executable
- gnssrefl.gps.highrate_nz(station, year, month, day)
NO LONGER SUPPORTED picks up a high-rate RINEX 2.11 file from GNS New zealand requires teqc to convert/merge the files
- Parameters:
station (str) – station name
year (int) – full year
month (int) – month or day of year
day (int) – day or zero
- gnssrefl.gps.ign_orbits(filename, directory, year)
Downloads sp3 files from the IGN archive
- Parameters:
filename (str) – name of the sp3 file
directory (str) – location of orbits at the IGN
year (int) – full year
- Returns:
foundit – whether sp3 file was found
- Return type:
bool
- gnssrefl.gps.ign_rinex3(station9ch, year, doy, srate)
Downloads a RINEX 3 file from IGN
- Parameters:
station9ch (str) – 9 character station name
year (int) – full year
doy (int) – day of year
srate (int) – sample rate
- Returns:
fexist – whether file was downloaded
- Return type:
bool
- gnssrefl.gps.igsname(year, month, day)
returns the name of an IGS orbit file
- Parameters:
year (integer) – four character year
month (integer) –
day (integer) –
- Returns:
name (str) – IGS orbit name
clockname (string) – COD clockname
- gnssrefl.gps.inout(c3gz)
Takes a Hatanaka rinex3 file that has been gzipped gunzips it and decompresses it
- Parameters:
c3gz (string) – name of a gzipped hatanaka compressed RINEX 3 filename
- Returns:
translated (boolean) – whether file was successfully translated or not
rnx (string) – filename of the uncompressed and de-Hatanaka’ed RINEX file
- gnssrefl.gps.is_it_legal(freq)
checks whether the frequency list set by the user in gnssir is legal
- Parameters:
freq (list of integers) – frequencies you want to check
Returns –
-------- –
legal (bool) – whether it is legal or not
- gnssrefl.gps.kgpsweek(year, month, day, hour, minute, second)
Calculates GPS week and GPS second of the week There is another version that works on character string. I think (kgpsweekC)
Examples
- kgpsweek(2023,1,1,0,0,0)
returns 2243 and 0
- Parameters:
year (int) – full year
month (int) – calendar month
day (int) – calendar day
hour (int) – hour of the Day (gps time)
minute (int) – minutes
second (int) – seconds
- Returns:
GPS_wk (int) – GPS week
GPS_sec_wk (int) – GPS second of the week
- gnssrefl.gps.kgpsweekC(z)
converts RINEX timetag line into integers/float
- Parameters:
z (str) – timetag from rinex file (YY MM DD MM SS.SSSS )
- Returns:
gpsw (integer) – GPS week
gpss (integer) – GPS seconds
- gnssrefl.gps.l2c_l5_list(year, doy)
Creates a satellite list of L2C and L5 transmitting satellites for a given year/doy
- Parameters:
year (int) – full year
doy (integer) – day of year
- Returns:
l2csatlist (numpy array (int)) – satellites possibly transmittingL2C
l5satlist (numpy array (int)) – satellites possibly transmitting L5
- gnssrefl.gps.llh2xyz(lat, lon, height)
converts llh to Cartesian values
- Parameters:
lat (float) – latitude in degrees
lon (float) – longitude in degrees
height (float) – ellipsoidal height in meters
- Returns:
x (float) – X coordinate (m)
y (float) – Y coordinate (m)
z (float) – Z coordinate (m)
Ref (Decker, B. L., World Geodetic System 1984,)
Defense Mapping Agency Aerospace Center.
modified from matlab version kindly provided by CCAR
- gnssrefl.gps.make_azim_choices(alist)
not used yet
- Parameters:
alist (list of floats) – azimuth pairs - must be even number of values, i.e. [amin1, amax1, amin2, amax2]
azval (list of floats) – azimuth regions for lomb scargle periodograms
input year and it makes sure output directories are created for orbits
- Parameters:
yyyy (int) – year
- gnssrefl.gps.make_snrdir(year, station)
makes various directories needed for SNR file/analysis outputs
- Parameters:
year (int) – full year
station (str) – 4 ch station name
- gnssrefl.gps.mjd(y, m, d, hour, minute, second)
calculate the integer part of MJD and the fractional part.
- Parameters:
year (int) – full year
month (int) – calendar month
day (int) – calendar day
hour (int) – hour of day
minute (int) – minute of the day
second (int) – second of the day
- Returns:
mjd (float) – modified julian day of y-m-d
fracDay (float) – fractional day
using information from http (//infohost.nmt.edu/~shipman/soft/sidereal/ims/web/MJD-fromDatetime.html)
- gnssrefl.gps.mjd_more(mmjd)
This is not working yet.
- Parameters:
mmjd (float) – mod julian date
- Returns:
year (int) – full year
mm (int) – month
dd (int) – day
doy (int) – day of year
- gnssrefl.gps.mjd_to_date(jd)
https://gist.github.com/jiffyclub/1294443
Converts Modified Julian Day to y,m,d
- Algorithm from Practical Astronomy with your Calculator or Spreadsheet
4th ed., Duffet-Smith and Zwart, 2011.
- Parameters:
jd (float) – Julian Day
- Returns:
year (int) – Year as integer. Years preceding 1 A.D. should be 0 or negative. The year before 1 A.D. is 0, 10 B.C. is year -9.
month (int) – Month as integer, Jan = 1, Feb. = 2, etc.
day (float) – Day, may contain fractional part.
- gnssrefl.gps.mjd_to_datetime(mjd)
- Parameters:
mjd (float) – modified julian date
- Returns:
dt
- Return type:
datetime object
- gnssrefl.gps.modjul_to_ydoy(MJD)
yet another data translation function. when will it end? Modified Julian Day to Year, Doy
Parameter
- MJD: float
modified julian day
- returns:
year (int) – full year
doy (int) – day of year
- gnssrefl.gps.month_converter(month)
brendan gave this to me - give it a 3 char month, returns integer
- gnssrefl.gps.more_confused_obstimes(tvd)
too slow
- Parameters:
tvd (numpy array of floats) – lsp results from a loadtxt command
- Returns:
modifiedjulian – mjd values
- Return type:
numpy array of floats
- gnssrefl.gps.myfavoritegpsobs()
returns list of GPS only SNR obs needed for gfzrnx.
- gnssrefl.gps.myfavoriteobs()
returns list of SNR obs needed for gfzrnx.
- gnssrefl.gps.myfindephem(week, sweek, ephem, prn)
# inputs are gps week, seconds of week # ephemerides and PRN number # returns the closest ephemeris block after the epoch # if one does not exist, returns the first one
- Parameters:
file (str) – nav filename
blocks (output is complicated - broadcast ephemeris) –
- gnssrefl.gps.myscan(rinexfile)
stripping the header code came from pyrinex. data are stored into a variable called table columns 0,1,2 are PRN, GPS week, GPS seconds, and observables rows are the different observations. these should be stored properly - this is a kluge
returns the name and location of the navigation file
- Parameters:
year (integer) –
month (integer) –
day (integer) –
- Returns:
navfilename (str) – name of the navigation file
navfiledir (str) – local directory where navigation file will be stored
retrieves navfile from either SOPAC or CDDIS
- Parameters:
navfile (str) – name of the broadcast orbit file
cyyyy (str) – 4 character yaer
cyy (string) – 2 character year
cdoy (str) – 3 character day of year
- Returns:
FileExists – whether the file was found
- Return type:
bool
- gnssrefl.gps.new_rinex3_rinex2(r3_filename, r2_filename, dec=1, gpsonly=False)
This code translates a RINEX 3 file into a RINEX 2.11 file. It is assumed that the gfzrnx exists and that the RINEX 3 file is Hatanaka uncompressed or compressed.
- Parameters:
r3_filename (str) – RINEX 3 format filename. Either Hatanaka compressed or uncompressed allowed
r2_filename (str) – RINEX 2.11 file
dec (integer) – decimation factor. If 0 or 1, no decimation is done.
gpsonly (bool) – whether you want only GPS signals. Default is false
- Returns:
fexists – whether the RINEX 2.11 file was created and exists
- Return type:
bool
- gnssrefl.gps.nextdoy(year, doy)
given a year/doy returns the subsequent year/doy
- Parameters:
year (int) – day of year
doy (int) – day of year
- Returns:
nyear (int) – next year
ndoy (int) – next day of year
- gnssrefl.gps.nicerTime(UTCtime)
Converts fractional time (hours) to HH:MM
- Parameters:
UTCtime (float) – fractional hours of the day
- Returns:
T – output as HH:MM
- Return type:
str
- gnssrefl.gps.norm(vect)
calculates magnitude of a vector
- Parameters:
vect (float) – vector
- Returns:
nv – norm of vect
- Return type:
float
- gnssrefl.gps.open_outputfile(station, year, doy, extension)
opens an output file in $REFL_CODE/year/results/station/extension directory for lomb scargle periodogram results
- Parameters:
station (str) – 4 ch station name
year (int) – full year
doy (int) – day of year
extension (str) – analysis extension name (for storage of results)
- Returns:
fileID – I don’t know the proper name of this - but what comes out when you open a file so you can keep writing to it
- Return type:
?
- gnssrefl.gps.open_plot(plt_screen)
is this used?
simple code to open a figure, called by gnssIR_lomb
- gnssrefl.gps.orbfile_cddis(name, year, secure_file, secure_dir, file2)
tries to download a file from a directory at CDDIS which it then stores it the year directory (with a given name)
- Parameters:
name (str) – the name of the orbit file you want to download from CDDIS
year (int) – full year
secure_file (str) – name of the file at CDDIS
secure_dir (str) – where the file lives at CDDIS
file2 (str) – name without the compression???
- Returns:
foundit (bool) – whether the file was found
now checks that file size is not zero. allows old file name downloads
- gnssrefl.gps.prevdoy(year, doy)
Given year and doy, return previous year and doy
- Parameters:
year (int) – full year
doy (int) – day of year
- Returns:
pyear (int) – previous year
pdoy (int) – previous day of year
- gnssrefl.gps.print_file_stats(ele, sat, s1, s2, s5, s6, s7, s8, e1, e2)
inputs
ele
sat
s1
s2
- gnssrefl.gps.propagate(week, sec_of_week, ephem)
inputs are GPS week, seconds of the week, and the appropriate ephemeris block from the navigation message returns the x,y,z, coordinates of the satellite and relativity correction (also in meters), so you add, not subtract
- gnssrefl.gps.queryUNR_modern(station)
Queries the UNR database for station coordinates that has been stored in sql. downloads the sql file and stores it locally if necessary
- Parameters:
station (str) – 4 character station name
- Returns:
lat (float) – latitude in degrees (zero if not found)
lon (float) – longitude in degrees (zero if not found)
ht (float) – ellipsoidal ht in meters (zzero if not found)
- gnssrefl.gps.quick_plot(plt_screen, gj, station, pltname, f)
inputs plt_screen variable (1 means go ahead) and integer variable gj which if > 0 there is something to plot also station name for the title pltname is png filename, if requested
- gnssrefl.gps.quickazel(gweek, gpss, sat, recv, ephemdata, localup, East, North)
assumes you have read in the broadcast ephemeris, know where your receiver is and the time (gps week, second of week)
- gnssrefl.gps.quickp(station, t, sealevel)
makes a quick plot of sea level prints the plot to the screen - it does not save it.
- Parameters:
station (str) – station name
t (numpy array in datetime format) – time of the sea level observations UTC
sealevel (list of floats) – meters (unknown datum)
- gnssrefl.gps.random() x in the interval [0, 1).
- gnssrefl.gps.randomfilename()
makes a string -length 9 - using random number generator. useful for filenames
- Returns:
rname – filename with nine random numerical characters
- Return type:
str
- gnssrefl.gps.rapid_gfz_orbits(year, month, day)
downloads gfz rapid orbit and stores in $ORBITS locally
- Parameters:
year (int) – full year
month (int) – month or day of year if day is set to zero
day (int) – day of month
- Returns:
littlename (str) – name of the orbit file
fdir (str) – name of the file directory where orbit is stored
foundit (bool) – whether file was found
- gnssrefl.gps.read_files(year, month, day, station)
- gnssrefl.gps.read_leapsecond_file(mjd)
reads leap second file and tries to figure out the UTC-GPS time offset needed for NMEA file users for the given MJD value
It will download and store the leap second file in REFL_CODE/Files if you don’t already have it.
- Parameters:
mjd (float) – Modified Julian Day for when you want to know the leap seconds since GPS began
- Returns:
offset – UTC-GPS time offset in seconds. This should be added to UTC to get GPS
- Return type:
int
- gnssrefl.gps.read_simon_williams(filename, outfilename)
Reads a PSMSL file and creates a new file in the standard format I use for tide gauge data in gnssrefl
- Parameters:
filename (str) – datafile of GNSS based water level measurements from the archive at PSMSL created by Simon Williams
outfilename (str) – where the rewritten data will go
- Returns:
outobstimes (datetime array) – time of observations
outmjd (numpy array of floats) – modified julian day
outsealevel (numpy array of floats) – sea level, meters
prn (numpy array of integers) – satellite numbers
fr (numpy array of integers) – frequency
az (numpy array of floats) – azimuth (degrees)
- gnssrefl.gps.read_sp3(file)
borrowed from Ryan Hardy, who got it from David Wiese …
- gnssrefl.gps.read_sp3file(file_path)
input: file_path is the sp3file name this code is from Joakim Strandberg I believe. It is for the python only version of the translator, which should be deprecated
- Returns:
sp3 (ndarray)
colums are satnum, gpsweek, gps_sow, x,y,z
x,y,z are in meters
satnum has 0, 100, 200, 300 added for gps, glonass, galileo,beidou,
respectively. all other satellites are ignored
- gnssrefl.gps.removeDC(dat, satNu, sat, ele, pele, azi, az1, az2, edot, seconds)
remove direct signal using given elevation angle (pele) and azimuth (az1,az2) constraints, return x,y as primary used data and windowed azimuth, time, and edot removed zero points, which 10^0 have value 1. used 5 to be sure?
- Parameters:
dat (numpy array of floats) – SNR data
satNu (float) – requested satellite number
sat (numpy array of floats) – satellite numbers
ele (numpy array of floats) – elevation angles, deg
pele (list of floats) – min and max elevation angles (deg)
azi (numpy array of floats) – azimuth angle, deg
az1 (float) – minimum azimuth angle (deg)
az2 (float) – maximum azimuth angle (deg)
edot (numpy array of floats) – derivative elevation angle (deg/sec)
seconds (numpy array of floatas) – seconds of the day
- Returns:
x (numpy array of floats) – sine of elevation angle ( i believed)
y (numpy array of floats) – SNR data in lineer units with DC component removed
sat (??) – not sure why this is sent and returned
azi (numpy array of flaots) – azimuth angles
seconds (numpy array of flaots) – seconds of the day
edot (numpy array of floats) – derivative of elevation angle
- gnssrefl.gps.replace_wget(url, f)
use requests instead of wget to download files this cannot be used for ftp addresses.
- Parameters:
url (str) – full path to file
f (str) – filename
- Returns:
success – whether file was found or not
- Return type:
bool
- gnssrefl.gps.result_directories(station, year, extension)
Creates directories for results
- Parameters:
station (str) – 4 ch station name
year (int) – full year
extension (str) – subdirectory for results (used for analysis strategy)
- gnssrefl.gps.rewrite_UNR_highrate(fname, station, year, doy)
takes a filename from was already retrieved? from UNReno, reads it, rewrites as all numbers for other uses. no header, but year, month, day, day of year, seconds vertical, east, north the latter three are in meters stores in $REFL_CODE/yyyy/pos/station
- gnssrefl.gps.rewrite_tseries(station)
given a station name, look at a daily blewitt position (ENV) file and write a new file that is more human friendly
- Parameters:
station (str) – 4 character station name
- gnssrefl.gps.rewrite_tseries_igs(station)
given a station name, look at a daily blewitt position (ENV) file and write a new file that is less insane to understand
- gnssrefl.gps.rewrite_tseries_wrapids(station)
given a station name, look at a daily blewitt position (ENV) file and write a new file that is less insane to understand
not sure what this does!
- gnssrefl.gps.rinex_ga_highrate(station, year, month, day)
no longer supported -
- Parameters:
station (str) – 4 character station ID, lowercase
year (int) – full year
month (int) – calendar month
day (integer) – day of the month
- gnssrefl.gps.rinex_jp(station, year, month, day)
Picks up RINEX file from Japanese GSI GeoNet archive URL : https://www.gsi.go.jp/ENGLISH/index.html
- Parameters:
station (str) – station name
year (int) – full year
month (int) – month or day of year
day (int) – day of month or zero
- gnssrefl.gps.rinex_name(station, year, month, day)
Defines rinex 2.11 file name
- Parameters:
station (str) – 4 character station ID
year (int) – full year
month (int) –
day (int) –
- Returns:
fnameo (str) – RINEX 2.11 name
fnamed – RINEX 2.11 name, Hatanaka compressed
- gnssrefl.gps.rinex_nrcan_highrate(station, year, month, day)
picks up 1-Hz RINEX 2.11 files from NRCAN requires gfzrnx or teqc to merge the 15 minute files
- Parameters:
station (string) – 4 character station name
year (integer) – year
month (integer) – month or day of year if day is set to zero
day (integer) – day
This is being used by the vegetation code picks up a RINEX 2.11 file from unavco low-rate area requires Hatanaka code
- Parameters:
station (str) – 4 ch station name
year (integer) – full year
month (integer) – month or day of year
day (integer) – day of month or zero
picks up a 1-Hz RINEX 2.11 file from unavco.
- Parameters:
station (str) – 4 ch station name
year (int) –
month (intr) –
day (int) –
- gnssrefl.gps.rot3(vector, angle)
- Parameters:
vector (3 vector) – float
angle (float) – radians
- Returns:
vector2 – float, original vector rotated by angle
- Return type:
3 vector
- gnssrefl.gps.save_plot(plotname)
save plot and send location info to the screen
- Parameters:
plotname (str) – name of output figure file
- gnssrefl.gps.set_subdir(subdir)
make sure that subdirectory exists for output files should return the directory name …
- Parameters:
subdir (str) – subdirectory in $REFL_CODE/Files
- gnssrefl.gps.snr_exist(station, year, doy, snrEnd)
check to see if the SNR file already exists uncompresses if necessary (gz or xz)
- Parameters:
station (str) – four character station name
year (int) – full year
doy (int) – day of year
snrEnd (str) – 2 character snr type, i.e. 66, 99
- Returns:
snre – whether SNR file exists.
- Return type:
boolean
- gnssrefl.gps.snr_name(station, year, month, day, option)
Defines SNR filename
- Parameters:
station (str) – 4 ch station name
year (int) –
month (int) –
day (int) –
option (int) – snr filename delimiter, i.e. 66
- Returns:
fname – snr filename
- Return type:
string
- gnssrefl.gps.sp3_name(year, month, day, pCtr)
defines old-style sp3 name
- Parameters:
year (int) –
month (int) –
day (int) –
pCtr (str) – Orbit processing center
- Returns:
sp3name (str) – old-style (lowercase) IGS name for sp3 file
sp3dir (str) – where file is stored locally
- gnssrefl.gps.store_orbitfile(filename, year, orbtype)
Stores orbit files locally
- Parameters:
filename (str) – orbit filename
year (int) – full year
orbtype (str) – kind of orbit (nav or sp3)
- Returns:
xdir – local directory where the orbit belongs
- Return type:
str
- gnssrefl.gps.store_snrfile(filename, year, station)
move an snr file to the right place
- Parameters:
filename (str) – name of SNR file
year (int) – full year
station (str) – 4 ch station name
- gnssrefl.gps.strip_compute(x, y, cf, maxH, desiredP, pfitV, minH)
strips snr data
- Parameters:
x (numpy array) – elevation angles in degrees
y (numpy array) – SNR data
cf (float) – scale factor for given frequency
maxH (float) – maximum reflector height in meters
desiredP (float) – precision of Lomb Scargle in meters
pfitV (integer) – polynomial order for DC model
minH (float) – minimum reflector height in meters
- Returns:
maxF (float) – maximum Reflector height (meters)
maxAmp (float) – amplitude of periodogram
eminObs (float) – minimum observed elevation angle in degrees
emaxObs (float) – maximum observed elevation angle in degrees
riseSet (integer) – 1 for rise and -1 for set
px (numpy array) – periodogram, x-axis, RH, meters
pz (numpy array) – periodogram, y-axis, volts/volts
- gnssrefl.gps.teqc_version()
Finds location of the teqc executable
- Returns:
gpse – location of teqc executable
- Return type:
str
- gnssrefl.gps.translate_dates(year, month, day)
i do not think this is used
- gnssrefl.gps.ultra_gfz_orbits(year, month, day, hour)
downloads rapid GFZ sp3 file and stores them in $ORBITS is this correct? or is the regular file?
- Parameters:
year (int) – full year
month (int) – month or day of year
day (int) – day or if set to 0, then month is really day of year
hour (int) – hour of the day
- Returns:
littlename (str) – name of the orbit file
fdir (str) – name of the file directory where orbit is stored
foundit (bool) – whether file was found
- gnssrefl.gps.unr_database(file1, file2, database_file)
Checks to see if the database lives in either file1 or file2 locations. Stem of the filename is third input, database_file
- Parameters:
file1 (str) – full name of database in $REFL_CODE/Files
file2 (str) – full name of database in local gnssrefl directory
database_file (str) – database file name
- Returns:
exists_now (bool) – whether you were successful in finding the database
database_location (str) – full name of the database you found and want to use going on
- gnssrefl.gps.up(lat, lon)
returns the up unit vector, and local east and north unit vectors needed for azimuth calc.
- Parameters:
latitude (float) – radians
longitude (float) – radians
- Returns:
East (three vector) – local transformation unit vector
North (three vector) – local transformation unit vector
- gnssrefl.gps.update_plot(plt_screen, x, y, px, pz)
is this used?
- plt_screenint
1 means update the plot
- xnumpy array of floats
elevation angles (deg)
- ynumpy array of floats
SNR data, volts/volts
- pxnumpy array of floats
periodogram, x-axis (meters)
- pznumpy array of floats
periodogram, y-axis
- gnssrefl.gps.update_quick_plot(station, f)
updates plot in quickLook
- Parameters:
station (str) – 4 ch name
f (int) – frequency
- gnssrefl.gps.warn_and_exit(snrexe, fortran)
if the GNSS/GPS to SNR executable does not exist, exit
- Parameters:
snrexe (str) – name of the executable
fortran (bool) – whether fortran is being used for translation
- class gnssrefl.gps.wgs84
Bases:
object
wgs84 parameters for Earth radius and flattening
- a = 6378137.0
- e = 0.08181919084262149
- f = 0.0033528106647474805
- gnssrefl.gps.window_data(s1, s2, s5, s6, s7, s8, sat, ele, azi, seconds, edot, f, az1, az2, e1, e2, satNu, pfitV, pele, screenstats)
window the SNR data for a given satellite azimuth and elevation angle range
also calculates the scale factor for various GNSS frequencies. currently returns meanTime in UTC hours and mean azimuth in degrees cf, which is the wavelength/2 currently works for GPS, GLONASS, GALILEO, and Beidou new: pele are the elevation angle limits for the polynomial fit. these are appplied before you start windowing the data
- Parameters:
s1 (numpy array) – SNR L1 data, floats
s2 (numpy array) – SNR L2 data, floats
s5 (numpy array) – SNR L5 data
s6 (numpy array floats) – SNR L6 data
s7 (numpy array floats) – SNR L7 data
s8 (numpy array floats) – SNR L8 data
sat (numpy array) – satellite number
ele (numpy array) – elevation angle (Degrees)
azi (numpy array) – azimuth angle (Degrees)
seconds (numpy array) – seconds of the day (GPS time)
edot (numpy array) – elev angle time rate of change (units?)
f (int) – requested frequency
az1 (float) – minimum azimuth limit, degrees
az2 (float) – maximum azimuth limit, degrees
e1 (float) – minimum elevation angle limit, degrees
e2 (float) – maximum elevation angle limit, degrees
satNu (int) – requested satellite number
pfitV (int) – polynomial order for DC fit
screenstats (bool) – Whether statistics come to the screen
- Returns:
x (numpy array of floats) – elevation angle, deg
y (numpy array of floats) – SNR, db-Hz
Nvv (int) – number of points in x
cf (float) – refl scale factor (lambda/2)
meanTime (float) – UTC hour of the arc
avgAzim (float) – average azimuth of the track (degrees)
outFact1 (float) – tan(elev)/elevdot, hours, from SNR file
outFact2 (float) – tan(elev)/elevdot, hours, from linear fit
delT (float) – track length in minutes
- gnssrefl.gps.write_QC_fails(delT, delTmax, eminObs, emaxObs, e1, e2, ediff, maxAmp, Noise, PkNoise, reqamp, tooclose2edge)
prints out various QC fails to the screen
- Parameters:
delT (float) – how long the satellite arc is (minutes)
delTmax (float) – max satellite arc allowed (minutes)
eminObs (float) – minimum observed elev angle (Deg)
emaxObs (float) – maximum observed elev angle (Deg)
e1 (float) – minimum allowed elev angle (deg)
e2 (float) – maximum allowed elev angle (deg)
ediff (float) – allowed min/max elevation diff from obs min/max elev angle (deg)
maxAmp (float) – measured peak LSP
Noise (float) – measured noise value for the periodogram
PkNoise (float) – required peak to noise
reqamp (float) – require peak LSP
tooclose2edge (bool) – wehther peak value is too close to begining or ending of the RH constraints
- gnssrefl.gps.xyz2llh(xyz, tol)
Computes latitude, longitude and height from XYZ (meters)
- Parameters:
xyz (list or np array) – X,Y,Z in meters
tol (float) – tolerance in meters for the calculation (1E-8 is good enough)
- Returns:
lat (float) – latitude in radians
lon (float) – longitude in radians
h (float) – ellipsoidal height in WGS84 in meters
- gnssrefl.gps.xyz2llhd(xyz)
Converts cartesian coordinates to latitude,longitude,height
- Parameters:
xyz (three vector of floats) – Cartesian position in meters
- Returns:
lat (float) – latitude in degrees
lon (float) – longitude in degrees
h (float) – ellipsoidal height in WGS84 in meters
- gnssrefl.gps.ydoy2datetime(y, doy)
translates year/day of year numpy array into datetimes for plotting
this was running slow for large datasets. changing to use lists and then asarray to numpy
- Parameters:
y (numpy array of floats) – full year
doy (numpy array of floats) – day of year
- Returns:
bigT – datetime objects
- Return type:
numpy array
- gnssrefl.gps.ydoy2mjd(year, doy)
calculates modified julian day from year and day of year
- Parameters:
year (int) – full year
doy (int) – day of year
- Returns:
mjd – modified julian day
- Return type:
float
- gnssrefl.gps.ydoy2useful(year, doy)
Calculates various dates
- Parameters:
year (int) – full year
doy (int) – day of year
- Returns:
year (int) – full year
month (int) – calendar month
day (integer) – calendar day
cyyyy (str) – four character year
cdoy (str) – three character day of year
YMD (str) – date as in ‘19-12-01’ for December 1, 2019
- gnssrefl.gps.ydoy2ymd(year, doy)
inputs: year and day of year (doy) returns: year, month, day
- gnssrefl.gps.ydoych(year, doy)
Converts year and doy to various character strings (two char year, 4 char year, 3 char day of year)
- Parameters:
year (int) – full year
doy (int) – day of year
- Returns:
cyyyy (str) – 4 character year
cyy (str) – 2 character year
cdoy (str) – 3 character day of year
- gnssrefl.gps.ymd2ch(year, month, day)
returns doy and character versions of year,month,day if day is zero, it assumes doy is in the month input
- Parameters:
year (int) – full year
month (int) – if day is zero this is day of yaer
day (int) – day of month or zero
- Returns:
month (int) – numerical month of the year
day (int) – day of the month
doy (int) – day of year
cyyyy (str) – 4 ch year
cyy (str) – 2 ch year
cdoy (str) – 4 ch year
- gnssrefl.gps.ymd2doy(year, month, day)
Calculates day of year and other date strings
- Parameters:
year (integer) – full year
month (integer) – month
day (integer) – day of the month
- Returns:
doy (int) – day of year
cdoy (str) – three character day of year
cyyyy (str) – four character year
cyy (str) – two character year
- gnssrefl.gps.ymd_hhmmss(year, doy, utc, dtime)
translates year, day of year and UTC hours into various other time parameters
- Parameters:
year (int) – full year
doy (int) – full year
UTC (float) – fractional hours
dtime (bool) – whether you want datetime object
- Returns:
bigT (datetime object)
year (int) – full year
month (int) – calendar month
day (int) – calendar day
hour (int) – hour of the day
minute (int) – minutes of the day
second (int) – seconds
- gnssrefl.gps.zenithdelay(h)
a very simple zenith troposphere delay in meters this is NOT to be used for precise geodetic applications
- Parameters:
h (float) – ellipsoidal (height) in meters
- Returns:
zd – simple zenith delay for the troposphere in meters
- Return type:
float