Skip to content

Commit

Permalink
variable epsilon2
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbeckers committed Dec 8, 2023
1 parent c2da47b commit 2d26caa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 8 additions & 5 deletions src/DIVAnd_conditionner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ function DIVAndFFTpcg(mask,pmn,xyi,xy,f,len,epsilon2;moddim=zeros(Int32,ndims(ma
# WARNING: for superobs all points should be in the bounding box of the grid, otherwise the selection will not be fine enough
#


eps2=epsilon2
if isa(epsilon2,Number)
eps2=epsilon2.*ones(size(f))
end

corr=zeros(Float64,size(pmn[1]))
Lpmnmean=DIVAnd_Lpmnmean(pmn,len)
Expand All @@ -145,10 +148,10 @@ function DIVAndFFTpcg(mask,pmn,xyi,xy,f,len,epsilon2;moddim=zeros(Int32,ndims(ma
if super<0
super=2*Int(ceil(1.5^ndims(pmn[1])*prod(size(pmn[1])./Lpmnmean)))
end
super=min(max(super,Int(ceil(sqrt(prod(size(pmn[1]))))),size(f,1))
super=min(max(super,Int(ceil(sqrt(prod(size(pmn[1])))))),size(f,1))
@show super
# TODO, use proper weighting if epsilon2 is not constant
newx,newval,sumw,varp,idx=DIVAnd_superobs(xy,f,super)
newx,newval,sumw,varp,idx=DIVAnd_superobs(xy,f,super;weights=1 ./eps2)

ILOC = localize_separable_grid(newx,mask,xyi)
myval=[]
Expand Down Expand Up @@ -176,7 +179,7 @@ function DIVAndFFTpcg(mask,pmn,xyi,xy,f,len,epsilon2;moddim=zeros(Int32,ndims(ma
# myloc=CartesianIndices(mask)[[myloclinear...]]
end
#@show epsilon2,myeps,myloc
BRD=DIVAndOIBRdecomposition(corr,myloc,epsilon2.*myeps)
BRD=DIVAndOIBRdecomposition(corr,myloc,myeps)
xOI= BRD\myval
fOI=deepcopy(xyi[1])

Expand Down Expand Up @@ -261,7 +264,7 @@ end
end
# ork is Bx
# One over epslilon2 TODO
work[:].= 1.0 ./ (epsilon2.*myeps)
work[:].= 1.0 ./ myeps
xin[:].=0.0
xin[myloc].=work
fx[:].= fx .+ x.*statevector_pack(mysv, (xin,))
Expand Down
10 changes: 6 additions & 4 deletions src/DIVAnd_superobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ function DIVAnd_superobs(x, val, nmax; weights = [], intensive = true)
range = coordmax - coordmin
coordmin -= range * eps(eltype(coord))
coordmax += range * eps(eltype(coord))

if weights == []
weights = ones(Float64, ndata)
end

## If only one point, return it
if ndata<2
return x, val, [1], [0], [0]
return x, val, weights, [0], [0]
end


Expand All @@ -69,9 +73,7 @@ function DIVAnd_superobs(x, val, nmax; weights = [], intensive = true)

# now allocate the arrays

if weights == []
weights = ones(Float64, ndata)
end


# Working arrays
VP = zeros(Float64, sz)
Expand Down

0 comments on commit 2d26caa

Please sign in to comment.