Skip to content

Commit

Permalink
Merge pull request #65 from GeoscienceAustralia/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
a2ray committed Jan 21, 2024
2 parents 7f35822 + 988aeee commit 6126286
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
@@ -1,7 +1,7 @@
name = "HiQGA"
uuid = "01574e87-63b6-4466-925a-334cf7e21b6b"
authors = ["richardt94 <29562583+richardt94@users.noreply.github.com>"]
version = "0.4.1"
version = "0.4.2"

[deps]
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
Expand Down
Expand Up @@ -36,4 +36,4 @@ else
@info transD_GP.TEMPEST1DInversion.get_misfit(-mtest, [zRx, x_rx, rx_pitch], tempest, nubounds)
end
@info transD_GP.TEMPEST1DInversion.get_misfit(-mtest, nu[end], tempest, nubounds)
transD_GP.TEMPEST1DInversion.plotmodelfield!(tempest, mtest, nutest)
transD_GP.plotmodelfield!(tempest, mtest, nutest)
3 changes: 3 additions & 0 deletions src/AEMnoNuisanceMcMCInversionTools.jl
Expand Up @@ -5,6 +5,9 @@ import ..AbstractOperator.loopacrossAEMsoundings
import ..AbstractOperator.plotmodelfield!
import ..AbstractOperator.getndata
import ..Options, ..OptionsStat
import ..AbstractOperator.summaryAEMimages
import ..AbstractOperator.plotindividualAEMsoundings

export makeAEMoperatorandoptions, loopacrossAEMsoundings, summaryAEMimages, plotindividualAEMsoundings
import ..main # McMC function
import ..DEBUGLEVEL_TDGP
Expand Down
17 changes: 11 additions & 6 deletions src/AEMwithNuisanceMcMCInversionTools.jl
Expand Up @@ -7,9 +7,12 @@ import ..AbstractOperator.getndata
import ..AbstractOperator.makebounds
import ..AbstractOperator.getoptnfromexisting
import ..AbstractOperator.getnufromsounding
import ..AbstractOperator.summaryAEMimages
import ..AbstractOperator.plotindividualAEMsoundings

import ..Options, ..OptionsStat, ..OptionsNuisance
export makeAEMoperatorandnuisanceoptions, loopacrossAEMsoundings, summaryAEMwithnuisanceimages, plotindividualAEMsoundingswithnuisance
export makeAEMoperatorandnuisanceoptions

import ..main # McMC function
using ..SoundingDistributor
import ..DEBUGLEVEL_TDGP
Expand Down Expand Up @@ -194,7 +197,7 @@ end

# plotting stuff

