comparison extract_ipm_date_interval.R @ 3:3126def1a8e9 draft

Uploaded
author greg
date Wed, 01 Aug 2018 08:18:47 -0400
parents 4dccc60b3525
children 3741790740f3
comparison
equal deleted inserted replaced
2:9c5a4d07edb8 3:3126def1a8e9
2 2
3 suppressPackageStartupMessages(library("data.table")) 3 suppressPackageStartupMessages(library("data.table"))
4 suppressPackageStartupMessages(library("optparse")) 4 suppressPackageStartupMessages(library("optparse"))
5 5
6 option_list <- list( 6 option_list <- list(
7 make_option(c("--input_dir"), action="store", dest="input_dir", help="Directory containing .csv outputs from insect_phenology_model"), 7 make_option(c("--input_dir"), action="store", dest="input_dir", help="Directory containing .csv outputs from insect_phenology_model"),
8 make_option(c("--start_date"), action="store", dest="start_date", default=NULL, help="Start date for custom date interval"), 8 make_option(c("--end_date"), action="store", dest="end_date", help="End date for date interval"),
9 make_option(c("--script_dir"), action="store", dest="script_dir", help="R script source directory") 9 make_option(c("--start_date"), action="store", dest="start_date", help="Start date for date interval"),
10 make_option(c("--script_dir"), action="store", dest="script_dir", help="R script source directory")
10 ) 11 )
11 12
12 parser <- OptionParser(usage="%prog [options] file", option_list=option_list); 13 parser <- OptionParser(usage="%prog [options] file", option_list=option_list);
13 args <- parse_args(parser, positional_arguments=TRUE); 14 args <- parse_args(parser, positional_arguments=TRUE);
14 opt <- args$options; 15 opt <- args$options;
53 year = get_year_from_date(start_date); 54 year = get_year_from_date(start_date);
54 # Get the DOY for start_date and end_date. 55 # Get the DOY for start_date and end_date.
55 start_date_doy = as.integer(strftime(start_date, format="%j")); 56 start_date_doy = as.integer(strftime(start_date, format="%j"));
56 end_date_doy = as.integer(strftime(end_date, format="%j")); 57 end_date_doy = as.integer(strftime(end_date, format="%j"));
57 # Get the ticks date labels for plots. 58 # Get the ticks date labels for plots.
58 ticks_and_labels = get_x_axis_ticks_and_labels(temperature_data_frame, prepend_end_doy_norm, append_start_doy_norm, date_interval=TRUE); 59 ticks_and_labels = get_x_axis_ticks_and_labels(temperature_data_frame, date_interval=TRUE);
59 ticks = c(unlist(ticks_and_labels[1])); 60 ticks = c(unlist(ticks_and_labels[1]));
60 date_labels = c(unlist(ticks_and_labels[2])); 61 date_labels = c(unlist(ticks_and_labels[2]));
61 # All latitude values are the same, so get the value 62 # All latitude values are the same, so get the value
62 # for plots from the first row. 63 # for plots from the first row.
63 latitude = temperature_data_frame$LATITUDE[1]; 64 latitude = temperature_data_frame$LATITUDE[1];