Commit 6ceea289 authored by md0276b's avatar md0276b
Browse files
parents e32df760 b40fb5ec
......@@ -6,6 +6,7 @@ library(ncdf4)
# setwd("//begmeil/gwel_public/atlantic/analysis/cdf/")
#setwd("//iota1/satcoast-public/atlantic/analysis/cdf/")
prefin="J:/"
prefin="//iota1/satcoast-public/"
path.atlantic.Chl=paste(prefin,'atlantic/analysis/cdf/',sep='')
#setwd(path.atlantic.Chl)
......@@ -13,7 +14,8 @@ path.atlantic.Chl=paste(prefin,'atlantic/analysis/cdf/',sep='')
dossier_out="C:/ptg/WORK/Atlantic/Chloro/"
dossier_out="D:/Data/Satellite/Atlantic/Chla/"
prefout='Y:/Satellite/'
dossier_out=paste(prefout,"Atlantic/Chla/data/",sep='')
prefout='//echosonde/data/Satellite/'
dossier_out=paste(prefout,"Atlantic/Chla/Rdata/",sep='')
# de 1998 a aujourd hui --------
# Replace output file if exists?
......@@ -25,7 +27,7 @@ lastChlaFile=fic2[length(fic2)]
lastpYearChla=substr(lastChlaFile,1,4)
currYear=substr(Sys.Date(),1,4)
# Define years to process
firstYearChla=lastpYear
firstYearChla=lastpYearChla
lastYearChla=currYear
for(annee in firstYearChla:lastYearChla){
......
......@@ -27,9 +27,7 @@ conv.n2char3.f=function(nn) {
pref="J:/"
iota1="/run/user/1000/gvfs/smb-share:domain=ifr,server=iota1,share=satcoast-public,user=mdoray/"
path.atlantic=paste(iota1,'atlantic/SST/',sep='')
path.atlantic=paste(pref,'atlantic/',sep='')
iota1="//iota1/satcoast-public/"
#
path.atlantic=paste(iota1,'atlantic/',sep='')
......@@ -39,7 +37,7 @@ path.atlantic=paste(iota1,'atlantic/',sep='')
patout="C:/ptg/WORK/Atlantic/SST/"
patout="/users/mathieu/Documents/Data/SST/"
patout="D:/Data/Satellite/Atlantic/SST/pathfinder/"
patout="G:/Satellite/Data/Atlantic/SST/pathfinder/"
patout="//echosonde/data/Satellite/Data/Atlantic/SST/pathfinder/"
# 1999-0101 - 2009-1231: Pathfinder ----
......@@ -116,10 +114,10 @@ patin=paste(path.atlantic,"ostia/",annee,"/SST/",sep="")
# >2010 : Odyssea -------------
replaceFile=FALSE
pref='Y:/Satellite/'
pref='//echosonde/data/Satellite/'
patout="C:/ptg/WORK/Atlantic/SST/odyssea/"
patout="D:/Data/Satellite/Atlantic/SST/odyssea/"
patout=paste(pref,"Atlantic/SST/data/",sep='')
patout=paste(pref,"Atlantic/SST/Rdata/",sep='')
# Most recent file in output path
fic2=sort(dir(path=patout,pattern=".data"))
......
......@@ -21,6 +21,8 @@ paletteGC=rasterTheme(region=gradient.colors)
# echosonde = define path to 'data' folder on 'echosonde' drive
echosonde='/run/user/1000/gvfs/smb-share:domain=ifr,server=echosonde,share=data,user=mdoray/'
echosonde='//echosonde/data/'
echosonde='Y:/'
# donnees2 = path to 'donnees2' drive
donnees2='/run/user/1000/gvfs/smb-share:domain=ifr,server=nantes,share=donnees2,user=mdoray/'
# on external drive
......@@ -28,7 +30,6 @@ pref='G:/'
pref='/media/mathieu/IfremerMData/'
# on network
pref=echosonde
pref='X:/'
# Rasters export path
path.export.grid.sat=paste(pref,'Satellite/Atlantic/',sep='')
......@@ -106,7 +107,8 @@ lyears.Chla=unique(substr(ficnam,1,4))
#pref='/media/mathieu/IfremerMData/'
# 2.1.1. Check file list in output folder ----------
#******************************************
lofiles.chla=list.files(paste(path.export.grid.sat,'/Chla/raster/',sep=''))
lofiles.chla=list.files(
paste(path.export.grid.sat,'/Chla/raster/',sep=''))
# 2.2. Convert to SSChla raster stacks (3-days composites) -----
#******************************************
......@@ -116,6 +118,11 @@ if (exists('sschla.rasterStack')){
lidik=NULL
}
# Recreate stack from scratch if problem in export
#rm('sschla.rasterStack')
#lidik=NULL
#year=seq(1998,2021,1)
jj=seq(from=1,to=366,by=3)
year=seq(min(lyears.Chla),max(lyears.Chla))
tabmax=1000 # chla max value
......@@ -171,7 +178,9 @@ for (i in 1:length(year)) {
}
}
# concert sschla.rasterStack to brick
plot(sschla.rasterStack)
# convert sschla.rasterStack to brick
# sschla.rasterBrick=brick(sschla.rasterStack)
# 2.3. Save Chla raster stack to disk ---------
......@@ -310,9 +319,9 @@ library(chron)
# 3.1. Chla ----------
#**********************
# 3.1.1. Eventually, import SSChla raster stack ------
echosonde='/run/user/1000/gvfs/smb-share:domain=ifr,server=echosonde,share=data,user=mdoray/'
donnees2='/run/user/1000/gvfs/smb-share:domain=ifr,server=nantes,share=donnees2,user=mdoray/'
path.export.grid.sat=paste(pref,'Satellite/Data/Atlantic/',sep='')
#echosonde='/run/user/1000/gvfs/smb-share:domain=ifr,server=echosonde,share=data,user=mdoray/'
#donnees2='/run/user/1000/gvfs/smb-share:domain=ifr,server=nantes,share=donnees2,user=mdoray/'
#path.export.grid.sat=paste(pref,'Satellite/Data/Atlantic/',sep='')
year=1998:2021
idi=paste('SSChla',paste(min(year),max(year),sep='-'),sep = "_")
filei2 = paste(path.export.grid.sat,'Chla/raster/',
......@@ -382,36 +391,8 @@ dim(chla.rs.aDates6d)
# correct layer names
names(chla.rb.6d)=substr(format(chla.rs.aDates6d[,2]),1,10)
# monthly averages: to be done by hand in a loop...
# lmyid=unique(chla.rs.times$myid)
# for (i in 1:length(lmyid)){
# print(lmyid[i])
# m=chla.rs.times$myid==lmyid[i]
# m <- grep(lmyid[i],chla.rs.times$myid)
# rmmi=raster::calc(chla.rb[[m]], mean,na.rm=TRUE)
# names(rmmi)=lmyid[i]
# rsdmi=raster::calc(chla.rb[[m]], sd,na.rm=TRUE)
# names(rsdmi)=lmyid[i]
# quantile90=function(x,...){quantile(x,probs=.9,na.rm=TRUE)}
# rq90mi=raster::calc(chla.rb[[m]], fun=quantile90,na.rm=TRUE)
# #plot(rq90mi)
# names(rq90mi)=lmyid[i]
# #plot(rmmi,main=lmyid[i])
# if (i==1){
# mchla.rb.yearmonth=rmmi
# sdchla.rb.yearmonth=rsdmi
# q90chla.rb.yearmonth=rq90mi
# }else{
# mchla.rb.yearmonth=stack(mchla.rb.yearmonth,rmmi)
# sdchla.rb.yearmonth=stack(sdchla.rb.yearmonth,rsdmi)
# q90chla.rb.yearmonth=stack(q90chla.rb.yearmonth,rq90mi)
# }
# }
# names(mchla.rb.yearmonth)=lmyid
# names(sdchla.rb.yearmonth)=lmyid
# names(q90chla.rb.yearmonth)=lmyid
# or easier, with stackApply:
# monthly averages:
# with stackApply:
quantile90=function(x,...){quantile(x,probs=.9,na.rm=TRUE)}
lmyid=unique(chla.rs.times$myid)
mchla.rb.yearmonth=stackApply(chla.rb,
......@@ -493,9 +474,9 @@ chla.rb.monthyear=aggregate(chla.rb,fact=c(1,1,30))
# 3.2. Create SST raster stack----------
#**********************
# 3.2.1. Eventually, import SSChla raste stack ------
echosonde='/run/user/1000/gvfs/smb-share:domain=ifr,server=echosonde,share=data,user=mdoray/'
donnees2='/run/user/1000/gvfs/smb-share:domain=ifr,server=nantes,share=donnees2,user=mdoray/'
path.export.grid.sat=paste(echosonde,'Satellite/Atlantic/',sep='')
#echosonde='/run/user/1000/gvfs/smb-share:domain=ifr,server=echosonde,share=data,user=mdoray/'
#donnees2='/run/user/1000/gvfs/smb-share:domain=ifr,server=nantes,share=donnees2,user=mdoray/'
#path.export.grid.sat=paste(echosonde,'Satellite/Atlantic/',sep='')
year=2000:2021
idi=paste('SST',paste(min(year),max(year),sep='-'),sep = "_")
filei2 = paste(path.export.grid.sat,'SST/raster/',paste('rasterStack',idi,sep='_'),'.grd',sep='')
......@@ -539,28 +520,7 @@ sst.rb.6d
# correct layer names
names(sst.rb.6d)=substr(format(sst.rs.aDates6d[,2]),1,10)
# monthly averages: to be done by hand in a loop...
#
# for (i in 1:length(lmyid)){
# print(lmyid[i])
# m=sst.rs.times$myid==lmyid[i]
# m <- grep(lmyid[i],sst.rs.times$myid)
# rmmi=raster::calc(sst.rb[[m]], mean,na.rm=TRUE)
# names(rmmi)=lmyid[i]
# rsdmi=raster::calc(sst.rb[[m]], sd,na.rm=TRUE)
# names(rsdmi)=lmyid[i]
# #plot(rmmi,main=lmyid[i])
# if (i==1){
# msst.rb.yearmonth=rmmi
# sdsst.rb.yearmonth=rsdmi
# }else{
# msst.rb.yearmonth=stack(msst.rb.yearmonth,rmmi)
# sdsst.rb.yearmonth=stack(sdsst.rb.yearmonth,rsdmi)
# }
# }
# names(msst.rb.yearmonth)=lmyid
# names(sdsst.rb.yearmonth)=lmyid
# monthly averages:
lmyid=unique(sst.rs.times$myid)
# or easier, with stackApply:
msst.rb.yearmonth=stackApply(sst.rb,indices=as.numeric(factor(sst.rs.times$myid)),fun=mean,na.rm=TRUE)
......
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