Skip to content

Commit 4978ca1

Browse files
authored
docs: add Documentation (#8)
1 parent ed62bf9 commit 4978ca1

12 files changed

Lines changed: 379 additions & 13 deletions

File tree

.github/workflows/Doc.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "src/**"
9+
- "docs/**"
10+
- "Project.toml"
11+
tags: ["*"]
12+
pull_request:
13+
paths:
14+
- "src/**"
15+
- "docs/**"
16+
- "Project.toml"
17+
workflow_dispatch:
18+
19+
concurrency:
20+
# Skip intermediate builds: always.
21+
# Cancel intermediate builds: only if it is a pull request build.
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
24+
25+
jobs:
26+
docs:
27+
permissions:
28+
actions: write # needed to allow julia-actions/cache to proactively delete old caches that it has created
29+
contents: write
30+
pull-requests: read
31+
statuses: write
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Build and deploy Documenter.jl docs
35+
uses: JuliaSpacePhysics/actions/DocsDocumenter@main

.github/workflows/DocCleanup.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Doc Preview Cleanup
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
# Ensure that only one "Doc Preview Cleanup" workflow is force pushing at a time
8+
concurrency:
9+
group: doc-preview-cleanup
10+
cancel-in-progress: false
11+
12+
jobs:
13+
doc-preview-cleanup:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: Checkout gh-pages branch
19+
uses: actions/checkout@v4
20+
with:
21+
ref: gh-pages
22+
- name: Delete preview and history + push changes
23+
run: |
24+
if [ -d "${preview_dir}" ]; then
25+
git config user.name "Documenter.jl"
26+
git config user.email "documenter@juliadocs.github.io"
27+
git rm -rf "${preview_dir}"
28+
git commit -m "delete preview"
29+
git branch gh-pages-new "$(echo "delete history" | git commit-tree "HEAD^{tree}")"
30+
git push --force origin gh-pages-new:gh-pages
31+
fi
32+
env:
33+
preview_dir: previews/PR${{ github.event.number }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
Manifest.toml
2+
/docs/build/

README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# HAPIClient
22

3-
[![Build Status](https://github.com/JuliaSpacePhysics/HAPIClient.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaSpacePhysics/HAPIClient.jl/actions/workflows/CI.yml?query=branch%3Amain)
3+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaSpacePhysics.github.io/HAPIClient.jl/dev/)
44
[![DOI](https://zenodo.org/badge/935193759.svg)](https://doi.org/10.5281/zenodo.15108960)
5+
[![Build Status](https://github.com/JuliaSpacePhysics/HAPIClient.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaSpacePhysics/HAPIClient.jl/actions/workflows/CI.yml?query=branch%3Amain)
56
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
67
[![Coverage](https://codecov.io/gh/JuliaSpacePhysics/HAPIClient.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaSpacePhysics/HAPIClient.jl)
78

@@ -45,13 +46,6 @@ data = get_data("CDAWeb/AC_H0_MFI/Magnitude,BGSEc", start_time, end_time)
4546
# Access the data
4647
Magnitude = data[1]
4748
BGSEc = data[2]
48-
49-
# Example with CSA server
50-
csa_dataset = "C4_CP_FGM_FULL"
51-
csa_parameters = "B_vec_xyz_gse,B_mag"
52-
csa_start = DateTime(2001, 6, 11, 0, 0, 0)
53-
csa_end = DateTime(2001, 6, 11, 0, 1, 0)
54-
csa_data = hapi(CSA, csa_dataset, csa_parameters, csa_start, csa_end)
5549
```
5650

5751
Recommended way to access variable properties:
@@ -64,8 +58,4 @@ parent(var)
6458
times(var)
6559
# to retrieve the metadata
6660
meta(var)
67-
```
68-
69-
### Visualization
70-
71-
For visualization, see [SPEDAS.jl quickstart](https://beforerr.github.io/SPEDAS.jl/dev/tutorials/getting-started/).
61+
```

docs/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[deps]
2+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
3+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4+
HAPIClient = "0ce0b37c-8851-4c5b-98a3-e691a5f19c53"

docs/make.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Documenter
2+
using HAPIClient
3+
4+
makedocs(;
5+
modules=[HAPIClient],
6+
sitename="HAPIClient.jl",
7+
format=Documenter.HTML(;
8+
prettyurls=get(ENV, "CI", "false") == "true",
9+
),
10+
pages=[
11+
"Home" => "index.md",
12+
"Usage" => "usage.md",
13+
"API Reference" => "api.md",
14+
],
15+
)
16+
17+
deploydocs(;
18+
repo="github.com/JuliaSpacePhysics/HAPIClient.jl",
19+
push_preview = true
20+
)

docs/src/api.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# API Reference
2+
3+
```@meta
4+
CurrentModule = HAPIClient
5+
```
6+
7+
## Main Functions
8+
9+
### Core HAPI Interface
10+
11+
```@docs; canonical=false
12+
hapi
13+
```
14+
15+
### Data Retrieval
16+
17+
```@docs; canonical=false
18+
get_data
19+
```
20+
21+
## Types
22+
23+
### Data Variables
24+
25+
```@docs; canonical=false
26+
HAPIVariable
27+
HAPIVariables
28+
```
29+
30+
## Constants
31+
32+
### Predefined Servers
33+
34+
HAPIClient.jl provides convenient constants for commonly used HAPI servers:
35+
36+
- `CDAWeb` - NASA's Coordinated Data Analysis Web
37+
- `CSA` - ESA's Cluster Science Archive
38+
39+
These are automatically exported and can be used directly:
40+
41+
```julia
42+
# Use predefined server constants
43+
catalog = hapi(CDAWeb)
44+
data = hapi(CSA, "C1_CP_FGM_FULL", "B_vec_xyz_gse", start_time, end_time)
45+
```
46+
47+
## Examples
48+
49+
### Basic Usage
50+
51+
```julia
52+
using HAPIClient
53+
using Dates
54+
55+
# List servers
56+
servers = hapi()
57+
58+
# Get catalog
59+
catalog = hapi(CDAWeb)
60+
61+
# Get data
62+
data = hapi(CDAWeb, "AC_H0_MFI", "Magnitude",
63+
DateTime(2001, 1, 1), DateTime(2001, 1, 2))
64+
```
65+
66+
### Working with Retrieved Data
67+
68+
```julia
69+
# Access first variable
70+
var = data[1]
71+
72+
# Get values, timestamps, and metadata
73+
values = parent(var)
74+
timestamps = times(var)
75+
metadata = meta(var)
76+
```
77+
78+
79+
## Public
80+
81+
```@autodocs
82+
Modules = [HAPIClient]
83+
Private = false
84+
```
85+
86+
## Private
87+
88+
```@autodocs
89+
Modules = [HAPIClient]
90+
Public = false
91+
```

docs/src/index.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# HAPIClient.jl
2+
3+
[![Build Status](https://github.com/JuliaSpacePhysics/HAPIClient.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaSpacePhysics/HAPIClient.jl/actions/workflows/CI.yml?query=branch%3Amain)
4+
[![DOI](https://zenodo.org/badge/935193759.svg)](https://doi.org/10.5281/zenodo.15108960)
5+
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
6+
[![Coverage](https://codecov.io/gh/JuliaSpacePhysics/HAPIClient.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaSpacePhysics/HAPIClient.jl)
7+
8+
A Julia client for the Heliophysics Application Programmer's Interface (HAPI).
9+
10+
HAPIClient.jl makes it easy to access heliophysics data from HAPI-compliant servers. The package supports:
11+
12+
- Listing available HAPI servers (See [HAPI Server Browser](https://hapi-server.org/servers/))
13+
- Browsing catalogs of datasets
14+
- Retrieving parameter information
15+
- Downloading time series data
16+
- Integration with Julia's ecosystem (Dates, Tables, Unitful)
17+
18+
## Installation
19+
20+
```julia
21+
using Pkg
22+
Pkg.add("HAPIClient")
23+
```
24+
25+
## Quick Start
26+
27+
```@example start
28+
using HAPIClient
29+
using Dates
30+
31+
# Get data from CDAWeb
32+
dataset = "AC_H0_MFI"
33+
parameters = "Magnitude,BGSEc"
34+
start_time = DateTime(2001, 1, 1, 5, 0, 0)
35+
end_time = DateTime(2001, 1, 1, 6, 0, 0)
36+
data = hapi(CDAWeb, dataset, parameters, start_time, end_time)
37+
```
38+
39+
## Navigation
40+
41+
- [Usage](usage.md) - Detailed usage examples and tutorials
42+
- [API Reference](api.md) - Complete API documentation

docs/src/usage.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Usage Guide
2+
3+
This guide provides detailed examples of how to use `HAPIClient.jl` to access heliophysics data from HAPI servers.
4+
5+
## Basic Usage
6+
7+
### Listing Available Servers
8+
9+
Start by exploring what HAPI servers are available:
10+
11+
```@example usage
12+
using HAPIClient
13+
14+
# List all available HAPI servers
15+
servers = hapi()
16+
```
17+
18+
### Getting Dataset Catalogs
19+
20+
Once you know which servers are available, you can browse their catalogs:
21+
22+
```@example usage
23+
# Get catalog of available datasets from CDAWeb
24+
catalog = hapi(CDAWeb)
25+
```
26+
27+
### Dataset Information
28+
29+
Get detailed information about parameters in a specific dataset:
30+
31+
```@example usage
32+
dataset = "AC_H0_MFI"
33+
params = hapi(CDAWeb, dataset)
34+
```
35+
36+
## Data Retrieval and Access
37+
38+
### Basic Data Download
39+
40+
Retrieve data for specific parameters within a time range:
41+
42+
```@example usage
43+
using Dates
44+
45+
dataset = "AC_H0_MFI"
46+
parameters = "Magnitude,BGSEc"
47+
start_time = DateTime(2001, 1, 1, 5, 0, 0)
48+
end_time = DateTime(2001, 1, 1, 6, 0, 0)
49+
50+
# Retrieve the data
51+
data = hapi(CDAWeb, dataset, parameters, start_time, end_time)
52+
```
53+
54+
### Alternative Path Format
55+
56+
You can also use a path-like format for data retrieval:
57+
58+
```julia
59+
# Alternative method using path format
60+
data = get_data("CDAWeb/AC_H0_MFI/Magnitude,BGSEc", start_time, end_time)
61+
```
62+
63+
### Accessing Retrieved Data
64+
65+
Once you have retrieved data, you can access individual variables:
66+
67+
```@example usage
68+
Magnitude = data.Magnitude # or data[1] if you know the order (same as `parameters` order)
69+
BGSEc = data.BGSEc # or data[2]
70+
var = data[2]
71+
```
72+
73+
Retrieve the values
74+
75+
```@example usage
76+
values = parent(var)
77+
```
78+
79+
Retrieve the timestamps
80+
81+
```@example usage
82+
timestamps = times(var)
83+
```
84+
85+
Retrieve the metadata
86+
87+
```@example usage
88+
metadata = meta(var)
89+
```
90+
91+
## Working with Different Servers
92+
93+
### CSA Example
94+
95+
```julia
96+
# Example with CSA (Cluster Science Archive) server
97+
csa_dataset = "C4_CP_FGM_FULL"
98+
csa_parameters = "B_vec_xyz_gse,B_mag"
99+
csa_start = DateTime(2001, 6, 11, 0, 0, 0)
100+
csa_end = DateTime(2001, 6, 11, 0, 1, 0)
101+
csa_data = hapi(CSA, csa_dataset, csa_parameters, csa_start, csa_end)
102+
```
103+
104+
## Data Analysis
105+
106+
The retrieved data integrates well with Julia's ecosystem:
107+
108+
```@example usage
109+
using CairoMakie
110+
111+
f = Figure()
112+
for (i, var) in enumerate(data)
113+
m = meta(var)
114+
ax = Axis(f[i,1]; xlabel="Time", ylabel=m["name"], title=m["description"])
115+
t = times(var)
116+
for c in eachcol(var)
117+
lines!(t, c)
118+
end
119+
i != length(data) && hidexdecorations!(; grid=false)
120+
end
121+
f
122+
```
123+
124+
For advanced visualization capabilities, `HAPIClient.jl` works well with the `SPEDAS.jl` ecosystem. See the [SPEDAS.jl quickstart guide](https://JuliaSpacePhysics.github.io/SPEDAS.jl/dev/tutorials/getting-started/) for detailed visualization examples.

0 commit comments

Comments
 (0)