tle.js
tle.js copied to clipboard
getEpochTimestamp returning NaN
When I use the getEpochTimestamp function it returns a NaN. All other get functions are working as expected.
function convertTLE(tle) { const satelliteData = { name: getSatelliteName(tle), semiMajorAxis: getSemiMajorAxis(getMeanMotion(tle)), eccentricity: getEccentricity(tle), inclination: getInclination(tle), rightAscension: getRightAscension(tle), perigee: getPerigee(tle), meanAnomaly: getMeanAnomaly(tle), epoch: getEpochTimestamp(tle), }; console.log(getEpochTimestamp(tle)); return satelliteData; }
Thanks for the heads up - can you provide the tle you're inputting? The test seems to be working fine using the ISS's tle.
Wow thanks for the prompt response!
I'm using the ISS one from celestrak, I suspected this could be the issue but the format looks right to me:
const tle = ISS (ZARYA) 1 25544U 98067A 22005.58472471 .00003968 00000+0 77828-4 0 9998 2 25544 51.6440 61.8159 0005338 6.5542 157.7978 15.49868185319960;
thanks in advance, Louis
From: David Calhoun @.> Sent: 05 January 2022 17:24 To: davidcalhoun/tle.js @.> Cc: louisjmorgan @.>; Author @.> Subject: Re: [davidcalhoun/tle.js] getEpochTimestamp returning NaN (Issue #28)
Thanks for the heads up - can you provide the tle you're inputting? The testhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdavidcalhoun%2Ftle.js%2Fblob%2Fmaster%2F__tests__%2Fgetters.js%23L208&data=04%7C01%7C%7C8a5b6709f9bd466ad7ef08d9d0704753%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770002911189860%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=W15VVQ3GNsL0Up9vv07CEtyfY04A4IEHKEnMND3CH68%3D&reserved=0 seems to be working fine using the ISS's tle.
— Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdavidcalhoun%2Ftle.js%2Fissues%2F28%23issuecomment-1005924473&data=04%7C01%7C%7C8a5b6709f9bd466ad7ef08d9d0704753%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770002911189860%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=nvfBUepVRXg0F3N92hdiJ83zVkBaJWtyRk5xeUGcSoM%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAHX2NRHDBFLYNXY5FXKGN4TUUR5GDANCNFSM5LKL2EKQ&data=04%7C01%7C%7C8a5b6709f9bd466ad7ef08d9d0704753%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770002911189860%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=MigfhiuFzICl9rx2NXVwVakC6i32HO7pnt7I5utrNzU%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C8a5b6709f9bd466ad7ef08d9d0704753%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770002911189860%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=cUexMGei2Chlwb0Ivxeq3x8l%2FbnilNutehUuGM30kvk%3D&reserved=0 or Androidhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7C8a5b6709f9bd466ad7ef08d9d0704753%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770002911189860%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=z98mCMEmMycal5uYYRXbUN4EWTAKyAM5RBpiVaAwRC4%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>
On first glance it looks like there's an extra two spaces in front of line 1 and 2? Could you try with this instead?
const tle = `ISS (ZARYA)
1 25544U 98067A 22005.58472471 .00003968 00000+0 77828-4 0 9998
2 25544 51.6440 61.8159 0005338 6.5542 157.7978 15.49868185319960`;
Unfortunately that's not working either. I've tried copying tle strings directly from your tests folder and those are not working either. As I said before the other getters are all working as expected.
From: David Calhoun @.> Sent: 05 January 2022 17:58 To: davidcalhoun/tle.js @.> Cc: louisjmorgan @.>; Author @.> Subject: Re: [davidcalhoun/tle.js] getEpochTimestamp returning NaN (Issue #28)
On first glance it looks like there's an extra two spaces in front of line 1 and 2? Could you try with this instead?
const tle = ISS (ZARYA) 1 25544U 98067A 22005.58472471 .00003968 00000+0 77828-4 0 9998 2 25544 51.6440 61.8159 0005338 6.5542 157.7978 15.49868185319960;
— Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdavidcalhoun%2Ftle.js%2Fissues%2F28%23issuecomment-1005949144&data=04%7C01%7C%7C70b1f6065325426947ed08d9d074f33b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770022975535215%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=AvWO%2BADBSDtCJi%2BHKMGtPz25MJpFOFmbOJHWiXh2TBQ%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAHX2NREKIPTH4MA7SEYCEPDUUSBDPANCNFSM5LKL2EKQ&data=04%7C01%7C%7C70b1f6065325426947ed08d9d074f33b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770022975535215%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=RccvqRuBFMF7vX%2B8hRu11JWgoHrZCzF6Xnox9VlZYAg%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C70b1f6065325426947ed08d9d074f33b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770022975535215%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ioDddWkWPya%2BJhkZmdgAzVzkqUdffTc0pdrJtSICLJw%3D&reserved=0 or Androidhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7C70b1f6065325426947ed08d9d074f33b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770022975535215%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=DttuiJ6X9mfgSeXpnaKbxXxzphpJI4bqwquo9f0ahkQ%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>
Weird, I'm not sure what's happening, I can't reproduce it. I tried it on both Node.js v14.17.5 and v16.13.1 and it works for me. Added this test, which passes on my side:
test("getEpochTimestamp 2", () => {
const tle = `ISS (ZARYA)
1 25544U 98067A 22005.58472471 .00003968 00000+0 77828-4 0 9998
2 25544 51.6440 61.8159 0005338 6.5542 157.7978 15.49868185319960`;
expect(getEpochTimestamp(tle)).toEqual(1641391320214);
});
First thing I'd try is to console.log the tle you're inputting into getEpochTimestamp - maybe it's not passing in what you expect?
Also, are you running this in Node or in a browser? If you could provide version details I'll try to reproduce on my side.
I'm using Node v16.13.1 with react and webpack, but all the calculations are contained within a single react component so I'm not sure that's affecting anything. The console output for the TLE looked normal:
ISS (ZARYA) 1 25544U 98067A 22005.58472471 .00003968 00000+0 77828-4 0 9998 2 25544 51.6440 61.8159 0005338 6.5542 157.7978 15.49868185319960
I'll try running your test in a basic two file node setup shortly and let you know if it exhibits the same behaviour.
Thanks again for your help, Louis
From: David Calhoun @.> Sent: 06 January 2022 15:25 To: davidcalhoun/tle.js @.> Cc: louisjmorgan @.>; Author @.> Subject: Re: [davidcalhoun/tle.js] getEpochTimestamp returning NaN (Issue #28)
Weird, I'm not sure what's happening, I can't reproduce it. I tried it on both Node.js v14.17.5 and v16.13.1 and it works. Added this test, which passes on my side:
test("getEpochTimestamp 2", () => {
const tle = ISS (ZARYA) 1 25544U 98067A 22005.58472471 .00003968 00000+0 77828-4 0 9998 2 25544 51.6440 61.8159 0005338 6.5542 157.7978 15.49868185319960;
expect(getEpochTimestamp(tle)).toEqual(1641391320214);
});
— Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdavidcalhoun%2Ftle.js%2Fissues%2F28%23issuecomment-1006677251&data=04%7C01%7C%7C9973cb920c3c42e85a8608d9d128b73a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770795061442366%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=kQU9aBbhjAOfmcepffK2gfWofMGoHe5Faf2RZwz7w38%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAHX2NRF7NJMSDO5UDMGTALDUUWX5BANCNFSM5LKL2EKQ&data=04%7C01%7C%7C9973cb920c3c42e85a8608d9d128b73a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770795061442366%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=LUVpPjtAVrIZ7glsKI3ZEipchThuarbWavQDbbQpFXQ%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C9973cb920c3c42e85a8608d9d128b73a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770795061442366%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=4NY2zpFS2MIjFWyOgvuj1lqwdwf2J%2BhTQJMSWJRhpOc%3D&reserved=0 or Androidhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7C9973cb920c3c42e85a8608d9d128b73a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637770795061442366%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=oY0HF06wD7AMfcK33apnPGR72apyjKvWLflHxkfbWJg%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>
@louisjmorgan did you have any luck? Would be nice to close this issue if it works now.
No to be honest I didn't. I switched to using satellite-js which was more suited to my needs as I'm calculating orbital positions.
Closing this out as I'm unable to reproduce.