Skip to content

Commit

Permalink
Added Galileo E1B signals
Browse files Browse the repository at this point in the history
  • Loading branch information
zsoerenm committed Oct 8, 2019
1 parent 0a77fbd commit fcf99c8
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GNSSSignals"
uuid = "52c80523-2a4e-5c38-8979-05588f836870"
authors = ["Soeren Zorn <[email protected]>"]
version = "0.10.1"
version = "0.10.2"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,3 @@ In addition to that, there are some auxiliarly functions:
julia> get_code_length(GPSL1)
1023
```

## Todo

* Add Galileo signals
1 change: 1 addition & 0 deletions data/codes_galileo_e1b.bin

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/GNSSSignals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module GNSSSignals
AbstractGNSSSystem,
GPSL1,
GPSL5,
GalileoE1B,
get_codes,
get_code_length,
get_shortest_code_length,
Expand All @@ -25,6 +26,8 @@ module GNSSSignals

struct GPSL5 <: AbstractGNSSSystem end

struct GalileoE1B <: AbstractGNSSSystem end

"""
$(SIGNATURES)
Expand All @@ -42,9 +45,9 @@ module GNSSSignals
end
end

include("gpsl1.jl")
include("gpsl5.jl")
include("gps_l1.jl")
include("gps_l5.jl")
include("galileo_e1b.jl")
include("carrier.jl")
include("common.jl")

end
111 changes: 111 additions & 0 deletions src/galileo_e1b.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
function read_from_documentation(raw_code)
raw_code_without_spaces = replace(replace(raw_code, " " => ""), "\n" => "")
code_hex_array = map(x -> parse(UInt16, x, base = 16), collect(raw_code_without_spaces))
code_bit_string = string(string.(code_hex_array, base = 2, pad = 4)...)
map(x -> parse(Int8, x, base = 2), collect(code_bit_string)) .* Int8(2) .- Int8(1)
end

const GALILEO_E1B_CODES = read_in_codes(joinpath(dirname(pathof(GNSSSignals)), "..", "data", "codes_galileo_e1b.bin"), 50, 4092)

"""
$(SIGNATURES)
Get codes of type GalileoE1B as a Matrix where each column
represents a PRN.
```julia-repl
julia> get_code(GalileoE1B)
```
"""
function get_codes(::Type{GalileoE1B})
GALILEO_E1B_CODES
end

"""
$(SIGNATURES)
Get code length of GNSS system GalileoE1B.
```julia-repl
julia> get_code_length(GalileoE1B)
```
"""
@inline function get_code_length(::Type{GalileoE1B})
4092
end

"""
$(SIGNATURES)
Get shortest code length of GNSS system GalileoE1B.
```julia-repl
julia> get_shortest_code_length(GalileoE1B)
```
"""
@inline function get_shortest_code_length(::Type{GalileoE1B})
get_code_length(GalileoE1B)
end

"""
$(SIGNATURES)
Get center frequency of GNSS system GalileoE1B.
```julia-repl
julia> get_center_frequency(GalileoE1B)
```
"""
@inline function get_center_frequency(::Type{GalileoE1B})
1.57542e9Hz
end

"""
$(SIGNATURES)
Get code frequency of GNSS system GalileoE1B.
```julia-repl
julia> get_code_frequency(GalileoE1B)
```
"""
@inline function get_code_frequency(::Type{GalileoE1B})
1023e3Hz
end

"""
$(SIGNATURES)
Get data frequency of GNSS system GalileoE1B.
```julia-repl
julia> get_data_frequency(GalileoE1B)
```
"""
@inline function get_data_frequency(::Type{GalileoE1B})
250Hz
end

"""
$(SIGNATURES)
Get code of type GalileoE1B at phase `phase` of prn `prn`.
The phase will not be wrapped by the code length. The phase has to smaller
than the code length. Includes only BOC(1,1) at the moment.
```julia-repl
julia> get_code_unsafe(GalileoE1B, 10.3, 1)
```
"""
Base.@propagate_inbounds function get_code_unsafe(::Type{GalileoE1B}, phase, prn::Int)
floored_2phase = floor(Int, 2 * phase)
get_code_unsafe(GalileoE1B, floored_2phase >> 1, prn::Int) *
(iseven(floored_2phase) * 2 - 1)
end

"""
$(SIGNATURES)
Get code of GNSS system GalileoE1B at phase `phase` of prn `prn`.
The phase will not be wrapped by the code length. The phase has to smaller
than the code length and must be an integer.
```julia-repl
julia> get_code_unsafe(GalileoE1B, 10, 1)
```
"""
Base.@propagate_inbounds function get_code_unsafe(::Type{GalileoE1B}, phase::Int, prn::Int)
GALILEO_E1B_CODES[1 + phase, prn]
end
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions test/galileo_e1b.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@testset "Galileo E1B" begin

@test @inferred(get_center_frequency(GalileoE1B)) == 1.57542e9Hz
@test @inferred(get_code_length(GalileoE1B)) == 4092
@test @inferred(get_shortest_code_length(GalileoE1B)) == 4092
@test @inferred(get_code(GalileoE1B, 0, 1)) == 1
@test @inferred(get_code(GalileoE1B, 0.0, 1)) == 1
@test @inferred(get_code(GalileoE1B, 0.5, 1)) == -1
@test @inferred(get_code(GalileoE1B, 1.0, 1)) == 1
@test @inferred(get_code(GalileoE1B, 1.5, 1)) == -1
@test @inferred(get_code_unsafe(GalileoE1B, 0.0, 1)) == 1
@test @inferred(get_data_frequency(GalileoE1B)) == 250Hz
@test @inferred(get_code_frequency(GalileoE1B)) == 1023e3Hz

end
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions test/runtests.jl

Large diffs are not rendered by default.

2 comments on commit fcf99c8

@zsoerenm
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/4175

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.2 -m "<description of version>" fcf99c88390a37cd888255cdec7edcc6975c002f
git push origin v0.10.2

Please sign in to comment.