Commit 5771f3f2 authored by Ronnie Leeper's avatar Ronnie Leeper
Browse files

Removing from repo *.Rproj.user files, which are not necessary for the project

parent 8d4a5b35
auto_roxygenize_for_build_and_reload="0"
auto_roxygenize_for_build_package="1"
auto_roxygenize_for_check="1"
makefile_args=""
{
"path" : "~/Documents/Research/MMTS-BiasBudget/Scripts",
"sortOrder" : [
{
"ascending" : true,
"columnIndex" : 2
}
]
}
\ No newline at end of file
{
"installOptions" : {
"installDependencies" : true,
"installFromRepository" : true,
"libraryPath" : "/Library/Frameworks/R.framework/Versions/3.2/Resources/library"
}
}
\ No newline at end of file
{
"activeTab" : 0
}
\ No newline at end of file
{
"left" : {
"panelheight" : 1115,
"splitterpos" : 461,
"topwindowstate" : "NORMAL",
"windowheight" : 1153
},
"right" : {
"panelheight" : 1115,
"splitterpos" : 691,
"topwindowstate" : "NORMAL",
"windowheight" : 1153
}
}
\ No newline at end of file
{
"TabSet1" : 0,
"TabSet2" : 1
}
\ No newline at end of file
{"active_set":"","sets":[]}
\ No newline at end of file
~%2FDocuments%2FResearch%2FMMTS-BiasBudget%2FScripts%2FprocessTowerData.R="19B8543D"
~%2FDocuments%2FResearch%2FSoilStudies%2FNARRvUSCRN%2FScripts%2FSoilAnalysis.R="600028D3"
{
"contents" : "#Process Tower Data\n\n#Created: Ronald D. Leeper\n#Date: 11.02.2015\n#Update: 11.17.2015\n\n#Purpose:\n#Read in tower station (A-D) data and create daily aggregates from the 16 second observations. From the tower data, generate\n#datasets for the respective biases:\n# 1). Sensor bias\n# 2). Sheilding bias\n# 3). Sitting bias (land cover)\n# 4). Time-of-observation (TOB) bias\n\n#11.13.2015 Update:\n# a). Included hourly moving averages of wind speed and solar radiation to evaluate atmospheric conditions at the time of observation\n# b). Set outlier observations from MMTS, -73.278 and 124.170 C, to NA\n\n#11.17.2015 Update:\n# IS THIS REASONABLE??\n# Refined the outlier QC checks to set MMTS-Nimbus obs to NA if they differed from MMTS-PRT obs by more than 5 C\n# Added preliminary analysis code to evalute the effectiveness of MMTS-NIMBUS QC checks\n\n#11.23.2015 Update:\n# The refined outlier QC check seems remove all the outliers. According to emails, the study ended (for MMTS systems) on Aug 23 2013.\n# The datasets should be truncated to that period. Should we have a common start date for all four towers? It could be immedately\n# following the relocation of towers from the period of colocation: Nov. 1 2012\n\n#This script is archieved via gitlab at this URL: git@k3.cicsnc.org:ronnieleeper/MMTS-BiasBudget.git\n\n#Directory Setup\nSystemDir = \"/Users/ronnieleeper/Documents/\"\nProjectDir = \"Research/MMTS-BiasBudget/\"\nDataDir = \"Data/ATDD-TowerData/\"\nOutputDir = \"Data/\"\n\n# Start and End Dates\nendDate = as.Date(\"20130815\", format=\"%Y%m%d\") #Several days before the Aug 23rd end date\nstartDate = as.Date(\"20121101\", format=\"%Y%m%d\") #Date towers were positioned at locations from A to D.\n\n#Tower IDs\ntowers = c(\"A\",\"B\",\"C\",\"D\")\ntowers = c(\"D\")\n\n#Open Necessary Libraries\nlibrary(zoo)\n\n#Loop per tower (A-D)\nfor (tower in towers){\n print(paste(\"Processing tower: \",tower,sep=\"\"))\n \n #Readin current tower dataset and header file\n filename = paste(SystemDir,ProjectDir,DataDir,\"data\",tower,\".csv\",sep=\"\")\n data = read.table(file=filename, header=FALSE, sep=\",\")\n \n #Tower Header file\n filename = paste(SystemDir,ProjectDir,DataDir,\"hdrsTower\",tower,\".csv\",sep=\"\")\n hdrs = read.table(file=filename, sep=\",\", stringsAsFactors=FALSE)\n \n #Invoke column headers using the header file\n colnames(data)<-hdrs\n \n #Create unique date field (combine YYYYMMDD) from which to aggragate over\n #Covert the day field to a two-digit ID\n data[data[,\"Day\"] < 10,\"Day\"] = paste(\"0\",data[data[,\"Day\"] < 10,\"Day\"],sep=\"\")\n data[data[,\"Month\"] < 10,\"Month\"] = paste(\"0\",data[data[,\"Month\"] < 10,\"Month\"],sep=\"\")\n #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))\n data[,length(data)+1] = as.Date(paste(data[,\"Year\"],data[,\"Month\"],data[,\"Day\"],sep=\"\"),format=\"%Y%m%d\")\n hdrs[length(hdrs)+1] = \"DailyID (12am Observer)\"\n colnames(data)<-hdrs\n \n #Truncate data by start and end dates\n data1 = data[data[,length(data)] >= startDate & data[,length(data)] <= endDate,]\n \n #Identify the relative position (column number) of interested variables in the dataset\n if (tower == \"D\"){\n for (x in 1:length(hdrs)){\n if (hdrs[x] == \"NimbusTemp\") mmtsNimbus = x\n if (hdrs[x] == \"PRT1 (First CRN temperature)\") met1PRT1 = x\n if (hdrs[x] == \"PRT2 (Second CRN Temperature)\") met1PRT2 = x\n if (hdrs[x] == \"PRT3 (Third CRN temperature)\") met1PRT3 = x\n if (hdrs[x] == \"PRT_Nim (PRT inside of MMTS shelter)\") mmtsPRT = x\n if (hdrs[x] == \"Rgin (Incoming shortwave radiation)\") inShtR = x\n if (hdrs[x] == \"Rgout (Outgoing shortwave radiation)\") outShtR = x\n if (hdrs[x] == \"Lwin (Incoming Longwave Radiation Wm-2) \") inLngR = x\n if (hdrs[x] == \"Lwout (Outgoing Longwave Radiation Wm-2)\") outLngR = x\n if (hdrs[x] == \"KZTemp (4-ban net radiometer body temperature)\") KZTemp = x\n if (hdrs[x] == \"U (Sonic anem ws)\") uwind = x\n if (hdrs[x] == \"V (Sonic ws)\") vwind = x\n if (hdrs[x] == \"W (Sonic vertical ws)\") wwind = x\n if (hdrs[x] == \"batt_volt_Min\") battVol = x\n if (hdrs[x] == \"DailyID (12am Observer)\") dailyID = x\n }\n \n #Correct radiation values using body temperature (pulled from scar_view.m file)\n data[,length(data)+1] = data[,inLngR] + 5.67e-8*(data[,KZTemp]+273.15)^4\n hdrs[,length(data)] = \"correctedLwin\"\n cortedInLng = length(data)\n data[,length(data)+1] = data[,outLngR] + 5.67e-8*(data[,KZTemp]+273.15)^4\n hdrs[,length(data)] = \"correctedLwout\"\n cortedOutLng = length(data)\n colnames(data)<-hdrs\n \n #Data QC\n #Set all observations to NA if battery voltages are less-than 11.2 volts\n minBatVolt = 11.2\n data[data[,battVol] < minBatVolt,c(mmtsNimbus,mmtsPRT,met1PRT1,met1PRT2,met1PRT3,inShtR,outShtR,inLngR,outLngR,uwind,vwind,wwind,cortedOutLng,cortedInLng)] = NA\n \n #Remove outliers MMTS data\n #If the mmtsNimbus differs from the mmtsPRT data by more than 5 C; following recommendations from scar_view.m\n outLierCriteria = 5\n data[abs(data[,mmtsNimbus]-data[,mmtsPRT])>outLierCriteria & !is.na(data[,mmtsNimbus]),c(1:6,mmtsNimbus,mmtsPRT)] = NA\n \n #Calculate Moving Averages\n #Calculate moving averages of windspeed and solar radition based on lag-times (60 minutes)\n sixtyMinuteMovingWindowCount = 226 #There are 225 16 second periods within a 60 minute window\n #Wind moving averages\n #Uwind\n #data[,length(data)+1] = SMA(data[,uwind], n=sixtyMinuteMovingWindowCount) #Calculate uwind moving average\n data[,length(data)+1] = rollapply(data[,uwind], width=sixtyMinuteMovingWindowCount, align=\"right\", FUN=mean, na.rm=T, fill=NA) #Calculate uwind moving average\n hdrs[length(data)] = \"uwind 60minMavg\" #Add variable to file header\n uwindmavg = length(hdrs) #Create a referece variable for calculated average\n #Vwind\n data[,length(data)+1] = rollapply(data[,vwind], width=sixtyMinuteMovingWindowCount, align=\"right\", FUN=mean, na.rm=T, fill=NA) #Calculate vwind moving average\n hdrs[length(data)] = \"vwind 60minMavg\" #Add variable to file header\n vwindmavg = length(hdrs) #Create a referece variable for calculated average\n \n #Solar moving averages\n #Incoming Shortwave Radiation\n data[,length(data)+1] = rollapply(data[,inShtR], width=sixtyMinuteMovingWindowCount, align=\"right\", FUN=mean, na.rm=T, fill=NA) #Calculate inShtR moving average\n hdrs[length(data)] = \"Rgin 60minMavg\" #Add variable to file header\n inShtRmavg = length(hdrs) #Create a referece variable for calculated average\n #Incoming Longwave Radiation\n data[,length(data)+1] = rollapply(data[,cortedInLng], width=sixtyMinuteMovingWindowCount, align=\"right\", FUN=mean, na.rm=T, fill=NA) \n hdrs[length(data)] = \"cLwin 60minMavg\" #Add variable to file header\n inCLngRmavg = length(hdrs) #Create a referece variable for calculated average\n #Outgoing Shortwave Radiation\n data[,length(data)+1] = rollapply(data[,outShtR], width=sixtyMinuteMovingWindowCount, align=\"right\", FUN=mean, na.rm=T, fill=NA)\n hdrs[length(data)] = \"Rgout 60minMavg\" #Add variable to file header\n outShtRmavg = length(hdrs) #Create a referece variable for calculated average\n #Outgoing Longwave Radiation\n data[,length(data)+1] = rollapply(data[,cortedOutLng], width=sixtyMinuteMovingWindowCount, align=\"right\", FUN=mean, na.rm=T, fill=NA)\n hdrs[length(data)] = \"cLout 60minMavg\" #Add variable to file header\n outCLngRmavg = length(hdrs) #Create a referece variable for calculated average\n \n #Compute PRT 5-minute running means\n fiveMinuteMovingWindowCount = 20 #There are 20 16-second periods within a five minute window\n #PRT1\n data[,length(data)+1] = rollapply(data[,met1PRT1], width=fiveMinuteMovingWindowCount, align=\"right\", FUN=mean, na.rm=T, fill=NA) #Calculate moving average\n hdrs[length(data)] = \"PRT1 5minMavg\" #Add variable to file header\n met1PRT1mavg = length(hdrs) #Create a referece variable for calculated average\n #PRT2\n data[,length(data)+1] = rollapply(data[,met1PRT2], width=fiveMinuteMovingWindowCount, align=\"right\", FUN=mean, na.rm=T, fill=NA) #Calculate moving average\n hdrs[length(data)] = \"PRT2 5minMavg\" #Add variable to file header\n met1PRT2mavg = length(hdrs) #Create a referece variable for calculated average\n #PRT3\n data[,length(data)+1] = rollapply(data[,met1PRT3], width=fiveMinuteMovingWindowCount, align=\"right\", FUN=mean, na.rm=T, fill=NA) #Calculate moving average\n hdrs[length(data)] = \"PRT3 5minMavg\" #Add variable to file header\n met1PRT3mavg = length(hdrs) #Create a referece variable for calculated average\n colnames(data)<-hdrs\n \n #Aggregate to daily values using dailyID\n #Maximum Aggregates\n tDdailyMx = aggregate(data[,c(mmtsNimbus,mmtsPRT,met1PRT1mavg,met1PRT2mavg,met1PRT3mavg)], by=list(data[,dailyID]), FUN=max, na.rm=T) #towerD Daily Maximum aggregates\n #Add prefix \"max\" to dataset headers\n dataHdrs = colnames(tDdailyMx)\n dataHdrs[1] = \"Date\"\n dataHdrs[2:length(dataHdrs)] = paste(\"max\",dataHdrs[2:length(dataHdrs)],sep=\"\")\n colnames(tDdailyMx)<-dataHdrs\n #Minimum Aggregates\n tDdailyMn = aggregate(data[,c(mmtsNimbus,mmtsPRT,met1PRT1mavg,met1PRT2mavg,met1PRT3mavg)], by=list(data[,dailyID]), FUN=min, na.rm=T) #towerD Daily Minimum aggregates\n #Add prefix \"min\" to dataset headers\n dataHdrs = colnames(tDdailyMn)\n dataHdrs[1] = \"Date\"\n dataHdrs[2:length(dataHdrs)] = paste(\"min\",dataHdrs[2:length(dataHdrs)],sep=\"\")\n colnames(tDdailyMn)<-dataHdrs\n \n #TODO; Evaluate wind and solar radiation at time of maximum (loop for each daily extreme)\n \n #Days with all missing data report infinity; set those observations to missing\n tDdailyMx[is.infinite(tDdailyMx[,2]),c(2,3)] = NA\n tDdailyMn[is.infinite(tDdailyMn[,2]),c(2,3)] = NA\n }\n}\n\n#TODO: REMOVE\n## Preliminary anlaysis ##\nhist(tDdailyMx[,7],xlab=\"Daily Maximum Difference MMTS-Nimbus minus MMTS-PRT\", main=\"Tower D\", xlim=c(-5,5), breaks=seq(from=-6,to=6,by=0.25),xaxs=\"i\", yaxs=\"i\")\nplot(x=tDdailyMx[,2],y=tDdailyMx[,3],xlab=\"MMTS-Nimbus Daily Maximum (C)\",ylab=\"MMTS-PRT Daily Maximum (C)\",main=\"Tower D\", xlim=c(-20,40), ylim=c(-20,40))\nabline(1,1)\n#par(mar = mar.default + c(0, 1, 0, 0))\ntseq = seq(from=1, to=length(tDdailyMx[,1]), by=5)\nplot(tDdailyMx[,3], type='l', col=\"blue\", axes=F, lwd=3, xaxs=\"i\", yaxs=\"i\", xlab=\"Date (YYYYMM)\", \n ylab=expression(bold(\"Daily Maximum Temperature\")), main=pltTitles, ylim=c(-20,40))\naxis(1, at=tseq, label=tDdailyMx[tseq,1])\naxis(2)\nlines(tDdailyMx[,2], col=\"red\", lwd=3)\nlegend(\"topleft\", legend=c(\"MMTS-PRT\",\"MMTS-Nimbus\"), ncol=2, fill, lty=1, lwd=3, col=c(\"blue\",\"red\"))",
"created" : 1447164802351.000,
"dirty" : true,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "1741599788",
"id" : "10ADB5A9",
"lastKnownWriteTime" : 1448284861,
"path" : "~/Documents/Research/MMTS-BiasBudget/Scripts/processTowerData.R",
"project_path" : "Scripts/processTowerData.R",
"properties" : {
},
"relative_order" : 1,
"source_on_save" : false,
"type" : "r_source"
}
\ No newline at end of file
{
"contents" : "",
"created" : 1447419772710.000,
"dirty" : false,
"encoding" : "",
"folds" : "",
"hash" : "0",
"id" : "1D3D84CA",
"lastKnownWriteTime" : 140735261503232,
"path" : null,
"project_path" : null,
"properties" : {
"cacheKey" : "1xlf5enzit",
"caption" : "data",
"contentUrl" : "grid_resource/gridviewer.html?env=&obj=data&cache_key=1xlf5enzit",
"displayedObservations" : "2839964",
"environment" : "",
"object" : "data",
"totalObservations" : "2839964",
"variables" : "42"
},
"relative_order" : 5,
"source_on_save" : false,
"type" : "r_dataframe"
}
\ No newline at end of file
{
"contents" : "",
"created" : 1448287343670.000,
"dirty" : false,
"encoding" : "",
"folds" : "",
"hash" : "0",
"id" : "3F1636B3",
"lastKnownWriteTime" : 4294967296,
"path" : null,
"project_path" : null,
"properties" : {
"cacheKey" : "905ia5m6dk",
"caption" : "data1",
"contentUrl" : "grid_resource/gridviewer.html?env=&obj=data1&cache_key=905ia5m6dk",
"displayedObservations" : 1482535,
"environment" : "",
"object" : "data1",
"totalObservations" : 1482535,
"variables" : 31
},
"relative_order" : 7,
"source_on_save" : false,
"type" : "r_dataframe"
}
\ No newline at end of file
{
"contents" : "",
"created" : 1447701848433.000,
"dirty" : false,
"encoding" : "",
"folds" : "",
"hash" : "0",
"id" : "5C7FD787",
"lastKnownWriteTime" : 2475636339810066688,
"path" : null,
"project_path" : null,
"properties" : {
"cacheKey" : "1bwj0crt0b",
"caption" : "tDdailyMx",
"contentUrl" : "grid_resource/gridviewer.html?env=&obj=tDdailyMx&cache_key=1bwj0crt0b",
"displayedObservations" : "528",
"environment" : "",
"object" : "tDdailyMx",
"totalObservations" : "528",
"variables" : "7"
},
"relative_order" : 6,
"source_on_save" : false,
"type" : "r_dataframe"
}
\ No newline at end of file
{
"contents" : "",
"created" : 1447169040883.000,
"dirty" : false,
"encoding" : "",
"folds" : "",
"hash" : "0",
"id" : "63A78CB5",
"lastKnownWriteTime" : 7310030925004284416,
"path" : null,
"project_path" : null,
"properties" : {
"cacheKey" : "zstb4ggtap",
"caption" : "tDdailyMn",
"contentUrl" : "grid_resource/gridviewer.html?env=&obj=tDdailyMn&cache_key=zstb4ggtap",
"displayedObservations" : "528",
"environment" : "",
"object" : "tDdailyMn",
"totalObservations" : "528",
"variables" : "6"
},
"relative_order" : 2,
"source_on_save" : false,
"type" : "r_dataframe"
}
\ No newline at end of file
This diff is collapsed.
{
"contents" : "",
"created" : 1448285304811.000,
"dirty" : false,
"encoding" : "",
"folds" : "",
"hash" : "0",
"id" : "9EFB6DBB",
"lastKnownWriteTime" : 4337310720,
"path" : null,
"project_path" : null,
"properties" : {
"cacheKey" : "gac4lwqlkt",
"caption" : "data[dailyID >= as.Date(startDate, format = \"%Y%m%d\") & dailyID <= ",
"contentUrl" : "grid_resource/gridviewer.html?env=_rs_no_env&obj=&cache_key=gac4lwqlkt",
"displayedObservations" : 0,
"environment" : "_rs_no_env",
"object" : "",
"totalObservations" : 0,
"variables" : 42
},
"relative_order" : 6,
"source_on_save" : false,
"type" : "r_dataframe"
}
\ No newline at end of file
Markdown is supported
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