@saber-usa/node-common 1.7.24 → 1.7.26

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.
Files changed (2) hide show
  1. package/package.json +12 -11
  2. package/src/astro.js +76 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saber-usa/node-common",
3
- "version": "1.7.24",
3
+ "version": "1.7.26",
4
4
  "description": "Common node functions for Saber",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "author": "Saber USA",
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
- "@aws-sdk/client-s3": "^3.1062.0",
26
+ "@aws-sdk/client-s3": "^3.1078.0",
27
27
  "date-fns": "^4.4.0",
28
28
  "lodash": "4.18.1",
29
29
  "mathjs": "^15.2.0",
@@ -31,20 +31,21 @@
31
31
  "plotly": "^1.0.6",
32
32
  "satellite.js": "^7.0.1",
33
33
  "solar-calculator": "^0.3.0",
34
- "three": "^0.184",
34
+ "three": "^0.185.1",
35
35
  "winston": "3.19.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@babel/preset-env": "^7.29.7",
38
+ "@babel/core": "^8.0.1",
39
+ "@babel/preset-env": "^8.0.2",
39
40
  "@eslint/js": "^10.0.1",
40
- "@jest/globals": "^30.3.0",
41
- "@sonar/scan": "^4.3.6",
41
+ "@jest/globals": "^30.4.1",
42
+ "@sonar/scan": "^4.3.8",
42
43
  "cross-env": "^10.1.0",
43
- "eslint": "^10.4.1",
44
- "eslint-plugin-jest": "^29.15.2",
45
- "globals": "^17.5.0",
46
- "jest": "^30.3.0",
47
- "jest-diff": "^30.3.0",
44
+ "eslint": "^10.6.0",
45
+ "eslint-plugin-jest": "^29.15.4",
46
+ "globals": "^17.7.0",
47
+ "jest": "^30.4.2",
48
+ "jest-diff": "^30.4.1",
48
49
  "nodemon": "3.1.14"
49
50
  },
50
51
  "overrides": {
package/src/astro.js CHANGED
@@ -1382,7 +1382,7 @@ const GetElsetUdlFromTle = (
1382
1382
  try {
1383
1383
  const tleResult = validateTle(l1, l2);
1384
1384
  if (!tleResult.ok) {
1385
- throw new Error(tleResult.errors.join("; "));
1385
+ throw new Error(`${tleResult.errors.join("; ")}: ${l1} | ${l2}`);
1386
1386
  }
1387
1387
 
1388
1388
  const elset = {};
@@ -1779,6 +1779,79 @@ const cartesianToElsetElements = (pv, epoch) => {
1779
1779
  return elset;
1780
1780
  };
1781
1781
 
1782
+ /**
1783
+ * Geodetic longitude and drift from propagated P/V at two times one day apart.
1784
+ * @param {Object} pvAtT satellite.js-style position/velocity at gmstTime (km, km/s)
1785
+ * @param {Object} pvAtTPlusOneDay position/velocity at gmst2Time
1786
+ * @param {Date|number} gmstTime passed to gstime for the first geodetic conversion
1787
+ * @param {Date|number} gmst2Time passed to gstime for the second geodetic conversion
1788
+ * @return {Object} latitude, longitude, longitude360, lonDriftDegreesPerDay
1789
+ */
1790
+ const getLonAndDriftFromPv = (pvAtT, pvAtTPlusOneDay, gmstTime, gmst2Time) => {
1791
+ try {
1792
+ const gmst = gstime(gmstTime);
1793
+ const gmst2 = gstime(gmst2Time);
1794
+
1795
+ const positionGd = eciToGeodetic(pvAtT.position, gmst);
1796
+ const positionGd2 = eciToGeodetic(pvAtTPlusOneDay.position, gmst2);
1797
+
1798
+ const lon = degreesLong(positionGd.longitude);
1799
+ const lon2 = degreesLong(positionGd2.longitude);
1800
+ const lat = degreesLat(positionGd.latitude);
1801
+
1802
+ let diff = lon2 - lon;
1803
+ if (diff < -180) {
1804
+ diff = (diff % 180) + 180;
1805
+ } else if (diff > 180) {
1806
+ diff = (diff % 180) - 180;
1807
+ }
1808
+
1809
+ return {
1810
+ latitude: lat,
1811
+ longitude: lon,
1812
+ longitude360: (lon + 360) % 360,
1813
+ lonDriftDegreesPerDay: diff,
1814
+ };
1815
+ } catch (e) {
1816
+ console.error(e);
1817
+ return {
1818
+ latitude: 0,
1819
+ longitude: 0,
1820
+ longitude360: 0,
1821
+ lonDriftDegreesPerDay: 0,
1822
+ };
1823
+ }
1824
+ };
1825
+
1826
+ /**
1827
+ * Osculating RAAN precession (deg/day) from P/V one day apart.
1828
+ * @param {Object} pvAtT satellite.js-style position/velocity (km, km/s)
1829
+ * @param {Object} pvAtTPlusOneDay position/velocity one day later
1830
+ * @return {number} RAAN drift in degrees per day
1831
+ */
1832
+ const getOsculatingRaanPrecessionFromPv = (pvAtT, pvAtTPlusOneDay) => {
1833
+ try {
1834
+ const kepl = cartesianToKeplerian(
1835
+ multiply(posToArray(pvAtT.position), 1000),
1836
+ multiply(posToArray(pvAtT.velocity), 1000),
1837
+ );
1838
+ const kepl2 = cartesianToKeplerian(
1839
+ multiply(posToArray(pvAtTPlusOneDay.position), 1000),
1840
+ multiply(posToArray(pvAtTPlusOneDay.velocity), 1000),
1841
+ );
1842
+ let diff = kepl2.raan - kepl.raan;
1843
+ if (diff < -180) {
1844
+ diff += 360;
1845
+ } else if (diff > 180) {
1846
+ diff -= 360;
1847
+ }
1848
+ return diff;
1849
+ } catch (e) {
1850
+ console.error(e);
1851
+ return 0;
1852
+ }
1853
+ };
1854
+
1782
1855
  /**
1783
1856
  * Get LEO RPO data for a given target satellite and a set of potential threat satellites.
1784
1857
  * @param {String} line1, line 1 of the target satellite
@@ -3524,6 +3597,8 @@ export {
3524
3597
  getTRIC,
3525
3598
  getSunDirection,
3526
3599
  getLonAndDrift,
3600
+ getLonAndDriftFromPv,
3601
+ getOsculatingRaanPrecessionFromPv,
3527
3602
  getRaanPrecession,
3528
3603
  checkTle,
3529
3604
  validateTle,