I am fairly new to coding and am having trouble even conceptualising how I will implement this problem in R. Sorry if I am missing something totally obvious.
I am trying to find the pressure correction factor (y) for each minute at a particular meteorological station. This is the formula:
x is the ratio of the elevation of the location over some constant
y is the pressure correction factor
m is the optical air mass at sea level
m depends on the time of day, and my time series has a column for the value of m at each minute of the series.
when x = 1, y = 1.
when x = 0.75, y= 1.25 -.012*m + .00037*m^2
when x= 0.5, y = 1.68 -.03*m + .0009*m^2
Between values of x, y is interpolated linearly.
The value of x I am interested in is 0.9804
This is as far as I have gotten in terms of implementation (it is not far):
x <- c(0.5 , .75 , 1)
pc1 = 1.248274 - 0.011997*DF$AirMass0 + 0.000370*DF$AirMass0^2
pc2 = 1.68219 - 0.03059*DF$AirMass0 + 0.000890*DF$AirMass0^2
pc <- c(0 , pc1[1], pc2[1] , 1)
approx(x, pc , n = 1000)
I know this is just calling my first value of airmass in my time series. Also, that even with n=1000, I will not be able to get an exact value of x=9804.
I realise it is a long shot that anyone will even read all of this, but I would really appreciate any help.
Thanks in advance :)
EDIT: Here's the head of my df
> dput(head(DF2))
structure(list(DF.Date = structure(c(1357296180, 1358021760,
1357991280, 1357629540, 1357287540, 1358158260), class = c("POSIXct",
"POSIXt"), tzone = "UTC"), DF.Irradiance = c(1055.64, 0, 975.22,
0.25, 953.33, 1017.62), DF.AirMass0 = c(0.0279842300461168, 0.0195227712650674,
0.0194685363977006, 0.0384509898910604, -0.142855127416022, 0.0322758934562728
)), row.names = c(NA, 6L), class = "data.frame")
> StationHeightCorrection <- exp(-167/8435.52)
> StationHeightCorrection
[1] 0.9803974