Package: ohirstar-scaleheight-lifetime
ohirstar_scaleheight_lifetimeThis ohirstar_scaleheight_lifetime module helps you estimate a plausible scale height and lifetime of stars.The code was written during the investigation of the OH/IR stars distribution in the Galaxy (Uno et al. 2020).
See the jupyternotebook (named as "OHIR-statistics.ipynb") for the detail of statistical analysis.RequirementsThe code was implemented on python3.7 and it uses the following python liblalies.numpymatplotlibscipypylabSetuppackage installationpip install git+https://github.com/yuriuno/ohirstar_scaleheight_lifetime.gitData analysis1. Scale height1.1 Construct a simple Galactic disk modelimport numpy as np
import matplotlib.pyplot as plt
from pylab import rcParams
from mpl_toolkits.mplot3d import Axes3D
from scipy import stats
import ohirstar_scaleheight_lifeitme.ohirstar_scaleheight_lifetme as sl

sh            = sl.ScaleHeight()
NUMBER        = 3990
SCALE_LENGTH  = 22   # kpc *exponential disk model
SCALE_HEIGHT  = 0.15 # kpc *gaussian (simplified sech z^2 disk model)
DIST_FUNC     = {'scale_length':SCALE_LENGTH, 'scale_height':SCALE_HEIGHT}
KINE_DIST     = 'near' # 'near' or  'far' * luminosity function based on near/far kinematic distance    
DETECTION_LIM = 0.122 # Jy   *SPLASH detection limit is 0.065 * 3 sigma 
mxyz, mlb, mflux = sh.model(DIST_FUNC, NUMBER, KINE_DIST)1.2 Evaluate your model using K-S testDATA   = np.load('./data/stat') # datatype: numpy strings
# DATA format: name, longitude, latitude, radial-velocity, expansion-velocity, velocity-uncertainity, flux-density, size, spot_num
REGION  = [{'l':[-28, -4], 'b':[-1.25, 1.25]},{'l':[4, 10], 'b':[-1.25,1.25]}, {'l':[14.35, 67.25], 'b':[-1.25,1.25]}] # specify the feild where you are evaluating
# dlb: np.array([l,b]) 
dlb     = np.array([[float(i) for i in DATA[1]],[float(i) for i in DATA[2]]])
p_value = sh.pvalue(dlb, mlb, mflux, DETECTION_LIM, REGION)
print(format(p_value,'.3f'))
>>> '0.531'1.3 Quick visualization of the constructed model.# 3D(X,Y,Z) [kpc]
sh.visualize(mxyz, mflux)# 2D(l,b) [deg]
sh.visualize(mlb, mflux)2. Lifetime2.1 A most plausible lifetimeLifetime of transient phenomenon such as the duration of OH masers associated with evolved starscan be estimated by consideing the probabilityof detectingmdissapeared maser sources innsamples ina given amount of time;dTas demonstrated byEngels and Jimenes-Esteban (2007).For example if you havem=3 maser sources vanished inn=100 samples afterdT=10 years, you will get the most prausible lifetime ~300 years.import numpy as np
from scipy.special import comb
import ohirstar_scaleheight_lifetime.ohirstar_scaleheight_lifetime as sl

M    = 30
N    = 445
DT   = 20
SPAN = 1000
lt   = sl.LifeTime(M,N,DT,SPAN)
lifetime = lt.lifetime()
print(format(lifetime,'.1f'))
>>> '296.7'2.2 Upper limits of a lifetimeMeanwhile, the upper limit of OH maser lifetimewith different significance levels can be estimated as follows.The upper limits for lifeitme of OH masers assuming at leastm=3 maser sources vanish inn=100 samples indT=10 years will be 505, 1258, 2000 years depending on significance levels (1, 2, 3σ).lifetime_upper_limit = lt.upper_limit()
print(lifetime_upper_limit)
>>> [326.90000000000435, 411.90000000000555, 512.900000000007] # 1 sigma, 2 sigma, 3 sigma2.3 Quick visualization of the probability distribution#  Pnm
xscale = 'linear'
type   = 'lifetime'
lt.visualize(xscale,type)# Qnm
xscale = 'linear'
type   = 'upper_limit'
lt.visualize(xscale,type)