Commit 3d5504b5 authored by peguerin's avatar peguerin
Browse files

correct and adjust data

parent 7f09b92f
......@@ -5,15 +5,41 @@ library("rgdal")
###############################################################################
## load data
coo=read.csv("01-sample_coords/all_coords.csv",sep="\t")
coo=na.omit(coo)
names(coo)=c("id","lat","lon")
coo=read.csv("01-sample_coords/all_CHECKED_coords.csv",sep="\t",header=T)
#coo=na.omit(coo)
#names(coo)=c("id","lat","lon")
latlon = data.frame(lon=coo$lon,lat=coo$lat)
### adjust coordinates to match chlorophyll grid
latlon$lon[380]=3.379638
latlon$lon[381]=3.379638
latlon$lon[382]=3.379638
latlon$lon[383]=3.379638
latlon$lon[384]=3.379638
latlon$lon[467]=-1.559533
latlon$lon[468]=-1.559533
latlon$lat[487]=36.63377
latlon$lat[495]=36.63377
latlon$lat[505]=36.63377
latlon$lat[506]=36.63377
latlon$lon[1032]=3.479638
latlon$lon[1033]=3.479638
latlon$lon[1034]=3.479638
latlon$lon[1035]=3.479638
latlon$lat[1984]=36.55913
latlon$lat[1985]=36.55913
latlon$lat[1986]=36.55913
coordinates(latlon) = c("lon", "lat")
### indiquer que les lat/lon est en projection google map
proj4string(latlon) = CRS("+init=epsg:4326")
## load raster of "chlorophyll benthic"
surface_files=c("01-infos/chlorophyll/surface/Present.Surface.Chlorophyll.Max.tif.zip",
"01-infos/chlorophyll/surface/Present.Surface.Chlorophyll.Mean.tif.zip",
......@@ -39,15 +65,15 @@ latlon = spTransform(latlon,proj4string(chloBenthicMeanRa))
#radius(rayon) du cercle du buffer ayant pour centre le point d'echantillonnage
#cercle de 2 km de diametre
buffer_distance=1000
buffer_distance=1100
chloBenthicMeanExtract=extract(chloBenthicMeanRa,latlon,buffer=buffer_distance,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloBenthicMaxExtract=extract(chloBenthicMaxRa,latlon,buffer=buffer_distance,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloBenthicMinExtract=extract(chloBenthicMinRa,latlon,buffer=buffer_distance,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloBenthicMeanExtract=extract(chloBenthicMeanRa,latlon,buffer=buffer_distance,fun=mean,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloBenthicMaxExtract=extract(chloBenthicMaxRa,latlon,buffer=buffer_distance,fun=mean,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloBenthicMinExtract=extract(chloBenthicMinRa,latlon,buffer=buffer_distance,fun=mean,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloSurfaceMeanExtract=extract(chloSurfaceMeanRa,latlon,buffer=buffer_distance,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloSurfaceMaxExtract=extract(chloSurfaceMaxRa,latlon,buffer=buffer_distance,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloSurfaceMinExtract=extract(chloSurfaceMinRa,latlon,buffer=buffer_distance,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloSurfaceMeanExtract=extract(chloSurfaceMeanRa,latlon,buffer=buffer_distance,fun=mean,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloSurfaceMaxExtract=extract(chloSurfaceMaxRa,latlon,buffer=buffer_distance,fun=mean,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chloSurfaceMinExtract=extract(chloSurfaceMinRa,latlon,buffer=buffer_distance,fun=mean,normalizeWeights=FALSE,weigths=TRUE,factors=TRUE)
chlotab=cbind(coo,as.numeric(chloBenthicMeanExtract),
as.numeric(chloBenthicMaxExtract),
......@@ -55,11 +81,11 @@ chlotab=cbind(coo,as.numeric(chloBenthicMeanExtract),
as.numeric(chloSurfaceMeanExtract),
as.numeric(chloSurfaceMaxExtract),
as.numeric(chloSurfaceMinExtract))
names(chlotab)=c("id","latitude","longitude",
names(chlotab)=c("labels","species","latitude","longitude",
"chloBenthicMean",
"chloBenthicMax",
"chloBenthicMin",
"chloSurfaceMean",
"chloSurfaceMax",
"chloSurfaceMin")
write.table(chlotab, file="03-results/all_chlorophyll.tsv",quote=F,sep="\t",col.names=T,row.names=F)
write.table(chlotab, file="03-results/all_CHECKED_chlorophyll.tsv",quote=F,sep="\t",col.names=T,row.names=F)
## just a tiny script to combine all descriptors table into single one
chlorotab=read.csv("03-results/all_CHECKED_chlorophyll.tsv",sep="\t",header=T)
salt_temp=read.csv("03-results/all_depth_repro_CORRECTED_temperature_salinity.csv",sep="\t",header=T)
scratch=merge(chlorotab,salt_temp,by="labels")
scratch$species[which(scratch$species =="Mul")]="mul"
scratch$species[which(scratch$species =="Ser")]="ser"
## LABELS tag
labels=c(as.character(scratch[which(scratch$species=="dip"),]$labels),
as.character(scratch[which(scratch$species=="mul"),]$labels),
as.character(scratch[which(scratch$species=="pan"),]$labels),
as.character(scratch[which(scratch$species=="ser"),]$labels))
## SPECIES tag
species=c(as.character(scratch[which(scratch$species=="dip"),]$species),
as.character(scratch[which(scratch$species=="mul"),]$species),
as.character(scratch[which(scratch$species=="pan"),]$species),
as.character(scratch[which(scratch$species=="ser"),]$species))
## SALINITY surface whole year
### diplodus salinity surface whole year
dip_salinity_surface_whole_yr_max=scratch[which(scratch$species=="dip"),]$salinity_surface_whole_year_max
dip_salinity_surface_whole_yr_mean=scratch[which(scratch$species=="dip"),]$salinity_surface_whole_year_mean
dip_salinity_surface_whole_yr_min=scratch[which(scratch$species=="dip"),]$salinity_surface_whole_year_min
### mullus salinity surface whole year
mul_salinity_surface_whole_yr_max=scratch[which(scratch$species=="mul"),]$salinity_surface_whole_year_max
mul_salinity_surface_whole_yr_mean=scratch[which(scratch$species=="mul"),]$salinity_surface_whole_year_mean
mul_salinity_surface_whole_yr_min=scratch[which(scratch$species=="mul"),]$salinity_surface_whole_year_min
### serran salinity surface whole year
ser_salinity_surface_whole_yr_max=scratch[which(scratch$species=="ser"),]$salinity_surface_whole_year_max
ser_salinity_surface_whole_yr_mean=scratch[which(scratch$species=="ser"),]$salinity_surface_whole_year_mean
ser_salinity_surface_whole_yr_min=scratch[which(scratch$species=="ser"),]$salinity_surface_whole_year_min
### pan salinity surface whole year
pan_salinity_surface_whole_yr_max=scratch[which(scratch$species=="pan"),]$salinity_surface_whole_year_max
pan_salinity_surface_whole_yr_mean=scratch[which(scratch$species=="pan"),]$salinity_surface_whole_year_mean
pan_salinity_surface_whole_yr_min=scratch[which(scratch$species=="pan"),]$salinity_surface_whole_year_min
### ALL salinity surface whole year
salinity_surface_whole_yr_max=c(dip_salinity_surface_whole_yr_max,
mul_salinity_surface_whole_yr_max,
pan_salinity_surface_whole_yr_max,
ser_salinity_surface_whole_yr_max)
salinity_surface_whole_yr_mean=c(dip_salinity_surface_whole_yr_mean,
mul_salinity_surface_whole_yr_mean,
pan_salinity_surface_whole_yr_mean,
ser_salinity_surface_whole_yr_mean)
salinity_surface_whole_yr_min=c(dip_salinity_surface_whole_yr_min,
mul_salinity_surface_whole_yr_min,
pan_salinity_surface_whole_yr_min,
ser_salinity_surface_whole_yr_min)
## SALINITY water column whole year
### diplodus salinity water column whole year
dip_salinity_water_column_whole_yr_max=scratch[which(scratch$species=="dip"),]$salinity_5_50_whole_year_max
dip_salinity_water_column_whole_yr_mean=scratch[which(scratch$species=="dip"),]$salinity_5_50_whole_year_mean
dip_salinity_water_column_whole_yr_min=scratch[which(scratch$species=="dip"),]$salinity_5_50_whole_year_min
### mullus salinity water column whole year
mul_salinity_water_column_whole_yr_max=scratch[which(scratch$species=="mul"),]$salinity_0_200_whole_year_max
mul_salinity_water_column_whole_yr_mean=scratch[which(scratch$species=="mul"),]$salinity_0_200_whole_year_mean
mul_salinity_water_column_whole_yr_min=scratch[which(scratch$species=="mul"),]$salinity_0_200_whole_year_min
### serran salinity water column whole year
ser_salinity_water_column_whole_yr_max=scratch[which(scratch$species=="ser"),]$salinity_0_200_whole_year_max
ser_salinity_water_column_whole_yr_mean=scratch[which(scratch$species=="ser"),]$salinity_0_200_whole_year_mean
ser_salinity_water_column_whole_yr_min=scratch[which(scratch$species=="ser"),]$salinity_0_200_whole_year_min
### pan salinity water column whole year
pan_salinity_water_column_whole_yr_max=scratch[which(scratch$species=="pan"),]$salinity_20_90_whole_year_max
pan_salinity_water_column_whole_yr_mean=scratch[which(scratch$species=="pan"),]$salinity_20_90_whole_year_mean
pan_salinity_water_column_whole_yr_min=scratch[which(scratch$species=="pan"),]$salinity_20_90_whole_year_min
### ALL salinity water column whole year
salinity_water_column_whole_yr_max=c(dip_salinity_water_column_whole_yr_max,
mul_salinity_water_column_whole_yr_max,
pan_salinity_water_column_whole_yr_max,
ser_salinity_water_column_whole_yr_max)
salinity_water_column_whole_yr_mean=c(dip_salinity_water_column_whole_yr_mean,
mul_salinity_water_column_whole_yr_mean,
pan_salinity_water_column_whole_yr_mean,
ser_salinity_water_column_whole_yr_mean)
salinity_water_column_whole_yr_min=c(dip_salinity_water_column_whole_yr_min,
mul_salinity_water_column_whole_yr_min,
pan_salinity_water_column_whole_yr_min,
ser_salinity_water_column_whole_yr_min)
## SALINITY SURFACE reproductive period
### diplodus salinity surface reproductive period
dip_salinity_surface_repro_max=scratch[which(scratch$species=="dip"),]$salinity_surface_march_june_max
dip_salinity_surface_repro_mean=scratch[which(scratch$species=="dip"),]$salinity_surface_march_june_mean
dip_salinity_surface_repro_min=scratch[which(scratch$species=="dip"),]$salinity_surface_march_june_min
### mullus salinity surface reproductive period
mul_salinity_surface_repro_max=scratch[which(scratch$species=="mul"),]$salinity_surface_march_july_max
mul_salinity_surface_repro_mean=scratch[which(scratch$species=="mul"),]$salinity_surface_march_july_mean
mul_salinity_surface_repro_min=scratch[which(scratch$species=="mul"),]$salinity_surface_march_july_min
### serran salinity surface reproductive period
ser_salinity_surface_repro_max=scratch[which(scratch$species=="ser"),]$salinity_surface_march_july_max
ser_salinity_surface_repro_mean=scratch[which(scratch$species=="ser"),]$salinity_surface_march_july_mean
ser_salinity_surface_repro_min=scratch[which(scratch$species=="ser"),]$salinity_surface_march_july_min
### pan salinity surface reproductive period
pan_salinity_surface_repro_max=scratch[which(scratch$species=="pan"),]$salinity_surface_june_november_max
pan_salinity_surface_repro_mean=scratch[which(scratch$species=="pan"),]$salinity_surface_june_november_mean
pan_salinity_surface_repro_min=scratch[which(scratch$species=="pan"),]$salinity_surface_june_november_min
### ALL salinity surface reproductive period
salinity_surface_repro_max=c(dip_salinity_surface_repro_max,
mul_salinity_surface_repro_max,
pan_salinity_surface_repro_max,
ser_salinity_surface_repro_max)
salinity_surface_repro_mean=c(dip_salinity_surface_repro_mean,
mul_salinity_surface_repro_mean,
pan_salinity_surface_repro_mean,
ser_salinity_surface_repro_mean)
salinity_surface_repro_min=c(dip_salinity_surface_repro_min,
mul_salinity_surface_repro_min,
pan_salinity_surface_repro_min,
ser_salinity_surface_repro_min)
## SALINITY water column reproductive period
### diplodus salinity water column reproductive period
dip_salinity_water_column_repro_max=scratch[which(scratch$species=="dip"),]$salinity_0_10_march_june_max
dip_salinity_water_column_repro_mean=scratch[which(scratch$species=="dip"),]$salinity_0_10_march_june_mean
dip_salinity_water_column_repro_min=scratch[which(scratch$species=="dip"),]$salinity_0_10_march_june_min
### mullus salinity water column reproductive period
mul_salinity_water_column_repro_max=scratch[which(scratch$species=="mul"),]$salinity_0_10_march_july_max
mul_salinity_water_column_repro_mean=scratch[which(scratch$species=="mul"),]$salinity_0_10_march_july_mean
mul_salinity_water_column_repro_min=scratch[which(scratch$species=="mul"),]$salinity_0_10_march_july_min
### serran salinity water column reproductive period
ser_salinity_water_column_repro_max=scratch[which(scratch$species=="ser"),]$salinity_0_10_march_july_max
ser_salinity_water_column_repro_mean=scratch[which(scratch$species=="ser"),]$salinity_0_10_march_july_mean
ser_salinity_water_column_repro_min=scratch[which(scratch$species=="ser"),]$salinity_0_10_march_july_min
### pan salinity water column reproductive period
pan_salinity_water_column_repro_max=scratch[which(scratch$species=="pan"),]$salinity_60_110_june_november_max
pan_salinity_water_column_repro_mean=scratch[which(scratch$species=="pan"),]$salinity_60_110_june_november_mean
pan_salinity_water_column_repro_min=scratch[which(scratch$species=="pan"),]$salinity_60_110_june_november_min
### ALL salinity water column reproductive period
salinity_water_column_repro_max=c(dip_salinity_water_column_repro_max,
mul_salinity_water_column_repro_max,
pan_salinity_water_column_repro_max,
ser_salinity_water_column_repro_max)
salinity_water_column_repro_mean=c(dip_salinity_water_column_repro_mean,
mul_salinity_water_column_repro_mean,
pan_salinity_water_column_repro_mean,
ser_salinity_water_column_repro_mean)
salinity_water_column_repro_min=c(dip_salinity_water_column_repro_min,
mul_salinity_water_column_repro_min,
pan_salinity_water_column_repro_min,
ser_salinity_water_column_repro_min)
## TEMPERATURE whole yr
### diplodus temperature whole yr
dip_sst_whole_yr_max=scratch[which(scratch$species=="dip"),]$temperature_surface_whole_year_max
dip_sst_whole_yr_mean=scratch[which(scratch$species=="dip"),]$temperature_surface_whole_year_mean
dip_sst_whole_yr_min=scratch[which(scratch$species=="dip"),]$temperature_surface_whole_year_min
### mullus temperature whole yr
mul_sst_whole_yr_max=scratch[which(scratch$species=="mul"),]$temperature_surface_whole_year_max
mul_sst_whole_yr_mean=scratch[which(scratch$species=="mul"),]$temperature_surface_whole_year_mean
mul_sst_whole_yr_min=scratch[which(scratch$species=="mul"),]$temperature_surface_whole_year_min
### serran temperature whole yr
ser_sst_whole_yr_max=scratch[which(scratch$species=="ser"),]$temperature_surface_whole_year_max
ser_sst_whole_yr_mean=scratch[which(scratch$species=="ser"),]$temperature_surface_whole_year_mean
ser_sst_whole_yr_min=scratch[which(scratch$species=="ser"),]$temperature_surface_whole_year_min
### pan temperature whole yr
pan_sst_whole_yr_max=scratch[which(scratch$species=="pan"),]$temperature_surface_whole_year_max
pan_sst_whole_yr_mean=scratch[which(scratch$species=="pan"),]$temperature_surface_whole_year_mean
pan_sst_whole_yr_min=scratch[which(scratch$species=="pan"),]$temperature_surface_whole_year_min
### ALL temperature whole yr
sst_whole_yr_max=c(dip_sst_whole_yr_max,
mul_sst_whole_yr_max,
pan_sst_whole_yr_max,
ser_sst_whole_yr_max)
sst_whole_yr_mean=c(dip_sst_whole_yr_mean,
mul_sst_whole_yr_mean,
pan_sst_whole_yr_mean,
ser_sst_whole_yr_mean)
sst_whole_yr_min=c(dip_sst_whole_yr_min,
mul_sst_whole_yr_min,
pan_sst_whole_yr_min,
ser_sst_whole_yr_min)
## TEMPERATURE reproductive period
### diplodus temperature reprodutive period
dip_sst_repro_max=scratch[which(scratch$species=="dip"),]$temperature_surface_march_june_max
dip_sst_repro_mean=scratch[which(scratch$species=="dip"),]$temperature_surface_march_june_mean
dip_sst_repro_min=scratch[which(scratch$species=="dip"),]$temperature_surface_march_june_min
### mullus temperature reprodutive period
mul_sst_repro_max=scratch[which(scratch$species=="mul"),]$temperature_surface_march_july_max
mul_sst_repro_mean=scratch[which(scratch$species=="mul"),]$temperature_surface_march_july_mean
mul_sst_repro_min=scratch[which(scratch$species=="mul"),]$temperature_surface_march_july_min
### serran temperature reprodutive period
ser_sst_repro_max=scratch[which(scratch$species=="ser"),]$temperature_surface_march_july_max
ser_sst_repro_mean=scratch[which(scratch$species=="ser"),]$temperature_surface_march_july_mean
ser_sst_repro_min=scratch[which(scratch$species=="ser"),]$temperature_surface_march_july_min
### pan temperature reprodutive period
pan_sst_repro_max=scratch[which(scratch$species=="pan"),]$temperature_surface_june_november_max
pan_sst_repro_mean=scratch[which(scratch$species=="pan"),]$temperature_surface_june_november_mean
pan_sst_repro_min=scratch[which(scratch$species=="pan"),]$temperature_surface_june_november_min
### ALL temperature reproductive period
sst_repro_max=c(dip_sst_repro_max,
mul_sst_repro_max,
pan_sst_repro_max,
ser_sst_repro_max)
sst_repro_mean=c(dip_sst_repro_mean,
mul_sst_repro_mean,
pan_sst_repro_mean,
ser_sst_repro_mean)
sst_repro_min=c(dip_sst_repro_min,
mul_sst_repro_min,
pan_sst_repro_min,
ser_sst_repro_min)
## CHLOROPHYLL benthic
### diplodus chlorophyll benthic
dip_chlo_benthic_max=scratch[which(scratch$species=="dip"),]$chloBenthicMax
dip_chlo_benthic_mean=scratch[which(scratch$species=="dip"),]$chloBenthicMean
dip_chlo_benthic_min=scratch[which(scratch$species=="dip"),]$chloBenthicMin
### mullus chlorophyll benthic
mul_chlo_benthic_max=scratch[which(scratch$species=="mul"),]$chloBenthicMax
mul_chlo_benthic_mean=scratch[which(scratch$species=="mul"),]$chloBenthicMean
mul_chlo_benthic_min=scratch[which(scratch$species=="mul"),]$chloBenthicMin
### serran chlorophyll benthic
ser_chlo_benthic_max=scratch[which(scratch$species=="ser"),]$chloBenthicMax
ser_chlo_benthic_mean=scratch[which(scratch$species=="ser"),]$chloBenthicMean
ser_chlo_benthic_min=scratch[which(scratch$species=="ser"),]$chloBenthicMin
### pan chlorophyll benthic
pan_chlo_benthic_max=scratch[which(scratch$species=="pan"),]$chloBenthicMax
pan_chlo_benthic_mean=scratch[which(scratch$species=="pan"),]$chloBenthicMean
pan_chlo_benthic_min=scratch[which(scratch$species=="pan"),]$chloBenthicMin
### ALL chlorophyll benthic
chlo_benthic_max=c(dip_chlo_benthic_max,
mul_chlo_benthic_max,
pan_chlo_benthic_max,
ser_chlo_benthic_max)
chlo_benthic_mean=c(dip_chlo_benthic_mean,
mul_chlo_benthic_mean,
pan_chlo_benthic_mean,
ser_chlo_benthic_mean)
chlo_benthic_min=c(dip_chlo_benthic_min,
mul_chlo_benthic_min,
pan_chlo_benthic_min,
ser_chlo_benthic_min)
## CHLOROPHYLL surface
### diplodus chlorophyll surface
dip_chlo_surface_max=scratch[which(scratch$species=="dip"),]$chloSurfaceMax
dip_chlo_surface_mean=scratch[which(scratch$species=="dip"),]$chloSurfaceMean
dip_chlo_surface_min=scratch[which(scratch$species=="dip"),]$chloSurfaceMin
### mullus chlorophyll surface
mul_chlo_surface_max=scratch[which(scratch$species=="mul"),]$chloSurfaceMax
mul_chlo_surface_mean=scratch[which(scratch$species=="mul"),]$chloSurfaceMean
mul_chlo_surface_min=scratch[which(scratch$species=="mul"),]$chloSurfaceMin
### serran chlorophyll surface
ser_chlo_surface_max=scratch[which(scratch$species=="ser"),]$chloSurfaceMax
ser_chlo_surface_mean=scratch[which(scratch$species=="ser"),]$chloSurfaceMean
ser_chlo_surface_min=scratch[which(scratch$species=="ser"),]$chloSurfaceMin
### pan chlorophyll surface
pan_chlo_surface_max=scratch[which(scratch$species=="pan"),]$chloSurfaceMax
pan_chlo_surface_mean=scratch[which(scratch$species=="pan"),]$chloSurfaceMean
pan_chlo_surface_min=scratch[which(scratch$species=="pan"),]$chloSurfaceMin
### ALL chlorophyll surface
chlo_surface_max=c(dip_chlo_surface_max,
mul_chlo_surface_max,
pan_chlo_surface_max,
ser_chlo_surface_max)
chlo_surface_mean=c(dip_chlo_surface_mean,
mul_chlo_surface_mean,
pan_chlo_surface_mean,
ser_chlo_surface_mean)
chlo_surface_min=c(dip_chlo_surface_min,
mul_chlo_surface_min,
pan_chlo_surface_min,
ser_chlo_surface_min)
final=data.frame(labels=labels,
species=species,
salinity_surface_whole_yr_max=salinity_surface_whole_yr_max,
salinity_surface_whole_yr_mean=salinity_surface_whole_yr_mean,
salinity_surface_whole_yr_min=salinity_surface_whole_yr_min,
salinity_water_column_whole_yr_max=salinity_water_column_whole_yr_max,
salinity_water_column_whole_yr_mean=salinity_water_column_whole_yr_mean,
salinity_water_column_whole_yr_min=salinity_water_column_whole_yr_min,
salinity_surface_repro_max=salinity_surface_repro_max,
salinity_surface_repro_mean=salinity_surface_repro_mean,
salinity_surface_repro_min=salinity_surface_repro_min,
salinity_water_column_repro_max=salinity_water_column_repro_max,
salinity_water_column_repro_mean=salinity_water_column_repro_mean,
salinity_water_column_repro_min=salinity_water_column_repro_min,
sst_whole_yr_max=sst_whole_yr_max,
sst_whole_yr_mean=sst_whole_yr_mean,
sst_whole_yr_min=sst_whole_yr_min,
sst_repro_max=sst_repro_max,
sst_repro_mean=sst_repro_mean,
sst_repro_min=sst_repro_min,
chlo_surface_max=chlo_surface_max,
chlo_surface_mean=chlo_surface_mean,
chlo_surface_min=chlo_surface_min,
chlo_benthic_max=chlo_benthic_max,
chlo_benthic_mean=chlo_benthic_mean,
chlo_benthic_min=chlo_benthic_min)
write.table(final, file="03-results/final_chloro_temperature_salinity.tsv",quote=F,sep="\t",col.names=T,row.names=F)
habitat=read.csv("03-results/all_habitat.tsv",sep="\t")
chlorophyll=read.csv("03-results/all_chlorophyll.tsv",sep="\t")
final=cbind(habitat,chlorophyll[,-c(1:3)])
write.table(final, file="03-results/all.tsv",quote=F,sep="\t",col.names=T,row.names=F)
......@@ -145,15 +145,6 @@ salt_temp=data.frame(labels=labels,
temperature_surface_whole_year_max=temp_surface_wyear$max,
temperature_surface_whole_year_mean=temp_surface_wyear$mean,
temperature_surface_whole_year_min=temp_surface_wyear$min,
temperature_0_200_whole_year_max=temp_0_200_wyear$max,
temperature_0_200_whole_year_mean=temp_0_200_wyear$mean,
temperature_0_200_whole_year_min=temp_0_200_wyear$min,
temperature_5_50_whole_year_max=temp_5_50_wyear$max,
temperature_5_50_whole_year_mean=temp_5_50_wyear$mean,
temperature_5_50_whole_year_min=temp_5_50_wyear$min,
temperature_20_90_whole_year_max=temp_20_90_wyear$max,
temperature_20_90_whole_year_mean=temp_20_90_wyear$mean,
temperature_20_90_whole_year_min=temp_20_90_wyear$min,
temperature_surface_march_july_max=temp_surface_march_july$max,
temperature_surface_march_july_mean=temp_surface_march_july$mean,
temperature_surface_march_july_min=temp_surface_march_july$min,
......@@ -162,20 +153,11 @@ salt_temp=data.frame(labels=labels,
temperature_surface_march_june_min=temp_surface_march_june$min,
temperature_surface_june_november_max=temp_surface_june_nov$max,
temperature_surface_june_november_mean=temp_surface_june_nov$mean,
temperature_surface_june_november_min=temp_surface_june_nov$min,
temperature_0_10_march_july_max=temp_0_10_march_july$max,
temperature_0_10_march_july_mean=temp_0_10_march_july$mean,
temperature_0_10_march_july_min=temp_0_10_march_july$min,
temperature_0_10_march_june_max=temp_0_10_march_june$max,
temperature_0_10_march_june_mean=temp_0_10_march_june$mean,
temperature_0_10_march_june_min=temp_0_10_march_june$min,
temperature_60_110_june_november_max=temp_60_110_june_nov$max,
temperature_60_110_june_november_mean=temp_60_110_june_nov$mean,
temperature_60_110_june_november_min=temp_60_110_june_nov$min
temperature_surface_june_november_min=temp_surface_june_nov$min
)
salt_temp[salt_temp==-Inf] <- NA
salt_temp[salt_temp==Inf] <- NA
salt_temp[salt_temp==NaN] <- NA
write.table(salt_temp, file="03-results/all_depth_repro_temperature_salinity.tsv",quote=F,sep="\t",col.names=T,row.names=F)
###############################################################################
## Librairies
library("raster")
library("rgdal")
library("ncdf4")
###############################################################################
###############################################################################
## load data
##salinity
fichier="01-infos/MEDSEA_REANALYSIS_PHYS_006_004_6Wto17E_0to210m_1m_vosaline_1987-2015.nc"
fichier="01-infos/MEDSEA_REANALYSIS_PHYS_006_004_6Wto17E_0to210m_1m_votemper_1987-2015.nc"
## coordinates
coof="01-sample_coords/GeneticData_usedInAnalyses_adjustedGPS.txt"
coo=read.table(coof,sep="\t",header=T,stringsAsFactors = FALSE)
labels=as.character(coo[,1])
latlon = data.frame(lon=as.numeric(coo$long_adjusted) ,lat=as.numeric(coo$lat_adjusted))
## shit lattitude to get a grid point
latlon[c(24:34,39, 40),]$lat=latlon[c(24:34,39, 40),]$lat-0.5
coordinates(latlon) = c("lon", "lat")
### indiquer que les lat/lon est en projection google map
proj4string(latlon) = CRS("+init=epsg:4326")
br <- nc_open(fichier)
brdepth = ncvar_get(br, "depth")
january=seq(1,(348-11),12)
february=seq(2,(348-10),12)
march=seq(3,(348-9),12)
april=seq(4,(348-8),12)
may=seq(5,(348-7),12)
june=seq(6,(348-6),12)
july=seq(7,(348-5),12)
august=seq(8,(348-4),12)
september=seq(9,(348-3),12)
october=seq(10,(348-2),12)
november=seq(11,348-1,12)
december=seq(12,348,12)
## salinities ALL
repro_period=cbind(january,february,march,april,may,june,july,august,september,october,november,december)
depth_range=which(brdepth <300)
salinities=array(, dim=c(dim(latlon)[1],348,26))
for(LVL in depth_range){
br <- brick(fichier,level=LVL)
LVL_ma_var=extract(br,latlon)
salinities[,,LVL]=LVL_ma_var[,repro_period]
}
temperatures=array(, dim=c(dim(latlon)[1],348,26))
for(LVL in depth_range){
br <- brick(fichier,level=LVL)
LVL_ma_var=extract(br,latlon)
temperatures[,,LVL]=LVL_ma_var[,repro_period]
}
write.table(salt_temp, file="03-results/ADJUSTED_depth_repro_temperature_salinity.tsv",quote=F,sep="\t",col.names=T,row.names=F)
labels lat_original long_original lat_adjusted long_adjusted
m_13.1_E1 41.183422 8.624897 41.183422 8.624897
m_13.10_E1 41.183422 8.624897 41.183422 8.624897
m_13.2 41.183422 8.624897 41.183422 8.624897
m_13.4_E1 41.183422 8.624897 41.183422 8.624897
m_13.5 41.183422 8.624897 41.183422 8.624897
m_13.6_E2 41.183422 8.624897 41.183422 8.624897
m_13.7_E1 41.183422 8.624897 41.183422 8.624897
m_13.8_E1 41.183422 8.624897 41.183422 8.624897
m_13.9_E2 41.183422 8.624897 41.183422 8.624897
m_73.1_E2 33.753171 35.080000 33.753171 35.08000
m_73.2_E2 33.753171 35.080000 33.753171 35.08000
m_73.5_E2 33.753171 35.080000 33.753171 35.08000
m_73.6_E1 33.753171 35.080000 33.753171 35.08000
m_73.7_E1 33.753171 35.080000 33.753171 35.08000
m_73.9_E1 33.753171 35.080000 33.753171 35.08000
m_85.1_E1 40.026309 17.227578 40.026309 17.227578
m_85.10_E1 40.026309 17.227578 40.026309 17.227578
m_85.2_E2 40.026309 17.227578 40.026309 17.227578
m_85.4_E2 40.026309 17.227578 40.026309 17.227578
m_85.5_E1 40.026309 17.227578 40.026309 17.227578
m_85.6_E1 40.026309 17.227578 40.026309 17.227578
m_85.8_E1 40.026309 17.227578 40.026309 17.227578
m_85.9_E1 40.026309 17.227578 40.026309 17.227578
mul_bal_115 39.699450 3.460200 39.697734 3.499120
mul_bal_116 39.691350 3.459200 39.691032 3.490110
mul_bal_117 39.707533 3.467950 39.698554 3.496334
mul_bal_118 39.686117 3.460833 39.685615 3.489760
mul_bal_119 39.706862 3.468217 39.701282 3.497615
mul_bal_120 39.721167 3.457150 39.735345 3.489274
mul_bal_121 39.721167 3.457150 39.735345 3.489274
mul_bal_122 39.717283 3.478233 39.717388 3.501584
mul_bal_123 39.677933 3.457033 39.677933 3.457033
mul_bal_124 39.706450 3.462450 39.693437 3.488137
mul_bal_125 39.706450 3.462450 39.693437 3.488137
mul_bal_126 40.073367 4.080367 40.123424 4.072093
mul_bal_127 40.073367 4.080367 40.123424 4.072093
mul_bal_128 40.073367 4.080367 40.123424 4.072093
mul_bal_129 40.073367 4.080367 40.123424 4.072093
mul_bal_130 39.708400 3.486233 39.709375 3.515509
mul_bal_131 39.708400 3.486233 39.709375 3.515509
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment