gnssrefl.spline_functions module

gnssrefl.spline_functions.arc_plots(lspfigs, snrfigs, reflh, pgram, sat, datet, elvlims, elvt, snrdt, azdesc)

moved these individual plots out of the way

lspfigs : bool

snrfigs : bool

reflhnumpy array

reflector heights (m)

pgramnumpy array

periodogram ?

sat : numpy array

datet : datetime

elvlimslist of floats

min and max elev angle (deg)


dt (datetime) –



Return type:


gnssrefl.spline_functions.define_inputfile(station, year, doy, snr_ending)
  • station (str) – 4 ch name of station

  • year (integer) –

  • doy (int) – day of year

  • snr_ending (int) – file ending, e.g. 66, 99


  • snrfile (str) – name of snrfile

  • snrdir (str) – name of output directory

  • cyyyy (str) – four character year

  • cdoy (str) – three character day of year

gnssrefl.spline_functions.freq_out(x, ofac, hifac)

inputs: x ofac: oversamping factor hifac outputs: two sets of frequencies arrays

gnssrefl.spline_functions.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.

  • elevAngles (numpy array) – satellite elevation angles in degrees

  • cf (float) – L-band wavelength/2 in meters

  • maxH (float) – maximum LSP grid frequency in meters

  • desiredPrec (float) – the LSP frequency grid spacing in meters


  • ofac (float) – oversampling factor

  • hifac (float) – high-frequency factor

gnssrefl.spline_functions.glonasswlen(prn, signal)

Given PRN, returns glonass wavelength

  • prn (integer) – satellite number

  • signal (string) – L1 or L2 for glonass


wavelength – wavelength for the given signal

Return type:



needs documentation


gt (float) – gps time



Return type:



needs documentation

gnssrefl.spline_functions.invsnr_header(xdir, outfile_type, station, outfile_name)

Makes header for output of invsnr analysis

  • xdir (str) – directory for the output file

  • outfile_type (str) – csv or txt

  • station (str) – 4 character name

  • outfile_name (str) – name of output - if empty string, it uses default


  • fileID (file) – used for writing to file

  • usetxt (bool) – boolean for the code calling this function to use if you write out special files, they go in the working directory

gnssrefl.spline_functions.kristine_dictionary(alld, sat, xsignal)

22feb09 added beidou

gnssrefl.spline_functions.l2c_l5_list(year, doy)

for given year and day of year, returns a satellite list of L2C and L5 transmitting satellites

to update this numpy array, the data are stored in a simple triple of PRN number, launch year, and launch date. author: kristine larson date: march 27, 2021 june 24, 2021: updated for SVN78

this should point to

gnssrefl.spline_functions.loadsnrfile(snrfile, thedir)

loads the snr file , but does not pick out the signal. using two functions will make it easier to use more than one frequency

do time modification here now. column 4 is time since GPS began, in seconds

  • snrfile (str) – name of the SNR file

  • thedir (str) – location of the SNR file


snrdata – floats. Time (python col 3) is converted to fake gps time

Return type:

numpy array

gnssrefl.spline_functions.make_wavelength_column(nr, snrdata, signal)


  • nr (integer) – number of rows in snrdata

  • snrdata (numpy array) – snrfile array

  • signal (string) – frequency ‘L1’,’L2, etc


onecolumn – snr data for the requested signal

Return type:

one-d numpy array

gnssrefl.spline_functions.plot_tracks(rh_arr, rh_dn)

send the array of LSP results (rh_arr) with time variable for plotting (rh_dn) kl feb09 adding beidou

  • rh_arr (numpy array) – data used by inverse code. Need to add desc

  • rh_dn (numpy array) – data used by inverse code. Need to add desc

gnssrefl.spline_functions.readklsnrtxt(snrfile, thedir, signal)

parses the contents of a snrfile. The file itself is read in a separate function now; if SNR data are zero for a given signal, the row is eliminated

As of Oct 28, 2023, gzip after reading SNR file

  • snrfile (str) – variable with the file contents

  • thedir (str) – directory where it is located

  • signal (str) – ‘L1’, ‘L2’ etc.


snrdata – 0 : satellite, usual (100 added for glonass, 200 added for galileo) 1 : elev angle, deg 2 : azimuth angle, deg 3 : time in seconds since GPS began 4 : SNR data in db-Hz 5 : new column with wavelength in it, in meters.

Return type:

numpy array of floats . Columns defined as:

gnssrefl.spline_functions.residuals_cubspl_js(inparam, knots, satconsts, signal, snrdt_arr, final_list, Nfreq)

function needed for snr-fitting inverse analysis js must stand for joakim strandberg ???

this has to be modified for multi-frequency fspecdict and Nfreq 22feb09 added beidou

  • inparam

  • knots

  • satconsts

  • signal

  • snrdt_arr

  • final_list

  • Nfreq

gnssrefl.spline_functions.residuals_cubspl_spectral(kval, knots, rh_arr)

function needed for inverse analysis

  • kval

  • knots (numpy array) –

  • rh_arr (numpy array) – reflector heights in meters

gnssrefl.spline_functions.satfreq2waveL(satc, xsignal, fsatnos)

given satellite constellation (‘G’, ‘E’ …) xsignal (‘L1’,’L2’ …) satnos (satellite numbers) 2022feb09 added Beidou.

gnssrefl.spline_functions.save_lsp_results(datet, maxind, reflh_sub, sat, elvt, azit, pgram_sub, snrdt, pktn, isignal)

