-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use package extensions, not Requires; to v0.5 (#66)
* Extensions for plots and units * import * Update import etc. * Purge Requires
- Loading branch information
1 parent
ec86c79
commit f130aa9
Showing
17 changed files
with
141 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
name = "Sinograms" | ||
uuid = "02a14def-c6e6-4ab0-b2df-0ab64bc8cdd7" | ||
authors = ["fessler <[email protected]>"] | ||
version = "0.4.1" | ||
version = "0.5" | ||
|
||
[deps] | ||
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" | ||
ImageGeoms = "9ee76f2b-840d-4475-b6d6-e485c9297852" | ||
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" | ||
LazyGrids = "7031d0ef-c40d-4431-b2f8-61a8d2f650db" | ||
Requires = "ae029012-a4dd-5104-9daa-d747884805df" | ||
|
||
[compat] | ||
FFTW = "1.4.5, 1.5" | ||
ImageGeoms = "0.9, 0.10" | ||
FFTW = "1.5" | ||
ImageGeoms = "0.11" | ||
Interpolations = "0.14, 0.15" | ||
LazyGrids = "0.4, 0.5, 1" | ||
Requires = "1.3" | ||
LazyGrids = "1" | ||
Unitful = "1.19" | ||
julia = "1.10" | ||
|
||
[weakdeps] | ||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" | ||
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" | ||
|
||
[extensions] | ||
Sinograms_Plots = "Plots" | ||
Sinograms_Units = "Unitful" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Sinograms_Plots.jl | ||
# support plots (possibly with units) iff user has loaded Plots | ||
|
||
module Sinograms_Plots | ||
|
||
include("sino-plot.jl") # fbp2 | ||
include("ct-plot.jl") # fbp3 | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Sinograms_Units.jl | ||
# Support data with units iff user has loaded Unitful | ||
|
||
module Sinograms_Units | ||
|
||
# extended: | ||
import Sinograms: fft_filter, to_radians, _unit_precision | ||
import FFTW: fft, ifft | ||
import Unitful: uconvert | ||
|
||
using Sinograms: _fft_filter, _reale | ||
using Unitful: °, rad, NoDims, unit | ||
using Unitful: Units, Quantity, convfact, ustrip | ||
|
||
|
||
#= | ||
https://github.com/PainterQubits/Unitful.jl/issues/375 | ||
=# | ||
function uconvert(a::Units, x::Quantity{T,D,U}) where {T<:AbstractFloat,D,U} | ||
return Quantity(x.val * T(convfact(a, U())), a) | ||
end | ||
|
||
|
||
""" | ||
to_radians(angles::AbstractArray{Unitful.Quantity}) | ||
Convert `Unitful` quantity array to radians. | ||
""" | ||
function to_radians(aa::AbstractArray{<: Quantity{T}}) where {T <: AbstractFloat} | ||
U = eltype(aa) | ||
c = rad(oneunit(U)) / oneunit(U) | ||
return aa * c | ||
end | ||
|
||
|
||
_unit_precision(x::Quantity{T}) where {T <: Number} = "Unit{$T}" | ||
|
||
|
||
# generic unitless linear operation applied to data with units | ||
function _linear_fun(fun::Function, | ||
x::AbstractArray{<: Quantity}, | ||
args... | ||
) | ||
x0 = ustrip(x) # unitless view into x data | ||
y0 = fun(x0, args...) | ||
u = unit(eltype(x)) | ||
Tu = typeof(one(eltype(y0)) * unit(eltype(x))) | ||
return reinterpret(Tu, y0) | ||
end | ||
|
||
# fft for data with units | ||
fft(x::AbstractArray{<: Quantity}, args...) = | ||
_linear_fun(fft, x, args...) | ||
ifft(x::AbstractArray{<: Quantity}, args...) = | ||
_linear_fun(ifft, x, args...) | ||
|
||
fft_filter(data::AbstractArray{<: Quantity{<:Complex}}, args...) = | ||
_fft_filter(data, args...) | ||
|
||
fft_filter(data::AbstractArray{<: Quantity{<:Real}}, args...) = | ||
_reale(_fft_filter(data, args...)) | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# exts.jl | ||
|
||
# methods defined in the extension(s) | ||
export sino_plot_rays, sino_geom_plot! | ||
export ct_geom_plot2!, ct_geom_plot3 | ||
|
||
sino_plot_rays(::Nothing) = throw("Run `using Plots` first") | ||
sino_geom_plot!(::Nothing) = throw("Run `using Plots` first") | ||
|
||
ct_geom_plot2!(::Nothing) = throw("Run `using Plots` first") | ||
ct_geom_plot3(::Nothing) = throw("Run `using Plots` first") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# unit.jl | ||
|
||
export to_radians | ||
|
||
""" | ||
to_radians(angles::AbstractArray{<:AbstractFloat}) | ||
When Unitful package not loaded, | ||
assume `angles` are in degrees and convert to radians. | ||
""" | ||
to_radians(aa::AbstractArray{T}) where {T <: AbstractFloat} = aa * T(deg2rad(1)) | ||
|
||
_unit_precision(x::T) where {T <: Number} = T |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
f130aa9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator() register
f130aa9
There was a problem hiding this comment.
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/107080
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.
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: