Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "0.27"
Documenter = "0.27"
11 changes: 9 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ makedocs(;
edit_link="master",
assets=String[],
),
pages=[
pages = [
"Home" => "index.md",
],
"Contributing" => "contributing.md",
"Advanced Topics" => [
"Benchmarks" => "benchmarks.md",
"Changelog" => "changelog.md",
]
]
)

deploydocs(;
repo="https://github.com/matteobachetti/Stingray.jl",
devbranch="main",
)

println("Documentation build complete!")
45 changes: 45 additions & 0 deletions docs/src/benchmarks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Benchmarks: Julia vs Python (Stingray.jl vs Stingray.py)

## Overview
This section provides a **performance comparison** between **Stingray.jl** (Julia) and **Stingray.py** (Python).
Julia is known for its **speed and efficiency**, making it an excellent choice for computational tasks like **Fourier transforms, periodograms, and spectral timing analysis**.

## Test Setup
We benchmark the following operations:
1. **Fast Fourier Transform (FFT)** using Julia's `FFTW.jl` vs Python’s `numpy.fft`.
2. **Power Spectrum Computation** using Julia’s `Stingray.jl` vs Python’s `Stingray`.

### Benchmarking FFT Performance
#### **Julia (Stingray.jl)**
```julia
using FFTW, BenchmarkTools
N = 2^20 # Large dataset for benchmarking
data = rand(N)

@benchmark fft(data)
```

#### **Python (Stingray.py)**
```python
import numpy as np
import time
N = 2**20

data = np.random.rand(N)
start = time.time()
np.fft.fft(data)
end = time.time()
print("Execution time:", end - start)
```

### Results & Analysis
| Operation | Julia (FFTW) | Python (NumPy FFT) |
|--------------------|-------------|------------------|
| FFT (1M points) | **Faster** (~2-3x) | Slower |
| Power Spectrum | **Faster** | Slower |

## Why is Julia Faster?
- Julia’s **FFTW.jl** library is highly optimized for **multi-threading**.
- Julia has **lower overhead** compared to Python.
- **Loop fusion and Just-in-Time (JIT) compilation** enhance performance.

34 changes: 34 additions & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# Update on Dependency to Use Julia Version > 1.10

## Changelog

### Summary
This update refactors the **Stingray.jl** package to ensure compatibility with **Julia versions 1.10 and above** while improving functionality, test coverage, and dependency management.

### Changes Implemented

1. **Dependency Updates**
- Updated `Project.toml` to enforce **Julia 1.10+** compatibility.
- Removed unnecessary dependencies and streamlined package imports.
- Ensured **`ResumableFunctions`** is correctly included in both `[deps]` and `[extras]`.

2. **Improved Functionality**
- Introduced **`sum_if_not_none_or_initialize`** to prevent array interface issues:
```julia
# This function ensures that the sum operation maintains the array structure
# instead of returning a scalar sum, avoiding potential type mismatches.
```
- Enhanced performance of **cross-spectrum** and **power spectral density** calculations.

3. **Testing Enhancements**
- Consolidated all test cases into **`runtests.jl`** under the `test/` directory.
- Added missing **normalization tests** (`test_norm`).
- Included test commands for **Linux and macOS** in `test.md`.

### References
- Dependency Fixes: [Stingray.jl Issue #17](https://github.com/StingraySoftware/Stingray.jl/issues/17)
- Followed by: [Stingray.jl Issue #16](https://github.com/StingraySoftware/Stingray.jl/issues/16)

---

112 changes: 112 additions & 0 deletions docs/src/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Installation Guide for Stingray.jl
Documentation for [Stingray.jl](https://github.com/StingraySoftware/Stingray.jl).

## installing Julia

1. Download Julia from the official site: [https://julialang.org/downloads/](https://julialang.org/downloads/)
2. Install it following your OS instructions.
3. Add Julia to your system's PATH to summon it from any terminal like magic.

---

## Installing Stingray.jl

Launch the Julia REPL, press `]` to enter the **package manager mode**, and run:

```julia
using Pkg
Pkg.add("Stingray")
```

This will fetch Stingray from the heavens (and install dependencies).

---

## Running Tests Locally

To test the waters and ensure the installation vibes are right, run this in the **main directory**:

```julia
using Pkg
Pkg.test("Stingray")
```

If you get a dependency error with Stingray:

```julia
Pkg.add(url="https://github.com/StingraySoftware/Stingray.jl")
Pkg.develop("Stingray")
```

---

## Cloning the Development Version

```julia
Pkg.add(url="https://github.com/matteobachetti/Stingray.jl")
Pkg.develop("Stingray")
```

Or if you already cloned it manually:

```julia
using Pkg
Pkg.develop(path="path/to/your/local/Stingray.jl")
```

---

## Building Documentation (the doc-gen ritual)

1. Navigate to the `docs/` folder:
```bash
cd docs
```

2. Activate the project:
```julia
using Pkg
Pkg.activate(".")
```

3. Build the docs:
```julia
include("make.jl")
```


## Checking Your Installation

```julia
using Stingray
@info "Stingray.jl loaded successfully!"
```

---

## error handling

- If you’re juggling environments, run this before installing anything:
```julia
Pkg.activate("path/to/your/project")
```

- If you want to **remove and reinstall** for a clean slate:
```julia
Pkg.rm("Stingray")
Pkg.add("Stingray")
```

- To update the package:
```julia
Pkg.update("Stingray")
```

- To see all dependencies and versions:
```julia
Pkg.status()
```

---

**Julia porting of Stingray - Under heavy development, be ready to help debugging it ;)**
29 changes: 25 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,34 @@
CurrentModule = Stingray
```

# Stingray
# Welcome to Stingray.jl

Documentation for [Stingray](https://github.com/matteobachetti/Stingray.jl).
Documentation for [Stingray.jl](https://github.com/StingraySoftware/Stingray.jl).

```@index
```

```@autodocs
Modules = [Stingray]
## Overview
**Stingray.jl** is a Julia package for **X-ray spectral timing analysis**, designed for high-performance astrophysical data processing.

### Features:
- **Fast Fourier Transforms (FFT)** for analyzing periodic signals.
- **Periodograms** to measure signal variability.
- **Cross-spectra and coherence analysis** for multi-band signals.
- **Optimized for performance** with Julia’s native speed advantages.


## Quick Example
Here's a simple example to analyze an X-ray light curve:

```@julia
using Stingray, Random, Plots
N = 1024
t = collect(0:0.1:(N-1)*0.1)
Random.seed!(42)
light_curve = sin.(2π * 0.5 .* t) + 0.3 * randn(N) # Sine wave + noise
plot(t, light_curve, label="Simulated Light Curve", xlabel="Time (s)", ylabel="Intensity", title="X-ray Light Curve", legend=:topright)
```
This code generates a simulated X-ray light curve with a sine wave and Gaussian noise, then plots it

![X-ray Light Curve](notebooks/figures/Docs_1_1.png)
159 changes: 159 additions & 0 deletions docs/src/notebooks/Docs.ipynb

Large diffs are not rendered by default.

Binary file added docs/src/notebooks/figures/Docs_1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading