Skip to content

Commit

Permalink
Update package name from gaea to gaia
Browse files Browse the repository at this point in the history
  • Loading branch information
mengqi-z committed Oct 4, 2024
1 parent 7bcca47 commit 6a79a79
Show file tree
Hide file tree
Showing 35 changed files with 221 additions and 219 deletions.
10 changes: 5 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# How to contribute

We welcome third-party patches, which are essential for advancing the science and architecture of gaea.
We welcome third-party patches, which are essential for advancing the science and architecture of gaia.
But there are a few guidelines that we ask contributors to follow, guidelines that ease the maintainers' organizational and logistical duties, while encouraging development by others. All contributors agree to abide by the code of conduct.

## Getting Started

* Make sure you have a [GitHub account](https://github.com/signup/free).
* **Open an issue** describing your proposed change or work (after making sure one does not already exist).
* Clearly describe the issue including steps to reproduce when it is a bug.
* Discuss how your change will affect gaea, and thus whether it's MAJOR, MINOR, or a PATCH.
* Discuss how your change will affect gaia, and thus whether it's MAJOR, MINOR, or a PATCH.
* Interact with the project maintainers to refine/change/prioritize your issue and identify what branch will be targeted (see below).
* Trivial changes to comments or documentation do not require creating a new issue.

Expand All @@ -20,15 +20,15 @@ But there are a few guidelines that we ask contributors to follow, guidelines th
* We will never accept pull requests to the `main` branch.
* Check for unnecessary whitespace with `git diff --check` before committing.
* Make sure your commit messages are descriptive but succinct, describing what was changed and why, and **reference the relevant issue number**. Make commits of logical units.
* Make sure you have added the necessary tests for your changes. Tests should be included in the root `tests` directory and are facilitated using `pytest` which is installed with the development version of gaea. See more info on using `pytest` here: https://docs.pytest.org/en/7.4.x/contents.html
* Make sure you have added the necessary tests for your changes. Tests should be included in the root `tests` directory and are facilitated using `pytest` which is installed with the development version of gaia. See more info on using `pytest` here: https://docs.pytest.org/en/7.4.x/contents.html
* Run _all_ the tests to assure nothing else was accidentally broken.

## Submitting Changes

* Submit a pull request.
* **Your pull request should include one of the following two statements**:
* You own the copyright on the code being contributed, and you hereby grant PNNL unlimited license to use this code in this version or any future version of gaea. You reserve all other rights to the code.
* Somebody else owns the copyright on the code being contributed (e.g., your employer because you did it as part of your work for them); you are authorized by that owner to grant PNNL an unlimited license to use this code in this version or any future version of gaea, and you hereby do so. All other rights to the code are reserved by the copyright owner.
* You own the copyright on the code being contributed, and you hereby grant PNNL unlimited license to use this code in this version or any future version of gaia. You reserve all other rights to the code.
* Somebody else owns the copyright on the code being contributed (e.g., your employer because you did it as part of your work for them); you are authorized by that owner to grant PNNL an unlimited license to use this code in this version or any future version of gaia, and you hereby do so. All other rights to the code are reserved by the copyright owner.
* The core team looks at Pull Requests on a regular basis, and will respond as soon as possible.


Expand Down
6 changes: 3 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ authors:
- family-names: "Abigail"
given-names: "Snyder"
orcid: "https://orcid.org/0000-0002-9034-9948"
title: "gaea: An R package to estimate crop yield responses to temperature and precipitation"
title: "gaia: An R package to estimate crop yield responses to temperature and precipitation"
version: 1.0.0
url: "https://github.com/JGCRI/gaea"
url: "https://github.com/JGCRI/gaia"
preferred-citation:
type: article
authors:
Expand All @@ -33,7 +33,7 @@ preferred-citation:
orcid: "https://orcid.org/0000-0002-9034-9948"
doi: "10.xxxxx/joss.xxxxx"
journal: "Journal of Open Source Software"
title: "gaea: An R package to estimate crop yield responses to temperature and precipitation"
title: "gaia: An R package to estimate crop yield responses to temperature and precipitation"
issue: x
volume: y
year: 2024
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: gaea
Title: gaea: An R package to estimate crop yield responses to temperature
Package: gaia
Title: gaia: An R package to estimate crop yield responses to temperature
and precipitation
Version: 1.0.0
Authors@R: c(
Expand All @@ -15,8 +15,8 @@ Authors@R: c(
Description: An empirical model to estimate annual crop yield responses to
temperature and precipitation.
License: BSD_3_clause + file LICENSE
URL: https://github.com/JGCRI/gaea
BugReports: https://github.com/JGCRI/gaea/issues
URL: https://github.com/JGCRI/gaia
BugReports: https://github.com/JGCRI/gaia/issues
Depends:
R (>= 4.1)
Imports:
Expand Down
2 changes: 1 addition & 1 deletion DISCLAIMER
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gaea
gaia

DISCLAIMER:

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gaea
gaia

BSD 3-Clause License

Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# gaea 1.0.0
# gaia 1.0.0

First release TBD
6 changes: 3 additions & 3 deletions R/crop_calendars.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ crop_calendars <- function(output_dir = file.path(getwd(), 'output')){
# format, subset data and replace location name
d$Location <- ifelse( d$Location == "Georgia" & d$Source == "USDA UPHD", "Georgia_USA", d$Location )
d <- subset( d, select = c( "Data.ID", "Location", "Crop", "Qualifier", "Plant.start", "Plant.end", "Harvest.start", "Harvest.end" ) )
d <- gaea::colname_replace( d, "Location", "country_name" )
d <- gaea::colname_replace( d, "Crop", "crop" )
d <- gaia::colname_replace( d, "Location", "country_name" )
d <- gaia::colname_replace( d, "Crop", "crop" )
d$crop <- tolower( d$crop )

# Average plant and harvest month
Expand All @@ -32,7 +32,7 @@ crop_calendars <- function(output_dir = file.path(getwd(), 'output')){

# Country codes
d <- merge( d, mapping_gcam_iso, by = "country_name", all.x = TRUE )
d <- gaea::iso_replace( d )
d <- gaia::iso_replace( d )

# Indicators for crops
crops <- tibble::tibble(
Expand Down
20 changes: 10 additions & 10 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#' @format R data frame
#' @examples
#' \dontrun{
#' library(gaea);
#' co2_historical <- gaea::co2_historical
#' library(gaia);
#' co2_historical <- gaia::co2_historical
#' }
"co2_historical"

Expand All @@ -17,8 +17,8 @@
#' @format R data frame
#' @examples
#' \dontrun{
#' library(gaea);
#' co2_projection <- gaea::co2_projection
#' library(gaia);
#' co2_projection <- gaia::co2_projection
#' }
"co2_projection"

Expand All @@ -29,8 +29,8 @@
#' @format R data frame
#' @examples
#' \dontrun{
#' library(gaea);
#' agprodchange_ni_gcam7 <- gaea::agprodchange_ni_gcam7
#' library(gaia);
#' agprodchange_ni_gcam7 <- gaia::agprodchange_ni_gcam7
#' }
"agprodchange_ni_gcam7"

Expand All @@ -40,8 +40,8 @@
#' @format R data frame
#' @examples
#' \dontrun{
#' library(gaea);
#' agprodchange_ni_gcam6 <- gaea::agprodchange_ni_gcam6
#' library(gaia);
#' agprodchange_ni_gcam6 <- gaia::agprodchange_ni_gcam6
#' }
"agprodchange_ni_gcam6"

Expand All @@ -51,7 +51,7 @@
#' @format R data frame
#' @examples
#' \dontrun{
#' library(gaea);
#' coef_default <- gaea::coef_default
#' library(gaia);
#' coef_default <- gaia::coef_default
#' }
"coef_default"
20 changes: 10 additions & 10 deletions R/data_aggregation.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ data_aggregation <- function(climate_hist_dir = NULL,
message('Starting Step: data_aggregation')

# read crop calendar output from crop_calendars function
crop_cal <- gaea::input_data(
crop_cal <- gaia::input_data(
folder_path = file.path(output_dir, 'data_processed'),
input_file = 'crop_calendar.csv'
)

# merge fao yield and fao irrigation equip data
yield <- gaea::merge_data(fao_yield, fao_irr_equip, 'iso', 'year')
yield <- gaia::merge_data(fao_yield, fao_irr_equip, 'iso', 'year')


# ----------------------------------------------------------------------------
Expand All @@ -46,7 +46,7 @@ data_aggregation <- function(climate_hist_dir = NULL,

} else {

gaea::path_check(climate_hist_dir)
gaia::path_check(climate_hist_dir)

# get file list
list_precip_rfc <- list.files(
Expand All @@ -70,17 +70,17 @@ data_aggregation <- function(climate_hist_dir = NULL,
file_temp <-list_temp_rfc[grepl(crop_id, list_temp_rfc)]

# aggregate weather data for crop_i
d_climate <- gaea::weather_agg(file_precip = file_precip,
d_climate <- gaia::weather_agg(file_precip = file_precip,
file_temp = file_temp,
crop_name = crop_i)

# estimate growing season for each crop and country (SAGE db)
d_crop <- gaea::crop_month(climate_data = d_climate,
d_crop <- gaia::crop_month(climate_data = d_climate,
crop_name = crop_i,
crop_calendar = crop_cal)

# merge data
d_crop <- gaea::data_merge(data = d_crop,
d_crop <- gaia::data_merge(data = d_crop,
crop_name = crop_i,
yield = yield,
co2_hist = co2_hist,
Expand All @@ -99,7 +99,7 @@ data_aggregation <- function(climate_hist_dir = NULL,
if(is.null(climate_impact_dir)){
stop('Please provide folder path to the projected climate data.')
} else {
gaea::path_check(climate_impact_dir)
gaia::path_check(climate_impact_dir)
}

# get file list
Expand All @@ -124,17 +124,17 @@ data_aggregation <- function(climate_hist_dir = NULL,
file_temp <-list_temp_rfc[grepl(crop_id, list_temp_rfc)]

# aggregate weather data for crop_i
d_climate <- gaea::weather_agg(file_precip = file_precip,
d_climate <- gaia::weather_agg(file_precip = file_precip,
file_temp = file_temp,
crop_name = crop_i)

# estimate growing season for each crop and country (SAGE db)
d_crop <- gaea::crop_month(climate_data = d_climate,
d_crop <- gaia::crop_month(climate_data = d_climate,
crop_name = crop_i,
crop_calendar = crop_cal)

# merge data
d_crop <- gaea::data_trans(data = d_crop,
d_crop <- gaia::data_trans(data = d_crop,
climate_model = climate_model,
climate_scenario = climate_scenario,
crop_name = crop_i,
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions R/pkg_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
pkg_example <- function(path = NULL) {

if (is.null(path)) {
dir(system.file('extras', package = 'gaea'))
dir(system.file('extras', package = 'gaia'))
} else {
system.file('extras', path, package = 'gaea', mustWork = TRUE)
system.file('extras', path, package = 'gaia', mustWork = TRUE)
}

}
Expand Down Expand Up @@ -222,8 +222,8 @@ merge_data <- function( d1, d2, x1, x2 )
x2.y <- paste( x2, "y", sep = "." )
d1[[x1.y]] <- NULL
d1[[x2.y]] <- NULL
d1 <- gaea::colname_replace( d1, x1.x, x1 )
d1 <- gaea::colname_replace( d1, x2.x, x2 )
d1 <- gaia::colname_replace( d1, x1.x, x1 )
d1 <- gaia::colname_replace( d1, x2.x, x2 )
d1$id <- NULL
return( d1 )
}
Expand Down Expand Up @@ -251,7 +251,7 @@ agprodchange_ref <- function(gcam_version = 'gcam7',
if(!is.null(gcamdata_dir)){

# If user provide their own gcamdata dirctory, then use user provided data
gaea::path_check(gcamdata_dir)
gaia::path_check(gcamdata_dir)

if(grepl('ssp1|ssp5', climate_scenario)){
agprodchange_ag <- data.table::fread(file.path(gcamdata_dir, 'outputs', 'L2052.AgProdChange_irr_high.csv'))
Expand Down Expand Up @@ -283,11 +283,11 @@ agprodchange_ref <- function(gcam_version = 'gcam7',

# if user doesn't provide any gcamdata, then use default
if(gcam_version == 'gcam6'){
agprodchange_ni <- gaea::agprodchange_ni_gcam6
agprodchange_ni <- gaia::agprodchange_ni_gcam6
}

if(gcam_version == 'gcam7'){
agprodchange_ni <- gaea::agprodchange_ni_gcam7
agprodchange_ni <- gaia::agprodchange_ni_gcam7
}

# filter based on the scenario
Expand Down
10 changes: 5 additions & 5 deletions R/weighted_climate.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ weighted_climate <- function(pr_ncdf = NULL,
for(pr_file in pr_ncdf) {

# check if pr file is valid
gaea::path_check(path = pr_file, file_type = 'nc')
gaia::path_check(path = pr_file, file_type = 'nc')

# precipitation
message(paste0('Processing: ', pr_file))

# get time periods of the nc file
nc_time <- gaea::get_nc_time(pr_file)
nc_time <- gaia::get_nc_time(pr_file)

# check if the data periods is within the selected periods
if (!is.null(time_periods)){
Expand Down Expand Up @@ -175,13 +175,13 @@ weighted_climate <- function(pr_ncdf = NULL,
for(tas_file in tas_ncdf) {

# check if pr file is valid
gaea::path_check(path = tas_file, file_type = 'nc')
gaia::path_check(path = tas_file, file_type = 'nc')

# precipitation
message(paste0('Processing: ', tas_file))

# get time periods of the nc file
nc_time <- gaea::get_nc_time(tas_file)
nc_time <- gaia::get_nc_time(tas_file)

# check if the data periods is within the selected periods
if (!is.null(time_periods)){
Expand Down Expand Up @@ -265,7 +265,7 @@ weighted_climate <- function(pr_ncdf = NULL,
}


} # end of for(crop in names(gaea::mirca_harvest_area))
} # end of for(crop in names(gaia::mirca_harvest_area))

message('The function weighted_climate is complete.')

Expand Down
14 changes: 7 additions & 7 deletions R/yield_impact.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ yield_impact <- function(pr_hist_ncdf = NULL,
# Step 1b: Process standard NetCDF files from ISIMIP to country level historical climate
if(any(!is.null(pr_hist_ncdf), !is.null(tas_hist_ncdf))){

gaea::weighted_climate(pr_ncdf = pr_hist_ncdf,
gaia::weighted_climate(pr_ncdf = pr_hist_ncdf,
tas_ncdf = tas_hist_ncdf,
timestep = timestep,
climate_model = climate_model,
Expand All @@ -70,7 +70,7 @@ yield_impact <- function(pr_hist_ncdf = NULL,
# Step 1b: Process standard NetCDF files from ISIMIP to country level projected climate
if(any(!is.null(pr_proj_ncdf), !is.null(tas_proj_ncdf))){

gaea::weighted_climate(pr_ncdf = pr_proj_ncdf,
gaia::weighted_climate(pr_ncdf = pr_proj_ncdf,
tas_ncdf = tas_proj_ncdf,
timestep = timestep,
climate_model = climate_model,
Expand All @@ -83,7 +83,7 @@ yield_impact <- function(pr_hist_ncdf = NULL,


# Step 2: Generate planting months for each country
gaea::crop_calendars(output_dir = output_dir)
gaia::crop_calendars(output_dir = output_dir)

# Step 3: Process multiple models to analyze historical weather variables and crop yields
if(all(is.null(climate_hist_dir),
Expand All @@ -99,21 +99,21 @@ yield_impact <- function(pr_hist_ncdf = NULL,
}


gaea::data_aggregation(climate_hist_dir = climate_hist_dir,
gaia::data_aggregation(climate_hist_dir = climate_hist_dir,
climate_impact_dir = climate_impact_dir,
climate_model = climate_model,
climate_scenario = climate_scenario,
output_dir = output_dir)

# Step 4: Yield regressions and create figures
if(!use_default_coeff){
gaea::yield_regression(diagnostics = diagnostics,
gaia::yield_regression(diagnostics = diagnostics,
output_dir = output_dir)
}


# Step 5: Project yields for future climate scenarios using regression analysis
df_yield_projection <- gaea::yield_shock_projection(use_default_coeff = use_default_coeff,
df_yield_projection <- gaia::yield_shock_projection(use_default_coeff = use_default_coeff,
climate_model = climate_model,
climate_scenario = climate_scenario,
base_year = base_year,
Expand All @@ -125,7 +125,7 @@ yield_impact <- function(pr_hist_ncdf = NULL,
)

# Step 6:
df_yield_impact_gcam <- gaea::gcam_agprodchange(data = df_yield_projection,
df_yield_impact_gcam <- gaia::gcam_agprodchange(data = df_yield_projection,
climate_model = climate_model,
climate_scenario = climate_scenario,
member = member,
Expand Down
Loading

0 comments on commit 6a79a79

Please sign in to comment.