Commit 96909d3a authored by Ronnie Leeper's avatar Ronnie Leeper
Browse files

Added code to process all tower datasets (A-D) and generate daily aggregates...

Added code to process all tower datasets (A-D) and generate daily aggregates for a midnight to midnight period.  Each tower dataset will need seperate handeling as avilable observations vary between towers.  Tower D processing has been started here, but is not complete.
parent 83ba6200
#Process Tower Data
#Created: Ronald D. Leeper
#Date: 10.27.2015
#Update: 10.27.2015
#Date: 11.02.2015
#Update: 11.04.2015
#Read in tower station (A-D) data and create daily aggregates from the 16 second frequency dataset.
#Read in tower station (A-D) data and create daily aggregates from the 16 second observations. From the tower data, generate
#datasets for the respective biases:
# 1). Sensor bias
# 2). Sheilding bias
# 3). Sitting bias (land cover)
# 4). Time-of-observation (TOB) bias
#This script is archieved via gitlab at this URL:
\ No newline at end of file
#Directory Setup
SystemDir = "/Users/ronnieleeper/Documents/"
ProjectDir = "Research/MMTS-BiasBudget/"
DataDir = "Data/ATDD-TowerData/"
OutputDir = "Data/"
#Tower IDs
towers = c("A","B","C","D")
#Loop per tower (A-D)
for (tower in towers){
print(paste("Processing tower: ",tower,sep=""))
#Readin current tower dataset and header file
filename = paste(SystemDir,ProjectDir,DataDir,"data",tower,".csv",sep="")
data = read.table(file=filename, header=FALSE, sep=",")
#Tower Header file
filename = paste(SystemDir,ProjectDir,DataDir,"hdrsTower",tower,".csv",sep="")
hdrs = read.table(file=filename, sep=",", stringsAsFactors=FALSE)
#Invoke column headers using the header file
#Create unique date field (combine YYYYMMDD) from which to aggragate over
#NOTE: This creates a midnight-to-midnight observer (we may want to apply various day definitions such as 7am-to-7am or 5pm-to-5pm))
data[,length(data)+1] = paste(data[,"Year"],data[,"Month"],data[,"Day"],sep="")
hdrs[length(hdrs)+1] = "DailyID (12am Observer)"
#Identify the relative position (column number) of interested variables in the dataset
if (tower == "D"){
for (x in 1:length(hdrs)){
if (hdrs[x] == "NimbusTemp") mmtsNimbus = x
if (hdrs[x] == "PRT1 (First CRN temperature)") met1PRT1 = x
if (hdrs[x] == "PRT2 (Second CRN Temperature)") met1PRT2 = x
if (hdrs[x] == "PRT3 (Third CRN temperature)") met1PRT3 = x
if (hdrs[x] == "PRT_Nim (PRT inside of MMTS shelter)") mmtsPRT = x
if (hdrs[x] == "Rgin (Incoming shortwave radiation)") inShtR = x
if (hdrs[x] == "Rgout (Outgoing shortwave radiation)") outShtR = x
if (hdrs[x] == "Lwin (Incoming Longwave Radiation Wm-2) ") inLngR = x
if (hdrs[x] == "Lwout (Outgoing Longwave Radiation Wm-2)") outLngR = x
if (hdrs[x] == "KZTemp (4-ban net radiometer body temperature)") KZTemp = x
if (hdrs[x] == "U (Sonic anem ws)") uwind = x
if (hdrs[x] == "V (Sonic ws)") vwind = x
if (hdrs[x] == "W (Sonic vertical ws)") wwind = x
if (hdrs[x] == "batt_volt_Min") battVol = x
if (hdrs[x] == "midObserDailyID") dailyID = x
#1). Correct longwave radiation values
#Aggregate by dailyID using max, min, and mean mathmatical methods
#Daily Maximum Values
dailyData = aggregate(data[,c()]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment