Skip to content

Commit

Permalink
fix: 🐛 fix Satellite class
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Dec 31, 2023
1 parent 7f65165 commit 20bc194
Show file tree
Hide file tree
Showing 58 changed files with 305 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"arrowParens": "always",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "never",
"proseWrap": "always",
"htmlWhitespaceSensitivity": "ignore",
"endOfLine": "lf",
"embeddedLanguageFormatting": "off"
Expand Down
30 changes: 30 additions & 0 deletions examples/sensor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable no-console */
import { Satellite } from '@src/objects/Satellite';
import { Sensor } from '../src/objects';
import { Degrees, Kilometers, SpaceObjectType, TleLine1, TleLine2 } from '../src/ootk';

const capeCodRadar = new Sensor({
lat: <Degrees>41.754785,
lon: <Degrees>-70.539151,
alt: <Kilometers>0.060966,
minAz: 347 as Degrees,
maxAz: 227 as Degrees,
minEl: 3 as Degrees,
maxEl: 85 as Degrees,
minRng: 0 as Kilometers,
maxRng: 5556 as Kilometers,
name: 'Cape Cod',
type: SpaceObjectType.PHASED_ARRAY_RADAR,
});

const sat = new Satellite({
tle1: '1 00005U 58002B 23361.70345217 .00000401 00000-0 53694-3 0 99999' as TleLine1,
tle2: '2 00005 34.2395 218.8683 1841681 30.7692 338.8934 10.85144797345180' as TleLine2,
});

const date = new Date('2023-12-31T20:51:19.934Z');

sat.propagateTo(date);

// console.log(sat.raeOpt(capeCodRadar, date));
console.log(sat.getJ2000().inertial);
3 changes: 3 additions & 0 deletions examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"ts-node": {
"require": ["tsconfig-paths/register"]
},
"compilerOptions": {
"module": "commonjs",
"target": "ES2015",
Expand Down
24 changes: 24 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"prettier": "^2.8.8",
"prettier-plugin-organize-imports": "^3.2.3",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^4.9.5",
"webpack": "^5.11.1",
"webpack-cli": "^4.10.0"
Expand Down
10 changes: 6 additions & 4 deletions src/body/Celestial.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { AzEl, Degrees, RaDec, Radians } from '@src/ootk';
import { AzEl, RaDec, Radians } from '@src/ootk';

Check failure on line 1 in src/body/Celestial.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find module './../../lib/types/types.d' or its corresponding type declarations.
import { RAD2DEG } from '@src/utils/constants';
import { Degrees } from './../../lib/types/types.d';
import { Sun } from './Sun';

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

static getStarAzEl(date: Date, lat: Degrees, lon: Degrees, ra: Radians, dec: Radians): AzEl<Radians> {
static getStarAzEl(date: Date, lat: Degrees, lon: Degrees, ra: Radians, dec: Radians): AzEl<Degrees> {
const c: RaDec = {
ra,
dec,
Expand All @@ -16,8 +18,8 @@ export class Celestial {
const el = <Radians>(azEl.el + Celestial.astroRefraction(azEl.el)); // elevation correction for refraction

return {
az: azEl.az,
el,
az: (azEl.az * RAD2DEG) as Degrees,
el: (el * RAD2DEG) as Degrees,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/body/Earth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Radians } from '@src/ootk';
import { EpochUTC } from '@src/time/EpochUTC';
import { DataHandler } from '../data/DataHandler';
import {
asec2rad,
Expand All @@ -11,7 +12,6 @@ import {
} from '../operations/constants';
import { angularDiameter, AngularDiameterMethod, evalPoly } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { NutationAngles } from './NutationAngles';
import { PrecessionAngles } from './PrecessionAngles';

Expand Down
2 changes: 1 addition & 1 deletion src/body/Moon.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { deg2rad } from '../operations/constants';
import { angularDiameter, AngularDiameterMethod } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { Earth } from './Earth';
import { Sun } from './Sun';

Expand Down
2 changes: 1 addition & 1 deletion src/body/Sun.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AzEl, Degrees, Kilometers, Meters, Radians, SunTime } from '@src/ootk';
import { EpochUTC } from '@src/time/EpochUTC';
import { RaDec } from '@src/types/types';
import { astronomicalUnit, deg2rad, speedOfLight, tau } from '../operations/constants';
import { angularDiameter, AngularDiameterMethod } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { DEG2RAD, MS_PER_DAY } from '../utils/constants';
import { Celestial } from './Celestial';
import { Earth } from './Earth';
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/ClassicalElements.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { sec2min, secondsPerDay } from '../operations/constants';
import { clamp, matchHalfPlane, newtonNu } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { rad2deg, tau } from './../operations/constants';
import { EquinoctialElements } from './EquinoctialElements';
import { OrbitRegime } from './OrbitRegime';
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/EquinoctialElements.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { newtonM } from '../operations/functions';
import { EpochUTC } from '../time/EpochUTC';
import { secondsPerDay, tau } from './../operations/constants';
import { ClassicalElements } from './ClassicalElements';
import { PositionVelocity } from './StateVector';
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/Geodetic.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { deg2rad, rad2deg } from '../operations/constants';
import { angularDistance, AngularDistanceMethod } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { ITRF } from './ITRF';

// / Geodetic coordinates.
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/Hill.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { Thrust } from './../force/Thrust';
import { Waypoint } from './../maneuver/Waypoint';
import { Matrix } from './../operations/Matrix';
import { Vector3D } from './../operations/Vector3D';
import { EpochUTC } from './../time/EpochUTC';
import { J2000 } from './J2000';
import { RelativeState } from './RelativeState';
// / Hill Modified Equidistant Cyllindrical _(EQCM)_ coordinates.
Expand Down
14 changes: 14 additions & 0 deletions src/coordinate/J2000.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,34 @@ import { StateVector } from './StateVector';
import { TEME } from './TEME';

export class J2000 extends StateVector {
/**
* Creates a J2000 instance from classical elements.
*/
static fromClassicalElements(elements: ClassicalElements): J2000 {
const rv = elements.toPositionVelocity();

return new J2000(elements.epoch, rv.position, rv.velocity);
}

/**
* Gets the name of the coordinate system.
*/
get name(): string {
return 'J2000';
}

/**
* Gets a value indicating whether the coordinate system is inertial.
*/
get inertial(): boolean {
return true;
}

/**
* Converts the coordinates from J2000 to the International Terrestrial Reference Frame (ITRF).
*
* This is an ECI to ECF transformation.
*/
toITRF(): ITRF {
const p = Earth.precession(this.epoch);
const n = Earth.nutation(this.epoch);
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/StateVector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { tau } from './../operations/constants';
import { ClassicalElements } from './ClassicalElements';

Expand Down
10 changes: 9 additions & 1 deletion src/coordinate/TEME.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import { ClassicalElements } from './ClassicalElements';
import { J2000 } from './J2000';
import { StateVector } from './StateVector';

// / True Equator Mean Equinox _(TEME)_ state vector
/**
* True Equator Mean Equinox (TEME) is a coordinate system commonly used in satellite tracking and orbit prediction.
* It is a reference frame that defines the position and orientation of an object relative to the Earth's equator
* and equinox.
*
* By using the True Equator Mean Equinox (TEME) coordinate system, we can accurately describe the position and motion
* of satellites relative to the Earth's equator and equinox. This is particularly useful for tracking and predicting
* satellite orbits in various applications, such as satellite communication, navigation, and remote sensing.
*/
export class TEME extends StateVector {
// / Create a new [TEME] object from a [ClassicalElements] object.
static fromClassicalElements(elements: ClassicalElements): TEME {
Expand Down
2 changes: 1 addition & 1 deletion src/coordinate/TLE.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EciVec3, SatelliteRecord, StateVectorSgp4 } from '@src/ootk';
import { Sgp4, Sgp4GravConstants } from '@src/sgp4/sgp4';
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { deg2rad, rad2deg, secondsPerDay, tau } from '../operations/constants';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { TEME } from './TEME';

export enum Sgp4OpsMode {
Expand Down
2 changes: 1 addition & 1 deletion src/covariance/CovarianceSample.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable class-methods-use-this */
import { EpochUTC } from '@src/time/EpochUTC';
import { J2000 } from '../coordinate/J2000';
import { RelativeState } from '../coordinate/RelativeState';
import { RIC } from '../coordinate/RIC';
Expand All @@ -9,7 +10,6 @@ import { Vector } from '../operations/Vector';
import { Vector3D } from '../operations/Vector3D';
import { RungeKutta89Propagator } from '../propagator/RungeKutta89Propagator';
import { Epoch } from '../time/Epoch';
import { EpochUTC } from '../time/EpochUTC';
import { CovarianceFrame, StateCovariance } from './StateCovariance';

// / Sigma point covariance sample.
Expand Down
2 changes: 1 addition & 1 deletion src/force/Thrust.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { J2000 } from './../coordinate/J2000';
import { RIC } from './../coordinate/RIC';
import { Force } from './Force';
Expand Down
2 changes: 1 addition & 1 deletion src/interpolator/ChebyshevInterpolator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { EpochWindow } from '@src/time/EpochWindow';
import { J2000 } from './../coordinate/J2000';
import { EpochUTC } from './../time/EpochUTC';
import { ChebyshevCoefficients } from './ChebyshevCoefficients';
import { StateInterpolator } from './StateInterpolator';

Expand Down
2 changes: 1 addition & 1 deletion src/interpolator/CubicSplineInterpolator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { EpochWindow } from '@src/time/EpochWindow';
import { J2000 } from '../coordinate/J2000';
import { EpochUTC } from '../time/EpochUTC';
import { CubicSpline } from './CubicSpline';
import { StateInterpolator } from './StateInterpolator';

Expand Down
2 changes: 1 addition & 1 deletion src/interpolator/Interpolator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { EpochWindow } from '@src/time/EpochWindow';
import { EpochUTC } from '../time/EpochUTC';

// / Interpolator base class.
export abstract class Interpolator {
Expand Down
2 changes: 1 addition & 1 deletion src/interpolator/LagrangeInterpolator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { EpochWindow } from '@src/time/EpochWindow';
import { J2000 } from '../coordinate/J2000';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { StateInterpolator } from './StateInterpolator';

export class LagrangeInterpolator extends StateInterpolator {
Expand Down
2 changes: 1 addition & 1 deletion src/interpolator/StateInterpolator.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable class-methods-use-this */

import { EpochUTC } from '@src/time/EpochUTC';
import { J2000 } from '../coordinate/J2000';
import { EpochUTC } from '../time/EpochUTC';
import { Interpolator } from './Interpolator';

// / Base class for state vector interpolators.
Expand Down
2 changes: 1 addition & 1 deletion src/interpolator/VerletBlendInterpolator.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { EpochWindow } from '@src/time/EpochWindow';
import { Earth } from '../body/Earth';
import { J2000 } from '../coordinate/J2000';
import { copySign } from '../operations/functions';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { CubicSplineInterpolator } from './CubicSplineInterpolator';
import { LagrangeInterpolator } from './LagrangeInterpolator';
import { StateInterpolator } from './StateInterpolator';
Expand Down
2 changes: 1 addition & 1 deletion src/maneuver/TwoBurnOrbitTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { Earth } from '../body/Earth';
import { Thrust } from '../force/Thrust';
import { EpochUTC } from '../time/EpochUTC';

// / Container for a two-burn orbit transfer.
export class TwoBurnOrbitTransfer {
Expand Down
2 changes: 1 addition & 1 deletion src/maneuver/Waypoint.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EpochUTC } from '@src/time/EpochUTC';
import { J2000 } from '../coordinate/J2000';
import { RIC } from '../coordinate/RIC';
import { Thrust } from '../force/Thrust';
import { StateInterpolator } from '../interpolator/StateInterpolator';
import { Vector3D } from '../operations/Vector3D';
import { EpochUTC } from '../time/EpochUTC';
import { ForceModel } from './../force/ForceModel';
import { DownhillSimplex } from './../optimize/DownhillSimplex';
import { LambertIOD } from './../orbit_determination/LambertIOD';
Expand Down
4 changes: 2 additions & 2 deletions src/objects/detailed-sat.ts → src/objects/.detailed-sat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
TleLine2,
} from '../types/types';

import { OptionsParams, Sat } from './sat';
import { OptionsParams, Satellite } from './Satellite';

/**
* Information about a space object.
Expand All @@ -47,7 +47,7 @@ interface ObjectInfo {
/**
* Represents a detailed satellite object with launch, spacecraft, and operations details.
*/
export class DetailedSat extends Sat {
export class DetailedSat extends Satellite {
configuration: string;
country: string;
dryMass: string;
Expand Down
Loading

0 comments on commit 20bc194

Please sign in to comment.