Download app/scripts/seed_synthetic.py from Adisri99/Space-Risk-Intelligence-API: direct link, hf CLI and curl.
- Browser
- Download file 993 Bytes
-
https://huggingface.co/spaces/Adisri99/Space-Risk-Intelligence-API/resolve/main/app/scripts/seed_synthetic.py
- Command line
-
hf download hf://spaces/Adisri99/Space-Risk-Intelligence-API/app/scripts/seed_synthetic.py
-
curl -L -o seed_synthetic.py https://huggingface.co/spaces/Adisri99/Space-Risk-Intelligence-API/resolve/main/app/scripts/seed_synthetic.py
993 Bytes
| import random | |
| from app.database import Base, engine, SessionLocal | |
| from app.repository import upsert_space_object | |
| def synthetic_objects(n=300): | |
| items=[] | |
| for i in range(n): | |
| shell=random.choice([(15.2,53),(14.9,98),(13.8,74),(2.0,0),(12.5,55)]); mm,inc=shell | |
| items.append({"object_id":f"OBJ-{i+1}","norad_cat_id":10000+i,"object_name":f"SIM_OBJECT_{i+1}","object_type":random.choice(["PAYLOAD","DEBRIS","ROCKET BODY"]),"mean_motion":round(random.gauss(mm,0.12),5),"inclination":round(random.gauss(inc,1.4),5),"eccentricity":round(abs(random.gauss(0.001,0.002)),6),"raan":round(random.uniform(0,360),4),"bstar":round(random.uniform(0.00001,0.005),8),"launch_year":random.randint(1998,2025)}) | |
| return items | |
| def main(): | |
| Base.metadata.create_all(bind=engine); db=SessionLocal() | |
| try: | |
| for item in synthetic_objects(): upsert_space_object(db,item) | |
| db.commit(); print("Synthetic objects loaded.") | |
| finally: db.close() | |
| if __name__=="__main__": main() | |