Mercurial > repos > greg > extract_ipm_date_interval
comparison utils.R @ 2:9c5a4d07edb8 draft
Uploaded
author | greg |
---|---|
date | Wed, 01 Aug 2018 08:18:39 -0400 |
parents | 4dccc60b3525 |
children | 0d9a74365270 |
comparison
equal
deleted
inserted
replaced
1:0764ac25c68f | 2:9c5a4d07edb8 |
---|---|
11 lsi = get_life_stage_index(life_stage); | 11 lsi = get_life_stage_index(life_stage); |
12 file_name = paste(lsi, base_name, sep="_"); | 12 file_name = paste(lsi, base_name, sep="_"); |
13 } | 13 } |
14 file_path = paste("output_plots_dir", file_name, sep="/"); | 14 file_path = paste("output_plots_dir", file_name, sep="/"); |
15 return(file_path); | 15 return(file_path); |
16 } | |
17 | |
18 get_year_from_date = function(date_str) { | |
19 date_str_items = strsplit(date_str, "-")[[1]]; | |
20 return (date_str_items[1]); | |
16 } | 21 } |
17 | 22 |
18 get_life_stage_index = function(life_stage, life_stage_nymph=NULL, life_stage_adult=NULL) { | 23 get_life_stage_index = function(life_stage, life_stage_nymph=NULL, life_stage_adult=NULL) { |
19 # Name collection elements so that they | 24 # Name collection elements so that they |
20 # are displayed in logical order. | 25 # are displayed in logical order. |
92 } else { | 97 } else { |
93 return(365); | 98 return(365); |
94 } | 99 } |
95 } | 100 } |
96 | 101 |
97 get_x_axis_ticks_and_labels = function(temperature_data_frame, prepend_end_doy_norm, append_start_doy_norm, date_interval=FALSE) { | 102 get_x_axis_ticks_and_labels = function(temperature_data_frame, prepend_end_doy_norm=NULL, append_start_doy_norm=NULL, date_interval=FALSE) { |
98 # Generate a list of ticks and labels for plotting the x axis. | 103 # Generate a list of ticks and labels for plotting the x axis. |
99 if (prepend_end_doy_norm > 0) { | 104 if (!is.null(prepend_end_doy_norm) & prepend_end_doy_norm > 0) { |
100 prepend_end_norm_row = which(temperature_data_frame$DOY==prepend_end_doy_norm); | 105 prepend_end_norm_row = which(temperature_data_frame$DOY==prepend_end_doy_norm); |
101 } else { | 106 } else { |
102 prepend_end_norm_row = 0; | 107 prepend_end_norm_row = 0; |
103 } | 108 } |
104 if (append_start_doy_norm > 0) { | 109 if (!is.null(append_start_doy_norm) & append_start_doy_norm > 0) { |
105 append_start_norm_row = which(temperature_data_frame$DOY==append_start_doy_norm); | 110 append_start_norm_row = which(temperature_data_frame$DOY==append_start_doy_norm); |
106 } else { | 111 } else { |
107 append_start_norm_row = 0; | 112 append_start_norm_row = 0; |
108 } | 113 } |
109 num_rows = dim(temperature_data_frame)[1]; | 114 num_rows = dim(temperature_data_frame)[1]; |