Mercurial > repos > greg > extract_ipm_date_interval
comparison extract_ipm_date_interval.R @ 7:869e7d06bdf3 draft
Uploaded
| author | greg |
|---|---|
| date | Wed, 01 Aug 2018 08:47:20 -0400 |
| parents | 87482a201699 |
| children | cf6a06a2346c |
comparison
equal
deleted
inserted
replaced
| 6:0d9a74365270 | 7:869e7d06bdf3 |
|---|---|
| 50 stop_err("Date intervals for plotting cannot exceed 50 days."); | 50 stop_err("Date intervals for plotting cannot exceed 50 days."); |
| 51 } | 51 } |
| 52 # Display the total number of days in the Galaxy history item blurb. | 52 # Display the total number of days in the Galaxy history item blurb. |
| 53 cat("Number of days in date interval: ", num_days, "\n"); | 53 cat("Number of days in date interval: ", num_days, "\n"); |
| 54 | 54 |
| 55 # Get the year from the start_date. | |
| 56 year = get_year_from_date(start_date); | |
| 57 # Get the DOY for start_date and end_date. | |
| 58 start_date_doy = as.integer(strftime(start_date, format="%j")); | |
| 59 end_date_doy = as.integer(strftime(end_date, format="%j")); | |
| 60 # Get the ticks date labels for plots. | |
| 61 ticks_and_labels = get_x_axis_ticks_and_labels(temperature_data_frame, date_interval=TRUE); | |
| 62 ticks = c(unlist(ticks_and_labels[1])); | |
| 63 date_labels = c(unlist(ticks_and_labels[2])); | |
| 64 # All latitude values are the same, so get the value | |
| 65 # for plots from the first row. | |
| 66 latitude = temperature_data_frame$LATITUDE[1]; | |
| 67 | |
| 68 input_files = list.files(path=input_dir, full.names=TRUE); | 55 input_files = list.files(path=input_dir, full.names=TRUE); |
| 69 for(input_file in input_files) { | 56 for(input_file in input_files) { |
| 70 temperature_data_frame = get_new_temperature_data_frame(input_file); | 57 temperature_data_frame = get_new_temperature_data_frame(input_file); |
| 71 start_date_row = which(temperature_data_frame$DATE==start_date); | 58 start_date_row = which(temperature_data_frame$DATE==start_date); |
| 72 end_date_row = which(temperature_data_frame$DATE==end_date); | 59 end_date_row = which(temperature_data_frame$DATE==end_date); |
| 73 # Extract the date interval. | 60 # Extract the date interval. |
| 74 temperature_data_frame = temperature_data_frame[start_date_row:end_date_row,]; | 61 temperature_data_frame = temperature_data_frame[start_date_row:end_date_row,]; |
| 62 # Get the ticks date labels for plots. | |
| 63 ticks_and_labels = get_x_axis_ticks_and_labels(temperature_data_frame, date_interval=TRUE); | |
| 64 ticks = c(unlist(ticks_and_labels[1])); | |
| 65 date_labels = c(unlist(ticks_and_labels[2])); | |
| 66 # All latitude values are the same, so get the value | |
| 67 # for plots from the first row. | |
| 68 latitude = temperature_data_frame$LATITUDE[1]; | |
| 75 # Save the date interval data into an output file | 69 # Save the date interval data into an output file |
| 76 # named the same as the input. | 70 # named the same as the input. |
| 77 file_path = paste("output_data_dir", input_file, sep="/"); | 71 file_path = paste("output_data_dir", input_file, sep="/"); |
| 78 write.csv(temperature_data_frame, file=file_path, row.names=F); | 72 write.csv(temperature_data_frame, file=file_path, row.names=F); |
| 79 # TODO: Save the datE interval plots... | 73 # TODO: Save the datE interval plots... |
