diff --git a/src/utils/functions.ts b/src/utils/functions.ts index 13b3294..7ee3d81 100644 --- a/src/utils/functions.ts +++ b/src/utils/functions.ts @@ -8,6 +8,7 @@ import { DifferentiableFunction, JacobianFunction, Radians, + SpaceObjectType, } from '../types/types'; /** @@ -618,3 +619,38 @@ export function toPrecision(value: number, places: number): number { export function sign(value: number) { return value >= 0 ? 1 : -1; } + +const spaceObjTypeStrMap = { + [SpaceObjectType.UNKNOWN]: 'Unknown', + [SpaceObjectType.PAYLOAD]: 'Payload', + [SpaceObjectType.ROCKET_BODY]: 'Rocket Body', + [SpaceObjectType.DEBRIS]: 'Debris', + [SpaceObjectType.SPECIAL]: 'Special', + [SpaceObjectType.BALLISTIC_MISSILE]: 'Ballistic Missile', + [SpaceObjectType.STAR]: 'Star', + [SpaceObjectType.INTERGOVERNMENTAL_ORGANIZATION]: 'Intergovernmental Organization', + [SpaceObjectType.SUBORBITAL_PAYLOAD_OPERATOR]: 'Suborbital Payload Operator', + [SpaceObjectType.PAYLOAD_OWNER]: 'Payload Owner', + [SpaceObjectType.METEOROLOGICAL_ROCKET_LAUNCH_AGENCY_OR_MANUFACTURER]: + 'Meteorological Rocket Launch Agency or Manufacturer', + [SpaceObjectType.PAYLOAD_MANUFACTURER]: 'Payload Manufacturer', + [SpaceObjectType.LAUNCH_AGENCY]: 'Launch Agency', + [SpaceObjectType.LAUNCH_SITE]: 'Launch Site', + [SpaceObjectType.LAUNCH_POSITION]: 'Launch Position', + [SpaceObjectType.LAUNCH_FACILITY]: 'Launch Facility', + [SpaceObjectType.CONTROL_FACILITY]: 'Control Facility', + [SpaceObjectType.GROUND_SENSOR_STATION]: 'Ground Sensor Station', + [SpaceObjectType.OPTICAL]: 'Optical', + [SpaceObjectType.MECHANICAL]: 'Mechanical', + [SpaceObjectType.PHASED_ARRAY_RADAR]: 'Phased Array Radar', + [SpaceObjectType.OBSERVER]: 'Observer', + [SpaceObjectType.BISTATIC_RADIO_TELESCOPE]: 'Bi-static Radio Telescope', + [SpaceObjectType.COUNTRY]: 'Country', + [SpaceObjectType.LAUNCH_VEHICLE_MANUFACTURER]: 'Launch Vehicle Manufacturer', + [SpaceObjectType.ENGINE_MANUFACTURER]: 'Engine Manufacturer', + [SpaceObjectType.NOTIONAL]: 'Notional', + [SpaceObjectType.FRAGMENT]: 'Fragment', +}; + +export const spaceObjType2Str = (spaceObjType: SpaceObjectType): string => + spaceObjTypeStrMap[spaceObjType] || 'Unknown'; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index f07fb93..658e858 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -42,7 +42,7 @@ class Utils { return Math.sqrt((pos1.x - pos2.x) ** 2 + (pos1.y - pos2.y) ** 2 + (pos1.z - pos2.z) ** 2); } - static dopplerFactor(location: EciVec3, position: EciVec3, velocity: EciVec3): Kilometers { + static dopplerFactor(location: EciVec3, position: EciVec3, velocity: EciVec3): number { const mfactor = 7.292115e-5; const c = 299792.458; // Speed of light in km/s @@ -60,8 +60,17 @@ class Utils { }; const rangeRate = (range.x * rangeVel.x + range.y * rangeVel.y + range.z * rangeVel.z) / distance; + let dopplerFactor = 0; - return (1 + (rangeRate / c) * sign(rangeRate)); + if (rangeRate < 0) { + dopplerFactor = 1 + (rangeRate / c) * sign(rangeRate); + } + + if (rangeRate >= 0) { + dopplerFactor = 1 - (rangeRate / c) * sign(rangeRate); + } + + return dopplerFactor; } } diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index c36dd5e..acacd1a 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -74,7 +74,7 @@ describe('Doppler factor', () => { }; const dopFactor = Utils.dopplerFactor(observerEcf, positionEcf, velocityEcf); - expect(dopFactor).toBeCloseTo(1.0000107847789212, numDigits); + expect(dopFactor).toBeCloseTo(0.9999892152210788, numDigits); }); test('if negative range rate works', () => {