Skip to content

Commit

Permalink
Add GIT LFS support (#80)
Browse files Browse the repository at this point in the history
* add LFS support, starting with MPC Orb file

* doc actions tweaked to make use of this

* updated an example so that it used this file instead of comets
  • Loading branch information
dahlend authored Jul 18, 2024
1 parent bcb0715 commit ca11db3
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 91 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/data/mpcorb_extended.json.gz filter=lfs diff=lfs merge=lfs -text
70 changes: 0 additions & 70 deletions .github/workflows/docs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
python: 311
platform_id: macosx_arm64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- run: cargo test --all-features
Expand Down
56 changes: 53 additions & 3 deletions .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,31 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
NEOSPY_CACHE_DIR: ${{ github.workspace }}/docs/data

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Test with cargo
run: |
cargo test
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip setuptools black mypy types-requests numpy
Expand All @@ -32,12 +42,52 @@ jobs:
- name: Lint with mypy
run: |
python3 -m mypy src/neospy/
# Build and run pytest
- name: Build neospy
run: |
python3 -m pip install '.[dev]' -v
- name: Test with pytest
run: |
python3 -m pytest --cov-report term-missing --cov=neospy
- name: Test with cargo
# Build documentation and push artifact
- name: Build Docs
run: |
cargo test
cd docs
make clean
make doctest
make html
- name: Fix permissions
run: |
chmod -c -R +rX "docs/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload Docs artifact
uses: actions/upload-artifact@master
with:
name: "github-pages"
path:
docs/html/


deploy:
needs: build
if: success() && github.ref == 'refs/heads/main'

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ members = ["src/neospy_core"]
default-members = ["src/neospy_core"]

[profile.release]
opt-level = 3
pyo3_disable_reference_pool = true
opt-level = 3
3 changes: 3 additions & 0 deletions docs/data/mpcorb_extended.json.gz
Git LFS file not shown
29 changes: 14 additions & 15 deletions src/examples/plot_mpc_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@
This will open an interactive 3d plot of the solar system.
This plots all comets from the MPC, along with the last 365 days of their orbit.
This plots all of the Hildas from the MPC, along with the last 90 days of their orbit.
"""

import neospy
import matplotlib.pyplot as plt
import numpy as np

# Set the X/Y/Z scale
zoom = 4
zoom = 4.0

# Fetch all known comet orbits
orb = neospy.mpc.fetch_known_comet_orbit_data()
# Fetch all known asteroid orbits
orb = neospy.mpc.fetch_known_orbit_data()

# Subset to the Hildas
orb = orb[orb["group_name"] == "Hilda"]

# convert the table of data to State objects
states = neospy.mpc.table_to_states(orb)

# Every object in the MPC orbit file has its own epoch of fit.
# This means that some objects epochs may be months or years away from
# others. In order to bring all of these objects to the same epoch, the
# function below finds the most common epoch in the data, and uses n-body
# integration to calculate the position of all objects that the median
# epoch. If all known objects are included, then this may take a little
# while to compute.
states = neospy.mpc.table_to_states(orb)

# function below will propagate the states to the first state's epoch.
states = neospy.propagate_two_body(states, states[0].jd)

# Grab the positions from this subset
pos = np.array([p.pos for p in states])
Expand All @@ -46,13 +48,10 @@
ax.plot(pos[0], pos[1], pos[2], color="black", alpha=0.2)

for state in states:
# Skip fragments
if " " in state.desig:
continue
jd = states[0].jd
jds = np.linspace(jd - 365, jd, 100)
jds = np.linspace(jd - 90, jd, 100)
pos = np.array([neospy.propagate_two_body([state], jd)[0].pos for jd in jds]).T
ax.plot(pos[0], pos[1], pos[2], color="black", alpha=0.2, lw=0.2)
ax.plot(pos[0], pos[1], pos[2], color="black", alpha=0.1, lw=0.2)

ax.scatter(0, 0, 0, color="red")
ax.set_xticks([-zoom, 0, zoom])
Expand Down

0 comments on commit ca11db3

Please sign in to comment.