#!/bin/bash
# Rotation period against diameter
# (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 \
   xscale=log yscale=log yflip=true xlabel='Diameter\ /\ km' ylabel='Period\ /\ h' xcrowd=0.242 \
    ycrowd=0.383 texttype=latex fontsize=20 \
   xmin=0 xmax=1000 ymin=0 ymax=1000 \
   legend=true legpos=0.9628,0.955 \
   auxvisible=false \
   in=ssoBFT-latest_Asteroid.parquet x=diameter.value y='$187[0]' shading=auto thick=2 \
   layer_1=Mark \
      color_1=light_grey \
      leglabel_1=SSOs \
   layer_2=Mark \
      icmd_2='select children>0' \
      size_2=2 color_2=blue \
      leglabel_2=Binaries \
   layer_3=Function \
      fexpr_3='13.38 * pow(x,0.783)' color_3=black dash_3=8,4 \
      leglabel_3=Zhou+2025 \
   layer_4=Function \
      fexpr_4=2.2 dash_4=3,3 \
      leglabel_4='Spin\ limit' 
