rf

package module
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2018 License: MIT Imports: 6 Imported by: 0

README

go-rf

Radio Frequency (RF) calculations and helpers for Golang

Documentation GitHub tag Build Status

This is intended to provide common calculations for rf fading and propagation in a dimensionally consistent manner.


If you have any questions, comments, or suggestions, feel free to open an issue or a pull request.

Documentation

Index

Constants

View Source
const (
	//C is the speed of light in air in meters per second
	C = 2.998e+8

	// FresnelObstructionOK is the largest acceptable proportion of fresnel zone impingement
	FresnelObstructionOK = 0.4
	// FresnelObstructionIdeal is the largest ideal proportion of fresnel zone impingement
	FresnelObstructionIdeal = 0.2

	// R is the (average) radius of the earth
	R = 6.371e6
)
View Source
const (
	Hz  Frequency = 1.0
	KHz           = Hz * 1000
	MHz           = KHz * 1000
	GHz           = MHz * 1000
)

Frequency helper types

View Source
const (
	WeissbergerMinFreq = 230 * MHz
	WeissbergerMaxFreq = 95 * GHz
	WeissbergerMinDist = 0 * M
	WeissbergerMaxDist = 400 * M
)
View Source
const FresnelMinDistanceWavelengthRadio = 0.1

FresnelMinDistanceWavelengthRadio is the minimum ratio of distance:wavelength for viable calculations This is used as a programattic sanity check for distance >> wavelength

Variables

This section is empty.

Functions

func BullingtonFigure12Method added in v0.1.1

func BullingtonFigure12Method(p1, p2 float64, d Distance, terrain []float64) (d1, d2, height float64)

BullingtonFigure12Method implements the Bullington Figure 12 (intersecting horizons) method to approximate height and distance for use in the Fresnell-Kirchoff path loss approximation. See: https://hams.soe.ucsc.edu/sites/default/files/Bullington%20VTS%201977.pdf

func CalculateFresnelKirckoffDiffractionParam added in v0.1.1

func CalculateFresnelKirckoffDiffractionParam(freq Frequency, d1, d2, h Distance) (v float64, err error)

CalculateFresnelKirckoffDiffractionParam Calculates the Fresnel-Kirchoff Diffraction parameter d1 and d2 are the distances between the "knife edge" impingement and the transmitter/receiver h is the impingement, where -ve is below Line of Sight (LoS) and +ve is above LoS https://en.wikipedia.org/wiki/Kirchhoff%27s_diffraction_formula https://s.campbellsci.com/documents/au/technical-papers/line-of-sight-obstruction.pdf

func DecibelMilliVoltToMilliWatt

func DecibelMilliVoltToMilliWatt(dbm float64) float64

DecibelMilliVoltToMilliWatt converts dBm to mW Note that this power decibels (10log10)

func FresnelFirstZoneMax

func FresnelFirstZoneMax(freq Frequency, dist Distance) (float64, error)

FresnelFirstZoneMax calculates the maximum fresnel zone radius for a given frequency

func FresnelPoint

func FresnelPoint(d1, d2 Distance, freq Frequency, order int64) (float64, error)

FresnelPoint calculates the fresnel zone radius d for a given wavelength and order at a point P between endpoints

func GraphBullingtonFigure12 added in v0.2.2

func GraphBullingtonFigure12(filename string, normalised bool, p1, p2 float64, d Distance, terrain []float64) error

GraphBullingtonFigure12 Graphs the terrain impingement calculated using the Bullington Figure 12 method

func MilliWattToDecibelMilliVolt

func MilliWattToDecibelMilliVolt(mw float64) float64

MilliWattToDecibelMilliVolt converts mW to dBm Note that this power decibels (10log10)

func Smooth added in v0.2.2

func Smooth(data []float64) []float64

func SmoothN added in v0.2.2

func SmoothN(n int, data []float64) []float64

func TerrainToPath added in v0.1.1

func TerrainToPath(p1, p2 float64, d Distance, terrain []float64) (Δd, Δh, θ float64, diffs []float64)

