Skip to content

Commit 542448f

Browse files
committed
git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cropsim@201 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
1 parent 2be302c commit 542448f

File tree

8 files changed

+43
-61
lines changed

8 files changed

+43
-61
lines changed

pkg/Rlintul/man/LINTUL-class.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040

4141
\alias{DailyWeather-class}
42+
\alias{Rcpp_DailyWeather-class}
4243

4344
\alias{Lintul1Control-class}
4445
\alias{Lintul1Crop-class}

pkg/Rlintul/src/LINTUL.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

pkg/meteor/R/RcppExports.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@
4141
.Call(`_meteor_E_Penman`, temp, relh, atmp, Rs, Rext, u, alpha, Z)
4242
}
4343

44-
.SVP <- function(temp, simple = FALSE) {
45-
.Call(`_meteor_SVP`, temp, simple)
44+
.SVP <- function(temp) {
45+
.Call(`_meteor_SVP`, temp)
4646
}
4747

48-
.VP <- function(temp, relh, simple = FALSE) {
49-
.Call(`_meteor_VP`, temp, relh, simple)
48+
.VP <- function(temp, relh) {
49+
.Call(`_meteor_VP`, temp, relh)
5050
}
5151

52-
.VPD <- function(temp, relh, simple = FALSE) {
53-
.Call(`_meteor_VPD`, temp, relh, simple)
52+
.VPD <- function(temp, relh) {
53+
.Call(`_meteor_VPD`, temp, relh)
5454
}
5555

5656
.ExtraTerrestrialRadiation <- function(doy, latitude, sc = 1367.7, FAO = FALSE) {

pkg/meteor/R/SVP.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11

2-
SVP <- function(temp, simple = FALSE) {
3-
.Call(`_meteor_SVP`, temp, simple)
2+
SVP <- function(temp) {
3+
.Call(`_meteor_SVP`, temp)
44
}
55

6-
VP <- function(temp, relh, simple = FALSE) {
7-
.Call(`_meteor_VP`, temp, relh, simple)
6+
VP <- function(temp, relh) {
7+
x <- cbind(temp, relh)
8+
.Call(`_meteor_VP`, x[,1], x[,2])
89
}
910

10-
VPD <- function(temp, relh, simple = FALSE) {
11-
.Call(`_meteor_VPD`, temp, relh, simple)
11+
VPD <- function(temp, relh) {
12+
x <- cbind(temp, relh)
13+
.Call(`_meteor_VPD`, x[,1], x[,2])
1214
}

pkg/meteor/man/day2hour.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
\name{daylyToHourly}
22

33
\alias{hourlyFromDailyTemp}
4-
\alias{hourlyFromDaily}
4+
\alias{hourlyFromDailyRelh}
55

66

77
\title{Estimate hourly values from daily values }

pkg/meteor/man/vaporpressure.Rd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Robert Hijmans, based on Python meteolib by Maarten J. Waterloo and J. Delsman \
4141
}
4242

4343
\examples{
44-
SVP(30, FALSE)
45-
SVP(30, TRUE)
46-
VP(30, 60)
47-
VPD(30, 60)
44+
temperature <- seq(-10,30,10)
45+
SVP(temperature)
46+
VP(temperature, 60)
47+
VPD(temperature, 60)
4848
}

pkg/meteor/src/RcppExports.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,40 +154,37 @@ BEGIN_RCPP
154154
END_RCPP
155155
}
156156
// SVP
157-
NumericVector SVP(NumericVector temp, bool simple);
158-
RcppExport SEXP _meteor_SVP(SEXP tempSEXP, SEXP simpleSEXP) {
157+
NumericVector SVP(NumericVector temp);
158+
RcppExport SEXP _meteor_SVP(SEXP tempSEXP) {
159159
BEGIN_RCPP
160160
Rcpp::RObject rcpp_result_gen;
161161
Rcpp::RNGScope rcpp_rngScope_gen;
162162
Rcpp::traits::input_parameter< NumericVector >::type temp(tempSEXP);
163-
Rcpp::traits::input_parameter< bool >::type simple(simpleSEXP);
164-
rcpp_result_gen = Rcpp::wrap(SVP(temp, simple));
163+
rcpp_result_gen = Rcpp::wrap(SVP(temp));
165164
return rcpp_result_gen;
166165
END_RCPP
167166
}
168167
// VP
169-
NumericVector VP(NumericVector temp, NumericVector relh, bool simple);
170-
RcppExport SEXP _meteor_VP(SEXP tempSEXP, SEXP relhSEXP, SEXP simpleSEXP) {
168+
NumericVector VP(NumericVector temp, NumericVector relh);
169+
RcppExport SEXP _meteor_VP(SEXP tempSEXP, SEXP relhSEXP) {
171170
BEGIN_RCPP
172171
Rcpp::RObject rcpp_result_gen;
173172
Rcpp::RNGScope rcpp_rngScope_gen;
174173
Rcpp::traits::input_parameter< NumericVector >::type temp(tempSEXP);
175174
Rcpp::traits::input_parameter< NumericVector >::type relh(relhSEXP);
176-
Rcpp::traits::input_parameter< bool >::type simple(simpleSEXP);
177-
rcpp_result_gen = Rcpp::wrap(VP(temp, relh, simple));
175+
rcpp_result_gen = Rcpp::wrap(VP(temp, relh));
178176
return rcpp_result_gen;
179177
END_RCPP
180178
}
181179
// VPD
182-
NumericVector VPD(NumericVector temp, NumericVector relh, bool simple);
183-
RcppExport SEXP _meteor_VPD(SEXP tempSEXP, SEXP relhSEXP, SEXP simpleSEXP) {
180+
NumericVector VPD(NumericVector temp, NumericVector relh);
181+
RcppExport SEXP _meteor_VPD(SEXP tempSEXP, SEXP relhSEXP) {
184182
BEGIN_RCPP
185183
Rcpp::RObject rcpp_result_gen;
186184
Rcpp::RNGScope rcpp_rngScope_gen;
187185
Rcpp::traits::input_parameter< NumericVector >::type temp(tempSEXP);
188186
Rcpp::traits::input_parameter< NumericVector >::type relh(relhSEXP);
189-
Rcpp::traits::input_parameter< bool >::type simple(simpleSEXP);
190-
rcpp_result_gen = Rcpp::wrap(VPD(temp, relh, simple));
187+
rcpp_result_gen = Rcpp::wrap(VPD(temp, relh));
191188
return rcpp_result_gen;
192189
END_RCPP
193190
}
@@ -217,9 +214,9 @@ static const R_CallMethodDef CallEntries[] = {
217214
{"_meteor_ET0_PriestleyTaylor", (DL_FUNC) &_meteor_ET0_PriestleyTaylor, 5},
218215
{"_meteor_ET0_Makkink", (DL_FUNC) &_meteor_ET0_Makkink, 4},
219216
{"_meteor_E_Penman", (DL_FUNC) &_meteor_E_Penman, 8},
220-
{"_meteor_SVP", (DL_FUNC) &_meteor_SVP, 2},
221-
{"_meteor_VP", (DL_FUNC) &_meteor_VP, 3},
222-
{"_meteor_VPD", (DL_FUNC) &_meteor_VPD, 3},
217+
{"_meteor_SVP", (DL_FUNC) &_meteor_SVP, 1},
218+
{"_meteor_VP", (DL_FUNC) &_meteor_VP, 2},
219+
{"_meteor_VPD", (DL_FUNC) &_meteor_VPD, 2},
223220
{"_meteor_ExtraTerrestrialRadiation", (DL_FUNC) &_meteor_ExtraTerrestrialRadiation, 4},
224221
{NULL, NULL, 0}
225222
};

pkg/meteor/src/wth_rcpp.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,39 +135,35 @@ NumericVector E_Penman(NumericVector temp, NumericVector relh, NumericVector atm
135135
/////// vapor pressure
136136

137137
// [[Rcpp::export(name =".SVP")]]
138-
NumericVector SVP(NumericVector temp, bool simple=false) {
138+
NumericVector SVP(NumericVector temp) {
139139
//saturated vapor pressure (Pa)
140140
NumericVector out(temp.size());
141-
if (simple) {
142-
for (int i=0; i < out.size(); i++) {
143-
out[i] = ESimple(temp[i]) ;
144-
}
145-
} else {
146-
for (int i=0; i < out.size(); i++) {
147-
out[i] = ES(temp[i]) ;
148-
}
141+
for (int i=0; i < out.size(); i++) {
142+
out[i] = ES(temp[i]) ;
149143
}
150144
return(out);
151145
}
152146

153147
// [[Rcpp::export(name =".VP")]]
154-
NumericVector VP(NumericVector temp, NumericVector relh, bool simple=false) {
148+
NumericVector VP(NumericVector temp, NumericVector relh) {
155149
// actual vapor pressure (Pa)
156150
NumericVector out(temp.size());
157-
NumericVector svp = SVP(temp, simple);
151+
double svp;
158152
for (int i=0; i < out.size(); i++) {
159-
out[i] = svp[i] * relh[i] / 100;
153+
svp = ES(temp[i]);
154+
out[i] = svp * relh[i] / 100;
160155
}
161156
return(out);
162157
}
163158

164159
// [[Rcpp::export(name =".VPD")]]
165-
NumericVector VPD(NumericVector temp, NumericVector relh, bool simple=false){
160+
NumericVector VPD(NumericVector temp, NumericVector relh){
166161
// vapor pressure deficit (Pa)
167162
NumericVector out(temp.size());
168-
NumericVector svp = SVP(temp, simple);
163+
double svp;
169164
for (int i=0; i < out.size(); i++) {
170-
out[i] = svp[i] - ( svp[i] * relh[i] / 100 );
165+
svp = ES(temp[i]);
166+
out[i] = svp - ( svp * relh[i] / 100 );
171167
}
172168
return(out);
173169
}

0 commit comments

Comments
 (0)