rf

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2017 License: MIT Imports: 3 Imported by: 0

README

go-rf

Radio Frequency calculations for Golang

Documentation GitHub tag Build Status


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

	Hz  Frequency = 1
	KHz           = Hz * 1000
	MHz           = KHz * 1000
	GHz           = MHz * 1000

	M  Distance = 1
	Km          = M * 1000

	// R is the (average) radius of the earth
	R = 6.371e6
)
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 CalculateDistance

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

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) float64

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

func CalculateFoliageLoss

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

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

func DecibelMilliVoltToMilliWatt

func DecibelMilliVoltToMilliWatt(dbm float64) float64

DecibelMilliVoltToMilliWatt converts dBm to mW

func FreeSpaceAttenuation

func FreeSpaceAttenuation(freq Frequency, distance Distance) float64

FreeSpaceAttenuation calculates the Free Space Path Loss for a given frequency and distance

func FreeSpaceAttenuationDB

func FreeSpaceAttenuationDB(freq Frequency, distance Distance) float64

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

func FrequencyToWavelength

func FrequencyToWavelength(freq Frequency) float64

FrequencyToWavelength calculates a wavelength from a frequency

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 MilliWattToDecibelMilliVolt

func MilliWattToDecibelMilliVolt(mw float64) float64

MilliWattToDecibelMilliVolt converts mW to dBm

Types

type Distance

type Distance float64

Distance type to assist with unit coherence

type Frequency

type Frequency float64

Frequency type to assist with unit coherence

func WavelengthToFrequency

func WavelengthToFrequency(wavelength float64) Frequency

WavelengthToFrequency calculates a frequency from a wavelength

Jump to

Keyboard shortcuts

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