Commit 57b30030 authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Fix imports/exports

parent 7d790364
......@@ -24,25 +24,41 @@ export
AbstractDeformableMirror,
# Wavefront sensors.
AbstractWavefrontMeasure,
AbstractWavefrontSensor,
AbstractWavefrontSensorAlgorithm,
AbstractWavefrontMeasure,
AbstractWavefrontSlope,
ShackHartmannGeometry,
ShackHartmannSensor,
WavefrontSlope,
WeightedWavefrontSlope,
# From TwoDimensional.
AbstractPoint, Point, BoundingBox,
# Methods for remote objects.
abort, configure, kill, reset, send, start, stop,
# Other methods.
calibrate, fit, camera, algorithm, layout,
# Utilities.
floating_point_type,
# Miscellaneous.
TimeoutError,
readfits,
writefits,
writefits!
writefits!,
# Statistics.
mean,
std,
var
#using MappedArrays # FIXME: for of_eltype?
using TwoDimensional
import TwoDimensional: AbstractPoint, Point, BoundingBox
using EasyFITS
import EasyFITS: readfits, writefits, writefits!
......@@ -50,26 +66,30 @@ import EasyFITS: readfits, writefits, writefits!
using MayOptimize
using LinearAlgebra
import Base: reset
import Base: reset, kill
import Sockets: send
import Statistics: mean
import Statistics: mean, std, var
# Undocumented methods that can be imported by sub-packages, notably
# TaoBindings.
function start end
function stop end
function abort end
function algorithm end
function calibrate end
function camera end
function configure end
function fit end
function layout end
function start end
function stop end
function wait_output end
function wait_command end
# FIXME: Remove the following.
function device end
function reference end
function set_reference! end
function algorithm end
function camera end
function image_size end
function layout end
function measurements end
function send! end
function subimages_bounding_boxes end
......
......@@ -14,9 +14,10 @@
module WavefrontSensors
export
AbstractWavefrontMeasure,
AbstractWavefrontSensor,
AbstractWavefrontSensorAlgorithm,
AbstractWavefrontMeasure,
AbstractWavefrontSlope,
ShackHartmannGeometry,
ShackHartmannSensor,
WavefrontSlope,
......@@ -46,6 +47,7 @@ import ..Tao:
algorithm,
camera,
device,
floating_point_type,
image_size,
layout,
measure!,
......@@ -66,10 +68,10 @@ import EasyFITS: write!, hduname, readfits, writefits, writefits!
import Base: write
"""
AbstractWavefrontMeasure{T}
`Tao.AbstractWavefrontMeasure{T}` is the super-type of the various
concrete measure types provided by wavefront sensors. Parameter `T` is the
floating-point type of the measurements.
is the super-type of the various concrete measure types provided by wavefront
sensors. Parameter `T` is the floating-point type of the measurements.
[`Tao.WavefrontSlope`](@ref) and [`Tao.WavefrontSlope`](@ref) are concrete
types of wavefront sensor measurements.
......@@ -80,34 +82,35 @@ Method [`Tao.floating_point_type`](@ref) yields `T`.
abstract type AbstractWavefrontMeasure{T<:AbstractFloat} end
"""
AbstractWavefrontSensorAlgorithm{S}
`Tao.AbstractWavefrontSensorAlgorithm{S}` is the super-type of the various
concrete algorithms used by wavefront sensors to extract their measurements.
Parameter `S` is the type of the measurements provided by the algorithm.
is the super-type of the various concrete algorithms used by wavefront sensors
to extract their measurements. Parameter `S` is the type of the measurements
provided by the algorithm.
Basic method `eltype` applied to a wavefront sensor algorithm yields the
type of measurements given be the algorithm.
Basic method `eltype` applied to a wavefront sensor algorithm yields the type
of measurements given be the algorithm.
"""
abstract type AbstractWavefrontSensorAlgorithm{S<:AbstractWavefrontMeasure} end
"""
AbstractWavefrontSensor{S}
`Tao.AbstractWavefrontSensor{S}` is the super-type of the various concrete
wavefront sensor types. Parameter `S` is the type of the measurements provided
by the sensor.
is the super-type of the various concrete wavefront sensor types. Parameter
`S` is the type of the measurements provided by the sensor.
Basic method `eltype` applied to a wavefront sensor yields the
type of measurements given be the wavefront sensor.
Basic method `eltype` applied to a wavefront sensor yields the type of
measurements given be the wavefront sensor.
"""
abstract type AbstractWavefrontSensor{S<:AbstractWavefrontMeasure} end
"""
AbstractWavefrontSlope{T}
`Tao.AbstractWavefrontSlope{T}` is the super-type of the various concrete
wavefront sensor slope types. Parameter `T` is the floating-point type of the
slopes.
is the super-type of the various concrete wavefront sensor slope types.
Parameter `T` is the floating-point type of the slopes.
Instances of descendant types have fields `x` and `y`. Method
[`Tao.floating_point_type`](@ref) yields `T`.
......@@ -141,9 +144,12 @@ WavefrontSlope(P::Point) = WavefrontSlope(P.x, P.y)
WavefrontSlope(S::AbstractWavefrontSlope) = WavefrontSlope(S.x, S.y)
WavefrontSlope{T}(S::WavefrontSlope{T}) where {T} = S
WavefrontSlope{T}(xy::NTuple{2,Real}) where {T<:AbstractFloat} = WavefrontSlope{T}(xy...)
WavefrontSlope{T}(P::Point) where {T<:AbstractFloat} = WavefrontSlope{T}(P.x, P.y)
WavefrontSlope{T}(S::AbstractWavefrontSlope) where {T<:AbstractFloat} = WavefrontSlope{T}(S.x, S.y)
WavefrontSlope{T}(xy::NTuple{2,Real}) where {T<:AbstractFloat} =
WavefrontSlope{T}(xy...)
WavefrontSlope{T}(P::Point) where {T<:AbstractFloat} =
WavefrontSlope{T}(P.x, P.y)
WavefrontSlope{T}(S::AbstractWavefrontSlope) where {T<:AbstractFloat} =
WavefrontSlope{T}(S.x, S.y)
WeightedWavefrontSlope(S::WeightedWavefrontSlope) = S
WeightedWavefrontSlope(x::Real, y::Real, wxx::Real, wxy::Real, wyy::Real) =
......@@ -163,7 +169,8 @@ WeightedWavefrontSlope{T}(xy::NTuple{2,Real}, wgt::NTuple{3,Real}) where {T<:Abs
WeightedWavefrontSlope{T}(xy..., wgt...)
TwoDimensional.Point(S::AbstractWavefrontSlope) = Point(S.x, S.y)
TwoDimensional.Point{T}(S::AbstractWavefrontSlope) where {T} = Point{T}(S.x, S.y)
TwoDimensional.Point{T}(S::AbstractWavefrontSlope) where {T} =
Point{T}(S.x, S.y)
Base.Tuple(S::WavefrontSlope) = (S.x, S.y)
Base.Tuple(S::WeightedWavefrontSlope) = (S.x, S.y, S.wxx, S.wxy, S.wyy)
......@@ -172,34 +179,30 @@ convert(::Type{T}, S::AbstractWavefrontSlope) where {T<:Point} = T(S)
convert(::Type{T}, P::AbstractPoint) where {T<:WavefrontSlope} = T(P.x, P.y)
convert(::Type{T}, xy::NTuple{2,Real}) where {T<:WavefrontSlope} = T(xy)
convert(::Type{T}, tup::NTuple{5,Real}) where {T<:WeightedWavefrontSlope} = T(tup)
convert(::Type{T}, tup::NTuple{5,Real}) where {T<:WeightedWavefrontSlope} =
T(tup)
convert(::Type{T}, S::T) where {T<:AbstractWavefrontSlope} = S
convert(::Type{T}, S::AbstractWavefrontSlope) where {T<:WavefrontSlope} = T(S)
convert(::Type{T}, S::WeightedWavefrontSlope) where {T<:WeightedWavefrontSlope} = T(S)
Base.iterate(itr::AbstractWavefrontSlope) = begin
vals = Tuple(itr)
return (vals[1], (vals, 2))
end
Base.iterate(itr::AbstractWavefrontSlope, state::Tuple{Tuple,Int}) = begin
# Make possible something like: (x,y,wxx,wxy,wyy) = s with s an instance of
# WeightedWavefrontSlope.
function Base.iterate(itr::AbstractWavefrontSlope,
state::Tuple{Tuple,Int} = (Tuple(itr), 1))
vals, i = state
return (i length(vals) ? (vals[i], (vals, i+1)) : nothing)
end
for X in (:AbstractWavefrontSensor,
:AbstractWavefrontMeasure,
:AbstractWavefrontSensorAlgorithm)
@eval begin
floating_point_type(::T) where {T<:$X} = floating_point_type(T)
floating_point_type(::Type{$X{T}}) where {T} = T
end
end
floating_point_type(::Type{<:AbstractWavefrontMeasure{T}}) where {T} = T
floating_point_type(x::AbstractWavefrontMeasure) =
floating_point_type(typeof(x))
for X in (:AbstractWavefrontSensor,
:AbstractWavefrontSensorAlgorithm)
@eval begin
floating_point_type(::T) where {T<:$X} = floating_point_type(T)
floating_point_type(::Type{<:$X{S}}) where {S} = floating_point_type(S)
Base.eltype(::$X{S}) where {S} = S
Base.eltype(::Type{<:$X{T}}) where {T} = T
end
......@@ -324,6 +327,9 @@ Base.timedwait(wfs::AbstractWavefrontSensor, timeout) = begin
return measure!(measurements(wfs), algorithm(wfs), wgt, img)
end
# FIXME: flatten -> reinterpret
"""
Tao.flatten(A) -> B
......
Supports Markdown
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