Skip to content

Commit

Permalink
Version 4.1.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezze committed Dec 18, 2020
2 parents 2577c59 + 2b8eb6e commit cb2fc41
Show file tree
Hide file tree
Showing 8 changed files with 288 additions and 41 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test
.eslintrc.json
.npmignore
.npmrc
.raiseverrc
.travis.yml
copyright-template.txt
rollup.*
Expand Down
20 changes: 20 additions & 0 deletions .raiseverrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"changelog": {
"enabled": true,
"path": "CHANGELOG.md",
"encoding": "utf-8",
"prefix": "##",
"bullet": "-"
},
"git": {
"enabled": true,
"release": "master",
"development": "develop",
"remote": "origin",
"commit": true,
"merge": true,
"all": false,
"tag": true,
"push": false
}
}
26 changes: 15 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
## Changelog
# Changelog

### 4.1.2 (2020-10-13)
## 4.1.3 (2020-12-18)

- Fixed calculation of Doppler effect (`dopplerFactor`).

## 4.1.2 (2020-10-13)

- Expose `error` in TypeScript definition of `SatRec`.
- Fix TypeScript definition for `PositionAndVelocity` to allow error handling.

### 4.1.1 (2020-09-15)
## 4.1.1 (2020-09-15)

- Fix TypeScript definition for `gstime` (#73).
- Fix documentation and TypeScript definition for `degreesLong` and `degreesLat` (#74).

### 4.1.0 (2020-09-14)
## 4.1.0 (2020-09-14)

- TypeScript support is added via new TypeScript definitions file (#71).
- Rollup and some other dependencies are upgraded.

### 4.0.0 (2020-01-21)
## 4.0.0 (2020-01-21)

- Node.js 12 support is added. Node.js 6 and Node.js 8 support is dropped (breaking change).
- Mocha, Chai and Istanbul are replaced by [Jest](https://jestjs.io/).
- Dependencies are upgraded.

### 3.0.1 (2019-03-14)
## 3.0.1 (2019-03-14)

- Unnecessary calculations in `sgp4` function are reduced (#47).
- `vkmpersec` calculation is moved to constants (#50).
- `degreesToRadians` function is used in docs instead of `deg2rad` constant (#53).
- Typos' fixes (#54).

### 3.0.0 (2018-11-26)
## 3.0.0 (2018-11-26)

- Node.js 4 support is dropped (breaking change).
- Deprecated functions `gstimeFromJday` and `gstimeFromDate` are removed (breaking change).
- New transformation functions are added: `radiansToDegrees`, `degreesToRadians`, `radiansLat`, `radiansLong`.

### 2.0.3 (2018-09-15)
## 2.0.3 (2018-09-15)

- `satrec` object is not cloned in `sgp4` and `sgp4init` functions due to [performance reasons](https://github.com/shashwatak/satellite-js/issues/45).

### 2.0.2 (2018-04-16)
## 2.0.2 (2018-04-16)

- [Wrong predictions for Molniya 3-47 orbits](https://github.com/shashwatak/satellite-js/issues/43) are fixed. Special thanks to [@nhamer](https://github.com/nhamer).

### 2.0.1 (2018-03-01)
## 2.0.1 (2018-03-01)

- `sgp4` function's call result is used in `sgp4init`.
- Longitude of `eciToGeodetic` result is in [-PI; PI] range now.

### 2.0.0 (2017-12-23)
## 2.0.0 (2017-12-23)

- Library became ES and Common.js compatible.
- Source code is reorganized to match [original Python library](https://pypi.python.org/pypi/sgp4/).
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ Special thanks to all contributors for improving usability and bug fixes :)
- [dangodev (Drew Powers)](https://github.com/dangodev)
- [thkruz (Theodore Kruczek)](https://github.com/thkruz)
- [bakercp (Christopher Baker)](https://github.com/bakercp)
- [Kyle G. Maxwell](https://github.com/kylegmaxwell)
- [Chad Johnston](https://github.com/iamthechad)
- [kylegmaxwell (Kyle G. Maxwell)](https://github.com/kylegmaxwell)
- [iamthechad (Chad Johnston)](https://github.com/iamthechad)
- [drom (Aliaksei Chapyzhenka)](https://github.com/drom)
- [PeterDaveHello (Peter Dave Hello)](https://github.com/PeterDaveHello)
- [Alesha72003](https://github.com/Alesha72003)
- [nhamer](https://github.com/nhamer)
- [owntheweb](https://github.com/owntheweb)
- [Zigone](https://github.com/Zigone)
Expand Down Expand Up @@ -221,8 +222,26 @@ npm run lint
npm run lint:test
```

Implementing new functions or features, please, if possible, provide tests to cover them and mention your works
in [Changelog](CHANGELOG.md).
Implementing new functions or features, please, if possible, provide tests to cover them and mention your works in
[Changelog](CHANGELOG.md). Please don't change version number in `package.json` and don't add it to `CHANGELOG.md`.
All these things should be done later with [raise-version](https://github.com/ezze/node-raise-version) when
merging to `master`:

```bash
npm run raise major
```

or

```bash
npm run raise minor
```

or

```bash
npm run raise patch
```

In order to get test code coverage run the following:

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "satellite.js",
"version": "4.1.2",
"version": "4.1.3",
"description": "SGP4/SDP4 calculation library",
"main": "lib/index.js",
"jsnext:main": "dist/satellite.es.js",
Expand All @@ -21,6 +21,7 @@
"test": "jest",
"test:coverage": "jest --coverage",
"test:coveralls": "npm run test:coverage && cat coverage/lcov.info | coveralls",
"raise": "raise-version",
"prepublishOnly": "npm run lint && npm run lint:test && npm test && npm run build"
},
"repository": {
Expand Down Expand Up @@ -60,6 +61,7 @@
"glob": "^7.1.6",
"jest": "^26.4.2",
"prepend-file": "^2.0.0",
"raise-version": "^0.4.0",
"rimraf": "^3.0.2",
"rollup": "^2.26.11",
"rollup-plugin-terser": "^7.0.2"
Expand Down
32 changes: 15 additions & 17 deletions src/dopplerFactor.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
export default function dopplerFactor(location, position, velocity) {
const currentRange = Math.sqrt(
((position.x - location.x) ** 2)
+ ((position.y - location.y) ** 2)
+ ((position.z - location.z) ** 2));
const mfactor = 7.292115E-5;
const c = 299792.458; // Speed of light in km/s

const nextPos = {
x: position.x + velocity.x,
y: position.y + velocity.y,
z: position.z + velocity.z,
const range = {
x: position.x - location.x,
y: position.y - location.y,
z: position.z - location.z,
};
range.w = Math.sqrt(range.x ** 2 + range.y ** 2 + range.z ** 2);

const nextRange = Math.sqrt(
((nextPos.x - location.x) ** 2)
+ ((nextPos.y - location.y) ** 2)
+ ((nextPos.z - location.z) ** 2));

let rangeRate = nextRange - currentRange;
const rangeVel = {
x: velocity.x + mfactor * location.y,
y: velocity.y - mfactor * location.x,
z: velocity.z,
};

function sign(value) {
return value >= 0 ? 1 : -1;
}

rangeRate *= sign(rangeRate);
const c = 299792.458; // Speed of light in km/s
return (1 + (rangeRate / c));
const rangeRate = (range.x * rangeVel.x + range.y * rangeVel.y + range.z * rangeVel.z) / range.w;

return (1 + (rangeRate / c) * sign(rangeRate));
}
67 changes: 65 additions & 2 deletions test/dopplerFactor.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,70 @@
import dopplerFactor from '../src/dopplerFactor'; // eslint-disable-line

const numDigits = 8;

const earthRadius = 6378.137;
const sincos45deg = Math.sqrt(2) / 2;

describe('Doppler factor', () => {
it('doppler factor', () => {
// TODO:
it('without observer movement', () => {
// North Pole
const observerEcf = {
x: 0,
y: 0,
z: earthRadius,
};
const positionEcf = {
x: 0,
y: 0,
z: earthRadius + 500,
};
// Escape velocity
const velocityEcf = {
x: 7.91,
y: 0,
z: 0,
};
const dopFactor = dopplerFactor(observerEcf, positionEcf, velocityEcf);
expect(dopFactor).toBeCloseTo(1, numDigits);
});

it('movement of observer is not affected', () => {
const observerEcf = {
x: earthRadius,
y: 0,
z: 0,
};
const positionEcf = {
x: earthRadius + 500,
y: 0,
z: 0,
};
const velocityEcf = {
x: 0,
y: 7.91,
z: 0,
};
const dopFactor = dopplerFactor(observerEcf, positionEcf, velocityEcf);
expect(dopFactor).toBeCloseTo(1, numDigits);
});

it('special case', () => {
const observerEcf = {
x: earthRadius,
y: 0,
z: 0,
};
const positionEcf = {
x: (earthRadius + 500) * sincos45deg, // z*sin(45)
y: (earthRadius + 500) * sincos45deg, // z*cos(45)
z: 0,
};
const velocityEcf = {
x: 7.91 * sincos45deg,
y: 7.91 * sincos45deg,
z: 0,
};
const dopFactor = dopplerFactor(observerEcf, positionEcf, velocityEcf);
expect(dopFactor).toBeCloseTo(1.0000107847789212, numDigits);
});
});
Loading

0 comments on commit cb2fc41

Please sign in to comment.