-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRUN_FLAME_2016_Picarro.R
More file actions
153 lines (120 loc) · 5.31 KB
/
RUN_FLAME_2016_Picarro.R
File metadata and controls
153 lines (120 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
############################################################################################
rm(list=ls(all=TRUE)) #clear the environment
# ==================================================
# Change directory to match desired dataset
# Change date and sitename!
# Should read ("/Dropbox/.../YYYY-MM-DD_SiteName)
# Added a loop function to do this for all 6 ColumbiaRiver Days. Remove loop if wanting to run a single day.
# ==================================================
FLAME_Data_Directory<-"Dropbox/FLAME_ColumbiaRiver/Data"
#Enter Picarro time offset in seconds
Picarro_Time_Offset<-15
# ==================================================
# Point to the main FLAME dropbox directory
# This should be your "yourcomputer"/Dropbox/FLAME
# ==================================================
setwd("E:/Dropbox/FLAME") #Loken Desk
# Other computers
# setwd("F:/Dropbox/FLAME") #?
# setwd("C:/Users/jtcrawford/Dropbox/FLAME") #Crawford Laptop
# setwd("C:/Users/Luke/Dropbox/FLAME") #Loken Laptop
# ==============================
# Don't change anything below!
# Script uses relative directories within "Dropbox/FLAME"
# ==============================
setwd("R scripts")
# call the FLAMe scripts
source("FLAMer.R")
# Load tau corrections
setwd("..")
setwd("Taus")
taus2015.01<-read.csv("Manual_Hydros_Taus_2015.csv", header=TRUE)
taus2016.01<-read.csv("Manual_Hydros_Taus_2016.01.csv", header=TRUE)
taus2016.02<-read.csv("Manual_Hydros_Taus_2016.02.csv", header=TRUE)
taus2016.03<-read.csv("Manual_Hydros_Taus_2016.03.csv", header=TRUE)
# Load rule table for sensorQC
setwd("..")
setwd("SensorQC")
ruletable<-read.csv("SensorQCRulesStrick2_2015.csv", header=TRUE, stringsAsFactors=FALSE)
# Add common basemaps
setwd("..")
setwd("basemaps")
Mendota_Base<-readOGR(getwd(), "Mendota_shape")
Mendota_Base_UTM<-spTransform(Mendota_Base, CRS("+proj=utm +zone=15 ellps=WGS84"))
Pool8_Base_UTM<-readOGR(getwd(), "Pool8")
Pool8_Base<-spTransform(Pool8_Base_UTM, CRS("+init=epsg:4326"))
lakes_Base_UTM<-readOGR(getwd(), "regional_lakes_3")
lakes_Base<-spTransform(lakes_Base_UTM, CRS("+init=epsg:4326"))
UNDERC_Base_UTM<-readOGR(getwd(), "Peter_Paul_Tuesday_shifted2")
UNDERC_Base<-spTransform(UNDERC_Base_UTM, CRS("+init=epsg:4326"))
# Read in zerotimes from Peter Turner
setwd("..")
setwd("Ambient_Times")
zerotimes<-read.csv("Ambient_Times_2015.csv", header=TRUE)
zerotimes[,1]<-as.POSIXct(strptime(as.character(zerotimes[,1]), format="%m/%d/%Y %H:%M"), tz="America/Chicago")
zerotimes[,2]<-as.POSIXct(strptime(as.character(zerotimes[,2]), format="%m/%d/%Y %H:%M"), tz="America/Chicago")
# point to the data folder; individual instrument files need to be in subfolders
# with the names 'laser', 'gps', 'ysi' 'nitro', 'meta', 'samples' (case sensitive)
setwd("..")
setwd("..")
setwd("..")
setwd(paste(getwd(), FLAME_Data_Directory, sep=""))
# ===========================================================
# Start Open CR Loop Code
# Loop code, here and an after flame_engage function
# Code will loop through all 13 UMR files and perform {flame engage}
# starting directory - setwd("E:/Dropbox/FLAME_ColumbiaRiver/Data")
# ===========================================================
CR_files<-list.files()
CR_files<-CR_files[which(CR_files!="ColumbiaRiver2016_AllDays")]
CR_files[1:2]
days<-CR_files[1]
for (days in CR_files){
FLAMEsubdirectory<-(days)
setwd(paste(getwd(), FLAMEsubdirectory, sep="/"))
# ===========================================================
# End Open CR Loop Code
# ===========================================================
# read in a metadata file
# indicates the date (YYYY-MM-DD !!!), site, instruments, flame intervals, and water samples
MetaPath <- list.files(path = paste(getwd(), "/meta", sep=""))
meta<-do.call("rbind", lapply(paste("meta/", MetaPath, sep=""), read.table, sep="," ,skip=0, header = TRUE, fill=TRUE))
Date<-as.Date(meta$Date[1], format="%Y-%m-%d")
Site<-as.character(meta$Site[1])
# grab samples and atm data if present
if (meta$number_of_samples[1]!=0){
SamplesPath <- list.files(path = paste(getwd(), "/samples", sep=""))
Samples<-do.call("rbind", lapply(paste("samples/", SamplesPath, sep=""), read.table, sep="," ,skip=0, header = TRUE, fill=TRUE))}
if (meta$number_of_atm_samples[1]>0){
AtmPath <- list.files(path = paste(getwd(), "/atm", sep=""))
Atm<-do.call("rbind", lapply(paste("atm/", AtmPath, sep=""), read.table, sep="," ,skip=0, header = TRUE, fill=TRUE))}
# Set correct basemap
if(Site=="Peter" | Site=="Paul" | Site=="Tuesday" |Site=="TuesdayLake" | Site=="PeterLake" |Site=="PaulLake"){
base<-UNDERC_Base
} else if(Site=="LakeMendota"){
base<-Mendota_Base
} else if(Site=="Pool8"){
base<-Pool8_Base
} else {
base<-lakes_Base
}
# Set correct Tau Conversion
if (meta$FLAME_Unit[1]=="2015.01"){
taus<-taus2015.01}
if (meta$FLAME_Unit[1]=="2016.01"){
taus<-taus2016.01}
if (meta$FLAME_Unit[1]=="2016.02"){
taus<-taus2016.02}
if (meta$FLAME_Unit[1]=="2016.03"){
taus<-taus2016.03}
# do all 'dem bad things to the FLAMe data
flame_engage_all_maps(meta)
# ===========================================================
# Start close UMR loop code - see above
# ===========================================================
print(FLAMEsubdirectory)
setwd("..")
}
# ===========================================================
# End close loop code
# ===========================================================