-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added function json2satrec
in io.js
#122
base: develop
Are you sure you want to change the base?
Changes from 2 commits
232be66
5840431
d6c82fe
ae74f65
4d914c4
db41147
0ebec62
748a53e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import sgp4init from './propagation/sgp4init'; | |
|
||
/* ----------------------------------------------------------------------------- | ||
* | ||
* function twoline2rv | ||
* function twoline2satrec | ||
* | ||
* this function converts the two line element set character string data to | ||
* variables and initializes the sgp4 variables. several intermediate varaibles | ||
|
@@ -146,3 +146,102 @@ export default function twoline2satrec(longstr1, longstr2) { | |
|
||
return satrec; | ||
} | ||
|
||
/* ----------------------------------------------------------------------------- | ||
* | ||
* function json2satrec | ||
* | ||
* this function converts the OMM json data to variables and initializes the sgp4 | ||
* variables. several intermediate varaibles and quantities are determined. note | ||
* that the result is a structure so multiple satellites can be processed | ||
* simultaneously without having to reinitialize. the verification mode is an | ||
* important option that permits quick checks of any changes to the underlying | ||
* technical theory. this option works using a modified tle file in which the | ||
* start, stop, and delta time values are included at the end of the second line | ||
* of data. this only works with the verification mode. the catalog mode simply | ||
* propagates from -1440 to 1440 min from epoch and is useful when performing | ||
* entire catalog runs. | ||
* | ||
* author : Hariharan Vitaladevuni 18 Aug 2023 | ||
* | ||
* inputs : | ||
* jsonobj - OMM json data | ||
* opsmode - mode of operation afspc or improved 'a', 'i'. Default: 'i'. | ||
* | ||
* outputs : | ||
* satrec - structure containing all the sgp4 satellite information | ||
* | ||
* coupling : | ||
* days2mdhms - conversion of days to month, day, hour, minute, second | ||
* jday - convert day month year hour minute second into julian date | ||
* sgp4init - initialize the sgp4 variables | ||
* | ||
* references : | ||
* https://celestrak.org/NORAD/documentation/gp-data-formats.php | ||
* norad spacetrack report #3 | ||
spacenewb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* vallado, crawford, hujsak, kelso 2006 | ||
--------------------------------------------------------------------------- */ | ||
function json2satrec(jsonobj, opsmode='i') { | ||
const opsmode = 'i'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. opsmode is passed as a parameter and defaulted to 'i'. This line of code would create a separate variable and cause the input parameter to be ignored. Please delete this line. |
||
const xpdotp = 1440.0 / (2.0 * pi); // 229.1831180523293; | ||
let year = 0; | ||
|
||
const satrec = {}; | ||
satrec.error = 0; | ||
|
||
satrec.satnum = jsonobj.NORAD_CAT_ID.toString(); | ||
|
||
var epoch = new Date(jsonobj.EPOCH + 'Z'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of var should be replaced with const. |
||
year = epoch.getUTCFullYear(); | ||
|
||
satrec.epochyr = Number(year.toString().slice(-2)); | ||
satrec.epochdays = | ||
(epoch - new Date(Date.UTC(year, 0, 1, 0, 0, 0))) / (86400 * 1000) + 1; | ||
|
||
satrec.ndot = jsonobj.MEAN_MOTION_DOT; | ||
satrec.nddot = jsonobj.MEAN_MOTION_DDOT; | ||
satrec.bstar = jsonobj.BSTAR; | ||
|
||
satrec.inclo = jsonobj.INCLINATION; | ||
satrec.nodeo = jsonobj.RA_OF_ASC_NODE; | ||
satrec.ecco = jsonobj.ECCENTRICITY; | ||
satrec.argpo = jsonobj.ARG_OF_PERICENTER; | ||
satrec.mo = jsonobj.MEAN_ANOMALY; | ||
satrec.no = jsonobj.MEAN_MOTION; | ||
|
||
// ---- find no, ndot, nddot ---- | ||
satrec.no /= xpdotp; // rad/min | ||
|
||
// ---- find standard orbital elements ---- | ||
satrec.inclo *= deg2rad; | ||
satrec.nodeo *= deg2rad; | ||
satrec.argpo *= deg2rad; | ||
satrec.mo *= deg2rad; | ||
|
||
// ---------------------------------------------------------------- | ||
// find sgp4epoch time of element set | ||
// remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch) | ||
// and minutes from the epoch (time) | ||
// ---------------------------------------------------------------- | ||
|
||
const mdhmsResult = days2mdhms(year, satrec.epochdays); | ||
|
||
const { mon, day, hr, minute, sec } = mdhmsResult; | ||
satrec.jdsatepoch = jday(year, mon, day, hr, minute, sec); | ||
|
||
// ---------------- initialize the orbit at sgp4epoch ------------------- | ||
sgp4init(satrec, { | ||
opsmode, | ||
satn: satrec.satnum, | ||
epoch: satrec.jdsatepoch - 2433281.5, | ||
xbstar: satrec.bstar, | ||
xecco: satrec.ecco, | ||
xargpo: satrec.argpo, | ||
xinclo: satrec.inclo, | ||
xmo: satrec.mo, | ||
xno: satrec.no, | ||
xnodeo: satrec.nodeo, | ||
}); | ||
|
||
return satrec; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why you are updating the name? Did you update the comments above too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because classically,
rv
stands for satellite state vector: [rx, ry, rz, vx, vy, vz]. This represents the position and velocity in the x,y and z directions. But this function actually returns asatrec
object.This is not the same as a satellite state vector. A
satrec
object is a dictionary containing all thesgp4
satellite information [sgp4io.cpp].I have not modified any other comments above. I figured that the old way on naming the function was not in-line with its modern interpretation of the term
rv
andsatrec
.