#!/bin/bash
# Histograms of albedo with Gaussian fit for C, S, and M taxonomies
# (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 xlabel=Albedo ylabel='Density\ count' texttype=latex fontsize=21 \
   xmin=0.013 xmax=1 ymin=0 ymax=3.55 \
   legend=true legpos=0.9091,0.857 \
   auxvisible=false \
   in=ssoBFT-latest_Asteroid.parquet x='$165' normalise=area \
   layer_1=Histogram \
      icmd_1='select "equals($179,\"C\") & equals($182,\"Spec\")"' \
      color_1=blue \
      leglabel_1='C\ types' \
   layer_2=Gaussian \
      icmd_2='select "equals($179,\"C\") & equals($182,\"Spec\")"' \
      color_2=blue thick_2=4 \
      leglabel_2='C\ types' \
   layer_3=Histogram \
      icmd_3='select "equals($179,\"S\") & equals($182,\"Spec\")"' \
      leglabel_3='S\ types' \
   layer_4=Gaussian \
      icmd_4='select "equals($179,\"S\") & equals($182,\"Spec\")"' \
      thick_4=4 \
      leglabel_4='S\ types' \
   layer_5=Histogram \
      icmd_5='select "equals($179,\"M\") & equals($182,\"Spec\")"' \
      color_5=light_grey \
      leglabel_5='M\ types' \
   layer_6=Gaussian \
      icmd_6='select "equals($179,\"M\") & equals($182,\"Spec\")"' \
      color_6=light_grey thick_6=4 \
      leglabel_6='M\ types'
