Skip to content

Commit

Permalink
feat: ✨ merge sun calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Dec 31, 2023
1 parent 69aaf26 commit 7f4146e
Show file tree
Hide file tree
Showing 19 changed files with 1,148 additions and 1,026 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": "error",
"func-style": "error",
"func-style": "off",
"function-call-argument-newline": "off",
"function-paren-newline": "off",
"generator-star-spacing": "error",
Expand Down
4 changes: 4 additions & 0 deletions examples/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Run the examples using ts-node.

Example:
npx ts-node .\examples\julian.ts -p ./examples/tsconfig.json
5 changes: 5 additions & 0 deletions examples/sun.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Degrees, Meters } from '@src/ootk';
import { Sun } from '../src/body/Sun';
/* eslint-disable no-console */

console.log(Sun.getTimes(new Date(), 41 as Degrees, -71 as Degrees, 0 as Meters));
13 changes: 13 additions & 0 deletions examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2015",
"baseUrl": "../",
"paths": {
"@lib/*": ["lib/*"],
"@dist/*": ["dist/*"],
"@src/*": ["src/*"],
"@test/*": ["test/*"]
}
}
}
118 changes: 60 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"opener": "^1.5.2",
"prettier": "^2.8.8",
"prettier-plugin-organize-imports": "^3.2.3",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"typescript": "^4.9.5",
"webpack": "^5.11.1",
"webpack-cli": "^4.10.0"
Expand Down
36 changes: 36 additions & 0 deletions src/body/Star.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { AzEl, Degrees, RaDec, Radians } from '@src/ootk';
import { Sun } from './Sun';

export class Star {
private constructor() {
// disable constructor
}

static getStarAzEl(date: Date, lat: Degrees, lon: Degrees, ra: Radians, dec: Radians): AzEl<Radians> {
const c: RaDec = {
ra,
dec,
};
const azEl = Sun.azEl(date, lat, lon, c);

const el = <Radians>(azEl.el + Star.astroRefraction(azEl.el)); // elevation correction for refraction

return {
az: azEl.az,
el,
};
}

/**
* get astro refraction
* @param {Radians} h - elevation
* @returns {number} refraction
*/
static astroRefraction(h: Radians): Radians {
if (h < 0) {
h = <Radians>0;
}

return <Radians>(0.0002967 / Math.tan(h + 0.00312536 / (h + 0.08901179)));
}
}
Loading

0 comments on commit 7f4146e

Please sign in to comment.