Skip to content

Commit e494788

Browse files
committed
feat: init wrapping
1 parent 46f6199 commit e494788

File tree

14 files changed

+173
-18
lines changed

14 files changed

+173
-18
lines changed

.github/workflows/Doc.yml

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/Manifest*.toml
55
/docs/Manifest*.toml
66
/docs/build/
7+
.CondaPkg

CondaPkg.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
sunpy = ""
3+
certifi = ""

Project.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
name = "SunPy"
22
uuid = "d53ba2b8-6a4a-4633-896a-a050af4da271"
3-
authors = ["Beforerr <zzj956959688@gmail.com> and contributors"]
43
version = "1.0.0-DEV"
4+
authors = ["Beforerr <zzj956959688@gmail.com> and contributors"]
5+
6+
[workspace]
7+
projects = ["test", "docs"]
8+
9+
[deps]
10+
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
511

612
[compat]
13+
PythonCall = "0.9"
714
julia = "1.10"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
[![Build Status](https://github.com/JuliaSpacePhysics/SunPy.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaSpacePhysics/SunPy.jl/actions/workflows/CI.yml?query=branch%3Amain)
66
[![Coverage](https://codecov.io/gh/JuliaSpacePhysics/SunPy.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaSpacePhysics/SunPy.jl)
77
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
8+
9+
A Julia wrapper around [SunPy](https://github.com/sunpy/sunpy)

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
34
SunPy = "d53ba2b8-6a4a-4633-896a-a050af4da271"

docs/make.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
using SunPy
22
using Documenter
33

4-
DocMeta.setdocmeta!(SunPy, :DocTestSetup, :(using SunPy); recursive=true)
4+
DocMeta.setdocmeta!(SunPy, :DocTestSetup, :(using SunPy); recursive = true)
55

66
makedocs(;
7-
modules=[SunPy],
8-
authors="Beforerr <zzj956959688@gmail.com> and contributors",
9-
sitename="SunPy.jl",
10-
format=Documenter.HTML(;
11-
canonical="https://JuliaSpacePhysics.github.io/SunPy.jl",
12-
edit_link="main",
13-
assets=String[],
7+
modules = [SunPy],
8+
authors = "Beforerr <zzj956959688@gmail.com> and contributors",
9+
sitename = "SunPy.jl",
10+
format = Documenter.HTML(;
11+
canonical = "https://JuliaSpacePhysics.github.io/SunPy.jl",
1412
),
15-
pages=[
13+
pages = [
1614
"Home" => "index.md",
15+
"Tutorials" => [
16+
"Coordinates" => "tutorials/coordinates.md",
17+
],
1718
],
1819
)
1920

2021
deploydocs(;
21-
repo="github.com/JuliaSpacePhysics/SunPy.jl",
22-
devbranch="main",
22+
repo = "github.com/JuliaSpacePhysics/SunPy.jl",
23+
push_preview = true
2324
)

docs/src/index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,23 @@ Documentation for [SunPy](https://github.com/JuliaSpacePhysics/SunPy.jl).
1212
```@autodocs
1313
Modules = [SunPy]
1414
```
15+
16+
## Quickstart
17+
18+
using the `Fido` interface to obtain solar data.
19+
20+
```@example sunpy
21+
using SunPy, PythonCall
22+
@py import sunpy.net: Fido, attrs as a
23+
Fido
24+
Fido.search(a.Time("2012/3/4", "2012/3/6"), a.Instrument.lyra, a.Level.two)
25+
```
26+
27+
https://docs.sunpy.org/en/stable/tutorial/maps.html
28+
29+
```@example sunpy
30+
pyimport("sunpy.data.sample")
31+
sunpy.data.sample.AIA_171_IMAGE
32+
my_map = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)
33+
# my_map.quicklook()
34+
```

docs/src/tutorials/coordinates.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Coordinates
2+
3+
This section of the guide introduces how coordinates are represented in sunpy.
4+
5+
Corresponding sunpy tutorial: https://docs.sunpy.org/en/stable/tutorial/coordinates.html#
6+
7+
```@example sunpy
8+
using SunPy
9+
using SunPy: SkyCoord
10+
using PythonCall
11+
@py import astropy.units as u
12+
@py import sunpy.coordinates.frames as frames
13+
```
14+
15+
```@example sunpy
16+
@py coord = SkyCoord(70*u.deg, -30*u.deg, obstime="2017-08-01",
17+
frame=frames.HeliographicStonyhurst)
18+
```
19+
20+
```@example sunpy
21+
coord.transform_to(frames.Helioprojective(observer="earth"))
22+
```
23+
24+
```@example sunpy
25+
@py import sunpy.data.sample: AIA_171_IMAGE
26+
@py import matplotlib.pyplot as plt
27+
28+
amap = sunpy.map.Map(AIA_171_IMAGE)
29+
coord = SkyCoord(100 * u.arcsec, 10*u.arcsec, frame=amap.coordinate_frame)
30+
pixels = amap.wcs.world_to_pixel(coord)
31+
```
32+
33+
```@example sunpy
34+
fig = plt.figure()
35+
ax = plt.subplot(projection=amap)
36+
amap.plot()
37+
ax.plot_coord(coord, 'o')
38+
fig
39+
```
40+
41+

src/SunPy.jl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
module SunPy
22

3-
# Write your package code here.
3+
using PythonCall
44

5+
export sunpy
6+
7+
include("types.jl")
8+
9+
const sunpy = PythonModule(PythonCall.pynew(), (:data, :map, :net, :visualization))
10+
const astropy = PythonModule(PythonCall.pynew())
11+
12+
function __init__()
13+
certifi = pyimport("certifi")
14+
ENV["SSL_CERT_FILE"] = pyconvert(String, certifi.where())
15+
16+
PythonCall.pycopy!(sunpy.mod, pyimport("sunpy"))
17+
PythonCall.pycopy!(astropy.mod, pyimport("astropy"))
18+
return
19+
end
20+
21+
function SkyCoord(args...; kw...)
22+
return (@pyconst pyimport("astropy.coordinates").SkyCoord)(args...; kw...)
23+
end
524
end

0 commit comments

Comments
 (0)