#Looking at data from Franfjorden #Run netcdf.R library(ggplot2) library(reshape2) ############################################## #Just some bit of the area: relevant_lon_pos = which(lon>7.11 & lon<7.13) relevant_lat_pos = which(lat<62.85 & lat>62.84) #If we want the whole area: relevant_lon_pos = 1:length(lon) relevant_lat_pos = 1:length(lat) #################### rel_lon = lon[relevant_lon_pos] rel_lat = lat[relevant_lat_pos] #Making one large vector for plotting lonVec = rep(rel_lon, length(rel_lat)) latVec = rep(rel_lat, each = length(rel_lon)) ################################################ #Testing for one (high tide) time and one depth: #total_concentration[longitude, latitude, depth, time] snapshot = total_concentration[relevant_lon_pos,relevant_lat_pos,which(depth==35),211] #Making df fit for plotting consVec = melt(snapshot, value.name = 'cons') ggplot(data.frame(consVec), aes(x=lonVec, y=latVec))+ geom_raster(aes(fill = cons)) + scale_fill_gradientn(colors =c('blue4','red'))+ ggtitle("") + theme(plot.title = element_text(hjust = 0.5)) ############################################# #Use snapshots from one set of tidal times #Found tidal times manually. hourcorr = 60*60 mincorr = 60 #correction from Kristiansund correction = -7.5*mincorr #Tides tidevann0610to0910High = c(08*hourcorr +54*mincorr, 21*hourcorr + 05*mincorr, 24*hourcorr + 09*hourcorr + 43*mincorr, 24*hourcorr + 21*hourcorr + 52*mincorr, 2*24*hourcorr + 10*hourcorr + 26*mincorr, 2*24*hourcorr + 22*hourcorr + 35*mincorr, 3*24*hourcorr + 11*hourcorr + 06*mincorr, 3*24*hourcorr + 23*hourcorr + 16*mincorr)+ correction tidevann0610to0910Low = c(02*hourcorr + 40*mincorr, 15*hourcorr + 02*mincorr, 24*hourcorr + 03*hourcorr + 33*mincorr, 24*hourcorr + 15*hourcorr + 50*mincorr, 2*24*hourcorr + 04*hourcorr + 19*mincorr, 2*24*hourcorr + 16*hourcorr + 33*mincorr, 3*24*hourcorr + 05*hourcorr + 02*mincorr, 3*24*hourcorr + 17*hourcorr + 13*mincorr) + correction highTides = as.POSIXct(tidevann0610to0910High,origin = "2018-10-06",tz = "GMT") lowTides = as.POSIXct(tidevann0610to0910Low,origin = "2018-10-06",tz = "GMT") #FIND CONCENTRATIONS AT RELEVANT TIMES #Testing highTides #Need to save the model at times closest to the tidal times #Make replicates of times as many times as we have tidal information timeMat = matrix(rep(time, times = length(tidevann0610to0910High)), byrow = TRUE, ncol= length(time)) timeDiff = abs(sweep(timeMat, 1, tidevann0610to0910High)) #subtracting tidal times highTidesPos = apply(timeDiff, 1, which.min) #Choosing the times with smallest difference #concentrations = # total_concentration[relevant_lon_pos,relevant_lat_pos,which(depth==25),highTidesPos] #consVec = melt(concentrations, value.name = 'cons', id = highTidesPos) #plots=list() #for (i in 1:length(highTidesPos)){ # plots[[i]]= ggplot(data.frame(lon=lonVec, lat=latVec, cons = consVec$cons[consVec$Var3==i]), aes(x=lon, y=lat)) + # geom_raster(aes(fill = cons)) + # scale_fill_gradientn(colors =c('blue4','red'))+ # ggtitle("") + # theme(plot.title = element_text(hjust = 0.5)) #} #library(gridExtra) #grid.arrange(grobs = plots, ncol = 2) #check cross section: #Don't manage to choose a good area.. #cons_depth = total_concentration[relevant_lon_pos,110,,highTidesPos[1]] #cross_sect = melt(cons_depth, value.name = "cons", na.rm = TRUE) #ggplot(cross_sect, aes(x = Var1, y = -Var2)) + # geom_raster(aes(fill = cons)) + # scale_fill_gradientn(colors =c('blue4','red'))