Skip to content

Commit

Permalink
Merge 88c036b into 5b62cbc
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed Aug 20, 2018
2 parents 5b62cbc + 88c036b commit 9366f50
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 163 deletions.
12 changes: 7 additions & 5 deletions .travis.yml
Expand Up @@ -4,16 +4,18 @@ os:
- linux
- osx
julia:
- 0.6
- 0.7
- 1.0
- nightly
git:
depth: 999999
notifications:
email: false
script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd()); Pkg.build("LombScargle"); Pkg.test("LombScargle"; coverage=true)'
- JULIA_NUM_THREADS=4 julia -e 'Pkg.test("LombScargle")'
- julia -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("LombScargle"); Pkg.test("LombScargle"; coverage=true)'
- JULIA_NUM_THREADS=4 julia -e 'using Pkg; Pkg.test("LombScargle")'
- julia -e 'using Pkg; cd(Pkg.dir("LombScargle")); Pkg.add("PyCall"); Pkg.add("Conda"); using Conda; Conda.add("astropy"); include(joinpath("test", "astropy.jl"))'
after_success:
- julia -e 'cd(Pkg.dir("LombScargle")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'
- julia -e 'cd(Pkg.dir("LombScargle")); Pkg.add("Documenter"); include(joinpath("docs", "make.jl"))'
- julia -e 'using Pkg; cd(Pkg.dir("LombScargle")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'
- julia -e 'using Pkg; cd(Pkg.dir("LombScargle")); Pkg.add("Documenter"); include(joinpath("docs", "make.jl"))'
32 changes: 16 additions & 16 deletions README.md
Expand Up @@ -117,7 +117,7 @@ manual.

