diff utils.R @ 60:393085589438 draft

Uploaded
author greg
date Thu, 20 Dec 2018 09:15:52 -0500
parents 892cf703be62
children
line wrap: on
line diff
--- a/utils.R	Wed Nov 21 11:42:37 2018 -0500
+++ b/utils.R	Thu Dec 20 09:15:52 2018 -0500
@@ -333,3 +333,21 @@
     }
     return(valid_date);
 }
+
+validate_doys = function(temperature_data_frame) {
+    # Ensure all DOY values are consecutive integers.
+    last_doy = 0;
+    num_rows = dim(temperature_data_frame)[1];
+    for (i in 1:num_rows) {
+        doy = as.integer(temperature_data_frame$DOY[i]);
+        if (last_doy == 0) {
+            last_doy = doy;
+        } else {
+            if (doy != last_doy + 1) {
+                msg = paste("DOY ", doy, " is not consecutive (previous DOY is ", last_doy, ".", sep="");
+                stop_err(msg);
+            }
+            last_doy = doy;
+        }
+    }
+}