Learn R Programming

insol (version 1.2.2)

sunvector: Solar vector

Description

Calculates a unit vector in the direction of the sun from the observer position.

Usage

sunvector(jd, latitude, longitude, timezone)

Arguments

jd

Julian Day and decimal fraction.

latitude

Latitude of observer in degrees and decimal fraction.

longitude

Longitude of observer in degrees and decimal fraction.

timezone

Time zone, west is negative.

Value

3 column matrix with the x, y , z coordinates of the sun vector.

Details

To calculate the sunvector to the nearest hour, give the Julian Day with a precission better than 1/24; to approximate it to the nearest minute use decimal fractions smaller than 1/(24*60), and so on.

References

Corripio, J. G.: 2003, Vectorial algebra algorithms for calculating terrain parameters from DEMs and the position of the sun for solar radiation modelling in mountainous terrain, International Journal of Geographical Information Science 17(1), 1-23.

See Also

sunpos

Examples

Run this code
# NOT RUN {
# Current solar vector at Greenwich observatory
sunvector(JD(Sys.time()),51.4778,-0.0017,0)

juneday = JD(seq(ISOdate(2019,6,21,0),ISOdate(2019,6,21,23,30),by='30 min'))
# }
# NOT RUN {
# Path of the sun over Greenwich in summer
require(scatterplot3d)
scatterplot3d(sunvector(juneday,51.4778,-0.0017,0),
	ylim=c(-1,1),zlim=c(0,1),pch=8,color='orange')
# }
# NOT RUN {
# print values 
options(digits=12)		# make sure decimals are printed
sunvector(juneday,51.4778,-0.0017,0)

# }

Run the code above in your browser using DataLab