@@ -11,16 +11,27 @@ options <- list(
1111 default = " site_info.csv" ,
1212 help = " CSV giving ids, locations, and PFTs for sites of interest"
1313 ),
14- optparse :: make_option(" --raw_parquet_dir" ,
15- default = " data_raw/management" ,
16- help = paste(
17- " Directory containing management inputs in Parquet format." ,
18- " Note: Code currently looks for subpaths that include hard-coded" ,
19- " version numbers for each management type." ,
20- " If this path is empty, cleaning is skipped and clean Parquet files" ,
21- " must already exist at the path specified by --clean_parquet_dir`."
22- )
14+ optparse :: make_option(" --phenology_path" ,
15+ default = " data_raw/management/phenology/v1.0" ,
16+ help = " Parquet file or directory of Parquet files containing phenology events" ,
17+ ),
18+ optparse :: make_option(" --planting_path" ,
19+ default = " data_raw/management/planting/v1.0" ,
20+ help = " Parquet file or directory of Parquet files containing planting events" ,
21+ ),
22+ optparse :: make_option(" --harvest_path" ,
23+ default = " data_raw/management/harvest/v1.0" ,
24+ help = " Parquet file or directory of Parquet files containing harvest events" ,
25+ ),
26+ optparse :: make_option(" --tillage_path" ,
27+ default = " data_raw/management/tillage/v1.0" ,
28+ help = " Parquet file or directory of Parquet files containing tillage events" ,
2329 ),
30+ optparse :: make_option(" --irrigation_path" ,
31+ default = " data_raw/management/irrigation/v1.1" ,
32+ help = " Parquet file or directory of Parquet files containing tillage events" ,
33+ ),
34+ # TODO add fertilization and NCC here
2435 optparse :: make_option(" --clean_parquet_dir" ,
2536 default = " data/management_ensembles" ,
2637 help = paste(
@@ -60,19 +71,7 @@ this_file <- function() {
6071 cmd_args <- commandArgs(trailingOnly = FALSE )
6172 normalizePath(sub(" ^--file=" , " " , grep(" ^--file=" , cmd_args , value = TRUE )))
6273}
63- event_prep_dir <- normalizePath(file.path(dirname(this_file()), " .." , " .." , " tools" , " event_prep" ))
64-
65- # TODO these probably deserve to be runtime args,
66- # but first better fix other version-specific assumptions below
67- mgmt_subdirs <- list (
68- pheno = file.path(args $ raw_parquet_dir , " phenology/v1.0" ),
69- plant = file.path(args $ raw_parquet_dir , " planting/v1.0" ),
70- harv = file.path(args $ raw_parquet_dir , " harvest/v1.0" ),
71- till = file.path(args $ raw_parquet_dir , " tillage/v1.0" ),
72- irri = file.path(args $ raw_parquet_dir , " irrigation/v1.1" ),
73- fert = NULL , # TODO
74- occ = NULL # TODO
75- )
74+ event_prep_dir <- normalizePath(file.path(dirname(this_file()), " .." , " tools" , " event_prep" ))
7675
7776if (! dir.exists(args $ event_outdir )) {
7877 dir.create(args $ event_outdir , recursive = TRUE )
@@ -82,28 +81,30 @@ cargs <- function(...) {
8281 paste0(" --" , ... names(), " =" , list (... ))
8382}
8483
85- if ( args $ raw_parquet_dir != " " ) {
86- PEcAn.logger :: logger.info(" Cleaning irrigation files" )
87- callr :: rscript(
88- file.path(event_prep_dir , " 01a-clean-irrigation.R" ),
89- cmdargs = cargs(
90- irr_path = mgmt_subdirs $ irri ,
91- outdir = args $ clean_parquet_dir
92- )
84+
85+ PEcAn.logger :: logger.info(" Cleaning irrigation files" )
86+ callr :: rscript(
87+ file.path(event_prep_dir , " 01a-clean-irrigation.R" ),
88+ cmdargs = cargs(
89+ irr_path = args $ irrigation_path ,
90+ outdir = args $ clean_parquet_dir ,
91+ site_info_path = args $ site_info_path
9392 )
94- PEcAn.logger :: logger.info(" Cleaning other management files" )
95- callr :: rscript(
96- file.path(event_prep_dir , " 01b-clean-other-events.R" ),
97- cmdargs = cargs(
98- pheno_dir = mgmt_subdirs $ pheno ,
99- planting_dir = mgmt_subdirs $ plant ,
100- harvest_dir = mgmt_subdirs $ harv ,
101- tillage_dir = mgmt_subdirs $ till ,
102- adjust_start = args $ start_date ,
103- outdir = args $ clean_parquet_dir
104- )
93+ )
94+ PEcAn.logger :: logger.info(" Cleaning other management files" )
95+ callr :: rscript(
96+ file.path(event_prep_dir , " 01b-clean-other-events.R" ),
97+ cmdargs = cargs(
98+ site_info_path = args $ site_info_path ,
99+ pheno_dir = args $ phenology_path ,
100+ planting_dir = args $ planting_path ,
101+ harvest_dir = args $ harvest_path ,
102+ tillage_dir = args $ tillage_path ,
103+ adjust_start = args $ start_date ,
104+ outdir = args $ clean_parquet_dir
105105 )
106- }
106+ )
107+
107108
108109PEcAn.logger :: logger.info(" converting management files to events" )
109110callr :: rscript(
0 commit comments