Convert terrain between two points of set heights into distances from the path between those points

func TerrainToPathXY added in v0.1.1

func TerrainToPathXY(p1, p2 float64, d Distance, terrain []float64) (x, y []float64, d2 float64)

TerrainToPathXY Converts terrain between two points of set heights into distances from the path between those points

func UnNormalisePoint added in v0.2.2

func UnNormalisePoint(p1, p2 float64, d Distance, x, y float64) (float64, float64)

UnNormalisePoint reverts a normalised (straight line between p1 and p2) point to a real world point

Types

type Attenuation added in v0.1.1

type Attenuation float64

Attenuation type (dB) to assist with unit coherence

const (
	DB Attenuation = 0
)

Attenuation helpers

func CalculateFoliageLoss

func CalculateFoliageLoss(freq Frequency, depth Distance) (Attenuation, error)

CalculateFoliageLoss calculates path loss in dB due to foliage based on the Weissberger model https://en.wikipedia.org/wiki/Weissberger%27s_model

func CalculateFreeSpacePathLoss added in v0.1.1

func CalculateFreeSpacePathLoss(freq Frequency, distance Distance) Attenuation

CalculateFreeSpacePathLoss calculates the Free Space Path Loss in Decibels for a given frequency and distance

func CalculateFresnelKirchoffLossApprox added in v0.1.1

func CalculateFresnelKirchoffLossApprox(v float64) (Attenuation, error)

CalculateFresnelKirchoffLossApprox Calculates approximate loss due to diffraction using the Fresnel-Kirchoff Diffraction parameter. This approximate is valid for values >= -0.7 https://s.campbellsci.com/documents/au/technical-papers/line-of-sight-obstruction.pdf

func CalculateRaleighFading

func CalculateRaleighFading(freq Frequency) (Attenuation, error)

CalculateRaleighFading calculates Raleigh fading https://en.wikipedia.org/wiki/Rayleigh_fading

func CalculateRicanFading

func CalculateRicanFading(freq Frequency) (Attenuation, error)

CalculateRicanFading calculates Rican fading https://en.wikipedia.org/wiki/Rician_fading

func CalculateWeibullFading

func CalculateWeibullFading(freq Frequency) (Attenuation, error)

CalculateWeibullFading calculates Weibull fading https://en.wikipedia.org/wiki/Weibull_fading

func FieldAbsToDB added in v0.1.1

func FieldAbsToDB(abs float64) Attenuation

FieldAbsToDB Converts an absolute field attenuation (20log10) to decibels

func (*Attenuation) FieldDBToAbs added in v0.1.1

func (a *Attenuation) FieldDBToAbs() float64

FieldDBToAbs Converts field attenuation (20log10) to absolute values

type Distance

type Distance float64

Distance type (m) to assist with unit coherence

const (
	M  Distance = 1.0
	Km          = M * 1000
)

Distance helper types

func CalculateDistance

func CalculateDistance(lat1, lng1, lat2, lng2, radius float64) Distance

CalculateDistance calculates the distance between two latitude and longitudes Using the haversine (flat earth) formula See: http://www.movable-type.co.uk/scripts/latlong.html

func CalculateDistanceLOS

func CalculateDistanceLOS(lat1, lng1, alt1, lat2, lng2, alt2 float64) Distance

CalculateDistanceLOS calculates the approximate Line of Sight distance between two lat/lon/alt points This achieves this by wrapping the haversine formula with a flat-earth approximation for height difference. This will be very inaccurate with larger distances. TODO: surely there is a better (ie. not written by me) algorithm for this

type Frequency

type Frequency float64

Frequency type (Hz) to assist with unit coherence

func WavelengthToFrequency

func WavelengthToFrequency(wavelength Wavelength) Frequency

WavelengthToFrequency calculates a frequency from a wavelength

type Wavelength added in v0.1.1

type Wavelength float64

Wavelength type (m) to assist with unit coherence

func FrequencyToWavelength

func FrequencyToWavelength(freq Frequency) Wavelength

FrequencyToWavelength calculates a wavelength from a frequency

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL