-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from IDEMSInternational/main
Update from MC
- Loading branch information
Showing
17 changed files
with
249 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,73 @@ | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
# epicsawrap | ||
# epicsawrap: R Package for Integrating rpicsa and epicsadata Functions for API Apps | ||
|
||
<!-- badges: start --> | ||
|
||
[![R-CMD-check](https://github.com/IDEMSInternational/epicsawrap/workflows/R-CMD-check/badge.svg)](https://github.com/IDEMSInternational/epicsawrap/actions) | ||
[![Codecov test | ||
coverage](https://codecov.io/gh/IDEMSInternational/epicsawrap/branch/main/graph/badge.svg)](https://app.codecov.io/gh/IDEMSInternational/epicsawrap?branch=main) | ||
[![Lifecycle: | ||
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) | ||
<!-- badges: end --> | ||
|
||
The goal of epicsawrap is to … | ||
## Overview | ||
|
||
**epicsawrap** is an R package that brings together the functionality of | ||
**rpicsa** and **epicsadata** packages to be used in creating API | ||
applications for crop and climate analysis. It provides a convenient | ||
interface for accessing and utilizing the functions from both packages, | ||
enabling the development of web-based tools and services for | ||
agricultural decision support. | ||
|
||
The package combines the capabilities of **rpicsa** for PICSA and | ||
climatic analysis for crops with **epicsadata** for retrieving climate | ||
and weather data, creating a powerful tool for addressing the needs of | ||
farmers, agronomists, and researchers. | ||
|
||
## Installation | ||
|
||
You can install the development version of epicsawrap from | ||
[GitHub](https://github.com/) with: | ||
You can install **epicsawrap** from CRAN using the following command: | ||
|
||
``` r | ||
# install.packages("devtools") | ||
# Install the 'devtools' package if you haven't already | ||
if (!require(devtools)) { | ||
install.packages("devtools") | ||
} | ||
|
||
# Install 'epicsawrap' from GitHub | ||
devtools::install_github("IDEMSInternational/epicsawrap") | ||
``` | ||
|
||
## Documentation | ||
|
||
For detailed information on each function, including arguments, usage, | ||
and examples, please refer to the package documentation. You can access | ||
it using the following command: | ||
|
||
``` r | ||
?epicsawrap | ||
``` | ||
|
||
The GitHub page for the `rpicsa` package can be found | ||
[here](https://github.com/IDEMSInternational/rpicsa). The GitHub page | ||
for the `epicsadata` package can be found | ||
[here](https://github.com/IDEMSInternational/epicsadata). | ||
|
||
## Contributing | ||
|
||
We welcome contributions from the community. If you have any bug | ||
reports, feature requests, or would like to contribute code to rpicsa, | ||
please visit our GitHub repository. | ||
|
||
## License | ||
|
||
This package is open-source and distributed under the GNU Lesser General | ||
Public License v3.0 License. Feel free to use, modify, and distribute it | ||
as needed. | ||
|
||
## Contact | ||
|
||
If you have any questions, suggestions, or feedback, please feel free to | ||
reach out to us. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library(testthat) | ||
library(epicsawrap) | ||
|
||
test_check("epicsawrap") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,18 @@ | ||
# library(testthat) | ||
# | ||
# # External functions call | ||
# # Test case 1: Test with all parameter | ||
# result <- epicsawrap::crop_success_probabilities( | ||
# country = "zm", | ||
# station_id = "16", | ||
# planting_dates = c(92, 122, 153), | ||
# water_requirements = c(300, 500, 700), | ||
# planting_length = c(120, 180), | ||
# start_before_season = TRUE | ||
# ) | ||
# | ||
# # Test case 2: Test with missing planting_length parameter | ||
# result_2 <- epicsawrap::crop_success_probabilities( | ||
# country = "zm", | ||
# station_id = "16", | ||
# planting_dates = c(1, 2, 3), | ||
# water_requirements = c(100, 200, 300), | ||
# start_before_season = TRUE | ||
# ) | ||
# | ||
# # Test case 2: Test with all missing parameters | ||
# result_3 <- epicsawrap::crop_success_probabilities( | ||
# country = "zm", | ||
# station_id = "16" | ||
# ) | ||
# | ||
# # Define test cases | ||
# test_that("crop_success_probabilities returns correct results", { | ||
# expect_no_error(result) | ||
# expect_no_error(result_2) | ||
# expect_no_error(result_3) | ||
# }) | ||
# | ||
# # Define test cases | ||
# test_that("crop_success_probabilities returns same results whether parameters are defined or not", { | ||
# expect_identical(result[[2]], result_3[[2]]) | ||
# }) | ||
# | ||
library(testthat) | ||
library(epicsawrap) | ||
|
||
# Test case 1 | ||
epicsadata::gcs_auth_file(file = "testdata/e-picsa-e630400792e7.json") | ||
test_1_results <- readRDS("testdata/test_1_crop_success_probabilities.rds") | ||
country <- "zm" | ||
station_id <- "test_1" | ||
test_that("Correct summaries are calculated", { | ||
result <- crop_success_probabilities(country, station_id, water_requirements = c(0, 100, 300)) | ||
expect_true(identical(result[[2]], test_1_results)) | ||
}) | ||
|
||
|
||
crop_success_probabilities(country, "01122", water_requirements = c(0, 100, 300)) | ||
|
||
|
||
daily <- epicsadata::get_daily_data(country = country, station_id = station_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,15 @@ | ||
# library(testthat) | ||
# | ||
# # External functions call | ||
# # Test case 1: Test with all parameters | ||
# result <- | ||
# season_start_probabilities( | ||
# country = "zm", | ||
# station_id = "16", | ||
# start_dates = c(10, 20, 100) | ||
# ) | ||
# | ||
# # Test case 2: Test with missing parameters | ||
# result_2 <- | ||
# season_start_probabilities(country = "zm", station_id = "16") | ||
# | ||
# # Define test cases | ||
# test_that("season_start_probabilities returns correct results", { | ||
# expect_no_error(result) | ||
# expect_no_error(result_2) | ||
# }) | ||
library(testthat) | ||
library(epicsawrap) | ||
|
||
# Test case 1 | ||
epicsadata::gcs_auth_file(file = "testdata/e-picsa-e630400792e7.json") | ||
test_1_results <- readRDS("testdata/test_1_season_start_probabilities.rds") | ||
country <- "zm" | ||
station_id <- "test_1" | ||
test_that("Correct summaries are calculated", { | ||
result <- season_start_probabilities(country, station_id, c(0, 150, 300)) | ||
expect_true(identical(result[[2]], test_1_results)) | ||
}) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,17 @@ | ||
# library(testthat) | ||
# | ||
# # Test case 1: Test with to = "annual" | ||
# result <- epicsawrap:::total_temperature_summaries( | ||
# country = "zm", | ||
# station_id = "23", | ||
# summaries = c("mean_tmin", "mean_tmax"), | ||
# to = "annual" | ||
# ) | ||
# | ||
# # Test case 2: Test with to = "monthly" | ||
# result_2 <- epicsawrap:::total_temperature_summaries( | ||
# country = "zm", | ||
# station_id = "1", | ||
# summaries = c("mean_tmin", "mean_tmax"), | ||
# to = "monthly" | ||
# ) | ||
# | ||
# # Define test cases | ||
# test_that("total_temperature_summaries returns correct results", { | ||
# # Mock the necessary external functions or datasets if needed | ||
# expect_length(result, 2) | ||
# expect_length(result_2, 2) | ||
# | ||
# expect_no_error(result) | ||
# expect_no_error(result_2) | ||
# }) | ||
library(testthat) | ||
library(epicsawrap) | ||
|
||
# Test case 1 | ||
epicsadata::gcs_auth_file(file = "testdata/e-picsa-e630400792e7.json") | ||
test_1_annual <- readRDS("testdata/test_1_annual.rds") | ||
test_1_monthly <- readRDS("testdata/test_1_monthly.rds") | ||
country <- "zm" | ||
station_id <- "test_1" | ||
|
||
test_that("Correct summaries are calculated", { | ||
result_annual <- annual_temperature_summaries(country, station_id) | ||
result_monthly <- monthly_temperature_summaries(country, station_id) | ||
|
||
expect_true(identical(result_annual[[2]], test_1_annual)) | ||
expect_true(identical(result_monthly[[2]], test_1_monthly)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
e-picsa-e630400792e7.json | ||
test.R | ||
epicsae630400792e7.json |
Oops, something went wrong.