DelfiSpace / DelfiTLM

Ground Segment Software for CubeSats
https://delfispace.github.io/DelfiTLM
8 stars 0 forks source link

Update db schema #59

Closed iiacoban42 closed 2 years ago

iiacoban42 commented 2 years ago
  1. Add a new stand-alone table for TLE with the following fields :
  1. Add a location field to the members table.
iiacoban42 commented 2 years ago

Shall we ask users for location when they sign up? Make it a required field?

StefanoSperetta commented 2 years ago

TLEs do not have a _validuntil but only a _validfrom date (this is because a new TLE is only released when the previous TLE shows a position error greater than a threshold) so I would remove the valid_until field.

The _validfrom date is encoded in the TLE so it might be easier to directly retrieve that when a new TLE is inserted. There are several ways of doing that, maybe using the Skyfield (https://pypi.org/project/skyfield/) and reading the epoch directly (https://rhodesmill.org/skyfield/earth-satellites.html#checking-a-tles-epoch) when the TLE is added to the database (I am not sure if we can make some custom Django Admin page for this). This might be much simpler than manually adding the TLE and calculating the start date (keep in mind Delfi-PQ has already ~50 TLEs, one new TLE released twice a day).

Currently, TLEs are the standard for short-term orbital elements but a "new" format is now being used as well: OMM. It contains exactly the same information but it is not formatted anymore as 2 lines of text with position-sensitive characters and maximum a 5-digit satellite identifier) but using XML or JSON (https://celestrak.com/NORAD/elements/gp.php?NAME=MICROSAT-R&FORMAT=JSON-PRETTY). This might be interesting for a second iteration as no parsing would be needed.

I would not make the user position a mandatory field mostly for privacy reasons. Most of the users could fill it but I would not oblige them.

StefanoSperetta commented 2 years ago

Some more comments about the TLE table and what can be used for. There are 2 main use cases for storing the TLE in the database:

These 2 use cases can be addressed with a dedicated function in python (probably needed in the future). It is nice to have a table of all acquired TLEs but its use is quite limited for external users. They will almost certainly only look for the last one but I am not against having a table view.

iiacoban42 commented 2 years ago

Thank you Stefano! I have an insertion function for string TLEs in #64. How would you like to go about updating the database with the latest TLEs? Spacetrack has an API available. Could we write a script to poll it for new TLEs and store them?

I got the format from Wikipedia, I hope it's the right one.

ISS (ZARYA)
1 25544U 98067A   08264.51782528 -.00002182  00000-0 -11606-4 0  2927
2 25544  51.6416 247.4627 0006703 130.5360 325.0288 15.72125391563537
StefanoSperetta commented 2 years ago

I would not write it by simply use this (https://pypi.org/project/spacetrack/). The main reason is that there are a lot of rules not to be banned from the server (TBD queries per minute, queries not aligned with the day/hour/minute start, etc..).

I would create a dedicated account on space-track (DelfiSpace is an organization associated with Delfi-C3, Delfi-N3xt and Delfi-PQ and I can add users). What is important to note is that TLEs are identified by the Norad ID (25544 in the ISS TLE) and this is satellite specific (so maybe I would put it as a satellite property). But straight after launch (and for the next 3-4 weeks) there is no TLE on spacetrack (it takes time to find and assign all objects) so we generate our own TLEs and, only after we successfully match one Norad ID to our satellite, we switch the automatic download on.

Norad (actually 18 SPCS) releases TLEs only when the error associated with the object "grows too much" (this is why there is no valid until date for the TLE) and often there are 1-2 TLEs / day released for LEO satellites. If you look at the download rules, we can't query TLEs more than once per 1h otherwise we get banned.

I think in the long term we should add a batch script ( was looking at how to add such behavior to Django) to query TLEs regularly and add them to the database.