Skip to content

Instantly share code, notes, and snippets.

# stolen from here: https://amor.cms.hu-berlin.de/~rodrigus/Jupyter%20Notebooks/Solar_System_N-Body_Simulation.html
import numpy as np
import scipy as sp
import time
import scipy.constants as cs
import matplotlib.pyplot as plt
from numba import jit
from numba import cuda
from mpl_toolkits.mplot3d import Axes3D
from astropy.time import Time
# Python 3.9+
# You need to get and put your API key here https://developers.google.com/youtube/v3/getting-started
APIKEY = "XYZYOURSECRETAPIKEYXYZ"
from time import sleep
import csv
import requests
f = open("subscriptions.csv")
@void4
void4 / groundtrack.py
Last active May 23, 2023 21:54
Quickly plot impacting asteroid groundtrack
"""
Dependencies:
find_orb (specifically the non-gui 'fo'): https://www.projectpluto.com/find_orb.htm
pip install pandas plotly
$ grab_mpc obs.txt 2023 CX1
# -E 8 includes ground track latlon+alt
# only with -e generates combined.json i think
from ortools.linear_solver import pywraplp
# Create the mip solver with the SCIP backend.
solver = pywraplp.Solver.CreateSolver('SCIP')
infinity = solver.infinity()
numSteps = 25
shipBuyingPrice = 10
shipSellingPrice = 10
factoryBuyingPrice = 20
int numSteps = 35;
float shipBuyingPrice = 10;
float factoryBuyingPrice = 30;
float workshopBuyingPrice = 50;
float passiveIncome = 1;
float shipIncomeMuliplier = 3;
float factoryIncomeMultiplier = 5;
float workshopIncomeMultiplier = 9;
range Times = 0..numSteps;
float initState_money = 50;
import shutil
from glob import glob
from natsort import natsorted
import os
RESULTF = "results"
os.makedirs(RESULTF, exist_ok=True)
def nextFilename():
import zstandard
path = "test.txt.zst"
class Buffer:
def __init__(self, path):
self.f = open(path, "rb")
self.reader = zstandard.ZstdDecompressor().stream_reader(self.f)
self.buffer = ""
$ solve-field --overwrite field.png
Reading input file 1 of 1: "field.png"...
Read file stdin: 516 x 738 pixels x 1 color(s); maxval 255
Using 8-bit output
Extracting sources...
simplexy: found 1341 sources.
Solving...
Reading file "./field.axy"...
Field 1 did not solve (index index-5206-47.fits, field objects 1-10).
Field 1 did not solve (index index-5206-46.fits, field objects 1-10).
$ solve-field --overwrite field.png
Reading input file 1 of 1: "field.png"...
Read file stdin: 516 x 738 pixels x 1 color(s); maxval 255
Using 8-bit output
Extracting sources...
simplexy: found 1341 sources.
Solving...
Reading file "./field.axy"...
Field 1 did not solve (index index-4219.fits, field objects 1-10).
Field 1 did not solve (index index-4218.fits, field objects 1-10).
# Python
# pip install python-chess
import chess
moves = []
# Queen, covers all lines and diagonals
for x in range(8):
for y in range(8):
board = chess.Board("8/8/8/8/8/8/8/8")