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
| library(sp) | |
| library(rgeos) | |
| library(rworldmap) | |
| # epsg.io | |
| wgs=CRS("+init=epsg:4326") | |
| map_dat=getMap() | |
| map_dat=spTransform(map_dat,wgs) |
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
| # This is a very general script to perform gif animations from | |
| # space-time Generalized Additive Model predictions | |
| # GIS libraries | |
| library(rgdal) | |
| library(rgeos) | |
| library(raster) | |
| library(tmap) | |
| # GAM libraries |
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
| # GIS libraries | |
| library(sp) | |
| library(rgdal) | |
| library(rgeos) | |
| library(raster) | |
| library(mapmisc) | |
| ## defines the coordinate reference system | |
| utm17=CRS("+init=epsg:26917") |
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
| using DelimitedFiles | |
| using DataFrames | |
| # HTML Path for data | |
| dat_path="http://recondata.sccf.org/cgi-data/nph-data.cgi?x=utc_date&y=salinity,temperature&min_date=20210101&max_date=20220301&node=11&data_format=text" | |
| # Just to read the data as a tab delimited file | |
| recon_data=readdlm(download(dat_path),'\t',skipstart=1,header=true) | |
| ## From what I can find on how to change the file |
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
| # Load Library | |
| library(mblm); # For trend line | |
| # Commented out - added function in script | |
| # devtools::install_github("SwampThingPaul/AnalystHelper") | |
| # library(AnalystHelper); # some plotting helper functions like axis_fun(...), pt_lines(...), etc | |
| ## axis function from AnalystHelper package | |
| axis_fun=function (side, at, at2, labels, cex.axis = 1, line = -0.25, | |
| lwd = 1, maj.tcl = -0.6, min.tcl = -0.3, las = 1, axisLine = 0, |
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
| ## Using as.Date with an arbitrary year you can define each peirod | |
| pre.emg.period=seq(as.Date("2021-03-01"),as.Date("2021-03-20"),"1 days") | |
| emg.period=seq(as.Date("2021-03-21"),as.Date("2021-04-14"),"1 days") | |
| mate.period=seq(as.Date("2021-04-15"),as.Date("2021-05-15"),"1 days") | |
| gest.period=seq(as.Date("2021-05-16"),as.Date("2021-08-23"),"1 days") | |
| post.part.period=seq(as.Date("2021-08-24"),as.Date("2021-10-31"),"1 days") | |
| # fake data | |
| dat=data.frame(Date=seq(as.Date("2019-01-01"),as.Date("2022-12-31"),"1 days")) | |
| dat$Yr=as.numeric(format(dat$Date,'%Y')) |
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
| b2=seq(-100,500,20) | |
| pal2=c(colorRampPalette(c("blue","grey90"))(length(b2[b2<0])), | |
| colorRampPalette(c("grey90",'red'))(length(b2[b2>0]))) | |
| plot(1:length(pal2),pch=21,cex=2,bg=pal2) | |
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
| library(zoo) | |
| # Read data and set up ---------------------------------------------------- | |
| dat=read.csv("ex_dat_S79_NA25.csv") | |
| dat$Date=as.Date(dat$Date) | |
| dat$S79.14d=with(dat,rollapply(S79,width=14,FUN=function(x)mean(x,na.rm=T),fill=NA,align="right")) | |
| dat$CRE.low=with(dat,ifelse(S79.14d<750,1,0)) # RECOVER Low flow envelope | |
| # Helper functions for 14-day periods | |
| dat$period.14=c(0,rep(1:(nrow(dat)-1))%/%14)+1 |
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
| # date.fun from personal AnalystHelper package | |
| date.fun=function (x, tz = "EST", form = "%F"){as.POSIXct(strptime(x, form), tz = tz)} | |
| # Example dataset | |
| example=c("19-AUG-53 12.00.00.000000000 AM", "26-AUG-53 12.00.00.000000000 AM", | |
| "26-AUG-53 12.00.00.000000000 AM", "26-AUG-53 12.00.00.000000000 AM", | |
| "26-AUG-53 12.00.00.000000000 AM", "26-AUG-53 12.00.00.000000000 AM", | |
| "01-APR-02 05.45.00.000000000 PM", "01-APR-02 12.00.00.000000000 AM", | |
| "01-APR-02 12.00.00.000000000 AM", "01-APR-02 12.00.00.000000000 AM", | |
| "01-APR-02 12.00.00.000000000 AM", "01-APR-02 12.00.00.000000000 AM") |
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
| ## | |
| ## LOK MFL 18 month period exploration and learning | |
| ## | |
| ## Code was compiled by Paul Julian | |
| ## contact info: pjulian@sccf.org | |
| # Libraries | |
| import datetime as dt | |
| # |