If the signal has uncertainties, the `signal` vector can also be a vector of
`Measurement` objects (from
[`Measurements.jl`](https://github.com/giordano/Measurements.jl) package), in
[`Measurements.jl`](https://github.com/JuliaPhysics/Measurements.jl) package), in
which case you need not to pass a separate `errors` vector for the uncertainties
of the signal. You can create arrays of `Measurement` objects with the
`measurement` function, see `Measurements.jl` manual at
Expand All @@ -141,7 +141,7 @@ julia> ntimes = 1001
1001

# Observation times
julia> t = linspace(0.01, 10pi, ntimes)
julia> t = range(0.01, stop=10pi, length=ntimes)
0.01:0.03140592653589793:31.41592653589793

# Randomize times
Expand Down Expand Up @@ -174,12 +174,12 @@ keyword is `true`) is able to handle a signal with uncertainties, and they will
be used as weights in the algorithm. The uncertainties can be passed either as
the third optional argument `errors` to `lombscargle` or by providing this
function with a `signal` vector of type `Measurement` (from
[`Measurements.jl`](https://github.com/giordano/Measurements.jl) package).
[`Measurements.jl`](https://github.com/JuliaPhysics/Measurements.jl) package).

```julia
using Measurements, Plots
ntimes = 1001
t = linspace(0.01, 10pi, ntimes)
t = range(0.01, stop=10pi, length=ntimes)
s = sinpi.(2t)
errors = rand(0.1:1e-3:4.0, ntimes)
plot(freqpower(lombscargle(t, s, errors, maximum_frequency=1.5))...)
Expand All @@ -201,7 +201,7 @@ single-threaded Astropy implementation. (Julia version: 0.7.0-DEV.2309,
commit 7ae9955c93; `LombScargle.jl` version: 0.3.1; Python version: 3.5.4; Astropy
version: 2.0.2. CPU: Intel(R) Core(TM) i7-4700MQ.)

![benchmarks](https://cdn.rawgit.com/giordano/LombScargle.jl/a019e9e79baa0d16ce1dc96954bea60beecf718c/perf/benchmarks.svg)
![benchmarks](https://cdn.rawgit.com/JuliaAstro/LombScargle.jl/a019e9e79baa0d16ce1dc96954bea60beecf718c/perf/benchmarks.svg)

Note that this comparison is unfair, as Astropy doesn’t support pre-planning a
periodogram nor exploiting multi-threading. A non-planned periodogram in single
Expand All @@ -210,13 +210,13 @@ thread mode in `LombScargle.jl` is still twice faster than Astropy.
Development
-----------

The package is developed at https://github.com/giordano/LombScargle.jl. There
The package is developed at https://github.com/JuliaAstro/LombScargle.jl. There
you can submit bug reports, make suggestions, and propose pull requests.

### History

The ChangeLog of the package is available in
[NEWS.md](https://github.com/giordano/LombScargle.jl/blob/master/NEWS.md) file
[NEWS.md](https://github.com/JuliaAstro/LombScargle.jl/blob/master/NEWS.md) file
in top directory.

License
Expand All @@ -234,10 +234,10 @@ Astropy Team.


[docs-latest-img]: https://img.shields.io/badge/docs-latest-blue.svg
[docs-latest-url]: https://giordano.github.io/LombScargle.jl/latest/
[docs-latest-url]: https://juliaastro.github.io/LombScargle.jl/latest/

[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg
[docs-stable-url]: https://giordano.github.io/LombScargle.jl/stable/
[docs-stable-url]: https://juliaastro.github.io/LombScargle.jl/stable/

[pkgeval-link]: http://pkg.julialang.org/?pkg=LombScargle

Expand All @@ -246,14 +246,14 @@ Astropy Team.
[pkg-0.6-img]: http://pkg.julialang.org/badges/LombScargle_0.6.svg
[pkg-0.6-url]: http://pkg.julialang.org/detail/LombScargle.html

[travis-img]: https://travis-ci.org/giordano/LombScargle.jl.svg?branch=master
[travis-url]: https://travis-ci.org/giordano/LombScargle.jl
[travis-img]: https://travis-ci.org/JuliaAstro/LombScargle.jl.svg?branch=master
[travis-url]: https://travis-ci.org/JuliaAstro/LombScargle.jl

[appvey-img]: https://ci.appveyor.com/api/projects/status/vv6mho713fuse6qy/branch/master?svg=true
[appvey-url]: https://ci.appveyor.com/project/giordano/lombscargle-jl
[appvey-url]: https://ci.appveyor.com/project/JuliaAstro/lombscargle-jl

[coveral-img]: https://coveralls.io/repos/github/giordano/LombScargle.jl/badge.svg?branch=master
[coveral-url]: https://coveralls.io/github/giordano/LombScargle.jl?branch=master
[coveral-img]: https://coveralls.io/repos/github/JuliaAstro/LombScargle.jl/badge.svg?branch=master
[coveral-url]: https://coveralls.io/github/JuliaAstro/LombScargle.jl?branch=master

[codecov-img]: https://codecov.io/gh/giordano/LombScargle.jl/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/giordano/LombScargle.jl
[codecov-img]: https://codecov.io/gh/JuliaAstro/LombScargle.jl/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/JuliaAstro/LombScargle.jl
7 changes: 4 additions & 3 deletions REQUIRE
@@ -1,3 +1,4 @@
julia 0.6.0
FFTW 0.0.1
Measurements 0.2.0
julia 0.7
FFTW 0.2.3
Measurements 1.0.0
SpecialFunctions 0.5.0
45 changes: 29 additions & 16 deletions appveyor.yml
@@ -1,9 +1,23 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
- julia_version: 0.7
- julia_version: 1
- julia_version: nightly

platform:
- x86 # 32-bit
- x64 # 64-bit

# Uncomment the following lines to allow failures on nightly julia
# (tests will run but not make your overall status red)
matrix:
allow_failures:
- julia_version: nightly

branches:
only:
- master
- /release-.*/

notifications:
- provider: Email
Expand All @@ -12,19 +26,18 @@ notifications:
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"LombScargle\"); Pkg.build(\"LombScargle\")"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"LombScargle\")"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
Binary file added docs/src/benchmarks.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/src/images.jl
Expand Up @@ -25,7 +25,7 @@ sz = (1200, 800)

# First periodograms
ntimes = 1001
t = linspace(0.01, 10pi, ntimes)
t = range(0.01, stop=10pi, length=ntimes)
t += step(t)*rand(ntimes)
s = sinpi(t) + 1.5cospi(2t) + rand(ntimes)
p = lombscargle(t, s)
Expand All @@ -38,7 +38,7 @@ savefig("period-periodogram.png")

# signal with uncertainties
ntimes = 1001
t = linspace(0.01, 10pi, ntimes)
t = range(0.01, stop=10pi, length=ntimes)
s = sinpi(2t)
errors = rand(0.1:1e-3:4.0, ntimes)
p = lombscargle(t, s, errors, maximum_frequency=1.5)
Expand Down
60 changes: 29 additions & 31 deletions docs/src/index.md
Expand Up @@ -10,7 +10,7 @@ end
Introduction
------------

[`LombScargle.jl`](https://github.com/giordano/LombScargle.jl) is a package for
[`LombScargle.jl`](https://github.com/JuliaAstro/LombScargle.jl) is a package for
a fast multi-threaded estimation of the [frequency
spectrum](https://en.wikipedia.org/wiki/Frequency_spectrum) of a periodic signal
with [the Lomb--Scargle
Expand Down Expand Up @@ -155,7 +155,7 @@ All these vectors must have the same length.

If the signal has uncertainties, the `signal` vector can also be a vector of
`Measurement` objects (from
[Measurements.jl](https://github.com/giordano/Measurements.jl) package), in
[Measurements.jl](https://github.com/JuliaPhysics/Measurements.jl) package), in
which case you need not to pass a separate `errors` vector for the uncertainties
of the signal. You can create arrays of `Measurement` objects with the
`measurement` function, see `Measurements.jl` manual at
Expand Down Expand Up @@ -240,40 +240,37 @@ more accurate the approximation.


The only prerequisite in order to be able to employ this fast method is to
provide a `frequencies` vector as a `Range` object, which ensures that the
frequency grid is perfectly evenly spaced. This is the default, since
`LombScargle.autofrequency` returns a `Range` object.
provide a `frequencies` vector as an `AbstractRange` object, which ensures that
the frequency grid is perfectly evenly spaced. This is the default, since
`LombScargle.autofrequency` returns an `AbstractRange` object.

!!! tip

In Julia, a `Range` object can be constructed for example with the
[linspace](http://docs.julialang.org/en/stable/stdlib/arrays/#Base.linspace)
function (you specify the start and the end of the range, and optionally the
length of the vector) or with the syntax
[start:stop](http://docs.julialang.org/en/stable/stdlib/math/#Base.:) (you
specify the start and the end of the range, and optionally the linear step; a
related function is
[colon](http://docs.julialang.org/en/stable/stdlib/math/#Base.colon)).
Somewhere in the middle is the
[range](http://docs.julialang.org/en/stable/stdlib/math/#Base.range) function:
you specify the start of the range and the length of the vector, and optionally
the linear step.

In Julia, an `AbstractRange` object can be constructed for example with the
[`range`](https://docs.julialang.org/en/latest/base/math/#Base.range) function
(you specify the start of the range, and optionally the stop, the length and the
step of the vector) or with the syntax
[`start:[step:]stop`](https://docs.julialang.org/en/latest/base/math/#Base.::)
(you specify the start and the end of the range, and optionally the linear
step).

Since this fast method is accurate only for large datasets, it is enabled by
default only if the number of output frequencies is larger than 200. You can
override the default choice of using this method by setting the `fast` keyword
to `true` or `false`. We recall that in any case, the `frequencies` vector must
be a `Range` in order to use this method.

To summarize, provided that `frequencies` vector is a `Range` object, you can
use the fast method:
To summarize, provided that `frequencies` vector is an `AbstractRange` object,
you can use the fast method:

- by default if the length of the output frequency grid is larger than
200 points
- in any case with the `fast=true` keyword

Setting `fast=false` always ensures you that this method will not be used,
instead `fast=true` actually enables it only if `frequencies` is a `Range`.
instead `fast=true` actually enables it only if `frequencies` is an
`AbstractRange`.

### Normalization

Expand Down Expand Up @@ -587,7 +584,7 @@ julia> using LombScargle
julia> ntimes = 1001
1001

julia> t = linspace(0.01, 10pi, ntimes) # Observation times
julia> t = range(0.01, stop = 10pi, length = ntimes) # Observation times
0.01:0.03140592653589793:31.41592653589793

julia> t += step(t)*rand(ntimes) # Randomize times
Expand Down Expand Up @@ -670,7 +667,7 @@ type `Measurement` (from
```julia
using Measurements, Plots
ntimes = 1001
t = linspace(0.01, 10pi, ntimes)
t = range(0.01, stop = 10pi, length = ntimes)
s = sinpi.(2t)
errors = rand(0.1:1e-3:4.0, ntimes)
# Run one of the two following equivalent commands
Expand Down Expand Up @@ -700,7 +697,7 @@ provided, instead it is always used if the signal has uncertainties.
in the periodogram (and you can get the period by taking its inverse):

```jldoctest
julia> t = linspace(0, 10, 1001);
julia> t = range(0, stop = 10, length = 1001);
julia> s = sinpi.(t);
Expand All @@ -710,7 +707,7 @@ julia> p = lombscargle(plan);
julia> findmaxperiod(p) # Period with highest power
1-element Array{Float64,1}:
0.00498778
0.004987779939149084
julia> findmaxfreq(p) # Frequency with the highest power
1-element Array{Float64,1}:
Expand Down Expand Up @@ -861,11 +858,11 @@ frequency fits well your data.

```julia
using Plots
t = linspace(0.01, 10pi, 1000) # Observation times
t = range(0.01, stop = 10pi, length = 1000) # Observation times
s = sinpi.(t) .+ 1.2cospi.(t) .+ 0.3rand(length(t)) # The noisy signal
# Pick-up the best frequency
f = findmaxfreq(lombscargle(t, s, maximum_frequency=10, samples_per_peak=20))[1]
t_fit = linspace(0, 1)
t_fit = range(0, stop = 1, length = 50)
s_fit = LombScargle.model(t, s, f, t_fit/f) # Determine the model
scatter(mod.(t.*f, 1), s, lab="Phased data", title="Best Lomb-Scargle frequency: $f")
plot!(t_fit, s_fit, lab="Best-fitting model", linewidth=4)
Expand All @@ -880,7 +877,7 @@ plot!(t_fit, s_fit, lab="Best-fitting model", linewidth=4)

```julia
using Plots
t = linspace(0.01, 5, 1000) # Observation times
t = range(0.01, stop = 5, length = 1000) # Observation times
s = sinpi.(2t) .+ 1.2cospi.(4t) .+ 0.3rand(length(t)) # Noisy signal
plan = LombScargle.plan(t, s, samples_per_peak=50)
p = lombscargle(plan)
Expand Down Expand Up @@ -912,7 +909,7 @@ single-threaded AstroPy implementation. (Julia version: 0.7.0-DEV.2309, commit
7ae9955c93; LombScargle.jl version: 0.3.1; Python version: 3.5.4; Astropy
version: 2.0.2. CPU: Intel(R) Core(TM) i7-4700MQ.)

![image](../../perf/benchmarks.png)
![image](perf/benchmarks.png)

Note that this comparison is unfair, as AstroPy doesn't support pre-planning a
periodogram nor exploiting multi-threading. A non-planned periodogram in single
Expand All @@ -921,13 +918,14 @@ thread mode in `LombScargle.jl` is still twice faster than AstroPy.
Development
-----------

The package is developed at <https://github.com/giordano/LombScargle.jl>. There
you can submit bug reports, make suggestions, and propose pull requests.
The package is developed at
<https://github.com/JuliaAstro/LombScargle.jl>. There you can submit bug
reports, make suggestions, and propose pull requests.

### History

The ChangeLog of the package is available in
[NEWS.md](https://github.com/giordano/LombScargle.jl/blob/master/NEWS.md) file
[NEWS.md](https://github.com/JuliaAstro/LombScargle.jl/blob/master/NEWS.md) file
in top directory.

License
Expand Down
4 changes: 2 additions & 2 deletions perf/benchmark.jl
Expand Up @@ -2,14 +2,14 @@

using LombScargle, BenchmarkTools, FFTW

N = round.(Int, logspace(1, 5, 15))
N = round.(Int, exp10.(range(1, stop=5, length=15)))
for nthreads in (1, 4)
FFTW.set_num_threads(nthreads)
info(string(nthreads) * " FFTW thread(s)")
open(joinpath(@__DIR__, "julia_times-" * string(nthreads) * ".dat"), "w") do file
for (j, n) in enumerate(N)
println("Iteration ", j, " (", n, " datapoints)")
t = collect(linspace(0.01, 10, n))
t = collect(range(0.01, stop=10, length=n))
s = sin.(t) .+ 1.5*cospi.(4t) .+ 3
plan = LombScargle.plan(t, s, fast = true, flags = FFTW.MEASURE)
time = minimum(@benchmark(lombscargle($plan)).times)/1e9
Expand Down
2 changes: 1 addition & 1 deletion src/LombScargle.jl
Expand Up @@ -15,7 +15,7 @@ __precompile__()

module LombScargle

using FFTW, Measurements
using FFTW, Measurements, LinearAlgebra, Statistics, SpecialFunctions

export lombscargle

Expand Down

0 comments on commit 9366f50

Please sign in to comment.