##FUNCTIONS TO READ BOREHOLE DATA #================================== download_html <- function(url) { download.file(url, "temp.html"); html_handle <- file("temp.html", "rt"); html_data <- readLines(html_handle); close(html_handle); unlink("temp.html"); return(html_data); } read_borehole=function(id) { id=casefold(id) url=paste("http://www.ncdc.noaa.gov/paleo/borehole/data/",id,".html",sep="") fred=download_html(url) n1=grep("Depth Below",fred) n2=grep("NOTE:",fred) bore=read.table(url,skip=n1,nrow=(n2-1)-n1) names(bore)=c("z","T_z") fred=gsub("
","",fred) date_measurement=as.numeric(substr(fred[grep("Date of measurement",fred)],29,35)) prior_steady_state=as.numeric(substr(fred[grep("Estimated prior steady state",fred)],44,47)) # deg C mean_conductivity=as.numeric(substr(fred[grep("Estimated mean conductivity",fred)],63,69)) #2.37 # W m-1 K-1 mean_thermal_gradient=as.numeric(substr(fred[grep("Estimated mean thermal gradient",fred)],53,59)) #2.37 #K km^-1 read_borehole=list(bore=bore,date=date_measurement,steady_state=prior_steady_state, mean_conductivity=mean_conductivity,mean_thermal_gradient=mean_thermal_gradient) read_borehole } DiffConst=1e-6 Kcond= 2.1 Kdiff=DiffConst*365.25*24*60*60;Kdiff # 31.5576 onvert to years