#!/bin/bash
# A simple (a,e) figure of the NEA source region probability (MMR 3:1)
# (c) SsODNet, B.Carry & J.Berthier, Lagrange/OCA & LTE/Obs. Paris

if [[ ! -f ssoBFT-latest_Asteroid.parquet ]]; then
  read -p "ssoBFT not found. Download it [~800MB]? [y/n]: " resp
  if [[ ${resp,,} = "y" ]]; then
    echo "Downloading ssoBFT ..."
    wget -q https://ssp.imcce.fr/data/ssoBFT-latest_Asteroid.parquet
  else
    exit 1
  fi
fi

topcat -stilts plot2plane \
   xpix=938 ypix=568 \
   xlabel='Semi-major\ axis\ /\ au' ylabel=Eccentricity texttype=latex fontsize=20 \
   xmin=0.5 xmax=3.5 ymin=0.002 ymax=1.016 \
   legend=false \
   auxflip=true auxmin=0 auxmax=0.97 \
   auxvisible=true auxlabel='Probability\ from\ 3:1' \
   layer=Mark \
      in=ssoBFT-latest_Asteroid.parquet icmd='select "contains(class,\"NEA\")"' \
      x=orbital_elements.semi_major_axis.value y=orbital_elements.eccentricity.value \
       weight=source_regions.mm31.value \
      shading=weighted size=2 color=blue 
