@saber-usa/node-common 1.7.40 → 1.7.41-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/udl.js +160 -1
package/package.json
CHANGED
package/src/udl.js
CHANGED
|
@@ -11,12 +11,162 @@ import {
|
|
|
11
11
|
azElToRaDec,
|
|
12
12
|
raDecToGeodetic,
|
|
13
13
|
estimateSlantRange,
|
|
14
|
+
getResiduals,
|
|
14
15
|
} from "./astro.js";
|
|
15
16
|
import {REGIMES, MU} from "./constants.js";
|
|
16
17
|
import {lowerCaseObjectKeys, jsonArrayOrNull} from "./transform.js";
|
|
17
18
|
import {isDefined} from "./utils.js";
|
|
18
19
|
import _ from "lodash";
|
|
19
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the sensor id for a UDL observation, preferring idSensor and
|
|
23
|
+
* falling back to origSensorId.
|
|
24
|
+
* @param {Object} ob UDL observation row
|
|
25
|
+
* @return {String|null} resolved sensor id
|
|
26
|
+
*/
|
|
27
|
+
const getSensorId = (ob) => ob.idSensor ?? ob.origSensorId ?? null;
|
|
28
|
+
|
|
29
|
+
const getObsSatno = (udlRow) => udlRow.idOnOrbit ?? udlRow.origObjectId ?? null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Converts a UDL EOObservation row to NPS EoObs (PascalCase keys).
|
|
33
|
+
* Callers that insert via ingest should wrap with lowerCaseObjectKeys.
|
|
34
|
+
* @param {Object} udlRow
|
|
35
|
+
* @param {Object} tles - satNo → TLE map (empty skips residuals)
|
|
36
|
+
* @param {Object} log - logger with .error
|
|
37
|
+
* @return {Object}
|
|
38
|
+
*/
|
|
39
|
+
const udlToNpsObs = (udlRow, tles = {}, log = console) => {
|
|
40
|
+
const satno = getObsSatno(udlRow);
|
|
41
|
+
const sensorId = getSensorId(udlRow);
|
|
42
|
+
let result = {
|
|
43
|
+
IdUdl: _.get(udlRow, "id", null),
|
|
44
|
+
ObTime: _.get(udlRow, "obTime", null),
|
|
45
|
+
IdSensor: sensorId,
|
|
46
|
+
SatNo: satno,
|
|
47
|
+
TrackId: _.get(udlRow, "trackId", null),
|
|
48
|
+
Uct: _.get(udlRow, "uct", null),
|
|
49
|
+
Azimuth: _.get(udlRow, "azimuth", null),
|
|
50
|
+
AzimuthRate: _.get(udlRow, "azimuthRate", null),
|
|
51
|
+
AzimuthUnc: _.get(udlRow, "azimuthUnc", null),
|
|
52
|
+
Elevation: _.get(udlRow, "elevation", null),
|
|
53
|
+
ElevationRate: _.get(udlRow, "elevationRate", null),
|
|
54
|
+
ElevationUnc: _.get(udlRow, "elevationUnc", null),
|
|
55
|
+
Range: _.get(udlRow, "range", null),
|
|
56
|
+
Ra: _.get(udlRow, "ra", null),
|
|
57
|
+
Dec: _.get(udlRow, "declination", null),
|
|
58
|
+
SenLat: _.get(udlRow, "senlat", null),
|
|
59
|
+
SenLon: _.get(udlRow, "senlon", null),
|
|
60
|
+
SenAlt: _.get(udlRow, "senalt", null),
|
|
61
|
+
SenX: _.get(udlRow, "senx", null),
|
|
62
|
+
SenY: _.get(udlRow, "seny", null),
|
|
63
|
+
SenZ: _.get(udlRow, "senz", null),
|
|
64
|
+
Mag: _.get(udlRow, "mag", null),
|
|
65
|
+
MagUnc: _.get(udlRow, "magUnc", null),
|
|
66
|
+
LosUnc: _.get(udlRow, "losUnc", null),
|
|
67
|
+
GeoLat: _.get(udlRow, "geolat", null),
|
|
68
|
+
GeoLon: _.get(udlRow, "geolon", null),
|
|
69
|
+
GeoAlt: _.get(udlRow, "geoalt", null),
|
|
70
|
+
GeoRange: _.get(udlRow, "georange", null),
|
|
71
|
+
SolarPhaseAngle: _.get(udlRow, "solarPhaseAngle", null),
|
|
72
|
+
SolarEqPhaseAngle: _.get(udlRow, "solarEqPhaseAngle", null),
|
|
73
|
+
SolarDecAngle: _.get(udlRow, "solarDecAngle", null),
|
|
74
|
+
ExpDuration: _.get(udlRow, "expDuration", null),
|
|
75
|
+
ShutterDelay: _.get(udlRow, "shutterDelay", null),
|
|
76
|
+
Source: _.get(udlRow, "source", null),
|
|
77
|
+
DataMode: _.get(udlRow, "dataMode", null),
|
|
78
|
+
Type: _.get(udlRow, "type", null),
|
|
79
|
+
AzimuthBias: _.get(udlRow, "azimuthBias", null),
|
|
80
|
+
ElevationBias: _.get(udlRow, "elevationBias", null),
|
|
81
|
+
RangeUnc: _.get(udlRow, "rangeUnc", null),
|
|
82
|
+
RangeBias: _.get(udlRow, "rangeBias", null),
|
|
83
|
+
RangeRate: _.get(udlRow, "rangeRate", null),
|
|
84
|
+
RangeRateUnc: _.get(udlRow, "rangeRateUnc", null),
|
|
85
|
+
RaUnc: _.get(udlRow, "raUnc", null),
|
|
86
|
+
RaBias: _.get(udlRow, "raBias", null),
|
|
87
|
+
RaRate: _.get(udlRow, "raRate", null),
|
|
88
|
+
DeclinationUnc: _.get(udlRow, "declinationUnc", null),
|
|
89
|
+
DeclinationBias: _.get(udlRow, "declinationBias", null),
|
|
90
|
+
DeclinationRate: _.get(udlRow, "declinationRate", null),
|
|
91
|
+
TimingBias: _.get(udlRow, "timingBias", null),
|
|
92
|
+
ReferenceFrame: _.get(udlRow, "referenceFrame", null),
|
|
93
|
+
SenReferenceFrame: _.get(udlRow, "senReferenceFrame", null),
|
|
94
|
+
CreatedAt: fixDate(_.get(udlRow, "createdAt", null)),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
result = enrichUdlFields({...result});
|
|
99
|
+
const tle = tles[satno];
|
|
100
|
+
const residuals = tle ? getResiduals([{...result}], tle) : null;
|
|
101
|
+
const first = residuals?.[0];
|
|
102
|
+
result.ElevationResidual = first?.ElErr ?? null;
|
|
103
|
+
result.AzimuthResidual = first?.AzErr ?? null;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
log.error("Error enriching UDL fields: ", e);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return result;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Converts a UDL RadarObservation row to NPS RadarObs (PascalCase keys).
|
|
113
|
+
* Sen* come from the sensors map only (not the UDL row).
|
|
114
|
+
* Callers that insert via ingest should wrap with lowerCaseObjectKeys.
|
|
115
|
+
* @param {Object} udlRow
|
|
116
|
+
* @param {Object} tles
|
|
117
|
+
* @param {Object} sensors - idSensor → {latitude, longitude, altitude}
|
|
118
|
+
* @param {Object} log
|
|
119
|
+
* @return {Object}
|
|
120
|
+
*/
|
|
121
|
+
const udlToRadarObs = (udlRow, tles = {}, sensors = {}, log = console) => {
|
|
122
|
+
const satno = getObsSatno(udlRow);
|
|
123
|
+
const sensorId = getSensorId(udlRow);
|
|
124
|
+
const sensor = sensors[sensorId];
|
|
125
|
+
|
|
126
|
+
let result = {
|
|
127
|
+
IdUdl: _.get(udlRow, "id", null),
|
|
128
|
+
ObTime: _.get(udlRow, "obTime", null),
|
|
129
|
+
IdSensor: sensorId,
|
|
130
|
+
SatNo: satno,
|
|
131
|
+
TrackId: _.get(udlRow, "trackId", null),
|
|
132
|
+
Uct: _.get(udlRow, "uct", null),
|
|
133
|
+
Azimuth: _.get(udlRow, "azimuth", null),
|
|
134
|
+
AzimuthUnc: _.get(udlRow, "azimuthUnc", null),
|
|
135
|
+
Elevation: _.get(udlRow, "elevation", null),
|
|
136
|
+
ElevationUnc: _.get(udlRow, "elevationUnc", null),
|
|
137
|
+
Ra: _.get(udlRow, "ra", null),
|
|
138
|
+
Dec: _.get(udlRow, "declination", null),
|
|
139
|
+
Range: _.get(udlRow, "range", null),
|
|
140
|
+
RangeUnc: _.get(udlRow, "rangeUnc", null),
|
|
141
|
+
RangeRate: _.get(udlRow, "rangeRate", null),
|
|
142
|
+
RangeRateUnc: _.get(udlRow, "rangeRateUnc", null),
|
|
143
|
+
Doppler: _.get(udlRow, "doppler", null),
|
|
144
|
+
DopplerUnc: _.get(udlRow, "dopplerUnc", null),
|
|
145
|
+
Rcs: _.get(udlRow, "rcs", null),
|
|
146
|
+
Snr: _.get(udlRow, "snr", null),
|
|
147
|
+
Beam: _.get(udlRow, "beam", null),
|
|
148
|
+
SenLat: sensor ? sensor.latitude : null,
|
|
149
|
+
SenLon: sensor ? sensor.longitude : null,
|
|
150
|
+
SenAlt: sensor ? sensor.altitude : null,
|
|
151
|
+
Source: _.get(udlRow, "source", null),
|
|
152
|
+
DataMode: _.get(udlRow, "dataMode", null),
|
|
153
|
+
Type: _.get(udlRow, "type", null),
|
|
154
|
+
CreatedAt: fixDate(_.get(udlRow, "createdAt", null)),
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
result = enrichUdlFields({...result});
|
|
159
|
+
const tle = tles[satno];
|
|
160
|
+
const residuals = tle && sensor ? getResiduals([{...result}], tle) : null;
|
|
161
|
+
const first = residuals?.[0];
|
|
162
|
+
result.ElevationResidual = first?.ElErr ?? null;
|
|
163
|
+
result.AzimuthResidual = first?.AzErr ?? null;
|
|
164
|
+
} catch (e) {
|
|
165
|
+
log.error("Error enriching UDL fields: ", e);
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
};
|
|
169
|
+
|
|
20
170
|
const udlToNpsElset = (udlRow) => {
|
|
21
171
|
let derivedElset;
|
|
22
172
|
try {
|
|
@@ -420,4 +570,13 @@ const udlToNpsState = (udlRow) => {
|
|
|
420
570
|
return npsState;
|
|
421
571
|
};
|
|
422
572
|
|
|
423
|
-
export {
|
|
573
|
+
export {
|
|
574
|
+
udlToNpsElset,
|
|
575
|
+
udlToNpsGroundSite,
|
|
576
|
+
udlToNpsConjunction,
|
|
577
|
+
udlToNpsState,
|
|
578
|
+
enrichUdlFields,
|
|
579
|
+
getSensorId,
|
|
580
|
+
udlToNpsObs,
|
|
581
|
+
udlToRadarObs,
|
|
582
|
+
};
|