#!/usr/bin/env python3

from optparse import OptionParser
import sqlite3
import numpy

"""
return merge rate R and VT parameter of O3a as an example of building p-astro model.

"""


def parse_command_line():
  parser = OptionParser()
  parser.add_option("-v", "--verbose", action = "store_true", help = "Be verbose.")
  parser.add_option("--category", help = "The category of p-astro, BNS, BBH, NSBH.")
  parser.add_option("--vt", help = "vt parameter counted from lvc_rates_injections_vtparams.")
  parser.add_option("--coinc-count", help="count of coinc events above likelihood threshold.")
  options, filenames = parser.parse_args()
  process_params = dict(options.__dict__)

  return options, process_params, filenames

options, process_params, filenames = parse_command_line()

merge_rate = {'BNS': 660, 'NSBH': 49, 'BBH': 37}  # implement merge rate constants from arxiv 2111.03634
VT = float(options.vt) * float(options.coinc_count)
N_expect = merge_rate[options.category] * VT

print(options.category+' average merge rate (O3a) is', merge_rate[options.category])
print(options.category+' VT(O3a)=', VT)
print(options.category+' expected count above lr threshold: ', N_expect)
