Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear OHC and HYCOM likelihood issue #82

Open
marosteg opened this issue Jun 14, 2023 · 2 comments
Open

Unclear OHC and HYCOM likelihood issue #82

marosteg opened this issue Jun 14, 2023 · 2 comments
Assignees

Comments

@marosteg
Copy link
Collaborator

marosteg commented Jun 14, 2023

One of the spearfish is yielding errors solely for OHC and HYCOM likelihood calculations. I tried removing days with only a surface layer (depth = 0 m) PDT observation but that didn't solve it.

The OHC error reads:
Error in { : task 8 failed - "newsplit: out of vertex space"

The HYCOM error reads:
Error in { :
task 8 failed - "C stack usage 8012680 is too close to the limit"

MWE below....

dir <- '~/Google Drive/Shared drives/MPG_WHOI/data/shortbill_spearfish/MiniPAT/'

#Read in metadata
meta <- read.csv('add_shortbillspearfish_meta.csv',header=T)

## format dates
meta$time_coverage_start <- lubridate::parse_date_time(meta$time_coverage_start, orders='Ymd HMS', tz='UTC')
meta$time_coverage_end <- lubridate::parse_date_time(meta$time_coverage_end, orders='Ymd HMS', tz='UTC')


fish <- list.files(dir)
fish <- fish[-c(8,9)]
i <- 5 #spearfish PTT 227133
fishID <- fish[i] # specify the individual
data_dir <- paste(dir, fishID, sep='')

#### 3.1 Load and prepare the tag data ####
  # SET START/END LOCATIONS iniloc is dataframe containing cols: day, month,
  # year, lat, lon and rows: start, end
  meta.i <- which(meta$ptt == fishID)
  iniloc <- data.frame(matrix(c(day(meta[meta.i,"time_coverage_start"]), month(meta[meta.i,"time_coverage_start"]), year(meta[meta.i,"time_coverage_start"]), meta$geospatial_lat_start[meta.i], meta$geospatial_lon_start[meta.i],   #start
                                day(meta[meta.i,"time_coverage_end"]), month(meta[meta.i,"time_coverage_end"]), year(meta[meta.i,"time_coverage_end"]), meta$geospatial_lat_end[meta.i], meta$geospatial_lon_end[meta.i]),   #end
                              nrow = 2, ncol = 5, byrow = T))
  names(iniloc) <- list("day", "month", "year", "lat", "lon")
  tag <- as.POSIXct(paste(iniloc[1, 1], "/", iniloc[1, 2], "/", iniloc[1, 3],
                          sep = ""), format = "%d/%m/%Y", tz = "UTC")
  pop <- as.POSIXct(paste(iniloc[2, 1], "/", iniloc[2, 2], "/", iniloc[2, 3],
                          sep = ""), format = "%d/%m/%Y", tz = "UTC")
  # VECTOR OF DATES FROM DATA. THIS WILL BE THE TIME STEPS, T, IN THE
  # LIKELIHOODS
  dateVec <- seq.POSIXt(tag, pop, by = "24 hours")


#### 3.1.2 Depth-Temperature Data ####
    pdtFile <- paste(data_dir,paste(fishID,"-PDTs.csv",sep=""),sep="/")
    pdt <- read.wc(pdtFile, type = "pdt", tag = tag, pop = pop, verbose = T)
    pdt <- pdt[, c("Date", "Depth", "MinTemp", "MaxTemp")]


#### 3.3.3 3D Depth-Temperature Likelihood ####
  # OCEAN HEAT CONTENT (INTEGRATED PDTs)
  if (!file.exists(paste0(data_dir, "/L.ohc.rds"))) {
    L.ohc <- calc.ohc.par(pdt, filename = "hycom", ohc.dir = hycom.dir, dateVec = dateVec, 
                          isotherm = "", use.se = T, ncores = 8)
    saveRDS(L.ohc,paste0(data_dir, "/L.ohc.rds"))
  } else {L.ohc <- readRDS(paste0(data_dir, "/L.ohc.rds"))}

  # DEPTH-TEMP LEVELS
  if (!file.exists(paste0(data_dir, "/L.hycom.rds"))) {
    L.hycom <- calc.hycom.par(pdt, filename = "hycom", hycom.dir = hycom.dir, dateVec = dateVec, 
                              use.se = T, ncores = 8)
    saveRDS(L.hycom,paste0(data_dir, "/L.hycom.rds"))
  } else {L.hycom <- readRDS(paste0(data_dir, "/L.hycom.rds"))}

add_shortbillspearfish_meta.csv

@camrinbraun
Copy link
Owner

I believe I fixed this in the last few months but its possible its a local change that has not yet been pushed to github. Try the following and remove any days that have <=3 bins. This is an issue because we use regression to predict at the appropriate depth levels to match HYCOM, which obviously fails with too few data points.

pdt %>% group_by(Date) %>% summarise(n=n())

@marosteg
Copy link
Collaborator Author

That solved it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants