API Reference
GNSS System Types
GNSSSignals.AbstractGNSS — Type
AbstractGNSS{C}Abstract supertype for all GNSS system types.
Concrete subtypes include GPSL1, GPSL5, and GalileoE1B. The type parameter C represents the code matrix type.
GNSSSignals.GPSL1 — Type
GPSL1{C} <: AbstractGNSS{C}GPS L1 C/A signal type.
GPS L1 uses BPSK (LOC) modulation with a 1023-chip C/A code at 1.023 Mcps, transmitted on the L1 carrier frequency of 1575.42 MHz.
Example
gpsl1 = GPSL1()
get_code_length(gpsl1) # 1023GNSSSignals.GPSL5 — Type
GPSL5{C} <: AbstractGNSS{C}GPS L5 signal type.
GPS L5 uses BPSK (LOC) modulation with a 10230-chip code at 10.23 Mcps and a 10-bit Neuman-Hofman secondary code, transmitted on the L5 carrier frequency of 1176.45 MHz.
Example
gpsl5 = GPSL5()
get_code_length(gpsl5) # 10230
get_secondary_code_length(gpsl5) # 10GNSSSignals.GalileoE1B — Type
GalileoE1B{C} <: AbstractGNSS{C}Galileo E1B signal type.
Galileo E1B uses CBOC(6,1,1/11) modulation with a 4092 chip code at 1.023 Mcps, transmitted on the E1 carrier frequency of 1575.42 MHz.
Modulation Types
GNSSSignals.LOC — Type
LOC()Legacy/BPSK modulation (no subcarrier).
Used for GPS L1 C/A and GPS L5 signals.
GNSSSignals.BOCsin — Type
BOCsin(m, n)Sine-phased Binary Offset Carrier modulation.
BOC(m,n) uses a subcarrier frequency of m * 1.023 MHz and a code rate of n * 1.023 Mcps.
Arguments
m: Subcarrier frequency multiplier (must be ≥ 1)n: Code rate multiplier (must be ≥ 1)
Example
boc11 = BOCsin(1, 1) # BOC(1,1)GNSSSignals.BOCcos — Type
BOCcos(m, n)Cosine-phased Binary Offset Carrier modulation.
BOC(m,n) uses a subcarrier frequency of m * 1.023 MHz and a code rate of n * 1.023 Mcps.
Arguments
m: Subcarrier frequency multiplier (must be ≥ 1)n: Code rate multiplier (must be ≥ 1)
Example
boc11 = BOCcos(1, 1) # BOC(1,1) with cosine phaseGNSSSignals.CBOC — Type
CBOC(boc1, boc2, boc1_power)Composite Binary Offset Carrier modulation.
CBOC combines two BOC modulations with specified power distribution. Used for Galileo E1B signals as CBOC(6,1,1/11).
Arguments
boc1: First BOC componentboc2: Second BOC componentboc1_power: Power fraction allocated to first BOC (0 < power < 1)
Example
cboc = CBOC(BOCsin(1, 1), BOCsin(6, 1), 10/11) # CBOC(6,1,1/11)Code Generation
GNSSSignals.gen_code — Function
gen_code(num_samples, gnss, prn, sampling_frequency)
gen_code(
num_samples,
gnss,
prn,
sampling_frequency,
code_frequency
)
gen_code(
num_samples,
gnss,
prn,
sampling_frequency,
code_frequency,
start_phase
)
gen_code(
num_samples,
gnss,
prn,
sampling_frequency,
code_frequency,
start_phase,
start_index
)
Generate a sampled code signal for a given PRN.
Allocates and returns a new buffer containing the spreading code sampled at the specified sampling frequency. For in-place operation, use gen_code!.
Arguments
num_samples: Number of samples to generategnss: GNSS system instance (e.g.,GPSL1(),GPSL5(),GalileoE1B())prn: PRN number of the satellitesampling_frequency: Sampling frequency (must be larger than code frequency)code_frequency: Code chipping rate (default: system's nominal code frequency)start_phase: Initial code phase in chips (default: 0.0)start_index: Index offset (default: 0)
Returns
Vector: Sampled code signal
Examples
julia> using Unitful: MHz
julia> sampled_code = gen_code(4000, GPSL1(), 1, 4MHz)
julia> length(sampled_code)
4000GNSSSignals.gen_code! — Function
gen_code!(sampled_code, gnss, prn, sampling_frequency)
gen_code!(
sampled_code,
gnss,
prn,
sampling_frequency,
code_frequency
)
gen_code!(
sampled_code,
gnss,
prn,
sampling_frequency,
code_frequency,
start_phase
)
gen_code!(
sampled_code,
gnss,
prn,
sampling_frequency,
code_frequency,
start_phase,
start_index_shift
)
gen_code!(
sampled_code,
gnss,
prn,
sampling_frequency,
code_frequency,
start_phase,
start_index_shift,
maximum_expected_sampling_frequency
)
gen_code!(
sampled_code,
gnss,
prn,
sampling_frequency,
code_frequency,
start_phase,
start_index_shift,
maximum_expected_sampling_frequency,
maximum_expected_doppler
)
gen_code!(
sampled_code,
gnss,
prn,
sampling_frequency,
code_frequency,
start_phase,
start_index_shift,
maximum_expected_sampling_frequency,
maximum_expected_doppler,
PHASET
)
Generate the code signal in-place for a given PRN.
This is a highly optimized function for generating sampled spreading codes at arbitrary sampling rates. It uses fixed-point arithmetic and minimizes memory access by exploiting the fact that consecutive samples often map to the same code chip. The algorithm avoids per-sample floating-point operations and modulo calculations, making it suitable for real-time GNSS signal processing applications.
Samples the spreading code at the specified sampling frequency and stores the result in the provided buffer. Includes subcarrier modulation for BOC-type signals.
Arguments
sampled_code: Pre-allocated output buffergnss: GNSS system instance (e.g.,GPSL1(),GPSL5(),GalileoE1B())prn: PRN number of the satellitesampling_frequency: Sampling frequency (must be larger than code frequency)code_frequency: Code chipping rate (default: system's nominal code frequency)start_phase: Initial code phase in chips (default: 0.0)start_index_shift: Index offset for the output buffer (default: 0)maximum_expected_sampling_frequency: Maximum expected sampling frequency for optimizationmaximum_expected_doppler: Maximum expected Doppler frequency (default: 8000 Hz)PHASET: Integer type for phase calculations (default:Int32)
Returns
- The modified
sampled_codebuffer
Examples
julia> using Unitful: MHz
julia> buffer = zeros(Int16, 4000)
julia> gen_code!(buffer, GPSL1(), 1, 4MHz)Code Access
GNSSSignals.get_code — Function
get_code(system, phase, prn)
Get the code value at a given phase for a specific PRN.
Returns the spreading code value (including subcarrier modulation for BOC signals) at the specified code phase. The phase is automatically wrapped to the code length.
Arguments
system: A GNSS system instance (e.g.,GPSL1(),GPSL5(),GalileoE1B())phase: Code phase in chipsprn: PRN number of the satellite
Returns
- Code value (typically
Int8for BPSK,Float32for CBOC)
Examples
julia> get_code(GPSL1(), 0.0, 1)
1
julia> get_code(GPSL1(), 1200.3, 1)
-1
julia> get_code.(GPSL1(), 0:1022, 1) # Full code periodget_code(modulation, system, phase, prn)
Get code value for BOC-modulated signals at a given phase.
Internal method that handles BOC modulation (sine or cosine phased).
get_code(modulation, system, phase, prn)
Get code value for LOC (BPSK) signals at a given phase.
Internal method that handles legacy/BPSK modulation without subcarrier.
GNSSSignals.get_code_unsafe — Function
get_code_unsafe(system, phase, prn)
Get the code value at a given phase without bounds checking.
This is a faster version of get_code that skips the modulo operation. The phase must be within [0, code_length * secondary_code_length).
Arguments
system: A GNSS system instancephase: Code phase in chips (must be within valid range)prn: PRN number of the satellite
Returns
- Code value at the given phase
Examples
julia> get_code_unsafe(GPSL1(), 500.0, 1)get_code_unsafe(modulation, system, phase, prn)
Get code value for BOC signals without bounds checking.
Internal method for BOC modulation without phase wrapping.
get_code_unsafe(modulation, system, phase, prn)
Get code value for LOC (BPSK) signals without bounds checking.
Internal method for BPSK modulation without phase wrapping.
GNSSSignals.get_codes — Function
get_codes(gnss)
Get the full code matrix for a GNSS system.
Returns the codes as a matrix where each column represents a PRN.
Arguments
gnss: A GNSS system instance (e.g.,GPSL1(),GPSL5(),GalileoE1B())
Returns
Matrix: Code matrix of size(code_length, num_prns)
Examples
julia> codes = get_codes(GPSL1())
julia> size(codes)
(1023, 37)System Properties
GNSSSignals.get_code_length — Function
get_code_length(gpsl1)
Get the code length for GPS L1.
Returns
Int: 1023 chips
Examples
julia> get_code_length(GPSL1())
1023get_code_length(gpsl5)
Get the code length for GPS L5.
Returns
Int: 10230 chips
Examples
julia> get_code_length(GPSL5())
10230get_code_length(galileo_e1b)
Get the code length for Galileo E1B.
Returns
Int: 4092 chips
Examples
julia> get_code_length(GalileoE1B())
4092GNSSSignals.get_secondary_code_length — Function
get_secondary_code_length(gnss)
Get the length of the secondary code.
Arguments
gnss: A GNSS system instance
Returns
Int: Secondary code length (1 if no secondary code)
Examples
julia> get_secondary_code_length(GPSL1())
1
julia> get_secondary_code_length(GPSL5())
10GNSSSignals.get_secondary_code — Function
get_secondary_code(gpsl1)
Get the secondary code for GPS L1.
GPS L1 has no secondary code, so this returns 1.
Returns
Int: 1 (no secondary code)
Examples
julia> get_secondary_code(GPSL1())
1get_secondary_code(galileo_e1b)
Get the secondary code for Galileo E1B.
Galileo E1B has no secondary code, so this returns 1.
Returns
Int: 1 (no secondary code)
Examples
julia> get_secondary_code(GalileoE1B())
1get_secondary_code(gnss, phase)
Get the secondary code value at a given phase.
Arguments
gnss: A GNSS system instancephase: Code phase in chips
Returns
- Secondary code value at the given phase
Examples
julia> get_secondary_code(GPSL5(), 10230.0) # Start of second code period
1get_secondary_code(gnss, code, phase)
Get secondary code value when code is a single integer (no secondary code).
Returns the code value unchanged.
get_secondary_code(gnss, code, phase)
Get secondary code value at phase when code is a tuple (has secondary code).
Computes the secondary code index from the phase and returns the corresponding value.
GNSSSignals.get_center_frequency — Function
get_center_frequency(gpsl1)
Get the center (carrier) frequency for GPS L1.
Returns
Frequency: 1575.42 MHz
Examples
julia> get_center_frequency(GPSL1())
1575420000 Hzget_center_frequency(gpsl5)
Get the center (carrier) frequency for GPS L5.
Returns
Frequency: 1176.45 MHz
Examples
julia> get_center_frequency(GPSL5())
1176450000 Hzget_center_frequency(galileo_e1b)
Get the center (carrier) frequency for Galileo E1B.
Returns
Frequency: 1575.42 MHz
Examples
julia> get_center_frequency(GalileoE1B())
1575420000 HzGNSSSignals.get_code_frequency — Function
get_code_frequency(gpsl1)
Get the code chipping rate for GPS L1.
Returns
Frequency: 1.023 MHz
Examples
julia> get_code_frequency(GPSL1())
1023000 Hzget_code_frequency(gpsl5)
Get the code chipping rate for GPS L5.
Returns
Frequency: 10.23 MHz
Examples
julia> get_code_frequency(GPSL5())
10230000 Hzget_code_frequency(galileo_e1b)
Get the code chipping rate for Galileo E1B.
Returns
Frequency: 1.023 MHz
Examples
julia> get_code_frequency(GalileoE1B())
1023000 HzGNSSSignals.get_data_frequency — Function
get_data_frequency(gpsl1)
Get the data bit rate for GPS L1.
Returns
Frequency: 50 Hz
Examples
julia> get_data_frequency(GPSL1())
50 Hzget_data_frequency(gpsl5)
Get the data bit rate for GPS L5.
Returns
Frequency: 100 Hz
Examples
julia> get_data_frequency(GPSL5())
100 Hzget_data_frequency(galileo_e1b)
Get the data bit rate for Galileo E1B.
Returns
Frequency: 250 Hz
Examples
julia> get_data_frequency(GalileoE1B())
250 HzGNSSSignals.get_code_center_frequency_ratio — Function
get_code_center_frequency_ratio(gnss)
Get the ratio of code frequency to center frequency.
This ratio is used to compute the code Doppler from the carrier Doppler.
Arguments
gnss: A GNSS system instance
Returns
Float64: The code-to-center frequency ratio
Examples
julia> get_code_center_frequency_ratio(GPSL1())
0.0006493506493506494GNSSSignals.get_modulation — Function
get_modulation(s)
Get the modulation type for a GNSS system.
Arguments
system: A GNSS system instance or type
Returns
Modulation: The modulation type (LOC,BOCsin,BOCcos, orCBOC)
Examples
julia> get_modulation(GPSL1())
LOC()
julia> get_modulation(GalileoE1B())
CBOC{BOCsin{Int64, Int64}, BOCsin{Int64, Int64}}(BOCsin{Int64, Int64}(1, 1), BOCsin{Int64, Int64}(6, 1), 0.90909094f0)GNSSSignals.get_system_string — Function
get_system_string(s)
Get the system name as a string.
Arguments
system: A GNSS system instance
Returns
String: System identifier string
Examples
julia> get_system_string(GPSL1())
"GPSL1"GNSSSignals.min_bits_for_code_length — Function
min_bits_for_code_length(gnss)
Get the minimum number of bits needed to represent the code length.
Calculates the number of bits required to represent the full code length, including secondary code if present.
Arguments
gnss: A GNSS system instance
Returns
Int: Number of bits needed
Examples
julia> min_bits_for_code_length(GPSL1())
10
julia> min_bits_for_code_length(GPSL5())
17GNSSSignals.get_code_type — Function
get_code_type(system)
Get the element type for code values of a GNSS system.
Returns the numeric type used to represent code values. For BPSK (LOC) signals, this is typically Int16. For CBOC signals, this is a floating-point type.
Arguments
system: A GNSS system instance
Returns
Type: The element type for code values
Examples
julia> get_code_type(GPSL1())
Int16
julia> get_code_type(GalileoE1B())
Float32Spectrum Functions
GNSSSignals.get_code_spectrum — Function
get_code_spectrum(system, f)
Get the spectral power density of a GNSS signal at a given frequency.
Computes the power spectral density based on the system's modulation type.
Arguments
system: A GNSS system instancef: Baseband frequency at which to evaluate the spectrum
Returns
- Spectral power density value
Examples
julia> using Unitful: kHz
julia> get_code_spectrum(GPSL1(), 0kHz)
9.775171065493646e-7GNSSSignals.get_code_spectrum_BPSK — Function
get_code_spectrum_BPSK(fc, f)
Calculate the spectral power density of a BPSK modulated signal.
Computes the power spectral density at baseband frequency f for a BPSK signal with chip rate fc.
Arguments
fc: Code chip ratef: Baseband frequency at which to evaluate the spectrum
Returns
- Spectral power density value
Examples
julia> using Unitful: MHz, kHz
julia> get_code_spectrum_BPSK(1.023MHz, 0kHz)
9.775171065493646e-7GNSSSignals.get_code_spectrum_BOCsin — Function
get_code_spectrum_BOCsin(fc, fs, f)
Calculate the spectral power density of a sine-phased BOC modulated signal.
Computes the power spectral density at baseband frequency f for a BOC(sin) signal with chip rate fc and subcarrier frequency fs.
Arguments
fc: Code chip ratefs: Subcarrier frequencyf: Baseband frequency at which to evaluate the spectrum
Returns
- Spectral power density value
GNSSSignals.get_code_spectrum_BOCcos — Function
get_code_spectrum_BOCcos(fc, fs, f)
Calculate the spectral power density of a cosine-phased BOC modulated signal.
Computes the power spectral density at baseband frequency f for a BOC(cos) signal with chip rate fc and subcarrier frequency fs.
Arguments
fc: Code chip ratefs: Subcarrier frequencyf: Baseband frequency at which to evaluate the spectrum
Returns
- Spectral power density value
Utility Functions
GNSSSignals.read_in_codes — Function
read_in_codes(type, filename, num_prns, code_length)
Read codes from a binary file.
Reads codes encoded in the specified type from a file. The code length must be provided by code_length and the number of PRNs by num_prns.
Arguments
type: The data type of the codes (e.g.,Int8)filename: Path to the binary file containing the codesnum_prns: Number of PRN codes in the filecode_length: Length of each code sequence
Returns
Matrix{type}: A matrix of size(code_length, num_prns)containing the codes
Examples
julia> read_in_codes(Int8, "/data/gpsl1codes.bin", 32, 1023)