Skip to content

Commit

Permalink
Merged all changes from CMISST_orig
Browse files Browse the repository at this point in the history
  • Loading branch information
brianburkenoaa committed Nov 12, 2024
1 parent 1e64f09 commit a8bcbbe
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions R/createStoredObjects.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ min.lon=0
max.lon=360
min.lat=-90
max.lat=90
years=seq(1967, 2023, 1)
years=seq(1950, 2023, 1)
months=seq(1,12,1)

# Function defined in getOceanData.R
Expand All @@ -43,7 +43,7 @@ oceanData_ERSST<-getOceanData(dataSet=dataSet,
min.lat=min.lat, max.lat=max.lat,
years = years, months = months)
save(x = "oceanData_ERSST", file = 'data/oceanSSTData.RData')
load('data/oceanSSTData.RData')
#load('data/oceanSSTData.RData')


# SSH ---------------------------------------------------------------------
Expand Down Expand Up @@ -74,7 +74,7 @@ oceanData_SSH<-getOceanData(dataSet=dataSet,
min.lat=min.lat, max.lat=max.lat,
years = years, months = months)
save(x = "oceanData_SSH", file = 'data/oceanSSHData.RData')
load('data/oceanSSHData.RData')
#load('data/oceanSSHData.RData')



Expand All @@ -95,6 +95,6 @@ response <- response[response$Year <= 2024 & response$Year >= 1950 & !is.na(resp
names(response)[names(response) == 'Year'] <- 'year'

save(x = "response", file = 'data/responseData.RData')
load('data/oceanSSHData.RData')
#load('data/oceanSSHData.RData')


2 changes: 1 addition & 1 deletion R/crossValidation.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ LOO_CV <- function(response = response,
se <- function(x) { return(sd(x)/sqrt(length(x))) }
mae$season<-factor(mae$season, levels = c("win","spr","sum","aut"))
# Trying this out - if I leave this line out, I might get all the individual predictions
if(exists("pred_out") & !pred_out) mae<-summaryBy(mae ~ model+season, data = mae, FUN = c(mean, se))
if(exists("pred_out")) if (!pred_out) mae<-summaryBy(mae ~ model+season, data = mae, FUN = c(mean, se))
return(list(mae))
}
3 changes: 2 additions & 1 deletion R/makePlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ makeBiplot <- function(input.season = input.season, cmisst = cmisst) {
x = par("usr")[1]*0.8, y=par("usr")[4]*0.80, cex=1.6, col="blue")
if (input.loocv) {
mae <- cmisst[[7]]
colnames(mae)[colnames(mae)=="mae.mean"] <- "mae"
text(paste("MAE =", round(mean(abs(mae[mae$season==input.season,"mae"])), 2)),
x = par("usr")[1]*0.75, y=par("usr")[4]*0.60, cex=1.6, col="blue")
}
Expand Down Expand Up @@ -158,4 +159,4 @@ makeTable <- function(cmisst = cmisst) {
out$year <- as.integer(out$year)#out <- out[,c(5,6,1:4)]
out$response <- index$response
out
}
}
5 changes: 3 additions & 2 deletions R/run_CMISST.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ load("data/land.Rdata")
load('data/responseData.RData')
# ERSST data
load('data/oceanSSTData.RData')
oceanData <- oceanData_ERSST

# define the updateCMISST() function
source('R/updateCMISST.R')
Expand All @@ -41,6 +40,8 @@ months=seq(1,12,1)
# Define Parameters
#************************************
input.spatialData = "ERSST"
if (input.spatialData == "ERSST") oceanData <- oceanData_ERSST
if (input.spatialData == "SSH") oceanData <- oceanData_SSH

# Input: Choose a stock
input.stock = "Sp_Chinook"
Expand Down Expand Up @@ -72,7 +73,7 @@ input.years= c(1980, 2023)
# emulating a forecasting scenario. How many years should be included?
# E.g., 5 will only test the 5 most recent years, and using the full
# time series length will remove every data point (one at a time)
loocvYears=5 # the most recent X years to include in the LOO CV
loocvYears=10 # the most recent X years to include in the LOO CV

# MAE LOO CV?
input.loocv= TRUE
Expand Down
Binary file modified data/oceanSSTData.RData
Binary file not shown.
Binary file modified data/responseData.RData
Binary file not shown.
Binary file added visual summary of files and data.pptx
Binary file not shown.

0 comments on commit a8bcbbe

Please sign in to comment.