Skip to content

Commit

Permalink
Merge pull request #37 from eta077/main
Browse files Browse the repository at this point in the history
0.1.1
  • Loading branch information
eta077 authored Nov 2, 2023
2 parents 14b0432 + b85c9d9 commit 4b0272a
Show file tree
Hide file tree
Showing 16 changed files with 438 additions and 211 deletions.
11 changes: 11 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
coverage:
status:
changes: false
patch: false
project: false

ignore:
- "tests"

comment:
layout: "reach,diff,files"
14 changes: 11 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
- package-ecosystem: github-actions
directory: /
schedule:
interval: "weekly"
interval: weekly
- package-ecosystem: cargo
directory: /
schedule:
interval: weekly
ignore:
- dependency-name: "*"
update-types:
- "version-update:semver-patch"
79 changes: 47 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
permissions:
contents: read

on:
push:
branches:
Expand All @@ -7,6 +10,10 @@ on:
branches:
- main
- release

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

name: Build

Expand All @@ -15,45 +22,53 @@ jobs:
name: Fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
command: fmt
args: --all -- --check
components: rustfmt
- run: cargo fmt --check

check:
name: Check
clippy:
name: Clippy
permissions:
contents: read
checks: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
components: clippy
- uses: actions-rs/clippy-check@v1
with:
command: check
args: --all-features

clippy:
name: Clippy
token: ${{ secrets.GITHUB_TOKEN }}

doc:
name: Doc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: --cfg docsrs

hack:
name: Feature Unionization
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- run: cargo hack --feature-powerset check

msrv:
name: MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
command: clippy
args: --all-features -- -D warnings
toolchain: 1.60.0
- run: cargo check --all-features
79 changes: 39 additions & 40 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
permissions:
contents: read

on:
push:
branches:
Expand All @@ -7,52 +10,48 @@ on:
branches:
- main
- release

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

name: Test

jobs:
test:
name: Test with coverage
env:
PROJECT_NAME_UNDERSCORE: astro_rs
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
RUSTDOCFLAGS: -Cpanic=abort
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Cache dependencies
uses: actions/cache@v2
env:
cache-name: cache-dependencies
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
- name: Generate test result and coverage report
run: |
cargo install cargo2junit grcov;
cargo test --all-features $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`;
grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info;
- name: Upload test results
uses: EnricoMi/publish-unit-test-result-action@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- run: cargo test --locked --all-features

minimal:
name: Minimal versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@nightly
- run: rustup default stable
- run: cargo +nightly update -Zdirect-minimal-versions
- run: cargo test --locked --all-features

coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# nightly is required for --doctests, see cargo-llvm-cov#2
- uses: dtolnay/rust-toolchain@nightly
with:
check_name: Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
files: results.xml
- name: Upload to CodeCov
uses: codecov/codecov-action@v3
components: llvm-tools-preview
- uses: taiki-e/install-action@cargo-llvm-cov
- if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- run: cargo +nightly llvm-cov --locked --all-features --lcov --doctests --output-path lcov.info
- uses: codecov/codecov-action@v3
with:
files: ./lcov.info
fail_ci_if_error: true
fail_ci_if_error: true
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

## [0.1.1]

Set MSRV, stricter dependency versions, better workflows

### Changed

- Switched from chrono to hifitime
- Switched from measurements to uom
- Included `coordinates` feature by default

## [0.1.0]

Initial FITS feature release
21 changes: 14 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astro-rs"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MIT"
description = "Astronomy utils"
Expand All @@ -21,20 +21,27 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
chrono = { version = "0.4", optional = true }
hifitime = { version = "3.6", optional = true }
hyper = { version = "0.14", features = ["client", "http1", "tcp"], optional = true }
measurements = { version = "0.11", optional = true }
thiserror = { version = "1.0" }
once_cell = { version = "1.16", optional = true }
rust_decimal = { version = "1.29" }
thiserror = { version = "1.0.7" }
uom = { version = "0.35", optional = true, default-features = false, features = ["autoconvert", "si", "std", "f64"] }
urlencoding = { version = "2.1", optional = true }

# pin to retain MSRV
tokio = { version = "1, <1.30.0" }
memchr = { version = "2.4, <2.6.3" }
regex = { version = "1.7, <1.10.0", optional = true }

[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] }
criterion = { version = "0.5", features = ["html_reports"] }
image = { version = "0.24", default-features = false, features = ["jpeg"] }
tokio-test = { version = "0.4" }

[features]
default = ["fits"]
coordinates = ["dep:chrono", "dep:hyper", "dep:measurements", "dep:urlencoding"]
default = ["coordinates", "fits"]
coordinates = ["dep:hifitime", "dep:hyper", "dep:once_cell", "dep:regex", "dep:uom", "dep:urlencoding"]
cosmology = []
fits = []

Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
![GitHub Build Status (branch)](https://img.shields.io/github/workflow/status/eta077/astro-rs/Build/release) ![GitHub Test Status (branch)](https://img.shields.io/github/workflow/status/eta077/astro-rs/Test/release?label=test) [![codecov](https://codecov.io/gh/eta077/astro-rs/branch/release/graph/badge.svg)](https://codecov.io/gh/eta077/astro-rs) [![docs.rs](https://img.shields.io/docsrs/astro-rs)](https://docs.rs/astro-rs/latest/astro_rs/)
![GitHub Build Status (branch)](https://img.shields.io/github/actions/workflow/status/eta077/astro-rs/build.yml?branch=release)
![GitHub Test Status (branch)](https://img.shields.io/github/actions/workflow/status/eta077/astro-rs/test.yml?branch=release&label=test)
[![codecov](https://codecov.io/gh/eta077/astro-rs/branch/release/graph/badge.svg)](https://codecov.io/gh/eta077/astro-rs)
[![docs.rs](https://img.shields.io/docsrs/astro-rs)](https://docs.rs/astro-rs/latest/astro_rs/)

# astro-rs
This library provides utilities to interact with astronomical data.
Expand All @@ -11,10 +14,19 @@ Inspired by Astropy (<http://astropy.org> / <https://github.com/astropy/astropy>
* Equal or surpass the Astropy benchmarks

## Technical goals
* Use pure Rust as opposed to wrapping other libraries
* Deserialize as lazily as possible
* Balance 'tight' (<https://www.ecorax.net/tightness>) types and adherance to the FITS API with graceful handling of deviation
* Balance 'tight' (<https://www.ecorax.net/tightness>) types and adherance to APIs with graceful handling of deviation

# Testing
Test assets are from the following sources:
* <https://esahubble.org/projects/fits_liberator/datasets_archives>
* <https://cxc.harvard.edu/cda/>

# Licensing
* Original code is licensed under the MIT license
* `astropy` is licensed under BSD-3-Clause
* `hifitime` is licensed under Apache-2.0

# MSRV
This crate's Minimum Supported Rust Version is `1.60.0`.
13 changes: 0 additions & 13 deletions codecov.yml

This file was deleted.

34 changes: 25 additions & 9 deletions src/coordinates/frames.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
use chrono::{DateTime, Utc};
use hifitime::Epoch;
use thiserror::Error;

use super::{EarthLocation, EquatorialCoord, HorizontalCoord};
use super::{EarthLocation, EquatorialCoord};

/// An enumeration of errors that can occur while converting coordinates from one frame to another.
#[derive(Debug, Error)]
pub enum AstroConversionError {}

/// Coordinates in the International Celestial Reference System.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub struct Icrs {
/// The coordinate value
pub coords: EquatorialCoord,
}

impl Icrs {
/// Converts coordinates from ICRS to AltAz
pub fn as_alt_az(&self, _date_time: &DateTime<Utc>, _location: &EarthLocation) -> AltAz {
AltAz::default()
/// Creates a new Icrs with the coordinate values rounded to the specified decimal place.
pub fn round(&self, dp: u32) -> Self {
Self {
coords: self.coords.round(dp),
}
}

/// Converts coordinates from ICRS to observed AltAz coordinates.
pub fn to_alt_az(
&self,
_date_time: &Epoch,
_location: &EarthLocation,
) -> Result<AltAz, AstroConversionError> {
Ok(AltAz::default())
}
}

/// Coordinates
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
/// Coordinates with respect to the WGS84 ellipsoid.
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub struct AltAz {
/// The coordinate value
pub coords: HorizontalCoord,
pub coords: EquatorialCoord,
}
Loading

0 comments on commit 4b0272a

Please sign in to comment.