Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sharpcoder/altaz-js
A package for astronomy math in javascript
https://github.com/sharpcoder/altaz-js
astronomy math space
Last synced: 7 days ago
JSON representation
A package for astronomy math in javascript
- Host: GitHub
- URL: https://github.com/sharpcoder/altaz-js
- Owner: SharpCoder
- Created: 2023-06-26T15:15:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-24T15:45:05.000Z (3 months ago)
- Last Synced: 2024-10-29T01:47:00.906Z (17 days ago)
- Topics: astronomy, math, space
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/altaz
- Size: 69.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AltAz
AltAz is a library for performing common astronomy calculations.
## Installation
Use any familiar package manager
```bash
pnpm install --save altaz
npm install --save altaz
yarn add altaz
```## Usage
```typescript
// *************************************************
// Calculating days julian
// *************************************************
import { instantToDaysJulian } from "altaz";
const jday = instantToDaysJulian(now);// *************************************************
// Calculating the position of a star at an instant
// *************************************************
import {
Angle,
GPSCoordinate,
round,
sphereToHorizontal,
SphericalCoordinate,
timeToAngle,
timeToDec,
} from "altaz";// Position of observer (Seattle)
const location = new GPSCoordinate(
Angle.fromDegrees(47.608013),
Angle.fromDegrees(-122.335167.),
);// Position of the star
const skyTarget = {
ra_h: 1.0,
ra_m: 1.0,
ra_s: 1.0,
dec_deg: 1.0,
dec_m: 1.0,
dec_s: 1.0,
};const starRightAscension = timeToAngle(
parseFloat(skyTarget.ra_h),
parseFloat(skyTarget.ra_m),
parseFloat(skyTarget.ra_s)
);const starDeclination = Angle.fromDegrees(
parseFloat(skyTarget.dec_deg) +
timeToDec(0, parseFloat(skyTarget.dec_m), parseFloat(skyTarget.dec_s))
);const targetPosition = new SphericalCoordinate(
1.0,
starRightAscension,
starDeclination
);const targetAltAz = sphereToHorizontal(location, targetPosition, new Date());
// *************************************************
// Calculating the position of a planet at an instant
// *************************************************
import { Mercury, sphereToHorizontal } from "altaz";// Position of observer (Seattle)
const location = new GPSCoordinate(
Angle.fromDegrees(47.608013),
Angle.fromDegrees(-122.335167.),
);// Position of the planet
const targetPosition = Mercury.asSphere();
const targetAltAz = sphereToHorizontal(location, targetPosition, new Date());
```## Installation
Build with the script
```bash
pnpm run build
npm run build
yarn run build
```## Tests
I have tests somewhere. I'll migrate them eventually but I promise the math here is pretty well tested and used in a few simple production apps.
## Contributing
Please open an issue first to discuss what you would like to change and we'll go from there.
## License
[MIT](https://choosealicense.com/licenses/mit/)