just cleaning up - move the temp_arr definition to a function each column is defined below.

  • datet (float) – seconds in GPSish time

  • reflh_sub (numpy of floats?) – windowed rh estimates

  • sat (int) – satellite number

  • elvt (numpy array of floats) – elevation angles(deg)

  • azit (numpy array of floats) – azimuth angles (deg)

  • snrdt (numpy array of floats) – detrended SNR data (DC component removed)

  • pktn (float) – peak 2 noise via Dave Purnell’s definition

  • isignal (int) – frequency, 1,2, or 5



Return type:

numpy array (12 columns)

gnssrefl.spline_functions.set_refraction_model(station, dmjd, lsp, imodel)

imodel is 1 for simple refraction model eventually will add other refraction models

Looks like this was copied from other code and should be consolidated …

  • station (str) – 4 ch station name

  • dmjd (float) – modified julian date

  • lsp (dictionary) – station information including latitude and longitude

  • imodel (integer) – set to 1 (time varying off) or 0 (time varying on)


  • p (float) – pressure (units?)

  • T (float) – temperature in deg C

  • irefr (int) – number value written to output files to keep track of refraction model

  • e (float) – water vapor pressure, hPa


turns signal input (e.g. L1+L2) to a list 22feb09 tried to add more frequencies …



Return type:


gnssrefl.spline_functions.simpleLSP(rhlims, lcar, precision, elvt, sinelvt, snrdt, sat, xsignal, screenstats, fout, pktnlim)
  • input

  • rhmax) (rhlims from dave's code (rhmin and) –

  • lcar (is gnss wavelength in m) –

  • periodogram (precision of the) –

  • meters (in) –

  • degrees (elvt - elevation angles in) –

  • sinelvt

  • angle (sine elevation) –

  • data (snrdt - detrended snr) –


just want to know how many true values there are in the a dictionary and then write them to a list, as in [‘G1’,’G2’] sure to be a better way - but this works for now

gnssrefl.spline_functions.snr2arcs(station, snrdata, azilims, elvlims, rhlims, precision, year, doy, signal='L1', normalize=False, snrfigs=False, lspfigs=False, polydeg=2, gaptlim=300, pktnlim=4, savefile=False, screenstats=False, l2c_only=False, satconsts=['G', 'R', 'E'], **kwargs)

reads an array of snr data (output from readklsnrtxt) and organises into: reflector height estimates, stats and detrended snr data for inverse analysis

  • station (str) – 4 ch station name

  • snrdata (numpy array) – contents of SNR datafile

  • azilims (list of floats) – azimuth angle limits (e.g., [90, 270])

  • elvlims (list of floats) – elevation angle limits (e.g., [5, 30])

  • rhlims (list of floats) – upper and lower reflector height limits (in metres) for quality control

  • signal (str) – default ‘L1’ (C/A), can also use L2…if want to use L5 or whatever else you need to make some edits

  • normalize (bool) – if you want to normalize the arcs so that they have the same amplitude

  • snrfigs (bool) – if you want to produce some figures of SNR arcs

  • lspfigs (bool) – if you want to produce some figures of Lomb-Scargle Periodograms

  • polydeg (float) – degree of polynomial for DC

  • gaptlim (float) – if there is a gap in time bigger than [gaptlim] seconds in a particular arc then it will be ignored

  • pktnlim (float) – peak to noise ratio qc condition = the peak of the LSP / mean of LSP within the range [rhlims]

  • savefile (bool) – if you want to save the output to a pickle file then use this parameter as the name (string)

  • kwargs (see below) –

  • tempres (int) – if want to use different temporal resolution to input data (in seconds)

  • satconsts (default use all given, otherwise specify from ['G', 'R', 'E'] (gps / glonass / galileo)) –


  • rh_arr (numpy array) – reflector height estimates and stats

  • snrdt_arr (numpy array) – detrended SNR data for inverse analysis

gnssrefl.spline_functions.snr2spline(station, year, doy, azilims, elvlims, rhlims, precision, kdt, snrfit=True, signal='L1', savefile=False, doplot=True, rough_in=0.1, **kwargs)

function analyzes a SNR file and outputs a fitted spline

note that the file must be 24 hours long or it will not work

  • station (str) – 4 ch station name

  • year (int) – full year

  • doy (int) – day of year

  • azilims (list of floats) – azimuth angle limits (e.g., [90, 270])

  • elvlims (list of floats) – elevation angle limits (e.g., [5, 30])

  • rhlims (list of floats) – upper and lower reflector height limits (in metres) for quality control e.g., [5, 10] is 5 and 10 m

  • precision (float) – precision of the periodogram (m)

  • kdt (float) – spline knot spacing in seconds

  • day (knots are spaced evenly except for at the start and end of the) –

  • spline (The idea is that you would ignore the first and last knots and then you could have a continuous) –

  • hours) (if kdt = 2 * 60 * 60 (2) –

  • 0h (then knots at) –

  • 1h

  • 3h

  • 21h (...) –

  • 23h

  • 24h

  • spline

  • days (with knots every 2 hours over multiple) –

  • snrfit (True or False if you want to do inverse modelling of the SNR data) –

  • signal ('L1', 'L2', currently under development) –

  • savefile (set True if you want to save the output to a file) –

  • doplot (set True if you want to produce a plot with the output from the analysis) –

  • rough_in ('roughness' parameter in the inverse modelling of SNR data (see Strandberg et al., 2016)) –

  • kwargs (see below) –

  • tempres (if want to use different temporal resolution to input data (in seconds)) –

  • satconsts (default use all given, otherwise specify from ['G', 'R', 'E'] (gps / glonass / galileo)) –


  • invout (dictionary) – outputs from inverse analysis

  • This documentation was provided by the original author, David Purnell