Created
February 5, 2025 20:28
-
-
Save SwampThingPaul/e4185237fd9713d99f5f466f9aac1942 to your computer and use it in GitHub Desktop.
NT Water Data example data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## column names for the different data | |
| col.names.WL <- c("DateTime.UTC","value.m","grade.code","approve.level","qual") | |
| col.names.Q <- c("DateTime.UTC","value.cms","grade.code","approve.level","qual") | |
| ## Build the html query | |
| servfull <- "https://ntg.aquaticinformatics.net/Export/DataSet?" | |
| dateMin <- as.Date("2005-01-01 00:00:00") | |
| dateMax <- as.Date("2005-12-01 00:00:00") | |
| location <- "G8140040" | |
| Calendar <- "CALENDARYEAR" | |
| other.std.vals <- c("DateRange=Custom", "UnitID=81", "Conversion=Instantaneous", | |
| "IntervalPoints=PointsAsRecorded", "ApprovalLevels=True", | |
| "Qualifiers=True", "Step=1", "ExportFormat=csv", | |
| "Compressed=false", "RoundData=False", "GradeCodes=True", | |
| "InterpolationTypes=False", "Timezone=0") | |
| # G8140040 - Daly River - Mount Nanar | |
| # Water level | |
| param.var <- "Measured Water Level" | |
| link <- paste0(servfull, | |
| paste("DataSet",gsub(" ","%20",param.var),sep="="), | |
| paste0(".Publish%40",location),"&", | |
| paste("Calendar",Calendar,sep="="),"&", | |
| paste("StartTime",paste(dateMin,"00:00:00"),sep="="),"&", | |
| paste("EndTime",paste(dateMax,"00:00:00"),sep="="),"&", | |
| paste(other.std.vals,collapse="&")) | |
| wl.dat <- read.csv(link,skip=5); # read data | |
| colnames(wl.dat) <- col.names.WL; # fix column names | |
| wl.dat$DateTime.UTC <- as.POSIXct(wl.dat$DateTime.UTC,tz="UTC"); # adjust datetime | |
| # Discharge | |
| param.var <- "Stream Discharge" | |
| other.std.vals <- gsub('UnitID=81',"UnitID=238",other.std.vals) | |
| link <- paste0(servfull, | |
| paste("DataSet",gsub(" ","%20",param.var),sep="="), | |
| paste0(".Publish%40",location),"&", | |
| paste("Calendar",Calendar,sep="="),"&", | |
| paste("StartTime",paste(dateMin,"00:00:00"),sep="="),"&", | |
| paste("EndTime",paste(dateMax,"00:00:00"),sep="="),"&", | |
| paste(other.std.vals,collapse="&")) | |
| Q.dat <- read.csv(link,skip=5); # read data | |
| colnames(Q.dat) <- col.names.Q; # fix column names | |
| Q.dat$DateTime.UTC <- as.POSIXct(Q.dat$DateTime.UTC,tz="UTC"); # adjust datetime | |
| ## Quick 2-panel plot showing water level and discharge with sampleing dates | |
| par(mar=c(2,3.5,0.5,1),oma=c(1.5,0.5,0.5,0.5)) | |
| layout(matrix(1:2,2,1)) | |
| xlim.val <- as.POSIXct(c("2005-04-01","2005-11-30"),tz="UTC") | |
| ylim.val <- c(1,4) | |
| plot(value.m~DateTime.UTC,wl.dat,xlim=xlim.val,ylim=ylim.val, | |
| type="n",las=1,ann=F) | |
| lines(value.m~DateTime.UTC,wl.dat,col="blue",lwd=2) | |
| abline(v=seq(as.POSIXct("2005-05-15",tz="UTC"), | |
| as.POSIXct("2005-11-15",tz="UTC"),"1 month"), | |
| lwd=3,col=adjustcolor("grey")) | |
| mtext(side=2,text="Water Level (m)",line=2.5) | |
| mtext(side=3,adj=0,text="Daly River - Mount Nanar (G8140040)") | |
| ylim.val <- c(0,400) | |
| plot(value.cms~DateTime.UTC,Q.dat, | |
| xlim=xlim.val,ylim=ylim.val, | |
| type="n",las=1,ann=F) | |
| lines(value.cms~DateTime.UTC,Q.dat,col="blue",lwd=2) | |
| abline(v=seq(as.POSIXct("2005-05-15",tz="UTC"), | |
| as.POSIXct("2005-11-15",tz="UTC"),"1 month"), | |
| lwd=3,col=adjustcolor("grey")) | |
| mtext(side=2,text=expression("Discharge (m"^"3"*"s"^"-1"*")"),line=2.5) | |
| mtext(side=1,text="Date (Month-2005)",line=2.25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment