Skip to content

Commit

Permalink
Version 5.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezze committed Jan 6, 2023
2 parents 3c1efc0 + 16b9924 commit 8a6aada
Show file tree
Hide file tree
Showing 17 changed files with 2,001,829 additions and 3,524 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ lib
sgp4_verification/lib/sgp4
*.log
package-lock.json
test/propagation/sgp4prop
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 5.0.0 (2023-01-06)

- Errors in calculations are fixed, WGS72 is used instead of WGS84 (#107).
- Dependencies are upgraded.

## 4.1.4 (2022-07-18)

- TypeScript definition for `ecfToEci` function is added.
Expand Down
52 changes: 29 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "satellite.js",
"version": "4.1.4",
"version": "5.0.0",
"description": "SGP4/SDP4 calculation library",
"main": "lib/index.js",
"jsnext:main": "dist/satellite.es.js",
Expand All @@ -10,8 +10,8 @@
"build": "rimraf lib dist && npm run transpile && npm run dist",
"transpile": "babel src --out-dir lib --ignore indexUmd.js && node --require @babel/register commands/add-copyright.js 'lib/**/*.js'",
"dist": "npm run dist:es && npm run dist:umd:dev && npm run dist:umd:prod",
"dist:es": "rollup --config rollup.config.es.js && node --require @babel/register commands/add-copyright.js 'dist/satellite.es.js'",
"dist:umd": "rollup --config rollup.config.js",
"dist:es": "rollup --bundleConfigAsCjs --config rollup.config.es.js && node --require @babel/register commands/add-copyright.js 'dist/satellite.es.js'",
"dist:umd": "rollup --bundleConfigAsCjs --config rollup.config.js",
"dist:umd:dev": "cross-env NODE_ENV=development npm run dist:umd && node --require @babel/register commands/add-copyright.js 'dist/**/satellite.js'",
"dist:umd:prod": "cross-env NODE_ENV=production npm run dist:umd && node --require @babel/register commands/add-copyright.js 'dist/**/satellite.min.js'",
"watch:es": "node --require @babel/register rollup.watch.es.js",
Expand Down Expand Up @@ -42,29 +42,35 @@
},
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-json-strings": "^7.10.4",
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-json-strings": "^7.18.6",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/preset-env": "^7.11.5",
"@babel/register": "^7.11.5",
"@rollup/plugin-babel": "^5.2.1",
"chokidar": "^3.4.2",
"copyfiles": "^2.3.0",
"coveralls": "^3.1.0",
"cross-env": "^7.0.2",
"eslint": "^7.9.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.0",
"glob": "^7.1.6",
"jest": "^26.4.2",
"prepend-file": "^2.0.0",
"raise-version": "^0.4.0",
"@babel/preset-env": "^7.20.2",
"@babel/register": "^7.18.9",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-terser": "^0.2.1",
"chokidar": "^3.5.3",
"copyfiles": "^2.4.1",
"coveralls": "^3.1.1",
"cross-env": "^7.0.3",
"eslint": "^8.31.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0",
"glob": "^8.0.3",
"jest": "^29.3.1",
"prepend-file": "^2.0.1",
"raise-version": "^0.5.0",
"rimraf": "^3.0.2",
"rollup": "^2.26.11",
"rollup-plugin-terser": "^7.0.2"
"rollup": "^3.9.1"
},
"jest": {
"testPathIgnorePatterns": [
"node_modules",
"test/propagation/sgp4prop"
]
},
"homepage": "https://github.com/shashwatak/satellite-js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';

const { NODE_ENV } = process.env;

Expand Down
10 changes: 5 additions & 5 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ export const twoPi = pi * 2;
export const deg2rad = pi / 180.0;
export const rad2deg = 180 / pi;
export const minutesPerDay = 1440.0;
export const mu = 398600.5; // in km3 / s2
export const earthRadius = 6378.137; // in km
export const mu = 398600.8; // in km3 / s2
export const earthRadius = 6378.135; // in km
export const xke = 60.0 / Math.sqrt((earthRadius * earthRadius * earthRadius) / mu);
export const vkmpersec = (earthRadius * xke) / 60.0;
export const tumin = 1.0 / xke;
export const j2 = 0.00108262998905;
export const j3 = -0.00000253215306;
export const j4 = -0.00000161098761;
export const j2 = 0.001082616;
export const j3 = -0.00000253881;
export const j4 = -0.00000165597;
export const j3oj2 = j3 / j2;
export const x2o3 = 2.0 / 3.0;
38 changes: 13 additions & 25 deletions src/io.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import {
pi,
tumin,
deg2rad,
} from './constants';
import { pi, deg2rad } from './constants';

import {
jday,
days2mdhms,
} from './ext';
import { jday, days2mdhms } from './ext';

import sgp4init from './propagation/sgp4init';

Expand Down Expand Up @@ -80,13 +73,16 @@ export default function twoline2satrec(longstr1, longstr2) {
satrec.epochdays = parseFloat(longstr1.substring(20, 32));
satrec.ndot = parseFloat(longstr1.substring(33, 43));
satrec.nddot = parseFloat(
`.${parseInt(longstr1.substring(44, 50), 10)
}E${longstr1.substring(50, 52)}`,
`.${parseInt(longstr1.substring(44, 50), 10)}E${longstr1.substring(
50,
52,
)}`,
);
satrec.bstar = parseFloat(
`${longstr1.substring(53, 54)
}.${parseInt(longstr1.substring(54, 59), 10)
}E${longstr1.substring(59, 61)}`,
`${longstr1.substring(53, 54)}.${parseInt(
longstr1.substring(54, 59),
10,
)}E${longstr1.substring(59, 61)}`,
);

// satrec.satnum = longstr2.substring(2, 7);
Expand All @@ -103,19 +99,15 @@ export default function twoline2satrec(longstr1, longstr2) {
// satrec.bstar= satrec.bstar * Math.pow(10.0, ibexp);

// ---- convert to sgp4 units ----
satrec.a = ((satrec.no * tumin) ** (-2.0 / 3.0));
satrec.ndot /= (xpdotp * 1440.0); // ? * minperday
satrec.nddot /= (xpdotp * 1440.0 * 1440);
// satrec.ndot /= (xpdotp * 1440.0); // ? * minperday
// satrec.nddot /= (xpdotp * 1440.0 * 1440);

// ---- find standard orbital elements ----
satrec.inclo *= deg2rad;
satrec.nodeo *= deg2rad;
satrec.argpo *= deg2rad;
satrec.mo *= deg2rad;

satrec.alta = (satrec.a * (1.0 + satrec.ecco)) - 1.0;
satrec.altp = (satrec.a * (1.0 - satrec.ecco)) - 1.0;

// ----------------------------------------------------------------
// find sgp4epoch time of element set
// remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch)
Expand All @@ -134,11 +126,7 @@ export default function twoline2satrec(longstr1, longstr2) {
const mdhmsResult = days2mdhms(year, satrec.epochdays);

const {
mon,
day,
hr,
minute,
sec,
mon, day, hr, minute, sec,
} = mdhmsResult;
satrec.jdsatepoch = jday(year, mon, day, hr, minute, sec);

Expand Down
1 change: 1 addition & 0 deletions src/propagation/dsinit.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export default function dsinit(options) {
const root22 = 1.7891679e-6;
const root44 = 7.3636953e-9;
const root54 = 2.1765803e-9;
// eslint-disable-next-line no-loss-of-precision
const rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec
const root32 = 3.7393792e-7;
const root52 = 1.1428639e-7;
Expand Down
5 changes: 3 additions & 2 deletions src/propagation/dspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export default function dspace(options) {
const g44 = 1.8014998;
const g52 = 1.0508330;
const g54 = 4.4108898;
// eslint-disable-next-line no-loss-of-precision
const rptim = 4.37526908801129966e-3; // equates to 7.29211514668855e-5 rad/sec
const stepp = 720.0;
const stepn = -720.0;
Expand Down Expand Up @@ -215,10 +216,10 @@ export default function dspace(options) {
+ (d3222 * Math.cos((-xomi + xli) - g32))
+ (d5220 * Math.cos((xomi + xli) - g52))
+ (d5232 * Math.cos((-xomi + xli) - g52))
+ (2.0 * d4410 * Math.cos((x2omi + x2li) - g44))
+ 2.0 * ((d4410 * Math.cos((x2omi + x2li) - g44))
+ (d4422 * Math.cos(x2li - g44))
+ (d5421 * Math.cos((xomi + x2li) - g54))
+ (d5433 * Math.cos((-xomi + x2li) - g54));
+ (d5433 * Math.cos((-xomi + x2li) - g54)));
xnddt *= xldot;
}

Expand Down
6 changes: 3 additions & 3 deletions src/propagation/initl.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ export default function initl(options) {
const tfrac = ts70 - ds70;

// find greenwich location at epoch
const c1 = 1.72027916940703639e-2;
const thgr70 = 1.7321343856509374;
const fk5r = 5.07551419432269442e-15;
const c1 = 1.72027916940703639e-2; // eslint-disable-line no-loss-of-precision
const thgr70 = 1.7321343856509374; // eslint-disable-line no-loss-of-precision
const fk5r = 5.07551419432269442e-15; // eslint-disable-line no-loss-of-precision
const c1p2p = c1 + twoPi;
gsto = (thgr70 + (c1 * ds70) + (c1p2p * tfrac) + (ts70 * ts70 * fk5r)) % twoPi;
if (gsto < 0.0) {
Expand Down
4 changes: 4 additions & 0 deletions src/propagation/sgp4init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
j4,
j3oj2,
x2o3,
tumin,
} from '../constants';

import dpper from './dpper';
Expand Down Expand Up @@ -262,6 +263,9 @@ export default function sgp4init(satrec, options) {
satrec.no = initlResult.no;
satrec.con41 = initlResult.con41;
satrec.gsto = initlResult.gsto;
satrec.a = (satrec.no * tumin) ** (-2.0 / 3.0);
satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
satrec.error = 0;

// sgp4fix remove this check as it is unnecessary
Expand Down
Loading

0 comments on commit 8a6aada

Please sign in to comment.