Learn R Programming

widals (version 0.6.2)

H.Earth.solar: Solar Radiation

Description

Calculate Incident Solar Area (ISA)

Usage

H.Earth.solar(x, y, dateDate)

Value

An unnamed list of length \(\tau\), each element of which is an \(n\) x 1 matrix.

Arguments

x

Longitude. Numeric vector of length \(n\).

y

Latitude. Numeric vector of length \(n\).

dateDate

Posix date. Numeric vector of length \(\tau\).

Details

This function returns a spacio-temporal covariate list (Earth's ISA is space-time non-seperable). A negative value indicates that at that time (list index), and at that location (matrix row), the sun is below the horizon all day.

Examples

Run this code

lat <- c(0, -88)
lon <- c(0, 0)
dateDate <- strptime( c('20120621', '20120320'), '%Y%m%d')

H.Earth.solar(lon, lat, dateDate)


## The function is currently defined as
function (x, y, dateDate) 
{
    Hst.ls <- list()
    n <- length(y)
    tau <- length(dateDate)
    equinox <- strptime("20110320", "%Y%m%d")
    for (i in 1:tau) {
        this.date <- dateDate[i]
        dfe <- as.integer(difftime(this.date, equinox, units = "day"))
        dfe
        psi <- 23.5 * sin(2 * pi * dfe/365.25)
        psi
        eta <- 90 - (360/(2 * pi)) * acos(cos(2 * pi * y/360) * 
            cos(2 * pi * psi/360) + sin(2 * pi * y/360) * sin(2 * 
            pi * psi/360))
        surface.area <- sin(2 * pi * eta/360)
        surface.area
        Hst.ls[[i]] <- cbind(surface.area)
    }
    return(Hst.ls)
  }

Run the code above in your browser using DataLab