function summaryAEMwithnuisanceimages(soundings::Array{S, 1}, opt_in::Options, optn_in::OptionsNuisance;
function summaryAEMimages(soundings::Array{S, 1}, opt_in::Options, optn_in::OptionsNuisance;
zall=[-1.],
qp1=0.05,
qp2=0.95,
Expand Down Expand Up @@ -414,7 +417,7 @@ function plotnuquant(nqlow, nqmid, nqhigh, nunominal, s, gridx, icol, nrows, ms=
nnu = min(size(nqlow, 1), size(nunominal, 1)) # in case we've inverted a zero bounds nuisance by mistech...
labelnu[1] == "" || @assert length(labelnu) == nnu
for inu = 1:nnu
s[icol] = subplot(nrows, 1, icol, sharex=s[icol-1])
s[icol].sharex(s[icol-1])
s[icol].fill_between(gridx, nqlow[inu,:], nqhigh[inu,:], alpha=0.5)
s[icol].plot(gridx, nqmid[inu,:])
s[icol].plot(gridx, nunominal[inu,:], "o", markersize=ms)
Expand All @@ -425,7 +428,7 @@ function plotnuquant(nqlow, nqmid, nqhigh, nunominal, s, gridx, icol, nrows, ms=
icol
end

function plotindividualsoundings(soundings::Vector{S},
function plotindividualAEMsoundings(soundings::Vector{S},
aem_in::Operator1D, opt_in::Options, optn_in::OptionsNuisance,
idxplot;
zall = [-1.],
Expand Down Expand Up @@ -492,7 +495,9 @@ function plotindividualsoundings(soundings::Vector{S},
end
end

plotindividualAEMsoundingswithnuisance = plotindividualsoundings

# legacy backwards compat
plotindividualAEMsoundingswithnuisance = plotindividualAEMsoundings
plotindividualsoundings = plotindividualAEMsoundings
summaryAEMwithnuisanceimages = summaryAEMimages
end # module

4 changes: 4 additions & 0 deletions src/AbstractOperator.jl
Expand Up @@ -40,5 +40,9 @@ function plotconvandlast end
function setnuforinvtype end
# for the Line type from LineRegression which is useful
function getsmoothline end
# summary stats from McMC AEM inversions
function summaryAEMimages end
# plot predictions from posterior for McMC AEM inversions
function plotindividualAEMsoundings end
export Operator, Operator1D, Operator2D, Sounding
end
2 changes: 1 addition & 1 deletion src/CSEM1DInversion.jl
Expand Up @@ -4,7 +4,7 @@ import ..AbstractOperator.get_misfit
import ..CSEM1DEr.getfield!
using ..AbstractOperator, ..CSEM1DEr
using PyPlot, LinearAlgebra, ..CommonToAll

import ..AbstractOperator.plotmodelfield!
import ..Model, ..Options

export CSEMRadialEr, plotmodelfield!, addnoise
Expand Down
35 changes: 29 additions & 6 deletions src/CommonToAll.jl
Expand Up @@ -1096,24 +1096,47 @@ function readcols(cols::Vector, fname::String; decfactor=1, startfrom=1, dotill=
end
end

function colstovtk(cols::Vector, fname::String; decfactor=1, hasthick=true)
function colstovtk(cols::Vector, fname::String; decfactor=1, hasthick=true, islog10=false, prefix="")
# for one file in a direcoty
X, Y, Z, σ, thick = readcols(cols, fname; decfactor)
thick = thick[1,:]
zall = thicktodepth(thick; hasthick)
zall = thicktodepth(thick; hasthick)
fstring = basename(fname)
dstring = dirname(fname)
fpath = joinpath(dstring, "LEI_Line_"*prefix*fstring)
colstovtk(X, Y, Z, σ, zall, fpath, islog10)
end

function colstovtk(X, Y, Z, σ, zall, fpath::String, islog10::Bool)
Ni = length(X)
Nk = length(zall)
x = [X[i] for i = 1:Ni, j = 1:1, k = 1:Nk]
y = [Y[i] for i = 1:Ni, j = 1:1, k = 1:Nk]
z = [Z[i] - zall[k] for i = 1:Ni, j = 1:1, k = 1:Nk]
σvtk = [σ[i, k] for i = 1:Ni, j = 1:1, k = 1:Nk]
fstring = basename(fname)
dstring = dirname(fname)
vtk_grid(joinpath(dstring, "LEI_Line_"*fstring), x, y, z) do vtk
vtk["cond_LEI"] = log10.(σvtk)
T = islog10 ? x->x : x->log10(x) # if log 10 leave alone
vtk_grid(fpath, x, y, z) do vtk
vtk["cond_LEI"] = T.(σvtk)
end
nothing
end

function colstovtk(cols::Dict, fname::String; decfactor=1, hasthick=true, islog10=false, prefix="")
Xc, Yc, Zc, σc, thickc, linec = map(x->get(cols, x, 0), ["X", "Y", "Z", "cond", "thick", "line"])
X, Y, Z, σ, thick, lines = readcols([Xc, Yc, Zc, σc, thickc, linec], fname; decfactor)
linenos = unique(Int.(lines))
thick = thick[1,:] # assumes all thicknesses are same
zall = thicktodepth(thick; hasthick)
dstring = dirname(fname)
for l in linenos
idx = lines .== l
fstring = "$l"
@info "doing Line "*fstring
fpath = joinpath(dstring, "LEI_Line_"*prefix*fstring)
colstovtk(X[idx], Y[idx], Z[idx], σ[idx,:], zall, fpath, islog10)
end
end

function thicktodepth(thick; hasthick=true)
if hasthick
zb = [0; cumsum(thick)]
Expand Down

2 comments on commit 6126286

@a2ray
Copy link
Collaborator Author

@a2ray a2ray commented on 6126286 Jan 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/99276

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.2 -m "<description of version>" 612628648731a27be02d8dfe789750ef7ae414dc
git push origin v0.4.2

Please sign in to comment.