#!/bin/bash
# Distribution of (G1,G2) for C and S types
# (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=G1 ylabel=G2 texttype=latex fontsize=22 \
   xmin=-4.0E-5 xmax=1 ymin=-4.0E-5 ymax=1 \
   legend=true legpos=0.8965,0.887 \
   auxvisible=false \
   in=ssoBFT-latest_Asteroid.parquet x='$218[indexOf($213,"Palomar/ZTF.r")]' \
    y='$221[indexOf($213,"Palomar/ZTF.r")]' nlevel=3 smooth=100 thick=2 \
   layer_1=Contour \
      icmd_1='select "$178==\"S\""' \
      color_1=red \
      leglabel_1='S\ type' \
   layer_2=Contour \
      icmd_2='select "$178==\"C\""' \
      color_2=light_grey \
      leglabel_2='C\ type' \
   layer_3=Function \
      fexpr_3=1-x color_3=black dash_3=12,3,3,3 \
      leglabel_3='Limit\ from\ Muinonen2010'
