diff --git a/ci/MPCORB.excerpt.DAT b/ci/MPCORB.excerpt.DAT new file mode 100644 index 0000000..28f32ec --- /dev/null +++ b/ci/MPCORB.excerpt.DAT @@ -0,0 +1,4 @@ +00001 3.4 0.15 K205V 162.68631 73.73161 80.28698 10.58862 0.0775571 0.21406009 2.7676569 0 MPO492748 6751 115 1801-2019 0.60 M-v 30h Williams 0000 (1) Ceres 20190915 +00002 4.2 0.15 K205V 144.97567 310.20237 173.02474 34.83293 0.2299723 0.21334458 2.7738415 0 MPO530953 8031 109 1821-2019 0.58 M-v 28h MPCW 0000 (2) Pallas 20190812 +00003 5.2 0.15 K205V 125.43538 248.06618 169.85146 12.99105 0.2569364 0.22612869 2.6682853 0 MPO530953 7023 106 1821-2020 0.59 M-v 38h MPCW 0000 (3) Juno 20200204 +00004 3.0 0.15 K205V 204.32771 150.87484 103.80908 7.14190 0.0885158 0.27150657 2.3620141 0 MPO530953 6964 102 1821-2020 0.60 M-p 18h MPCW 0000 (4) Vesta 20200203 diff --git a/design/mpc_make_excerpt.py b/design/mpc_make_excerpt.py new file mode 100644 index 0000000..4cda852 --- /dev/null +++ b/design/mpc_make_excerpt.py @@ -0,0 +1,30 @@ +# mpc_make_excerpt.py + +"""Search the MPCORB file for minor planets, given their packed designations.""" + +import argparse +import re +import sys +import zlib + +from skyfield.api import load +from skyfield.data import mpc + +def main(argv): + parser = argparse.ArgumentParser(description='Grep MPCORB.DAT.gz') + parser.add_argument('designations', nargs='+', help='packed designations' + ' of the minor planets whose orbits you need') + args = parser.parse_args(argv) + + designations = [re.escape(d.encode('ascii')) for d in args.designations] + pattern = rb'^((?:%s) .*\n)' % rb'|'.join(designations) + r = re.compile(pattern, re.M) + + data = load.open(mpc.MPCORB_URL).read() + data = zlib.decompress(data, wbits = zlib.MAX_WBITS | 16) + lines = r.findall(data) + + sys.stdout.buffer.write(b''.join(lines)) + +if __name__ == '__main__': + main(sys.argv[1:])