From 7feddb2639900a9f227984f53c28b38d1a5e1176 Mon Sep 17 00:00:00 2001
From: Atul Kedia <atul.kedia@ldas-osg.ligo.caltech.edu>
Date: Wed, 22 Feb 2023 09:00:16 -0800
Subject: [PATCH 01/12] update to EOSManager for review. EOSManager.py is
 updated. EOSManager_old.py is the older EOSManager left for comparison
 purposes.

---
 .../Code/RIFT/physics/EOSManager.py           | 1969 +++++++++--------
 .../Code/RIFT/physics/EOSManager_old.py       |  880 ++++++++
 2 files changed, 1969 insertions(+), 880 deletions(-)
 create mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager_old.py

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
index 7332f332f..694872746 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
@@ -1,880 +1,1089 @@
-#
-#  EOSManager.py 
-#
-# SEE ALSO
-#   - util_WriteXMLWithEOS
-#   - gwemlightcurves.KNTable
-
-# SERIOUS LIMITATIONS
-#   - EOSFromFile  : File i/o for each EOS creation will slow things donw.  This command is VERY trivial, so we should be able
-#          to directly create the structure ourselves, using eos_alloc_tabular
-#           https://github.com/lscsoft/lalsuite/blob/master/lalsimulation/src/LALSimNeutronStarEOSTabular.c
-
-rosDebug=False
-
-import numpy as np
-import os
-import sys
-import lal
-import lalsimulation as lalsim
-from scipy.integrate import quad
-import scipy.interpolate as interp
-import scipy
-
-try:
-    from natsort import natsorted
-except:
-    print(" - no natsorted - ")
-
-#import gwemlightcurves.table as gw_eos_table
-
-from . import MonotonicSpline as ms
-
-
-C_CGS=2.997925*10**10 # Argh, Monica!
-DENSITY_CGS_IN_MSQUARED=7.42591549e-25  # g/cm^3 m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom)
-
-
-def make_compactness_from_lambda_approximate(lambda_vals):
-    """
-    make_compactness_from_lambda_approximate
-    Eq (B1) from https://arxiv.org/pdf/1812.04803.pdf, based on Maselli et al 2013, Yagi and Yunes 2017
-
-    Note this will yield *extreme* compactnesses for poorly-constrained GW observations, as the 'lambda' inferred will be wildly large/prior-dominated
-    """
-
-    return 0.371 -0.0391*np.log(lambda_vals) + 0.001056*np.log(lambda_vals)**2
-
-
-###
-### SERVICE 0: General EOS structure
-###
-
-class EOSConcrete:
-    """
-    Class characterizing a specific EOS solution.  This structure *SHOULD* 
-        - auto-build the mass-radius via a TOV solve
-         - provides ability to query the lambda(m) relationship and (in the future) higher-order multipole moments; etc
-    As many of these features are already provided by lalsimulation, 
-    """
-
-    def __init__(self,name=None):
-        self.name=name
-        self.eos = None
-        self.eos_fam = None
-        return None
-
-    def lambda_from_m(self, m):
-        eos_fam = self.eos_fam
-        if m<10**15:
-            m=m*lal.MSUN_SI
-
-        k2=lalsim.SimNeutronStarLoveNumberK2(m, eos_fam)
-        r=lalsim.SimNeutronStarRadius(m, eos_fam)
-
-        m=m*lal.G_SI/lal.C_SI**2
-        lam=2./(3*lal.G_SI)*k2*r**5
-        dimensionless_lam=lal.G_SI*lam*(1/m)**5
-
-        return dimensionless_lam
-
-    def estimate_baryon_mass_from_mg(self,m):
-        """
-        Estimate m_b = m_g + m_g^2/(R_{1.4}/km) based on https://arxiv.org/pdf/1905.03784.pdf Eq. (6)
-        """
-        r1p4 =lalsim.SimNeutronStarRadius(1.4*lal.MSUN_SI, self.eos_fam)/1e3
-        return m + (1./r1p4)*m**2 #(m/lal.MSUN_SI)
-
-    def pressure_density_on_grid_alternate(self,logrho_grid,enforce_causal=False):
-        """ 
-        pressure_density_on_grid.
-        Input and output grid units are in SI (rho: kg/m^3; p = N/m^2)
-        Pressure provided by lalsuite (=EOM integration)
-        Density computed by m*n = (epsilon+p)/c^2mn exp(-h), which does NOT rely on lalsuite implementation 
-        """
-        dat_out = np.zeros(len(logrho_grid))
-        fam = self.eos_fam
-        eos = self.eos
-        npts_internal = 10000
-        p_internal = np.zeros(npts_internal)
-        rho_internal = np.zeros(npts_internal)
-        epsilon_internal = np.zeros(npts_internal)
-        hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
-        if enforce_causal:
-            # strip out everything except the causal part.
-            hmax = lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos)
-        h = np.linspace(0.0001,hmax,npts_internal)
-        for indx in np.arange(npts_internal):
-            p_internal[indx] = lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10 to get CGS
-            epsilon_internal[indx] =lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(h[indx],eos)  # SI. Note factor of C^2 needed to get mass density
-            rho_internal[indx] =np.exp(-h[indx])* (epsilon_internal[indx]+p_internal[indx])/(lal.C_SI**2)  # 
-#        print epsilon_internal[10],rho_internal[10], p_internal[10], h[10]
-        logp_of_logrho = interp.interp1d(np.log10(rho_internal),np.log10(p_internal),kind='linear',bounds_error=False,fill_value=np.inf)  # should change to Monica's spline
- #       print logrho_grid,
-        return logp_of_logrho(logrho_grid)
-
-    def pressure_density_on_grid(self,logrho_grid,reference_pair=None,enforce_causal=False):
-        """ 
-        pressure_density_on_grid.
-        Input and output grid units are in SI (rho: kg/m^3; p = N/m^2)
-        POTENTIAL PROBLEMS OF USING LALSUITE
-            - lalinference_o2 / master: Unless patched, the *rest mass* density is not reliable.  
-              To test with the unpatched LI version, use reference_pair to specify a low-density EOS.
-              This matching is highly suboptimal, so preferably test either (a) a patched code or (b) the alternative code below
-        """
-        dat_out = np.zeros(len(logrho_grid))
-        fam = self.eos_fam
-        eos = self.eos
-        npts_internal = 10000
-        p_internal = np.zeros(npts_internal)
-        rho_internal = np.zeros(npts_internal)
-        hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
-        if enforce_causal:
-            # strip out everything except the causal part.
-            hmax = lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos)
-        h = np.linspace(0.0001,hmax,npts_internal)
-        for indx in np.arange(npts_internal):
-            rho_internal[indx] = lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10^(-3) to get CGS
-            p_internal[indx] = lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10 to get CGS
-        if not (reference_pair is None):
-            indx_match = np.argmin( np.abs(np.log10(p_internal) - np.log10(reference_pair[1]))) # force agreement of densities at target pressure, if requested! Addresses bug /ambiguity in scaling of rest mass estimate; intend to apply in highly nonrelativistic regime
-            delta_rho = np.log10(reference_pair[0]) -np.log10(rho_internal[indx_match]) 
-            rho_internal *= np.power(10, delta_rho)
-#            print  np.log10(np.c_[rho_internal,p_internal])
-        logp_of_logrho = interp.interp1d(np.log10(rho_internal),np.log10(p_internal),kind='linear',bounds_error=False,fill_value=np.inf)  # should change to Monica's spline
- #       print logrho_grid,
-        return logp_of_logrho(logrho_grid)
-
-    def test_speed_of_sound_causal(self, test_only_under_mmax=True,fast_test=True):
-        """
-        Test if EOS satisfies speed of sound.
-        Relies on low-level lalsimulation interpolation routines to get v(h) and as such is not very reliable
-
-        By DEFAULT, we are testing the part of the EOS that is
-             - at the largest pressure (assuming monotonic sound speed)
-             - associated with the maximum mass NS that is stable
-        We can also test the full table that is provided to us.
-        https://git.ligo.org/lscsoft/lalsuite/blob/lalinference_o2/lalinference/src/LALInference.c#L2513
-        """
-        npts_internal = 1000
-        eos = self.eos
-        fam = self.eos_fam
-        # Largest NS provides largest attained central pressure
-        m_max_SI = self.mMaxMsun*lal.MSUN_SI
-        if not test_only_under_mmax:
-            hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
-        else:
-            try:
-                pmax = lalsim.SimNeutronStarCentralPressure(m_max_SI,fam)  
-                hmax = lalsim.SimNeutronStarEOSPseudoEnthalpyOfPressure(pmax,eos)
-            except:
-                # gatch gsl interpolation errors for example
-                return False  
-        if fast_test: 
-            # https://git.ligo.org/lscsoft/lalsuite/blob/lalinference_o2/lalinference/src/LALInference.c#L2513
-            try:
-                vsmax = lalsim.SimNeutronStarEOSSpeedOfSoundGeometerized(hmax, eos)
-                return vsmax <1.1
-            except:
-                # catch gsl interpolation errors for example
-                return False
-        else:
-            if rosDebug:
-                print(" performing comprehensive test ")
-        h = np.linspace(0.0001,hmax,npts_internal)
-#        h = np.linspace(0.0001,lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos),npts_internal)
-        vs_internal = np.zeros(npts_internal)
-        for indx in np.arange(npts_internal):
-            vs_internal[indx] =  lalsim.SimNeutronStarEOSSpeedOfSoundGeometerized(h[indx],eos)
-            if rosDebug:
-                print(h[indx], vs_internal[indx])
-        return not np.any(vs_internal>1.1)   # allow buffer, so we have some threshold
-
-###
-### SERVICE 1: lalsimutils structure
-###
-#  See https://github.com/lscsoft/lalsuite/tree/master/lalsimulation/src for available types
-class EOSLALSimulation(EOSConcrete):
-    def __init__(self,name):
-        self.name=name
-        self.eos = None
-        self.eos_fam = None
-        self.mMaxMsun=None
-
-
-        eos = lalsim.SimNeutronStarEOSByName(name)
-        fam = lalsim.CreateSimNeutronStarFamily(eos)
-        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
-        self.eos = eos
-        self.eos_fam = fam
-        self.mMaxMsun = mmass
-        return None
-
-
-
-
-
-###
-### SERVICE 2: EOSFromFile
-###
-
-# Example directory: EOS_Tables
-#dirEOSTablesBase = os.environ["EOS_TABLES"]
-dirLALSimulationBase = os.environ["LALSIMULATION_DATADIR"]  # LAL table data
-## Add routines to find, parse standard directory of EOS files and load suitable metadata into memory
-## Follow framework of NRWaveformCatalogManager3
-
-
-class EOSFromDataFile(EOSConcrete):
-    """ 
-    FromDataFileEquationOfState
-    (just accepts filename...not attempting to parse a catalog)
-    
-    """
-    def __init__(self,name=None,fname=None):
-        self.name=name
-        self.fname=fname
-        self.eos = None
-        self.eos_fam = None
-        self.mMax = None
-
-        self.eos, self.eos_fam = self.eos_ls()
-        return None
-
-    def eos_ls(self):
-        # From Monica, but using code from GWEMLightcurves
-        #  https://gwemlightcurves.github.io/_modules/gwemlightcurves/KNModels/table.html
-        """
-        EOS tables described by Ozel `here <https://arxiv.org/pdf/1603.02698.pdf>`_ and downloadable `here <http://xtreme.as.arizona.edu/NeutronStars/data/eos_tables.tar>`_. LALSim utilizes this tables, but needs some interfacing (i.e. conversion to SI units, and conversion from non monotonic to monotonic pressure density tables)
-    """
-        obs_max_mass = 2.01 - 0.04  # used
-        print("Checking %s" % self.name)
-        eos_fname = ""
-        if os.path.exists(self.fname):
-            # NOTE: Adapted from code by Monica Rizzo
-            print("Loading from %s" % self.fname)
-            bdens, press, edens = np.loadtxt(self.fname, unpack=True)
-            press *= DENSITY_CGS_IN_MSQUARED
-            edens *= DENSITY_CGS_IN_MSQUARED
-            eos_name = self.name
-
-            if not np.all(np.diff(press) > 0):
-                keep_idx = np.where(np.diff(press) > 0)[0] + 1
-                keep_idx = np.concatenate(([0], keep_idx))
-                press = press[keep_idx]
-                edens = edens[keep_idx]
-            assert np.all(np.diff(press) > 0)
-            if not np.all(np.diff(edens) > 0):
-                keep_idx = np.where(np.diff(edens) > 0)[0] + 1
-                keep_idx = np.concatenate(([0], keep_idx))
-                press = press[keep_idx]
-                edens = edens[keep_idx]
-            assert np.all(np.diff(edens) > 0)
-
-            # Creating temporary file in suitable units
-            print("Dumping to %s" % self.fname)
-            eos_fname = "./" +eos_name + "_geom.dat" # assume write acces
-            np.savetxt(eos_fname, np.transpose((press, edens)), delimiter='\t')
-            eos = lalsim.SimNeutronStarEOSFromFile(eos_fname)
-            fam = lalsim.CreateSimNeutronStarFamily(eos)
-
-        else:
-            print(" No such file ", self.fname)
-            sys.exit(0)
-
-        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
-        self.mMaxMsun = mmass
-        return eos, fam
-
-    def p_rho_arrays(self):
-        print(self.fname)
-        dat_file = np.array(np.loadtxt(self.fname))
-        nb=dat_file[:,0]
-        p=dat_file[:,1]
-        rho=dat_file[:,2] 
-        return nb,p,rho
-    def interp_eos_p_of_rho(self):
-        nb,p,rho=self.p_rho_arrays()
-        n=len(p)
-        p=np.log10(p)
-        rho=np.log10(rho)
-        consts=ms.interpolate(rho,p)
-        line_const=ms.lin_extrapolate(rho,p)
-        #linearly interpolate anything outside range
-        line_lower=line_const[0,:]
-        line_upper=line_const[1,:]
-        return consts,line_upper,line_lower
-
-   #interpolates Log10 of data
-    def interp_eos_rho_of_p(self):
-        nb,p,rho=self.p_rho_arrays()
-        n=len(p)
-        p=np.log10(p)
-        rho=np.log10(rho)
-        consts=ms.interpolate(p,rho)  
-        line_const=ms.lin_extrapolate(p,rho)
-       #linearly interpolate anything outside range
-        line_lower=line_const[0,:]
-        line_upper=line_const[1,:]
-        return consts,line_upper,line_lower
-    def interp_eos_nb_of_p(model_name):
-        nb,p,rho=self.p_rho_arrays()
-        n=len(p)
-        p=np.log10(p)
-        nb=np.log10(nb)
-        consts=ms.interpolate(p,nb)
-        line_const=ms.lin_extrapolate(p,nb)
-        #linearly interpolate anything outside range
-        line_lower=line_const[0,:]
-        line_upper=line_const[1,:]
-        return consts,line_upper,line_lower
-
-
-
-
-
-###
-### SERVICE 2: Parameterized EOS (specify functions)
-###
-
-# COMMON POLYTROPE TABLE
-# eos logP1 gamma1 gamma2 gamma3
-# PAL6 34.380 2.227 2.189 2.159 
-# SLy 34.384 3.005 2.988 2.851 
-# AP1 33.943 2.442 3.256 2.908 
-# AP2 34.126 2.643 3.014 2.945
-# AP3 34.392 3.166 3.573 3.281  
-# AP4 34.269 2.830 3.445 3.348 
-# FPS 34.283 2.985 2.863 2.600 
-# WFF1 34.031 2.519 3.791 3.660 
-# WFF2 34.233 2.888 3.475 3.517  
-# WFF3 34.283 3.329 2.952 2.589  
-# BBB2 34.331 3.418 2.835 2.832 
-# BPAL12 34.358 2.209 2.201 2.176 
-# ENG 34.437 3.514 3.130 3.168 
-# MPA1 34.495 3.446 3.572 2.887 
-# MS1 34.858 3.224 3.033 1.325 
-# MS2 34.605 2.447 2.184 1.855 
-# MS1b 34.855 3.456 3.011 1.425 
-# PS 34.671 2.216 1.640 2.365 
-# GS1 34.504 2.350 1.267 2.421 
-# GS2 34.642 2.519 1.571 2.314 
-# BGN1H1 34.623 3.258 1.472 2.464 
-# GNH3 34.648 2.664 2.194 2.304 
-# H1 34.564 2.595 1.845 1.897
-# H2 34.617 2.775 1.855 1.858
-# H3 34.646 2.787 1.951 1.901
-# H4 34.669 2.909 2.246 2.144
-# H5 34.609 2.793 1.974 1.915
-# H6 34.593 2.637 2.121 2.064
-# H7 34.559 2.621 2.048 2.006
-# PCL2 34.507 2.554 1.880 1.977 
-# ALF1 34.055 2.013 3.389 2.033 
-# ALF2 34.616 4.070 2.411 1.890 
-# ALF3 34.283 2.883 2.653 1.952 
-# ALF4 34.314 3.009 3.438 1.803
-
-# Rizzo code: EOS_param.py
-class EOSPiecewisePolytrope(EOSConcrete):
-    def __init__(self,name,param_dict=None):
-        self.name=name
-        self.eos = None
-        self.eos_fam = None
-        self.mMaxMsun=None
-
-
-        eos=self.eos=lalsim.SimNeutronStarEOS4ParameterPiecewisePolytrope(param_dict['logP1'], param_dict['gamma1'], param_dict['gamma2'], param_dict['gamma3'])
-        eos_fam=self.eos_fam=lalsim.CreateSimNeutronStarFamily(eos)
-        self.mMaxMsun = lalsim.SimNeutronStarMaximumMass(eos_fam) / lal.MSUN_SI
-
-        return None
-
-
-class EOSLindblomSpectral(EOSConcrete):
-    def __init__(self,name=None,spec_params=None,verbose=False,use_lal_spec_eos=False):
-        if name is None:
-            self.name = 'spectral'
-        else:
-            self.name=name
-        self.eos = None
-        self.eos_fam = None
-
-        self.spec_params = spec_params
-#        print spec_params
-
-        if use_lal_spec_eos:
-#            self.eos=lalsim.SimNeutronStarEOS4ParameterSpectralDecomposition(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'])   # Should have this function! but only on master
-            self.eos=lalsim.SimNeutronStarEOSSpectralDecomposition_for_plot(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'],4)
-        else:
-            # Create data file
-            self.make_spec_param_eos(500,save_dat=True,ligo_units=True,verbose=verbose)
-            # Use data file
-            #print " Trying to load ",name+"_geom.dat"
-            import os; #print os.listdir('.')
-            cwd = os.getcwd()
-            self.eos=eos = lalsim.SimNeutronStarEOSFromFile(cwd+"/"+name+"_geom.dat")
-        self.eos_fam = fam=lalsim.CreateSimNeutronStarFamily(self.eos)
-        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
-        self.mMaxMsun = mmass
-
-        return None
-
-    def test_bounded_adiabatic_index(self,bounds=[0.6,4.5]):
-        """
-        Gamma(p) \in bounds
-        Uses xmax and other parameters from spectral result
-        """
-        spec_params =self.spec_params
-        if not 'gamma3' in spec_params:
-            spec_params['gamma3']=spec_params['gamma4']=0
-        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
-        xmax = self.spec_params['xmax']
-        xvals = np.linspace(0,xmax,500)
-        gamma_vals = gamma_of_x(xvals, coefficients)
-        if rosDebug:
-            print("  Spectral EOS debug test limits: Gamma bounds", np.min(gamma_vals), np.max(gamma_vals))
-        return  not( np.any(gamma_vals < bounds[0]) or np.any(gamma_vals>bounds[1]) )
-            
-
-    def make_spec_param_eos(self, npts=500, plot=False, verbose=False, save_dat=False,ligo_units=False,interpolate=False,eosname_lalsuite="SLY4"):
-        """
-        Load values from table of spectral parameterization values
-        Table values taken from https://arxiv.org/pdf/1009.0738.pdf
-        Comments:
-            - eos_vals is recorded as *pressure,density* pairs, because the spectral representation is for energy density vs pressure
-            - units swap between geometric and CGS
-            - eosname_lalsuite is used for the low-density EOS
-        """
-
-        spec_params = self.spec_params
-        if not 'gamma3' in spec_params:
-            spec_params['gamma3']=spec_params['gamma4']=0
-        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
-        p0=spec_params['p0']
-        eps0=spec_params['epsilon0']
-        xmax=spec_params['xmax'] 
-
-        x_range=np.linspace(0,xmax,npts)
-        p_range=p0*np.exp(x_range)
-       
-        eos_vals=np.zeros((npts,2))
-        eos_vals[:,1]=p_range
-
-        eos_vals[:,0] = epsilon(x_range,p0,eps0, coefficients)
-        # for i in range(0, len(x_range)):
-        #    eos_vals[i,0]=epsilon(x_range[i], p0, eps0, coefficients)
-        #    if verbose==True:
-        #        print "x:",x_range[i],"p:",p_range[i],"p0",p0,"epsilon:",eos_vals[i,0]
-  
-    #doing as those before me have done and using SLY4 as low density region
-        # THIS MUST BE FIXED TO USE STANDARD LALSUITE ACCESS, do not assume the file exists
-#        low_density=np.loadtxt(dirEOSTablesBase+"/LALSimNeutronStarEOS_SLY4.dat")
-        low_density = np.loadtxt(dirLALSimulationBase+"/LALSimNeutronStarEOS_"+ eosname_lalsuite+".dat")
-        low_density[:,0]=low_density[:,0]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
-        low_density[:,1]=low_density[:,1]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
-        low_density[:,[0, 1]] = low_density[:,[1, 0]]  # reverse order
-
-        cutoff=eos_vals[0,:]   
-        if verbose:
-            print(" cutoff ", cutoff)
- 
-        break_pt=0
-        for i in range(0, len(low_density)):
-            if low_density[i,0] > cutoff[0] or low_density[i,1] > cutoff[1]:   
-                break_pt=i
-                break 
-    
-        eos_vals=np.vstack((low_density[0:break_pt,:], eos_vals)) 
-
-        if not interpolate:
-#            print eos_vals
-            if ligo_units:
-                eos_vals *= DENSITY_CGS_IN_MSQUARED/(C_CGS**2)  # converts to geometric units: first convert from cgs energy density to g/cm^2, then to 1/m^2.
- #               print " Rescaled "
-#                print eos_vals
-            
-            if save_dat == True:
-                np.savetxt(self.name+"_geom.dat", eos_vals[:,[1,0]])  #NOTE ORDER
-
-            return eos_vals
-        
-        # Optional: interpolate in the log, to generate a denser EOS model
-        # Will produce better M(R) models for LAL
-        p_of_epsilon = ms.interpolate(np.log10(eos_vals[1:,0]), np.log10(eos_vals[1:,1]))
-  
-        new_eos_vals = np.zeros((resample_pts, 2))
-        epsilon_range = np.linspace(min(np.log10(eos_vals[1:,0])), max(np.log10(eos_vals[1:,0])), resample_pts)
-        new_eos_vals[:, 0] = 10**epsilon_range 
- 
-        for i in range(0, resample_pts):
-            if verbose == True:
-                print("epsilon", 10**epsilon_range[i])
-
-            new_eos_vals[i,1] = 10**ms.interp_func(epsilon_range[i], np.log10(eos_vals[1:,0]), np.log10(eos_vals[1:,1]), p_of_epsilon)
-
-            if verbose == True:
-                print("p", new_eos_vals[i,1])
-    
-        new_eos_vals = check_monotonicity(new_eos_vals)
-        new_eos_vals = np.vstack((np.array([0.,0.]), new_eos_vals))
-        return new_eos_vals
-
-
-
-def gamma_of_x(x, coeffs):
-        """
-        Eq 6 from https://arxiv.org/pdf/1009.0738.pdf
-        """
-        gamma=0
-        # Equivalent to np.polyval(coeffs[::-1],x)
-        gamma=np.polyval(coeffs[::-1],x)
-        # for i in range(0,len(coeffs)):
-        #     gamma+=coeffs[i]*x**i 
-        gamma=np.exp(gamma)  
-        return gamma
-  
-def mu(x, coeffs):
-        """
-        Eq 8 from https://arxiv.org/pdf/1009.0738.pdf
-        """
-
-
-        # very inefficient: does integration multiple times. Should change to ODE solve
-        if isinstance(x, (list, np.ndarray)):
-            def int_func(dummy,x_prime):
-              return (gamma_of_x(x_prime, coeffs))**(-1)    
-            y = scipy.integrate.odeint(int_func,[0],x,full_output=False).T  # x=0 needs to be value in array
-            return np.exp(-1.*y)
-#            val=np.zeros(len(x))
-#            for i in range(0,len(x)):
-#                tmp=quad(int_func, 0, x[i])
-#                val[i]=tmp[0]  
-#            return np.exp(-1.*val)
-        else:    
-            def int_func(x_prime):
-              return (gamma_of_x(x_prime, coeffs))**(-1)    
-            val=quad(int_func, 0, x)
-
-        return np.exp(-1.*val[0])
-
-def epsilon(x, p0, eps0, coeffs,use_ode=True):
-        """
-        Eq. 7 from https://arxiv.org/pdf/1009.0738.pdf
-        """
-        mu_of_x=mu(x, coeffs)  
-        if use_ode and isinstance(x, (list,np.ndarray)):
-          mu_intp = scipy.interpolate.interp1d(x,mu_of_x,bounds_error=False,fill_value=0)
-          def int_func(dummy,x_prime):
-            num = mu_intp(x_prime)*np.exp(x_prime)
-            denom = gamma_of_x(x_prime, coeffs)
-            return num / denom
-          y= scipy.integrate.odeint(int_func,0,x,full_output=False).T  # x=0 needs to be value in array
-          eps=(eps0*C_CGS**2)/mu_of_x + p0/mu_of_x * y
-          return eps
-        else:
-          def int_func(x_prime):
-            num = mu(x_prime, coeffs)*np.exp(x_prime)
-            denom = gamma_of_x(x_prime, coeffs)
-            return num / denom
-          
-        # very inefficient: does integration multiple times. Should change to ODE solve
-        # Would require lookup interpolation of mu_of_x
-        val=quad(int_func, 0, x)
-        #val=romberg(int_func, 0, x, show=True)   
-        eps=(eps0*C_CGS**2)/mu_of_x + p0/mu_of_x * val[0]
- 
-        return eps
-
-
-
-
-###
-### Utilities
-###
-
-# Les-like
-def make_mr_lambda_lal(eos,n_bins=100):
-    """
-    Construct mass-radius curve from EOS
-    Based on modern code resources (https://git.ligo.org/publications/gw170817/bns-eos/blob/master/scripts/eos-params.py) which access low-level structures
-    """
-    fam=lalsim.CreateSimNeutronStarFamily(eos)
-    max_m = lalsim.SimNeutronStarMaximumMass(fam)/lal.MSUN_SI
-    min_m = lalsim.SimNeutronStarFamMinimumMass(fam)/lal.MSUN_SI
-    mgrid = np.linspace(min_m,max_m, n_bins)
-    mrL_dat = np.zeros((n_bins,3))
-    mrL_dat[:,0] = mgrid
-    for indx in np.arange(n_bins):
-       mass_now = mgrid[indx]
-       r = lalsim.SimNeutronStarRadius(mass_now*lal.MSUN_SI,fam)/1000.
-       mrL_dat[indx,1] = r
-       k = lalsim.SimNeutronStarLoveNumberK2(mass_now*lal.MSUN_SI,fam)
-       c = mass_now * lal.MRSUN_SI / (r*1000.)
-       mrL_dat[indx,2] = (2. / 3.) * k / c**5.
-
-    return mrL_dat
-
-# Rizzo
-def make_mr_lambda(eos,use_lal=False):
-   """
-   construct mass-radius curve from EOS    
-   DOES NOT YET WORK RELIABLY
-   """
-   if use_lal:
-       make_mr_lambda_lal(eos)
-
-   fam=lalsim.CreateSimNeutronStarFamily(eos)
- 
-   r_cut = 40   # Some EOS we consider for PE purposes will have very large radius!
-
-   #set p_nuc max
-   #   - start at a fiducial nuclear density
-   #   - not sure what these termination conditions are designed to do ... generally this pushes to  20 km
-   #   - generally this quantity is the least reliable
-   p_nuc=3.*10**33   # consistent with examples
-   fac_min=0
-   r_fin=0
-   while r_fin > r_cut+8 or r_fin < r_cut:
-       # Generally tries to converge to density corresponding to 20km radius
-      try: 
-         answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_min)*p_nuc, eos)      # r(SI), m(SI), lambda
-      except:
-          # If failure, backoff
-         fac_min=-0.05
-         break 
-      r_fin=answer[0]
-      r_fin=r_fin*10**-3  # convert to SI
-#      print "R: ",r_fin
-      if r_fin<r_cut:
-         fac_min-=0.05
-      elif r_fin>r_cut+8:
-         fac_min+=0.01
-   answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_min)*p_nuc, eos)      # r(SI), m(SI), lambda
-   m_min = answer[1]/lal.MSUN_SI
-
-   #set p_nuc min
-   #   - tries to converge to central pressure corresponding to maximum NS mass
-   #   - very frustrating...this data is embedded in the C code
-   fac_max=1.6
-   r_fin=20.
-   m_ref = lalsim.SimNeutronStarMaximumMass(fam)/lal.MSUN_SI
-   r_ref = lalsim.SimNeutronStarRadius(lalsim.SimNeutronStarMaximumMass(fam), fam)/(10**3)
-   answer=None
-   while r_fin > r_ref  or r_fin < 7:
-       #print "Trying min:"
-#       print "p_c: ",(10**fac_max)*p_nuc
-       try:
-          answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)         
-          if answer[0]*10**-3 < r_ref:
-             break 
-       except:
-          fac_max-=0.05
-          working=False
-          while working==False:
-             try:
-                answer_tmp=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)
-                working=True
-             except:
-                fac_max-=0.05
-          break
-          #print lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)
-       r_fin=answer[0]/10**3 # convert to km
-       if rosDebug:
-           print("R: ",r_fin, r_ref, " M: ", answer[1]/lal.MSUN_SI, m_ref , m_min) # should converge to maximum mass
-       if r_fin>8:
-          fac_max+=0.05
-       if r_fin<6:
-          fac_max-=0.01
-#       print 10**fac_max
-
-   #generate mass-radius curve
-   npts_out = 1000
-   scale=np.logspace(fac_min,fac_max,npts_out)
-   
-   mr_array=np.zeros((npts_out,3))
-   for s,i in zip(scale,range(0,len(scale))):
-#       print s
-       mr_array[i,:]=lalsim.SimNeutronStarTOVODEIntegrate(s*p_nuc, eos)
-      
-   mr_array[:,0]=mr_array[:,0]/10**3 
-   mr_array[:,1]=mr_array[:,1]/lal.MSUN_SI
-   mr_array[:,2]=2./(3*lal.G_SI)*mr_array[:,2]*(mr_array[:,0]*10**3)**5
-   mr_array[:,2]=lal.G_SI*mr_array[:,2]*(1/(mr_array[:,1]*lal.MSUN_SI*lal.G_SI/lal.C_SI**2))**5
-
-#   print mr_array[:,1]
-
-   return mr_array
-
-
-
-def LookupCrustEpsilonAtPressure(p_ref,eosname_lalsuite="SLY4"):
-    """
-    Tool for spectral EOS manager to find epsilon(p) via lookup tables from the lalsuite data files.
-    Units are *CGS*
-    Uses linear interpolation in the log. 
-
-    Warning: lalsuite files use lal units (epsilon, p in 1/m^2), but we will presume p and epsilon are in energy density
-
-    """
-    lal_dat =np.loadtxt(dirLALSimulationBase+"/LALSimNeutronStarEOS_"+ eosname_lalsuite+".dat")
-    lal_dat[:,0]=lal_dat[:,0]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
-    lal_dat[:,1]=lal_dat[:,1]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
-#    lal_dat[:,[0, 1]] = lal_dat[:,[1, 0]]  # reverse order
-    
-    # Interpolate in log
-    lal_dat_log = np.log10(lal_dat)   # note first sample is zero,and causes problems nominally with this interpolation
-    eps_out = np.power(10.,np.interp(np.log10(p_ref),  lal_dat_log[:,0], lal_dat_log[:,1]))
-    return eps_out
-
-
-
-###
-###  EOSSequence : For large sets of EOS we must access simultaneously (100 Mb plus), pretabulated
-# 
-#   These will be a different data structure, where we don't necessariliy provide all the EOSConcrete structures, 
-#   Example: https://zenodo.org/record/6502467#.YulOeaRE1Pw 
-###
-
-
-
-###
-### SERVICE 0: General EOS structure
-###
-
-class EOSSequenceLandry:
-    """
-    Class characterizing a sequence of specific EOS solutions, using the Landry format.
-    Assumes user provides (a) EOS realization, (b) precomputed results from TOV solve; and (c) discrete ID
-
-    PENDING
-       - mMax access
-    """
-
-    def __init__(self,name=None,fname=None,load_eos=False,load_ns=False,oned_order_name=None,oned_order_mass=None,no_sort=True,verbose=False):
-        import h5py
-        self.name=name
-        self.fname=fname
-        self.eos_ids = None
-        self.eos_names = None   # note this array can be SORTED, use the oned_order_indx_original for original order
-        self.eos_tables = None
-        self.eos_ns_tov = None
-        self.oned_order_name = None
-        self.oned_order_mass=oned_order_mass
-        self.oned_order_values=None
-        self.oned_order_indx_original = None
-        self.verbose=verbose
-        with h5py.File(self.fname, 'r') as f:
-            names = list(f['ns'].keys())
-            names = natsorted(names)  # sort them sanely
-            self.eos_ids = list(f['id'])
-            self.eos_names = np.array(names,dtype=str)
-            # The following loads a LOT into memory, as a dictionary
-            if load_ns:
-                if verbose:
-                    print(" EOSSequenceLandry: Loading TOV results for {}".format(fname))
-                # Convert to dictionary, so not closed.  Note this sucks up a lot of i/o time, and ideally we don't close the file
-                self.eos_ns_tov = {}
-                for name in names:
-                    self.eos_ns_tov[name] = np.array(f['ns'][name])
-                if verbose:
-                    print(" EOSSequenceLandry: Completed TOV i/o {}".format(fname))
-                create_order = False
-                if oned_order_name == 'R' or oned_order_name=='r':
-                    create_order=True
-                    self.oned_order_name='R'  # key value in fields
-                if oned_order_name == 'Lambda' or oned_order_name=='lambdda':
-                    create_order=True
-                    self.oned_order_name='Lambda'  # key value in fields
-                if not(self.oned_order_mass):
-                    # Can't order if we don't have a reference mass
-                    create_order=False
-                if create_order:
-                    self.oned_order_indx_original = np.arange(len(self.eos_names))
-                    vals = np.zeros(len(self.eos_names))
-                    if self.oned_order_name =='Lambda':
-                        for indx in np.arange(len(self.eos_names)):
-                            vals[indx] =self.lambda_of_m_indx(self.oned_order_mass,indx)
-                    if self.oned_order_name =='R':
-                        for indx in np.arange(len(self.eos_names)):
-                            vals[indx] =self.R_of_m_indx(self.oned_order_mass,indx)
-
-                    # resort 'names' field with new ordering
-                    # is it actually important to do the sorting?  NO, code should work with original lexographic order, since we only use nearest neighbors!
-                    if no_sort:
-                        self.oned_order_values = vals
-                    else:
-                        indx_sorted = np.argsort(vals)
-                        if verbose: 
-                            print(indx_sorted)
-                        self.eos_names = self.eos_names[indx_sorted]  
-                        self.oned_order_values = vals[indx_sorted]
-                        self.oned_order_indx_original =  self.oned_order_indx_original[indx_sorted]
-
-            if load_eos:
-                self.eos_tables = f['eos']
-        return None
-
-    def m_max_of_indx(self,indx):
-        name = self.eos_names[indx]
-        return np.max(self.eos_ns_tov[name]['M'])
-
-    def lambda_of_m_indx(self,m_Msun,indx):
-        """
-        lambda(m) evaluated for a *single* m_Msun value (almost always), for a specific indexed EOS
-        
-        Generally we assume the value is UNIQUE and associated with a single stable phase
-        """
-        if self.eos_ns_tov is None:
-            raise Exception(" Did not load TOV results ")
-        name = self.eos_names[indx]
-        if self.verbose:
-            print(" Loading from {}".format(name))
-        dat = np.array(self.eos_ns_tov[name])
-        # Sort masses
-        indx_sort = np.argsort(dat["M"])
-        # Interpolate versus m, ASSUME single-valued / no phase transition ! 
-        # Interpolate versus *log lambda*, so it is smoother and more stable
-        valLambda = np.log(dat["Lambda"][indx_sort])
-        valM = dat["M"][indx_sort]
-        return np.exp(np.interp(m_Msun, valM, valLambda))
-
-    def R_of_m_indx(self,m_Msun,indx):
-        """
-        R(m) evaluated for a *single* m_Msun value (almost always), for a specific indexed EOS
-        
-        Generally we assume the value is UNIQUE and associated with a single stable phase; should FIX?
-        """
-        if self.eos_ns_tov is None:
-            raise Exception(" Did not load TOV results ")
-        name = self.eos_names[indx]
-        if self.verbose:
-            print(" Loading from {}".format(name))
-        dat = np.array(self.eos_ns_tov[name])
-        # Sort masses
-        indx_sort = np.argsort(dat["M"])
-        # Interpolate versus m, ASSUME single-valued / no phase transition ! 
-        # Interpolate versus *log lambda*, so it is smoother and more stable
-        valR = np.log(dat["R"][indx_sort])
-        valM = dat["M"][indx_sort]
-        return np.exp(np.interp(m_Msun, valM, valR))
-
-    def mmax_of_indx(self,indx):
-        if self.eos_ns_tov is None:
-            raise Exception(" Did not load TOV results ")
-        name = self.eos_names[indx]
-        if self.verbose:
-            print(" Loading from {}".format(name))
-        
-        return np.max(self.eos_ns_tov[name]['M'])
-
-    def lookup_closest(self,order_val):
-        """
-        Given a proposed ordering statistic value, provides the *index* of the closest value.  Assumes *scalar* input
-        Should be using the fact that this is ordered ... but we are not
-        """
-        if self.eos_ns_tov is None:
-            raise Exception(" Did not load TOV results ")
-        if self.oned_order_values is None:
-            raise Exception(" Did not generate ordering statistic ")
-        
-        return np.argmin( np.abs(order_val - self.oned_order_values))
+#
+#  EOSManager.py 
+#
+# SEE ALSO
+#   - util_WriteXMLWithEOS
+#   - gwemlightcurves.KNTable
+
+# SERIOUS LIMITATIONS
+#   - EOSFromFile  : File i/o for each EOS creation will slow things donw.  This command is VERY trivial, so we should be able
+#          to directly create the structure ourselves, using eos_alloc_tabular
+#           https://github.com/lscsoft/lalsuite/blob/master/lalsimulation/src/LALSimNeutronStarEOSTabular.c
+
+rosDebug=False
+
+import numpy as np
+import os
+import sys
+import lal
+import lalsimulation as lalsim
+from scipy.integrate import quad
+import scipy.interpolate as interp
+import scipy
+
+try:
+    from natsort import natsorted
+except:
+    print(" - no natsorted - ")
+
+#import gwemlightcurves.table as gw_eos_table
+
+#from . import MonotonicSpline as ms
+from RIFT.physics import MonotonicSpline as ms
+
+
+C_CGS=lal.C_SI*100        # Argh, Monica!
+DENSITY_CGS_IN_MSQUARED=7.42591549e-25  # g/cm^3 m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom)
+
+
+def make_compactness_from_lambda_approximate(lambda_vals):
+    """
+    make_compactness_from_lambda_approximate
+    Eq (B1) from https://arxiv.org/pdf/1812.04803.pdf, based on Maselli et al 2013, Yagi and Yunes 2017
+
+    Note this will yield *extreme* compactnesses for poorly-constrained GW observations, as the 'lambda' inferred will be wildly large/prior-dominated
+    """
+
+    return 0.371 -0.0391*np.log(lambda_vals) + 0.001056*np.log(lambda_vals)**2
+
+
+###
+### SERVICE 0: General EOS structure
+###
+
+class EOSConcrete:
+    """
+    Class characterizing a specific EOS solution.  This structure *SHOULD* 
+        - auto-build the mass-radius via a TOV solve
+         - provides ability to query the lambda(m) relationship and (in the future) higher-order multipole moments; etc
+    As many of these features are already provided by lalsimulation, we just front-end them
+    """
+
+    def __init__(self,name=None):
+        self.name=name
+        self.eos = None
+        self.eos_fam = None
+        return None
+
+    def lambda_from_m(self, m):
+        eos_fam = self.eos_fam
+        if m<10**15:
+            m=m*lal.MSUN_SI
+
+        k2=lalsim.SimNeutronStarLoveNumberK2(m, eos_fam)
+        r=lalsim.SimNeutronStarRadius(m, eos_fam)
+
+        m=m*lal.G_SI/lal.C_SI**2
+        lam=2./(3*lal.G_SI)*k2*r**5
+        dimensionless_lam=lal.G_SI*lam*(1/m)**5
+
+        return dimensionless_lam
+
+    def estimate_baryon_mass_from_mg(self,m):
+        """
+        Estimate m_b = m_g + m_g^2/(R_{1.4}/km) based on https://arxiv.org/pdf/1905.03784.pdf Eq. (6)
+        Note baryon mass can be computed exactly with a TOV solution integral (e.g., Eq. 6.21 of Haensel's book)
+             N_b = 4\pi (1+z_{surf}) \int_0^R e^{Phi} (rho + P/c^2)/m_b sqrt(1-2 G m(r)/r c^2)
+        but lalsuite doesn't provide access to this low-level info
+        """
+        r1p4 =lalsim.SimNeutronStarRadius(1.4*lal.MSUN_SI, self.eos_fam)/1e3
+        return m + (1./r1p4)*m**2 #(m/lal.MSUN_SI)
+
+    def pressure_density_on_grid_alternate(self,logrho_grid,enforce_causal=False):
+        """
+        pressure_density_on_grid.
+        Input and output grid units are in SI (rho: kg/m^3; p = N/m^2)
+        Pressure provided by lalsuite (=EOM integration)
+        Density computed by m*n = (epsilon+p)/c^2mn exp(-h), which does NOT rely on lalsuite implementation 
+        """
+        dat_out = np.zeros(len(logrho_grid))
+        fam = self.eos_fam
+        eos = self.eos
+        npts_internal = 10000
+        p_internal = np.zeros(npts_internal)
+        rho_internal = np.zeros(npts_internal)
+        epsilon_internal = np.zeros(npts_internal)
+        hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
+        if enforce_causal:
+            # strip out everything except the causal part.
+            hmax = lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos)
+        h = np.linspace(0.0001,hmax,npts_internal)
+        for indx in np.arange(npts_internal):
+            p_internal[indx] = lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10 to get CGS
+            epsilon_internal[indx] =lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(h[indx],eos)  # SI. Note factor of C^2 needed to get mass density
+            rho_internal[indx] =np.exp(-h[indx])* (epsilon_internal[indx]+p_internal[indx])/(lal.C_SI**2)  # 
+#        print epsilon_internal[10],rho_internal[10], p_internal[10], h[10]
+        logp_of_logrho = interp.interp1d(np.log10(rho_internal),np.log10(p_internal),kind='linear',bounds_error=False,fill_value=np.inf)  # should change to Monica's spline
+ #       print logrho_grid,
+        return logp_of_logrho(logrho_grid)
+
+    def pressure_density_on_grid(self,logrho_grid,reference_pair=None,enforce_causal=False):
+        """ 
+        pressure_density_on_grid.
+        Input and output grid units are in SI (rho: kg/m^3; p = N/m^2)
+        POTENTIAL PROBLEMS OF USING LALSUITE
+            - lalinference_o2 / master: Unless patched, the *rest mass* density is not reliable.  
+              To test with the unpatched LI version, use reference_pair to specify a low-density EOS.
+              This matching is highly suboptimal, so preferably test either (a) a patched code or (b) the alternative code below
+        """
+        dat_out = np.zeros(len(logrho_grid))
+        fam = self.eos_fam
+        eos = self.eos
+        npts_internal = 10000
+        p_internal = np.zeros(npts_internal)
+        rho_internal = np.zeros(npts_internal)
+        hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
+        if enforce_causal:
+            # strip out everything except the causal part.
+            hmax = lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos)
+        h = np.linspace(0.0001,hmax,npts_internal)
+        for indx in np.arange(npts_internal):
+            rho_internal[indx] = lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10^(-3) to get CGS
+            p_internal[indx] = lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10 to get CGS
+        if not (reference_pair is None):
+            indx_match = np.argmin( np.abs(np.log10(p_internal) - np.log10(reference_pair[1]))) # force agreement of densities at target pressure, if requested! Addresses bug /ambiguity in scaling of rest mass estimate; intend to apply in highly nonrelativistic regime
+            delta_rho = np.log10(reference_pair[0]) -np.log10(rho_internal[indx_match]) 
+            rho_internal *= np.power(10, delta_rho)
+#            print  np.log10(np.c_[rho_internal,p_internal])
+        logp_of_logrho = interp.interp1d(np.log10(rho_internal),np.log10(p_internal),kind='linear',bounds_error=False,fill_value=np.inf)  # should change to Monica's spline
+ #       print logrho_grid,
+        return logp_of_logrho(logrho_grid)
+
+    def test_speed_of_sound_causal(self, test_only_under_mmax=True,fast_test=True):
+        """
+        Test if EOS satisfies speed of sound.
+        Relies on low-level lalsimulation interpolation routines to get v(h) and as such is not very reliable
+
+        By DEFAULT, we are testing the part of the EOS that is
+             - at the largest pressure (assuming monotonic sound speed)
+             - associated with the maximum mass NS that is stable
+        We can also test the full table that is provided to us.
+        https://git.ligo.org/lscsoft/lalsuite/blob/lalinference_o2/lalinference/src/LALInference.c#L2513
+        """
+        npts_internal = 1000
+        eos = self.eos
+        fam = self.eos_fam
+        # Largest NS provides largest attained central pressure
+        m_max_SI = self.mMaxMsun*lal.MSUN_SI
+        if not test_only_under_mmax:
+            hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
+        else:
+            try:
+                pmax = lalsim.SimNeutronStarCentralPressure(m_max_SI,fam)  
+                hmax = lalsim.SimNeutronStarEOSPseudoEnthalpyOfPressure(pmax,eos)
+            except:
+                # gatch gsl interpolation errors for example
+                return False  
+        if fast_test: 
+            # https://git.ligo.org/lscsoft/lalsuite/blob/lalinference_o2/lalinference/src/LALInference.c#L2513
+            try:
+                vsmax = lalsim.SimNeutronStarEOSSpeedOfSoundGeometerized(hmax, eos)
+                return vsmax <1.1
+            except:
+                # catch gsl interpolation errors for example
+                return False
+        else:
+            if rosDebug:
+                print(" performing comprehensive test ")
+        h = np.linspace(0.0001,hmax,npts_internal)
+#        h = np.linspace(0.0001,lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos),npts_internal)
+        vs_internal = np.zeros(npts_internal)
+        for indx in np.arange(npts_internal):
+            vs_internal[indx] =  lalsim.SimNeutronStarEOSSpeedOfSoundGeometerized(h[indx],eos)
+            if rosDebug:
+                print(h[indx], vs_internal[indx])
+        return not np.any(vs_internal>1.1)   # allow buffer, so we have some threshold
+
+###
+### SERVICE 1: lalsimutils structure
+###
+#  See https://github.com/lscsoft/lalsuite/tree/master/lalsimulation/src for available types
+class EOSLALSimulation(EOSConcrete):
+    def __init__(self,name):
+        self.name=name
+        self.eos = None
+        self.eos_fam = None
+        self.mMaxMsun=None
+
+
+        eos = lalsim.SimNeutronStarEOSByName(name)
+        fam = lalsim.CreateSimNeutronStarFamily(eos)
+        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
+        self.eos = eos
+        self.eos_fam = fam
+        self.mMaxMsun = mmass
+        return None
+
+
+
+
+
+###
+### SERVICE 2: EOSFromFile
+###
+
+# Example directory: EOS_Tables
+#dirEOSTablesBase = os.environ["EOS_TABLES"]
+dirLALSimulationBase = os.environ["LALSIMULATION_DATADIR"]  # LAL table data
+## Add routines to find, parse standard directory of EOS files and load suitable metadata into memory
+## Follow framework of NRWaveformCatalogManager3
+
+
+class EOSFromTabularData(EOSConcrete):
+    """ 
+    Input: 
+       * Tabular data (baryon_density = n , pressure = p, energy density = \rho)
+       * method for primitives: this information is partially redundant, in that \ln n_b/n_ref = \int   c^2 [d rho] / (P(rho) + rho c^2), etc
+          Need some specific choice for inter-edge interpolation (and redundance resolution) 
+       * Low-density approximation (if desired) for filling down to surface density.  
+           WARNING: Will generally match imperfectly, need some resolution to that procedure
+    Creates
+        * LALSimulation data structure as desired
+    Warning: 
+        * Currently generates intermediate data file by writing to disk
+    """
+
+    def __init__(self,name=None,eos_data=None,eos_units=None,reject_phase_transitions=True,debug=False, add_low_density=False):
+        eos_name = name
+        if not(eos_data):
+            raise Exception("EOS data required to use EOSFromTabularData")
+        if not(name):
+            eos_name="default"
+
+        # Assume CGS for now
+        bdens = eos_data["baryon_density"]
+        press = eos_data["pressure"]
+        edens = eos_data["energy_density"]
+
+        # Convert to 
+        press *= DENSITY_CGS_IN_MSQUARED
+        edens *= DENSITY_CGS_IN_MSQUARED
+        
+        if reject_phase_transitions:   # Normally lalsuite can't handle regions of constant pressure. Using a pressure/density only approach isn't suited to phase transitions
+            if not np.all(np.diff(press) > 0):    # BLOCKS PHASE TRANSITIONS
+                keep_idx = np.where(np.diff(press) > 0)[0] + 1
+                keep_idx = np.concatenate(([0], keep_idx))
+                press = press[keep_idx]
+                edens = edens[keep_idx]
+            assert np.all(np.diff(press) > 0)
+            if not np.all(np.diff(edens) > 0):
+                keep_idx = np.where(np.diff(edens) > 0)[0] + 1
+                keep_idx = np.concatenate(([0], keep_idx))
+                press = press[keep_idx]
+                edens = edens[keep_idx]
+            assert np.all(np.diff(edens) > 0)
+    
+        # Create temporary file
+        # Creating temporary file in suitable units
+        if debug:
+                print("Dumping to %s" % self.fname)
+        eos_fname = "./" +eos_name + "_geom.dat" # assume write acces
+        np.savetxt(eos_fname, np.transpose((press, edens)), delimiter='\t')
+        eos = lalsim.SimNeutronStarEOSFromFile(eos_fname)
+        fam = lalsim.CreateSimNeutronStarFamily(eos)
+
+        self.name = eos_name
+        self.eos =eos
+        self.eos_family =fam
+        return None
+
+
+
+class EOSFromDataFileOriginal(EOSConcrete):
+    """ 
+    REWRITE THIS TO CALL CLASS ABOVE, and use modern interpolation
+    FromDataFileEquationOfState
+    (just accepts filename...not attempting to parse a catalog)
+    
+    """
+    def __init__(self,name=None,fname=None):
+        self.name=name
+        self.fname=fname
+        self.eos = None
+        self.eos_fam = None
+        self.mMax = None
+
+        self.eos, self.eos_fam = self.eos_ls()
+        return None
+
+    def eos_ls(self):
+        # From Monica, but using code from GWEMLightcurves
+        #  https://gwemlightcurves.github.io/_modules/gwemlightcurves/KNModels/table.html
+        """
+        EOS tables described by Ozel `here <https://arxiv.org/pdf/1603.02698.pdf>`_ and downloadable `here <http://xtreme.as.arizona.edu/NeutronStars/data/eos_tables.tar>`_. LALSim utilizes this tables, but needs some interfacing (i.e. conversion to SI units, and conversion from non monotonic to monotonic pressure density tables)
+    """
+        obs_max_mass = 2.01 - 0.04  # used
+        print("Checking %s" % self.name)
+        eos_fname = ""
+        if os.path.exists(self.fname):
+            # NOTE: Adapted from code by Monica Rizzo
+            print("Loading from %s" % self.fname)
+            bdens, press, edens = np.loadtxt(self.fname, unpack=True)
+            press *= DENSITY_CGS_IN_MSQUARED
+            edens *= DENSITY_CGS_IN_MSQUARED
+            eos_name = self.name
+
+            if not np.all(np.diff(press) > 0):    # BLOCKS PHASE TRANSITIONS
+                keep_idx = np.where(np.diff(press) > 0)[0] + 1
+                keep_idx = np.concatenate(([0], keep_idx))
+                press = press[keep_idx]
+                edens = edens[keep_idx]
+            assert np.all(np.diff(press) > 0)
+            if not np.all(np.diff(edens) > 0):
+                keep_idx = np.where(np.diff(edens) > 0)[0] + 1
+                keep_idx = np.concatenate(([0], keep_idx))
+                press = press[keep_idx]
+                edens = edens[keep_idx]
+            assert np.all(np.diff(edens) > 0)
+
+            # Creating temporary file in suitable units
+            print("Dumping to %s" % self.fname)
+            eos_fname = "./" +eos_name + "_geom.dat" # assume write acces
+            np.savetxt(eos_fname, np.transpose((press, edens)), delimiter='\t')
+            eos = lalsim.SimNeutronStarEOSFromFile(eos_fname)
+            fam = lalsim.CreateSimNeutronStarFamily(eos)
+
+        else:
+            print(" No such file ", self.fname)
+            sys.exit(0)
+
+        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
+        self.mMaxMsun = mmass
+        return eos, fam
+
+    def p_rho_arrays(self):
+        print(self.fname)
+        dat_file = np.array(np.loadtxt(self.fname))
+        nb=dat_file[:,0]
+        p=dat_file[:,1]
+        rho=dat_file[:,2] 
+        return nb,p,rho
+    def interp_eos_p_of_rho(self):
+        nb,p,rho=self.p_rho_arrays()
+        n=len(p)
+        p=np.log10(p)
+        rho=np.log10(rho)
+        consts=ms.interpolate(rho,p)
+        line_const=ms.lin_extrapolate(rho,p)
+        #linearly interpolate anything outside range
+        line_lower=line_const[0,:]
+        line_upper=line_const[1,:]
+        return consts,line_upper,line_lower
+
+   #interpolates Log10 of data
+    def interp_eos_rho_of_p(self):
+        nb,p,rho=self.p_rho_arrays()
+        n=len(p)
+        p=np.log10(p)
+        rho=np.log10(rho)
+        consts=ms.interpolate(p,rho)  
+        line_const=ms.lin_extrapolate(p,rho)
+       #linearly interpolate anything outside range
+        line_lower=line_const[0,:]
+        line_upper=line_const[1,:]
+        return consts,line_upper,line_lower
+    def interp_eos_nb_of_p(model_name):
+        nb,p,rho=self.p_rho_arrays()
+        n=len(p)
+        p=np.log10(p)
+        nb=np.log10(nb)
+        consts=ms.interpolate(p,nb)
+        line_const=ms.lin_extrapolate(p,nb)
+        #linearly interpolate anything outside range
+        line_lower=line_const[0,:]
+        line_upper=line_const[1,:]
+        return consts,line_upper,line_lower
+
+
+
+
+
+###
+### SERVICE 2: Parameterized EOS (specify functions)
+###
+
+# COMMON POLYTROPE TABLE
+# eos logP1 gamma1 gamma2 gamma3
+# PAL6 34.380 2.227 2.189 2.159 
+# SLy 34.384 3.005 2.988 2.851 
+# AP1 33.943 2.442 3.256 2.908 
+# AP2 34.126 2.643 3.014 2.945
+# AP3 34.392 3.166 3.573 3.281  
+# AP4 34.269 2.830 3.445 3.348 
+# FPS 34.283 2.985 2.863 2.600 
+# WFF1 34.031 2.519 3.791 3.660 
+# WFF2 34.233 2.888 3.475 3.517  
+# WFF3 34.283 3.329 2.952 2.589  
+# BBB2 34.331 3.418 2.835 2.832 
+# BPAL12 34.358 2.209 2.201 2.176 
+# ENG 34.437 3.514 3.130 3.168 
+# MPA1 34.495 3.446 3.572 2.887 
+# MS1 34.858 3.224 3.033 1.325 
+# MS2 34.605 2.447 2.184 1.855 
+# MS1b 34.855 3.456 3.011 1.425 
+# PS 34.671 2.216 1.640 2.365 
+# GS1 34.504 2.350 1.267 2.421 
+# GS2 34.642 2.519 1.571 2.314 
+# BGN1H1 34.623 3.258 1.472 2.464 
+# GNH3 34.648 2.664 2.194 2.304 
+# H1 34.564 2.595 1.845 1.897
+# H2 34.617 2.775 1.855 1.858
+# H3 34.646 2.787 1.951 1.901
+# H4 34.669 2.909 2.246 2.144
+# H5 34.609 2.793 1.974 1.915
+# H6 34.593 2.637 2.121 2.064
+# H7 34.559 2.621 2.048 2.006
+# PCL2 34.507 2.554 1.880 1.977 
+# ALF1 34.055 2.013 3.389 2.033 
+# ALF2 34.616 4.070 2.411 1.890 
+# ALF3 34.283 2.883 2.653 1.952 
+# ALF4 34.314 3.009 3.438 1.803
+
+# Rizzo code: EOS_param.py
+class EOSPiecewisePolytrope(EOSConcrete):
+    def __init__(self,name,param_dict=None):
+        self.name=name
+        self.eos = None
+        self.eos_fam = None
+        self.mMaxMsun=None
+
+
+        eos=self.eos=lalsim.SimNeutronStarEOS4ParameterPiecewisePolytrope(param_dict['logP1'], param_dict['gamma1'], param_dict['gamma2'], param_dict['gamma3'])
+        eos_fam=self.eos_fam=lalsim.CreateSimNeutronStarFamily(eos)
+        self.mMaxMsun = lalsim.SimNeutronStarMaximumMass(eos_fam) / lal.MSUN_SI
+
+        return None
+
+######################################################################
+########################## Spectral Lindblom #########################
+######################################################################
+
+class EOSLindblomSpectral(EOSConcrete):
+    def __init__(self,name=None,spec_params=None,verbose=False,use_lal_spec_eos=False):
+        if name is None:
+            self.name = 'spectral'
+        else:
+            self.name=name
+        self.eos = None
+        self.eos_fam = None
+
+        self.spec_params = spec_params
+#        print spec_params
+
+        if use_lal_spec_eos:
+#            self.eos=lalsim.SimNeutronStarEOS4ParameterSpectralDecomposition(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'])   # Should have this function! but only on master
+            self.eos=lalsim.SimNeutronStarEOSSpectralDecomposition_for_plot(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'],4)
+        else:
+            # Create data file
+            self.make_spec_param_eos(500,save_dat=True,ligo_units=True,verbose=verbose)
+            # Use data file
+            #print " Trying to load ",name+"_geom.dat"
+            import os; #print os.listdir('.')
+            cwd = os.getcwd()
+            self.eos=eos = lalsim.SimNeutronStarEOSFromFile(cwd+"/"+name+"_geom.dat")
+        self.eos_fam = fam=lalsim.CreateSimNeutronStarFamily(self.eos)
+        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
+        self.mMaxMsun = mmass
+
+        return None
+
+    def test_bounded_adiabatic_index(self,bounds=[0.6,4.5]):
+        """
+        Gamma(p) \in bounds
+        Uses xmax and other parameters from spectral result
+        """
+        spec_params =self.spec_params
+        if not 'gamma3' in spec_params:
+            spec_params['gamma3']=spec_params['gamma4']=0
+        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
+        xmax = self.spec_params['xmax']
+        xvals = np.linspace(0,xmax,500)
+        gamma_vals = gamma_of_x(xvals, coefficients)
+        if rosDebug:
+            print("  Spectral EOS debug test limits: Gamma bounds", np.min(gamma_vals), np.max(gamma_vals))
+        return  not( np.any(gamma_vals < bounds[0]) or np.any(gamma_vals>bounds[1]) )
+            
+
+    def make_spec_param_eos(self, npts=500, plot=False, verbose=False, save_dat=False,ligo_units=False,interpolate=False,eosname_lalsuite="SLY4"):
+        """
+        Load values from table of spectral parameterization values
+        Table values taken from https://arxiv.org/pdf/1009.0738.pdf
+        Comments:
+            - eos_vals is recorded as *pressure,density* pairs, because the spectral representation is for energy density vs pressure
+            - units swap between geometric and CGS
+            - eosname_lalsuite is used for the low-density EOS
+        """
+
+        spec_params = self.spec_params
+        if not 'gamma3' in spec_params:
+            spec_params['gamma3']=spec_params['gamma4']=0
+        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
+        p0=spec_params['p0']
+        eps0=spec_params['epsilon0']
+        xmax=spec_params['xmax'] 
+
+        x_range=np.linspace(0,xmax,npts)
+        p_range=p0*np.exp(x_range)
+        
+        eos_vals=np.zeros((npts,2))
+        eos_vals[:,1]=p_range
+
+        eos_vals[:,0] = epsilon(x_range,p0,eps0, coefficients)
+        # for i in range(0, len(x_range)):
+        #    eos_vals[i,0]=epsilon(x_range[i], p0, eps0, coefficients)
+        #    if verbose==True:
+        #        print "x:",x_range[i],"p:",p_range[i],"p0",p0,"epsilon:",eos_vals[i,0]
+  
+    #doing as those before me have done and using SLY4 as low density region
+        # THIS MUST BE FIXED TO USE STANDARD LALSUITE ACCESS, do not assume the file exists
+#        low_density=np.loadtxt(dirEOSTablesBase+"/LALSimNeutronStarEOS_SLY4.dat")
+        low_density = np.loadtxt(dirLALSimulationBase+"/LALSimNeutronStarEOS_"+ eosname_lalsuite+".dat")
+        low_density[:,0]=low_density[:,0]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
+        low_density[:,1]=low_density[:,1]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
+        low_density[:,[0, 1]] = low_density[:,[1, 0]]  # reverse order
+
+        cutoff=eos_vals[0,:]   
+        if verbose:
+            print(" cutoff ", cutoff)
+ 
+        break_pt=0
+        for i in range(0, len(low_density)):
+            if low_density[i,0] > cutoff[0] or low_density[i,1] > cutoff[1]:   
+                break_pt=i
+                break 
+    
+        eos_vals=np.vstack((low_density[0:break_pt,:], eos_vals)) 
+
+        if not interpolate:
+#            print eos_vals
+            if ligo_units:
+                eos_vals *= DENSITY_CGS_IN_MSQUARED/(C_CGS**2)  # converts to geometric units: first convert from cgs energy density to g/cm^2, then to 1/m^2.
+ #               print " Rescaled "
+#                print eos_vals
+            
+            if save_dat == True:
+                np.savetxt(self.name+"_geom.dat", eos_vals[:,[1,0]])  #NOTE ORDER
+
+            return eos_vals
+        
+        # Optional: interpolate in the log, to generate a denser EOS model
+        # Will produce better M(R) models for LAL
+        p_of_epsilon = ms.interpolate(np.log10(eos_vals[1:,0]), np.log10(eos_vals[1:,1]))
+  
+        new_eos_vals = np.zeros((resample_pts, 2))
+        epsilon_range = np.linspace(min(np.log10(eos_vals[1:,0])), max(np.log10(eos_vals[1:,0])), resample_pts)
+        new_eos_vals[:, 0] = 10**epsilon_range 
+ 
+        for i in range(0, resample_pts):
+            if verbose == True:
+                print("epsilon", 10**epsilon_range[i])
+
+            new_eos_vals[i,1] = 10**ms.interp_func(epsilon_range[i], np.log10(eos_vals[1:,0]), np.log10(eos_vals[1:,1]), p_of_epsilon)
+
+            if verbose == True:
+                print("p", new_eos_vals[i,1])
+    
+        new_eos_vals = check_monotonicity(new_eos_vals)
+        new_eos_vals = np.vstack((np.array([0.,0.]), new_eos_vals))
+        return new_eos_vals
+
+
+######################################################################
+###################### CAUSAL Spectral Lindblom ######################
+######################################################################
+
+class EOSLindblomSpectralSoundSpeedVersusPressure(EOSConcrete):
+    """
+    Based on https://journals.aps.org/prd/abstract/10.1103/PhysRevD.105.063031  <-> https://arxiv.org/pdf/2202.12285.pdf
+    
+    EOS spectral representation of sound speed versus pressure, as expansion of Upsilon(p): see Eq. (11).
+    Uses function call to lalsuite to implement low-level interface
+    
+    """
+    def __init__(self,name=None,spec_params=None,verbose=False,use_lal_spec_eos=True):
+        if name is None:
+            self.name = 'spectral'
+        else:
+            self.name=name
+        self.eos = None
+        self.eos_fam = None
+
+        self.spec_params = spec_params
+#        print spec_params
+
+        if use_lal_spec_eos:
+            self.eos = lalsim.SimNeutronStarEOS4ParamCausalSpectralDecomposition(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'])
+        else:
+            # Create data file
+            self.make_spec_param_eos(500,save_dat=True,ligo_units=True,verbose=verbose)
+            # Use data file
+            #print " Trying to load ",name+"_geom.dat"
+            import os; #print os.listdir('.')
+            cwd = os.getcwd()
+            self.eos=eos = lalsim.SimNeutronStarEOSFromFile(cwd+"/"+name+"_geom.dat")
+        self.eos_fam = fam=lalsim.CreateSimNeutronStarFamily(self.eos)
+        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
+        self.mMaxMsun = mmass
+
+        return None
+    
+    def make_spec_param_eos(self, xvar='energy_density', yvar='pressure',npts=500, plot=False, verbose=False, save_dat=False,ligo_units=False,interpolate=False,eosname_lalsuite="SLY4"):
+        """
+        Load values from table of spectral parameterization values
+        from separate calculations.
+        Comments:
+            - eos_vals is recorded as *pressure,density* pairs, because the spectral representation is for energy density vs pressure
+            - units swap between geometric and CGS
+            - eosname_lalsuite is used for the low-density EOS
+        """
+        spec_params = self.spec_params
+        if not 'gamma3' in spec_params:
+            spec_params['gamma3']=spec_params['gamma4']=0
+        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
+        
+        try :
+            eos = lalsim.SimNeutronStarEOS4ParamCausalSpectralDecomposition(coefficients[0],coefficients[1],coefficients[2],coefficients[3])
+        except:
+            raise Exception(" Did not load LALSimulation with Causal Spectral parameterization.")
+        
+        
+        maxenthalpy = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
+        #minenthalpy = lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos)
+        enthalpy_index = 0.005
+        enthalpy, rho, epsilon, press, speed = [], [], [], [], []
+        
+        while enthalpy_index < maxenthalpy:
+            rho.append(lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(enthalpy_index, eos)*.001)  # g cm^-3
+            epsilon.append(lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(enthalpy_index, eos)*10/(lal.C_SI*100)**2)  # J m^-3 *10/c^2 = g cm^-3
+            press.append(lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(enthalpy_index, eos)*10)    # dyn cm^-2 ~ g cm^-1 s^-2
+            speed.append(lalsim.SimNeutronStarEOSSpeedOfSound(enthalpy_index,eos)*100)
+            enthalpy.append(enthalpy_index)
+            enthalpy_index = enthalpy_index*1.01
+        
+        enthalpy, rho, epsilon, press, speed  = np.array(enthalpy), np.array(rho), np.array(epsilon), np.array(press), np.array(speed)
+        
+        new_eos_vals = np.column_stack((epsilon, press)) # CGS units
+        
+        extraction_dict_lalsim_raw = {
+            'pseudo_enthalpy': enthalpy,
+            'rest_mass_density': rho,  # g cm^-3
+            'baryon_density': rho/(lal.AMU_SI*1e3),  #  cm^-3
+            'pressure': press,    # dyn cm^-2 ~ g cm^-1 s^-2
+            'energy_density': epsilon, # J m^-3 *10/c^2 = g cm^-3
+            'sound_speed_over_c': speed/(lal.C_SI*100)    # [c]
+            }
+        
+        new_eos_vals = np.column_stack((extraction_dict_lalsim_raw[xvar], extraction_dict_lalsim_raw[yvar])) # CGS units
+        
+        
+        return new_eos_vals
+
+
+
+def gamma_of_x(x, coeffs):
+        """
+        Eq 6 from https://arxiv.org/pdf/1009.0738.pdf
+        """
+        gamma=0
+        # Equivalent to np.polyval(coeffs[::-1],x)
+        gamma=np.polyval(coeffs[::-1],x)
+        # for i in range(0,len(coeffs)):
+        #     gamma+=coeffs[i]*x**i 
+        gamma=np.exp(gamma)  
+        return gamma
+
+def mu(x, coeffs):
+        """
+        Eq 8 from https://arxiv.org/pdf/1009.0738.pdf
+        """
+        # very inefficient: does integration multiple times. Should change to ODE solve
+        
+        if isinstance(x, (list, np.ndarray)):
+            def int_func(dummy,x_prime):
+              return (gamma_of_x(x_prime, coeffs))**(-1)    
+            y = scipy.integrate.odeint(int_func,[0],x,full_output=False).T  # x=0 needs to be value in array
+            return np.exp(-1.*y)
+#            val=np.zeros(len(x))
+#            for i in range(0,len(x)):
+#                tmp=quad(int_func, 0, x[i])
+#                val[i]=tmp[0]  
+#            return np.exp(-1.*val)
+        else:
+            def int_func(x_prime):
+              return (gamma_of_x(x_prime, coeffs))**(-1)    
+            val=quad(int_func, 0, x)
+
+        return np.exp(-1.*val[0])
+
+def epsilon(x, p0, eps0, coeffs,use_ode=True):
+        """
+        Eq. 7 from https://arxiv.org/pdf/1009.0738.pdf
+        """
+        mu_of_x=mu(x, coeffs)  
+        if use_ode and isinstance(x, (list,np.ndarray)):
+          mu_intp = scipy.interpolate.interp1d(x,mu_of_x,bounds_error=False,fill_value=0)
+          def int_func(dummy,x_prime):
+            num = mu_intp(x_prime)*np.exp(x_prime)
+            denom = gamma_of_x(x_prime, coeffs)
+            return num / denom
+          y= scipy.integrate.odeint(int_func,0,x,full_output=False).T  # x=0 needs to be value in array
+          eps=(eps0*C_CGS**2)/mu_of_x + p0/mu_of_x * y
+          return eps
+        else:
+          def int_func(x_prime):
+            num = mu(x_prime, coeffs)*np.exp(x_prime)
+            denom = gamma_of_x(x_prime, coeffs)
+            return num / denom
+        
+        # very inefficient: does integration multiple times. Should change to ODE solve
+        # Would require lookup interpolation of mu_of_x
+        val=quad(int_func, 0, x)
+        #val=romberg(int_func, 0, x, show=True)   
+        eps=(eps0*C_CGS**2)/mu_of_x + p0/mu_of_x * val[0]
+ 
+        return eps
+
+
+
+
+###
+### Utilities
+###
+
+# Les-like
+def make_mr_lambda_lal(eos,n_bins=100):
+    """
+    Construct mass-radius curve from EOS
+    Based on modern code resources (https://git.ligo.org/publications/gw170817/bns-eos/blob/master/scripts/eos-params.py) which access low-level structures
+    """
+    fam=lalsim.CreateSimNeutronStarFamily(eos)
+    max_m = lalsim.SimNeutronStarMaximumMass(fam)/lal.MSUN_SI
+    min_m = lalsim.SimNeutronStarFamMinimumMass(fam)/lal.MSUN_SI
+    mgrid = np.linspace(min_m,max_m, n_bins)
+    mrL_dat = np.zeros((n_bins,3))
+    mrL_dat[:,0] = mgrid
+    for indx in np.arange(n_bins):
+       mass_now = mgrid[indx]
+       r = lalsim.SimNeutronStarRadius(mass_now*lal.MSUN_SI,fam)/1000.
+       mrL_dat[indx,1] = r
+       k = lalsim.SimNeutronStarLoveNumberK2(mass_now*lal.MSUN_SI,fam)
+       c = mass_now * lal.MRSUN_SI / (r*1000.)
+       mrL_dat[indx,2] = (2. / 3.) * k / c**5.
+
+    return mrL_dat
+
+# Rizzo
+def make_mr_lambda(eos,use_lal=False):
+   """
+   construct mass-radius curve from EOS    
+   DOES NOT YET WORK RELIABLY
+   """
+   if use_lal:
+       make_mr_lambda_lal(eos)
+
+   fam=lalsim.CreateSimNeutronStarFamily(eos)
+ 
+   r_cut = 40   # Some EOS we consider for PE purposes will have very large radius!
+
+   #set p_nuc max
+   #   - start at a fiducial nuclear density
+   #   - not sure what these termination conditions are designed to do ... generally this pushes to  20 km
+   #   - generally this quantity is the least reliable
+   p_nuc=3.*10**33   # consistent with examples
+   fac_min=0
+   r_fin=0
+   while r_fin > r_cut+8 or r_fin < r_cut:
+       # Generally tries to converge to density corresponding to 20km radius
+      try: 
+         answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_min)*p_nuc, eos)      # r(SI), m(SI), lambda
+      except:
+          # If failure, backoff
+         fac_min=-0.05
+         break 
+      r_fin=answer[0]
+      r_fin=r_fin*10**-3  # convert to SI
+#      print "R: ",r_fin
+      if r_fin<r_cut:
+         fac_min-=0.05
+      elif r_fin>r_cut+8:
+         fac_min+=0.01
+   answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_min)*p_nuc, eos)      # r(SI), m(SI), lambda
+   m_min = answer[1]/lal.MSUN_SI
+
+   #set p_nuc min
+   #   - tries to converge to central pressure corresponding to maximum NS mass
+   #   - very frustrating...this data is embedded in the C code
+   fac_max=1.6
+   r_fin=20.
+   m_ref = lalsim.SimNeutronStarMaximumMass(fam)/lal.MSUN_SI
+   r_ref = lalsim.SimNeutronStarRadius(lalsim.SimNeutronStarMaximumMass(fam), fam)/(10**3)
+   answer=None
+   while r_fin > r_ref  or r_fin < 7:
+       #print "Trying min:"
+#       print "p_c: ",(10**fac_max)*p_nuc
+       try:
+          answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)         
+          if answer[0]*10**-3 < r_ref:
+             break 
+       except:
+          fac_max-=0.05
+          working=False
+          while working==False:
+             try:
+                answer_tmp=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)
+                working=True
+             except:
+                fac_max-=0.05
+          break
+          #print lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)
+       r_fin=answer[0]/10**3 # convert to km
+       if rosDebug:
+           print("R: ",r_fin, r_ref, " M: ", answer[1]/lal.MSUN_SI, m_ref , m_min) # should converge to maximum mass
+       if r_fin>8:
+          fac_max+=0.05
+       if r_fin<6:
+          fac_max-=0.01
+#       print 10**fac_max
+
+   #generate mass-radius curve
+   npts_out = 1000
+   scale=np.logspace(fac_min,fac_max,npts_out)
+   
+   mr_array=np.zeros((npts_out,3))
+   for s,i in zip(scale,range(0,len(scale))):
+#       print s
+       mr_array[i,:]=lalsim.SimNeutronStarTOVODEIntegrate(s*p_nuc, eos)
+      
+   mr_array[:,0]=mr_array[:,0]/10**3 
+   mr_array[:,1]=mr_array[:,1]/lal.MSUN_SI
+   mr_array[:,2]=2./(3*lal.G_SI)*mr_array[:,2]*(mr_array[:,0]*10**3)**5
+   mr_array[:,2]=lal.G_SI*mr_array[:,2]*(1/(mr_array[:,1]*lal.MSUN_SI*lal.G_SI/lal.C_SI**2))**5
+
+#   print mr_array[:,1]
+
+   return mr_array
+
+
+
+def LookupCrustEpsilonAtPressure(p_ref,eosname_lalsuite="SLY4"):
+    """
+    Tool for spectral EOS manager to find epsilon(p) via lookup tables from the lalsuite data files.
+    Units are *CGS*
+    Uses linear interpolation in the log. 
+
+    Warning: lalsuite files use lal units (epsilon, p in 1/m^2), but we will presume p and epsilon are in energy density
+
+    """
+    lal_dat =np.loadtxt(dirLALSimulationBase+"/LALSimNeutronStarEOS_"+ eosname_lalsuite+".dat")
+    lal_dat[:,0]=lal_dat[:,0]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
+    lal_dat[:,1]=lal_dat[:,1]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
+#    lal_dat[:,[0, 1]] = lal_dat[:,[1, 0]]  # reverse order
+    
+    # Interpolate in log
+    lal_dat_log = np.log10(lal_dat)   # note first sample is zero,and causes problems nominally with this interpolation
+    eps_out = np.power(10.,np.interp(np.log10(p_ref),  lal_dat_log[:,0], lal_dat_log[:,1]))
+    return eps_out
+
+
+
+###
+###  EOSSequence : For large sets of EOS we must access simultaneously (100 Mb plus), pretabulated
+# 
+#   These will be a different data structure, where we don't necessariliy provide all the EOSConcrete structures, 
+#   Example: https://zenodo.org/record/6502467#.YulOeaRE1Pw 
+###
+
+
+
+###
+### SERVICE 0: General EOS structure
+###
+
+class EOSSequenceLandry:
+    """
+    Class characterizing a sequence of specific EOS solutions, using the Landry format.
+    Assumes user provides (a) EOS realization, (b) precomputed results from TOV solve; and (c) discrete ID
+
+    PENDING
+       - mMax access
+    """
+
+    def __init__(self,name=None,fname=None,load_eos=False,load_ns=False,oned_order_name=None,oned_order_mass=None,no_sort=True,verbose=False):
+        import h5py
+        self.name=name
+        self.fname=fname
+        self.eos_ids = None
+        self.eos_names = None   # note this array can be SORTED, use the oned_order_indx_original for original order
+        self.eos_tables = None
+        self.eos_ns_tov = None
+        self.oned_order_name = None
+        self.oned_order_mass=oned_order_mass
+        self.oned_order_values=None
+        self.oned_order_indx_original = None
+        self.verbose=verbose
+        with h5py.File(self.fname, 'r') as f:
+            names = list(f['ns'].keys())
+            names = natsorted(names)  # sort them sanely
+            self.eos_ids = list(f['id'])
+            self.eos_names = np.array(names,dtype=str)
+            # The following loads a LOT into memory, as a dictionary
+            if load_ns:
+                if verbose:
+                    print(" EOSSequenceLandry: Loading TOV results for {}".format(fname))
+                # Convert to dictionary, so not closed.  Note this sucks up a lot of i/o time, and ideally we don't close the file
+                self.eos_ns_tov = {}
+                for name in names:
+                    self.eos_ns_tov[name] = np.array(f['ns'][name])
+                if verbose:
+                    print(" EOSSequenceLandry: Completed TOV i/o {}".format(fname))
+                create_order = False
+                if oned_order_name == 'R' or oned_order_name=='r':
+                    create_order=True
+                    self.oned_order_name='R'  # key value in fields
+                if oned_order_name == 'Lambda' or oned_order_name=='lambdda':
+                    create_order=True
+                    self.oned_order_name='Lambda'  # key value in fields
+                if not(self.oned_order_mass):
+                    # Can't order if we don't have a reference mass
+                    create_order=False
+                if create_order:
+                    self.oned_order_indx_original = np.arange(len(self.eos_names))
+                    vals = np.zeros(len(self.eos_names))
+                    if self.oned_order_name =='Lambda':
+                        for indx in np.arange(len(self.eos_names)):
+                            vals[indx] =self.lambda_of_m_indx(self.oned_order_mass,indx)
+                    if self.oned_order_name =='R':
+                        for indx in np.arange(len(self.eos_names)):
+                            vals[indx] =self.R_of_m_indx(self.oned_order_mass,indx)
+
+                    # resort 'names' field with new ordering
+                    # is it actually important to do the sorting?  NO, code should work with original lexographic order, since we only use nearest neighbors!
+                    if no_sort:
+                        self.oned_order_values = vals
+                    else:
+                        indx_sorted = np.argsort(vals)
+                        if verbose: 
+                            print(indx_sorted)
+                        self.eos_names = self.eos_names[indx_sorted]  
+                        self.oned_order_values = vals[indx_sorted]
+                        self.oned_order_indx_original =  self.oned_order_indx_original[indx_sorted]
+
+            if load_eos:
+                self.eos_tables = f['eos']
+        return None
+
+    def m_max_of_indx(self,indx):
+        name = self.eos_names[indx]
+        return np.max(self.eos_ns_tov[name]['M'])
+
+    def lambda_of_m_indx(self,m_Msun,indx):
+        """
+        lambda(m) evaluated for a *single* m_Msun value (almost always), for a specific indexed EOS
+        
+        Generally we assume the value is UNIQUE and associated with a single stable phase
+        """
+        if self.eos_ns_tov is None:
+            raise Exception(" Did not load TOV results ")
+        name = self.eos_names[indx]
+        if self.verbose:
+            print(" Loading from {}".format(name))
+        dat = np.array(self.eos_ns_tov[name])
+        # Sort masses
+        indx_sort = np.argsort(dat["M"])
+        # Interpolate versus m, ASSUME single-valued / no phase transition ! 
+        # Interpolate versus *log lambda*, so it is smoother and more stable
+        valLambda = np.log(dat["Lambda"][indx_sort])
+        valM = dat["M"][indx_sort]
+        return np.exp(np.interp(m_Msun, valM, valLambda))
+
+    def R_of_m_indx(self,m_Msun,indx):
+        """
+        R(m) evaluated for a *single* m_Msun value (almost always), for a specific indexed EOS
+        
+        Generally we assume the value is UNIQUE and associated with a single stable phase; should FIX?
+        """
+        if self.eos_ns_tov is None:
+            raise Exception(" Did not load TOV results ")
+        name = self.eos_names[indx]
+        if self.verbose:
+            print(" Loading from {}".format(name))
+        dat = np.array(self.eos_ns_tov[name])
+        # Sort masses
+        indx_sort = np.argsort(dat["M"])
+        # Interpolate versus m, ASSUME single-valued / no phase transition ! 
+        # Interpolate versus *log lambda*, so it is smoother and more stable
+        valR = np.log(dat["R"][indx_sort])
+        valM = dat["M"][indx_sort]
+        return np.exp(np.interp(m_Msun, valM, valR))
+
+    def mmax_of_indx(self,indx):
+        if self.eos_ns_tov is None:
+            raise Exception(" Did not load TOV results ")
+        name = self.eos_names[indx]
+        if self.verbose:
+            print(" Loading from {}".format(name))
+        
+        return np.max(self.eos_ns_tov[name]['M'])
+
+    def lookup_closest(self,order_val):
+        """
+        Given a proposed ordering statistic value, provides the *index* of the closest value.  Assumes *scalar* input
+        Should be using the fact that this is ordered ... but we are not
+        """
+        if self.eos_ns_tov is None:
+            raise Exception(" Did not load TOV results ")
+        if self.oned_order_values is None:
+            raise Exception(" Did not generate ordering statistic ")
+        
+        return np.argmin( np.abs(order_val - self.oned_order_values))
+
+
+####
+#### General lalsimulation interfacing
+####
+
+class QueryLS_EOS:
+    """
+    ExtractorFromEOS
+      Class to repeatedly query a single lalsuite EOS object, using a common interface (e.g., to extract array outputs by name, unit conversions, etc)
+    """
+    def __init__(self,eos):
+        self.eos = eos
+        # Primitive extractors.  Assume I need to vectorize these, and that it isn't available
+        extraction_dict_lalsim_raw = {
+            'pseudo_enthalpy': lambda x: x,
+            'rest_mass_density': lambda x: lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*.001,  # g cm^-3
+            'baryon_density': lambda x: (lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*.001)/(lal.AMU_SI*1e3),  #  cm^-3
+           'pressure': lambda x: lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(x, eos)*10,    # dyn cm^-2 ~ g cm^-1 s^-2
+           'energy_density': lambda x: lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(x,eos)*10/(lal.C_SI*100)**2 , # J m^-3 *10/c^2 = g cm^-3
+           'sound_speed_over_c':lambda x: lalsim.SimNeutronStarEOSSpeedOfSound(x,eos)/lal.C_SI
+          }
+        self.extraction_dict_lalsim = {}
+        for name in         extraction_dict_lalsim_raw:
+            self.extraction_dict_lalsim[name] = np.vectorize(extraction_dict_lalsim_raw[name])
+    
+    def convert(self,var, var_name = None):
+        if not(var_name):
+            raise Exception("Variable required to convert.")
+        if var_name == 'rest_mass_density':
+            return var*5.6096*10**-13 # MeV fm^-3    ## c**2/(coulomb charge) * 1/(10**39 * 10**3 * 10**6) See https://en.wikipedia.org/wiki/Electronvolt#Mass for a handy conversion. lal.C_SI**2/(lal.QE_SI*10**48)
+        if var_name == 'energy_density':
+            return var*5.6096*10**-13 # MeV fm^-3
+        if var_name == 'energy_density':
+            return var/(2.7*10**14) # nuclear saturation density in cgs = 2.7*10**14. ~ 0.16 fm^-3
+        if var_name == 'sound_speed_over_c':
+            return var*lal.C_SI*100   # cm s-1
+        if var_name == 'pressure':
+            raise Exception('not yet implemented')
+            return ##Check this conversion. possibly same as density with or without c**2. [MeV fm^-3]
+        
+        # IN PROGRESS
+        #   - adiabatic index
+        #Gamma = (self.extraction_dict_lalsim['energy_density']()*(lal.C_SI*100)**2 + self.extraction_dict_lalsim['pressure']())/(self.extraction_dict_lalsim['pressure']()) *np.square(self.extraction_dict_lalsim['sound_speed_over_c']())
+
+
+    def extract_param(self, p, pseudo_enthalpy):
+        return self.extraction_dict_lalsim[p](pseudo_enthalpy)
+
+
+
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager_old.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager_old.py
new file mode 100644
index 000000000..7332f332f
--- /dev/null
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager_old.py
@@ -0,0 +1,880 @@
+#
+#  EOSManager.py 
+#
+# SEE ALSO
+#   - util_WriteXMLWithEOS
+#   - gwemlightcurves.KNTable
+
+# SERIOUS LIMITATIONS
+#   - EOSFromFile  : File i/o for each EOS creation will slow things donw.  This command is VERY trivial, so we should be able
+#          to directly create the structure ourselves, using eos_alloc_tabular
+#           https://github.com/lscsoft/lalsuite/blob/master/lalsimulation/src/LALSimNeutronStarEOSTabular.c
+
+rosDebug=False
+
+import numpy as np
+import os
+import sys
+import lal
+import lalsimulation as lalsim
+from scipy.integrate import quad
+import scipy.interpolate as interp
+import scipy
+
+try:
+    from natsort import natsorted
+except:
+    print(" - no natsorted - ")
+
+#import gwemlightcurves.table as gw_eos_table
+
+from . import MonotonicSpline as ms
+
+
+C_CGS=2.997925*10**10 # Argh, Monica!
+DENSITY_CGS_IN_MSQUARED=7.42591549e-25  # g/cm^3 m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom)
+
+
+def make_compactness_from_lambda_approximate(lambda_vals):
+    """
+    make_compactness_from_lambda_approximate
+    Eq (B1) from https://arxiv.org/pdf/1812.04803.pdf, based on Maselli et al 2013, Yagi and Yunes 2017
+
+    Note this will yield *extreme* compactnesses for poorly-constrained GW observations, as the 'lambda' inferred will be wildly large/prior-dominated
+    """
+
+    return 0.371 -0.0391*np.log(lambda_vals) + 0.001056*np.log(lambda_vals)**2
+
+
+###
+### SERVICE 0: General EOS structure
+###
+
+class EOSConcrete:
+    """
+    Class characterizing a specific EOS solution.  This structure *SHOULD* 
+        - auto-build the mass-radius via a TOV solve
+         - provides ability to query the lambda(m) relationship and (in the future) higher-order multipole moments; etc
+    As many of these features are already provided by lalsimulation, 
+    """
+
+    def __init__(self,name=None):
+        self.name=name
+        self.eos = None
+        self.eos_fam = None
+        return None
+
+    def lambda_from_m(self, m):
+        eos_fam = self.eos_fam
+        if m<10**15:
+            m=m*lal.MSUN_SI
+
+        k2=lalsim.SimNeutronStarLoveNumberK2(m, eos_fam)
+        r=lalsim.SimNeutronStarRadius(m, eos_fam)
+
+        m=m*lal.G_SI/lal.C_SI**2
+        lam=2./(3*lal.G_SI)*k2*r**5
+        dimensionless_lam=lal.G_SI*lam*(1/m)**5
+
+        return dimensionless_lam
+
+    def estimate_baryon_mass_from_mg(self,m):
+        """
+        Estimate m_b = m_g + m_g^2/(R_{1.4}/km) based on https://arxiv.org/pdf/1905.03784.pdf Eq. (6)
+        """
+        r1p4 =lalsim.SimNeutronStarRadius(1.4*lal.MSUN_SI, self.eos_fam)/1e3
+        return m + (1./r1p4)*m**2 #(m/lal.MSUN_SI)
+
+    def pressure_density_on_grid_alternate(self,logrho_grid,enforce_causal=False):
+        """ 
+        pressure_density_on_grid.
+        Input and output grid units are in SI (rho: kg/m^3; p = N/m^2)
+        Pressure provided by lalsuite (=EOM integration)
+        Density computed by m*n = (epsilon+p)/c^2mn exp(-h), which does NOT rely on lalsuite implementation 
+        """
+        dat_out = np.zeros(len(logrho_grid))
+        fam = self.eos_fam
+        eos = self.eos
+        npts_internal = 10000
+        p_internal = np.zeros(npts_internal)
+        rho_internal = np.zeros(npts_internal)
+        epsilon_internal = np.zeros(npts_internal)
+        hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
+        if enforce_causal:
+            # strip out everything except the causal part.
+            hmax = lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos)
+        h = np.linspace(0.0001,hmax,npts_internal)
+        for indx in np.arange(npts_internal):
+            p_internal[indx] = lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10 to get CGS
+            epsilon_internal[indx] =lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(h[indx],eos)  # SI. Note factor of C^2 needed to get mass density
+            rho_internal[indx] =np.exp(-h[indx])* (epsilon_internal[indx]+p_internal[indx])/(lal.C_SI**2)  # 
+#        print epsilon_internal[10],rho_internal[10], p_internal[10], h[10]
+        logp_of_logrho = interp.interp1d(np.log10(rho_internal),np.log10(p_internal),kind='linear',bounds_error=False,fill_value=np.inf)  # should change to Monica's spline
+ #       print logrho_grid,
+        return logp_of_logrho(logrho_grid)
+
+    def pressure_density_on_grid(self,logrho_grid,reference_pair=None,enforce_causal=False):
+        """ 
+        pressure_density_on_grid.
+        Input and output grid units are in SI (rho: kg/m^3; p = N/m^2)
+        POTENTIAL PROBLEMS OF USING LALSUITE
+            - lalinference_o2 / master: Unless patched, the *rest mass* density is not reliable.  
+              To test with the unpatched LI version, use reference_pair to specify a low-density EOS.
+              This matching is highly suboptimal, so preferably test either (a) a patched code or (b) the alternative code below
+        """
+        dat_out = np.zeros(len(logrho_grid))
+        fam = self.eos_fam
+        eos = self.eos
+        npts_internal = 10000
+        p_internal = np.zeros(npts_internal)
+        rho_internal = np.zeros(npts_internal)
+        hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
+        if enforce_causal:
+            # strip out everything except the causal part.
+            hmax = lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos)
+        h = np.linspace(0.0001,hmax,npts_internal)
+        for indx in np.arange(npts_internal):
+            rho_internal[indx] = lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10^(-3) to get CGS
+            p_internal[indx] = lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10 to get CGS
+        if not (reference_pair is None):
+            indx_match = np.argmin( np.abs(np.log10(p_internal) - np.log10(reference_pair[1]))) # force agreement of densities at target pressure, if requested! Addresses bug /ambiguity in scaling of rest mass estimate; intend to apply in highly nonrelativistic regime
+            delta_rho = np.log10(reference_pair[0]) -np.log10(rho_internal[indx_match]) 
+            rho_internal *= np.power(10, delta_rho)
+#            print  np.log10(np.c_[rho_internal,p_internal])
+        logp_of_logrho = interp.interp1d(np.log10(rho_internal),np.log10(p_internal),kind='linear',bounds_error=False,fill_value=np.inf)  # should change to Monica's spline
+ #       print logrho_grid,
+        return logp_of_logrho(logrho_grid)
+
+    def test_speed_of_sound_causal(self, test_only_under_mmax=True,fast_test=True):
+        """
+        Test if EOS satisfies speed of sound.
+        Relies on low-level lalsimulation interpolation routines to get v(h) and as such is not very reliable
+
+        By DEFAULT, we are testing the part of the EOS that is
+             - at the largest pressure (assuming monotonic sound speed)
+             - associated with the maximum mass NS that is stable
+        We can also test the full table that is provided to us.
+        https://git.ligo.org/lscsoft/lalsuite/blob/lalinference_o2/lalinference/src/LALInference.c#L2513
+        """
+        npts_internal = 1000
+        eos = self.eos
+        fam = self.eos_fam
+        # Largest NS provides largest attained central pressure
+        m_max_SI = self.mMaxMsun*lal.MSUN_SI
+        if not test_only_under_mmax:
+            hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
+        else:
+            try:
+                pmax = lalsim.SimNeutronStarCentralPressure(m_max_SI,fam)  
+                hmax = lalsim.SimNeutronStarEOSPseudoEnthalpyOfPressure(pmax,eos)
+            except:
+                # gatch gsl interpolation errors for example
+                return False  
+        if fast_test: 
+            # https://git.ligo.org/lscsoft/lalsuite/blob/lalinference_o2/lalinference/src/LALInference.c#L2513
+            try:
+                vsmax = lalsim.SimNeutronStarEOSSpeedOfSoundGeometerized(hmax, eos)
+                return vsmax <1.1
+            except:
+                # catch gsl interpolation errors for example
+                return False
+        else:
+            if rosDebug:
+                print(" performing comprehensive test ")
+        h = np.linspace(0.0001,hmax,npts_internal)
+#        h = np.linspace(0.0001,lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos),npts_internal)
+        vs_internal = np.zeros(npts_internal)
+        for indx in np.arange(npts_internal):
+            vs_internal[indx] =  lalsim.SimNeutronStarEOSSpeedOfSoundGeometerized(h[indx],eos)
+            if rosDebug:
+                print(h[indx], vs_internal[indx])
+        return not np.any(vs_internal>1.1)   # allow buffer, so we have some threshold
+
+###
+### SERVICE 1: lalsimutils structure
+###
+#  See https://github.com/lscsoft/lalsuite/tree/master/lalsimulation/src for available types
+class EOSLALSimulation(EOSConcrete):
+    def __init__(self,name):
+        self.name=name
+        self.eos = None
+        self.eos_fam = None
+        self.mMaxMsun=None
+
+
+        eos = lalsim.SimNeutronStarEOSByName(name)
+        fam = lalsim.CreateSimNeutronStarFamily(eos)
+        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
+        self.eos = eos
+        self.eos_fam = fam
+        self.mMaxMsun = mmass
+        return None
+
+
+
+
+
+###
+### SERVICE 2: EOSFromFile
+###
+
+# Example directory: EOS_Tables
+#dirEOSTablesBase = os.environ["EOS_TABLES"]
+dirLALSimulationBase = os.environ["LALSIMULATION_DATADIR"]  # LAL table data
+## Add routines to find, parse standard directory of EOS files and load suitable metadata into memory
+## Follow framework of NRWaveformCatalogManager3
+
+
+class EOSFromDataFile(EOSConcrete):
+    """ 
+    FromDataFileEquationOfState
+    (just accepts filename...not attempting to parse a catalog)
+    
+    """
+    def __init__(self,name=None,fname=None):
+        self.name=name
+        self.fname=fname
+        self.eos = None
+        self.eos_fam = None
+        self.mMax = None
+
+        self.eos, self.eos_fam = self.eos_ls()
+        return None
+
+    def eos_ls(self):
+        # From Monica, but using code from GWEMLightcurves
+        #  https://gwemlightcurves.github.io/_modules/gwemlightcurves/KNModels/table.html
+        """
+        EOS tables described by Ozel `here <https://arxiv.org/pdf/1603.02698.pdf>`_ and downloadable `here <http://xtreme.as.arizona.edu/NeutronStars/data/eos_tables.tar>`_. LALSim utilizes this tables, but needs some interfacing (i.e. conversion to SI units, and conversion from non monotonic to monotonic pressure density tables)
+    """
+        obs_max_mass = 2.01 - 0.04  # used
+        print("Checking %s" % self.name)
+        eos_fname = ""
+        if os.path.exists(self.fname):
+            # NOTE: Adapted from code by Monica Rizzo
+            print("Loading from %s" % self.fname)
+            bdens, press, edens = np.loadtxt(self.fname, unpack=True)
+            press *= DENSITY_CGS_IN_MSQUARED
+            edens *= DENSITY_CGS_IN_MSQUARED
+            eos_name = self.name
+
+            if not np.all(np.diff(press) > 0):
+                keep_idx = np.where(np.diff(press) > 0)[0] + 1
+                keep_idx = np.concatenate(([0], keep_idx))
+                press = press[keep_idx]
+                edens = edens[keep_idx]
+            assert np.all(np.diff(press) > 0)
+            if not np.all(np.diff(edens) > 0):
+                keep_idx = np.where(np.diff(edens) > 0)[0] + 1
+                keep_idx = np.concatenate(([0], keep_idx))
+                press = press[keep_idx]
+                edens = edens[keep_idx]
+            assert np.all(np.diff(edens) > 0)
+
+            # Creating temporary file in suitable units
+            print("Dumping to %s" % self.fname)
+            eos_fname = "./" +eos_name + "_geom.dat" # assume write acces
+            np.savetxt(eos_fname, np.transpose((press, edens)), delimiter='\t')
+            eos = lalsim.SimNeutronStarEOSFromFile(eos_fname)
+            fam = lalsim.CreateSimNeutronStarFamily(eos)
+
+        else:
+            print(" No such file ", self.fname)
+            sys.exit(0)
+
+        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
+        self.mMaxMsun = mmass
+        return eos, fam
+
+    def p_rho_arrays(self):
+        print(self.fname)
+        dat_file = np.array(np.loadtxt(self.fname))
+        nb=dat_file[:,0]
+        p=dat_file[:,1]
+        rho=dat_file[:,2] 
+        return nb,p,rho
+    def interp_eos_p_of_rho(self):
+        nb,p,rho=self.p_rho_arrays()
+        n=len(p)
+        p=np.log10(p)
+        rho=np.log10(rho)
+        consts=ms.interpolate(rho,p)
+        line_const=ms.lin_extrapolate(rho,p)
+        #linearly interpolate anything outside range
+        line_lower=line_const[0,:]
+        line_upper=line_const[1,:]
+        return consts,line_upper,line_lower
+
+   #interpolates Log10 of data
+    def interp_eos_rho_of_p(self):
+        nb,p,rho=self.p_rho_arrays()
+        n=len(p)
+        p=np.log10(p)
+        rho=np.log10(rho)
+        consts=ms.interpolate(p,rho)  
+        line_const=ms.lin_extrapolate(p,rho)
+       #linearly interpolate anything outside range
+        line_lower=line_const[0,:]
+        line_upper=line_const[1,:]
+        return consts,line_upper,line_lower
+    def interp_eos_nb_of_p(model_name):
+        nb,p,rho=self.p_rho_arrays()
+        n=len(p)
+        p=np.log10(p)
+        nb=np.log10(nb)
+        consts=ms.interpolate(p,nb)
+        line_const=ms.lin_extrapolate(p,nb)
+        #linearly interpolate anything outside range
+        line_lower=line_const[0,:]
+        line_upper=line_const[1,:]
+        return consts,line_upper,line_lower
+
+
+
+
+
+###
+### SERVICE 2: Parameterized EOS (specify functions)
+###
+
+# COMMON POLYTROPE TABLE
+# eos logP1 gamma1 gamma2 gamma3
+# PAL6 34.380 2.227 2.189 2.159 
+# SLy 34.384 3.005 2.988 2.851 
+# AP1 33.943 2.442 3.256 2.908 
+# AP2 34.126 2.643 3.014 2.945
+# AP3 34.392 3.166 3.573 3.281  
+# AP4 34.269 2.830 3.445 3.348 
+# FPS 34.283 2.985 2.863 2.600 
+# WFF1 34.031 2.519 3.791 3.660 
+# WFF2 34.233 2.888 3.475 3.517  
+# WFF3 34.283 3.329 2.952 2.589  
+# BBB2 34.331 3.418 2.835 2.832 
+# BPAL12 34.358 2.209 2.201 2.176 
+# ENG 34.437 3.514 3.130 3.168 
+# MPA1 34.495 3.446 3.572 2.887 
+# MS1 34.858 3.224 3.033 1.325 
+# MS2 34.605 2.447 2.184 1.855 
+# MS1b 34.855 3.456 3.011 1.425 
+# PS 34.671 2.216 1.640 2.365 
+# GS1 34.504 2.350 1.267 2.421 
+# GS2 34.642 2.519 1.571 2.314 
+# BGN1H1 34.623 3.258 1.472 2.464 
+# GNH3 34.648 2.664 2.194 2.304 
+# H1 34.564 2.595 1.845 1.897
+# H2 34.617 2.775 1.855 1.858
+# H3 34.646 2.787 1.951 1.901
+# H4 34.669 2.909 2.246 2.144
+# H5 34.609 2.793 1.974 1.915
+# H6 34.593 2.637 2.121 2.064
+# H7 34.559 2.621 2.048 2.006
+# PCL2 34.507 2.554 1.880 1.977 
+# ALF1 34.055 2.013 3.389 2.033 
+# ALF2 34.616 4.070 2.411 1.890 
+# ALF3 34.283 2.883 2.653 1.952 
+# ALF4 34.314 3.009 3.438 1.803
+
+# Rizzo code: EOS_param.py
+class EOSPiecewisePolytrope(EOSConcrete):
+    def __init__(self,name,param_dict=None):
+        self.name=name
+        self.eos = None
+        self.eos_fam = None
+        self.mMaxMsun=None
+
+
+        eos=self.eos=lalsim.SimNeutronStarEOS4ParameterPiecewisePolytrope(param_dict['logP1'], param_dict['gamma1'], param_dict['gamma2'], param_dict['gamma3'])
+        eos_fam=self.eos_fam=lalsim.CreateSimNeutronStarFamily(eos)
+        self.mMaxMsun = lalsim.SimNeutronStarMaximumMass(eos_fam) / lal.MSUN_SI
+
+        return None
+
+
+class EOSLindblomSpectral(EOSConcrete):
+    def __init__(self,name=None,spec_params=None,verbose=False,use_lal_spec_eos=False):
+        if name is None:
+            self.name = 'spectral'
+        else:
+            self.name=name
+        self.eos = None
+        self.eos_fam = None
+
+        self.spec_params = spec_params
+#        print spec_params
+
+        if use_lal_spec_eos:
+#            self.eos=lalsim.SimNeutronStarEOS4ParameterSpectralDecomposition(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'])   # Should have this function! but only on master
+            self.eos=lalsim.SimNeutronStarEOSSpectralDecomposition_for_plot(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'],4)
+        else:
+            # Create data file
+            self.make_spec_param_eos(500,save_dat=True,ligo_units=True,verbose=verbose)
+            # Use data file
+            #print " Trying to load ",name+"_geom.dat"
+            import os; #print os.listdir('.')
+            cwd = os.getcwd()
+            self.eos=eos = lalsim.SimNeutronStarEOSFromFile(cwd+"/"+name+"_geom.dat")
+        self.eos_fam = fam=lalsim.CreateSimNeutronStarFamily(self.eos)
+        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
+        self.mMaxMsun = mmass
+
+        return None
+
+    def test_bounded_adiabatic_index(self,bounds=[0.6,4.5]):
+        """
+        Gamma(p) \in bounds
+        Uses xmax and other parameters from spectral result
+        """
+        spec_params =self.spec_params
+        if not 'gamma3' in spec_params:
+            spec_params['gamma3']=spec_params['gamma4']=0
+        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
+        xmax = self.spec_params['xmax']
+        xvals = np.linspace(0,xmax,500)
+        gamma_vals = gamma_of_x(xvals, coefficients)
+        if rosDebug:
+            print("  Spectral EOS debug test limits: Gamma bounds", np.min(gamma_vals), np.max(gamma_vals))
+        return  not( np.any(gamma_vals < bounds[0]) or np.any(gamma_vals>bounds[1]) )
+            
+
+    def make_spec_param_eos(self, npts=500, plot=False, verbose=False, save_dat=False,ligo_units=False,interpolate=False,eosname_lalsuite="SLY4"):
+        """
+        Load values from table of spectral parameterization values
+        Table values taken from https://arxiv.org/pdf/1009.0738.pdf
+        Comments:
+            - eos_vals is recorded as *pressure,density* pairs, because the spectral representation is for energy density vs pressure
+            - units swap between geometric and CGS
+            - eosname_lalsuite is used for the low-density EOS
+        """
+
+        spec_params = self.spec_params
+        if not 'gamma3' in spec_params:
+            spec_params['gamma3']=spec_params['gamma4']=0
+        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
+        p0=spec_params['p0']
+        eps0=spec_params['epsilon0']
+        xmax=spec_params['xmax'] 
+
+        x_range=np.linspace(0,xmax,npts)
+        p_range=p0*np.exp(x_range)
+       
+        eos_vals=np.zeros((npts,2))
+        eos_vals[:,1]=p_range
+
+        eos_vals[:,0] = epsilon(x_range,p0,eps0, coefficients)
+        # for i in range(0, len(x_range)):
+        #    eos_vals[i,0]=epsilon(x_range[i], p0, eps0, coefficients)
+        #    if verbose==True:
+        #        print "x:",x_range[i],"p:",p_range[i],"p0",p0,"epsilon:",eos_vals[i,0]
+  
+    #doing as those before me have done and using SLY4 as low density region
+        # THIS MUST BE FIXED TO USE STANDARD LALSUITE ACCESS, do not assume the file exists
+#        low_density=np.loadtxt(dirEOSTablesBase+"/LALSimNeutronStarEOS_SLY4.dat")
+        low_density = np.loadtxt(dirLALSimulationBase+"/LALSimNeutronStarEOS_"+ eosname_lalsuite+".dat")
+        low_density[:,0]=low_density[:,0]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
+        low_density[:,1]=low_density[:,1]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
+        low_density[:,[0, 1]] = low_density[:,[1, 0]]  # reverse order
+
+        cutoff=eos_vals[0,:]   
+        if verbose:
+            print(" cutoff ", cutoff)
+ 
+        break_pt=0
+        for i in range(0, len(low_density)):
+            if low_density[i,0] > cutoff[0] or low_density[i,1] > cutoff[1]:   
+                break_pt=i
+                break 
+    
+        eos_vals=np.vstack((low_density[0:break_pt,:], eos_vals)) 
+
+        if not interpolate:
+#            print eos_vals
+            if ligo_units:
+                eos_vals *= DENSITY_CGS_IN_MSQUARED/(C_CGS**2)  # converts to geometric units: first convert from cgs energy density to g/cm^2, then to 1/m^2.
+ #               print " Rescaled "
+#                print eos_vals
+            
+            if save_dat == True:
+                np.savetxt(self.name+"_geom.dat", eos_vals[:,[1,0]])  #NOTE ORDER
+
+            return eos_vals
+        
+        # Optional: interpolate in the log, to generate a denser EOS model
+        # Will produce better M(R) models for LAL
+        p_of_epsilon = ms.interpolate(np.log10(eos_vals[1:,0]), np.log10(eos_vals[1:,1]))
+  
+        new_eos_vals = np.zeros((resample_pts, 2))
+        epsilon_range = np.linspace(min(np.log10(eos_vals[1:,0])), max(np.log10(eos_vals[1:,0])), resample_pts)
+        new_eos_vals[:, 0] = 10**epsilon_range 
+ 
+        for i in range(0, resample_pts):
+            if verbose == True:
+                print("epsilon", 10**epsilon_range[i])
+
+            new_eos_vals[i,1] = 10**ms.interp_func(epsilon_range[i], np.log10(eos_vals[1:,0]), np.log10(eos_vals[1:,1]), p_of_epsilon)
+
+            if verbose == True:
+                print("p", new_eos_vals[i,1])
+    
+        new_eos_vals = check_monotonicity(new_eos_vals)
+        new_eos_vals = np.vstack((np.array([0.,0.]), new_eos_vals))
+        return new_eos_vals
+
+
+
+def gamma_of_x(x, coeffs):
+        """
+        Eq 6 from https://arxiv.org/pdf/1009.0738.pdf
+        """
+        gamma=0
+        # Equivalent to np.polyval(coeffs[::-1],x)
+        gamma=np.polyval(coeffs[::-1],x)
+        # for i in range(0,len(coeffs)):
+        #     gamma+=coeffs[i]*x**i 
+        gamma=np.exp(gamma)  
+        return gamma
+  
+def mu(x, coeffs):
+        """
+        Eq 8 from https://arxiv.org/pdf/1009.0738.pdf
+        """
+
+
+        # very inefficient: does integration multiple times. Should change to ODE solve
+        if isinstance(x, (list, np.ndarray)):
+            def int_func(dummy,x_prime):
+              return (gamma_of_x(x_prime, coeffs))**(-1)    
+            y = scipy.integrate.odeint(int_func,[0],x,full_output=False).T  # x=0 needs to be value in array
+            return np.exp(-1.*y)
+#            val=np.zeros(len(x))
+#            for i in range(0,len(x)):
+#                tmp=quad(int_func, 0, x[i])
+#                val[i]=tmp[0]  
+#            return np.exp(-1.*val)
+        else:    
+            def int_func(x_prime):
+              return (gamma_of_x(x_prime, coeffs))**(-1)    
+            val=quad(int_func, 0, x)
+
+        return np.exp(-1.*val[0])
+
+def epsilon(x, p0, eps0, coeffs,use_ode=True):
+        """
+        Eq. 7 from https://arxiv.org/pdf/1009.0738.pdf
+        """
+        mu_of_x=mu(x, coeffs)  
+        if use_ode and isinstance(x, (list,np.ndarray)):
+          mu_intp = scipy.interpolate.interp1d(x,mu_of_x,bounds_error=False,fill_value=0)
+          def int_func(dummy,x_prime):
+            num = mu_intp(x_prime)*np.exp(x_prime)
+            denom = gamma_of_x(x_prime, coeffs)
+            return num / denom
+          y= scipy.integrate.odeint(int_func,0,x,full_output=False).T  # x=0 needs to be value in array
+          eps=(eps0*C_CGS**2)/mu_of_x + p0/mu_of_x * y
+          return eps
+        else:
+          def int_func(x_prime):
+            num = mu(x_prime, coeffs)*np.exp(x_prime)
+            denom = gamma_of_x(x_prime, coeffs)
+            return num / denom
+          
+        # very inefficient: does integration multiple times. Should change to ODE solve
+        # Would require lookup interpolation of mu_of_x
+        val=quad(int_func, 0, x)
+        #val=romberg(int_func, 0, x, show=True)   
+        eps=(eps0*C_CGS**2)/mu_of_x + p0/mu_of_x * val[0]
+ 
+        return eps
+
+
+
+
+###
+### Utilities
+###
+
+# Les-like
+def make_mr_lambda_lal(eos,n_bins=100):
+    """
+    Construct mass-radius curve from EOS
+    Based on modern code resources (https://git.ligo.org/publications/gw170817/bns-eos/blob/master/scripts/eos-params.py) which access low-level structures
+    """
+    fam=lalsim.CreateSimNeutronStarFamily(eos)
+    max_m = lalsim.SimNeutronStarMaximumMass(fam)/lal.MSUN_SI
+    min_m = lalsim.SimNeutronStarFamMinimumMass(fam)/lal.MSUN_SI
+    mgrid = np.linspace(min_m,max_m, n_bins)
+    mrL_dat = np.zeros((n_bins,3))
+    mrL_dat[:,0] = mgrid
+    for indx in np.arange(n_bins):
+       mass_now = mgrid[indx]
+       r = lalsim.SimNeutronStarRadius(mass_now*lal.MSUN_SI,fam)/1000.
+       mrL_dat[indx,1] = r
+       k = lalsim.SimNeutronStarLoveNumberK2(mass_now*lal.MSUN_SI,fam)
+       c = mass_now * lal.MRSUN_SI / (r*1000.)
+       mrL_dat[indx,2] = (2. / 3.) * k / c**5.
+
+    return mrL_dat
+
+# Rizzo
+def make_mr_lambda(eos,use_lal=False):
+   """
+   construct mass-radius curve from EOS    
+   DOES NOT YET WORK RELIABLY
+   """
+   if use_lal:
+       make_mr_lambda_lal(eos)
+
+   fam=lalsim.CreateSimNeutronStarFamily(eos)
+ 
+   r_cut = 40   # Some EOS we consider for PE purposes will have very large radius!
+
+   #set p_nuc max
+   #   - start at a fiducial nuclear density
+   #   - not sure what these termination conditions are designed to do ... generally this pushes to  20 km
+   #   - generally this quantity is the least reliable
+   p_nuc=3.*10**33   # consistent with examples
+   fac_min=0
+   r_fin=0
+   while r_fin > r_cut+8 or r_fin < r_cut:
+       # Generally tries to converge to density corresponding to 20km radius
+      try: 
+         answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_min)*p_nuc, eos)      # r(SI), m(SI), lambda
+      except:
+          # If failure, backoff
+         fac_min=-0.05
+         break 
+      r_fin=answer[0]
+      r_fin=r_fin*10**-3  # convert to SI
+#      print "R: ",r_fin
+      if r_fin<r_cut:
+         fac_min-=0.05
+      elif r_fin>r_cut+8:
+         fac_min+=0.01
+   answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_min)*p_nuc, eos)      # r(SI), m(SI), lambda
+   m_min = answer[1]/lal.MSUN_SI
+
+   #set p_nuc min
+   #   - tries to converge to central pressure corresponding to maximum NS mass
+   #   - very frustrating...this data is embedded in the C code
+   fac_max=1.6
+   r_fin=20.
+   m_ref = lalsim.SimNeutronStarMaximumMass(fam)/lal.MSUN_SI
+   r_ref = lalsim.SimNeutronStarRadius(lalsim.SimNeutronStarMaximumMass(fam), fam)/(10**3)
+   answer=None
+   while r_fin > r_ref  or r_fin < 7:
+       #print "Trying min:"
+#       print "p_c: ",(10**fac_max)*p_nuc
+       try:
+          answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)         
+          if answer[0]*10**-3 < r_ref:
+             break 
+       except:
+          fac_max-=0.05
+          working=False
+          while working==False:
+             try:
+                answer_tmp=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)
+                working=True
+             except:
+                fac_max-=0.05
+          break
+          #print lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)
+       r_fin=answer[0]/10**3 # convert to km
+       if rosDebug:
+           print("R: ",r_fin, r_ref, " M: ", answer[1]/lal.MSUN_SI, m_ref , m_min) # should converge to maximum mass
+       if r_fin>8:
+          fac_max+=0.05
+       if r_fin<6:
+          fac_max-=0.01
+#       print 10**fac_max
+
+   #generate mass-radius curve
+   npts_out = 1000
+   scale=np.logspace(fac_min,fac_max,npts_out)
+   
+   mr_array=np.zeros((npts_out,3))
+   for s,i in zip(scale,range(0,len(scale))):
+#       print s
+       mr_array[i,:]=lalsim.SimNeutronStarTOVODEIntegrate(s*p_nuc, eos)
+      
+   mr_array[:,0]=mr_array[:,0]/10**3 
+   mr_array[:,1]=mr_array[:,1]/lal.MSUN_SI
+   mr_array[:,2]=2./(3*lal.G_SI)*mr_array[:,2]*(mr_array[:,0]*10**3)**5
+   mr_array[:,2]=lal.G_SI*mr_array[:,2]*(1/(mr_array[:,1]*lal.MSUN_SI*lal.G_SI/lal.C_SI**2))**5
+
+#   print mr_array[:,1]
+
+   return mr_array
+
+
+
+def LookupCrustEpsilonAtPressure(p_ref,eosname_lalsuite="SLY4"):
+    """
+    Tool for spectral EOS manager to find epsilon(p) via lookup tables from the lalsuite data files.
+    Units are *CGS*
+    Uses linear interpolation in the log. 
+
+    Warning: lalsuite files use lal units (epsilon, p in 1/m^2), but we will presume p and epsilon are in energy density
+
+    """
+    lal_dat =np.loadtxt(dirLALSimulationBase+"/LALSimNeutronStarEOS_"+ eosname_lalsuite+".dat")
+    lal_dat[:,0]=lal_dat[:,0]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
+    lal_dat[:,1]=lal_dat[:,1]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
+#    lal_dat[:,[0, 1]] = lal_dat[:,[1, 0]]  # reverse order
+    
+    # Interpolate in log
+    lal_dat_log = np.log10(lal_dat)   # note first sample is zero,and causes problems nominally with this interpolation
+    eps_out = np.power(10.,np.interp(np.log10(p_ref),  lal_dat_log[:,0], lal_dat_log[:,1]))
+    return eps_out
+
+
+
+###
+###  EOSSequence : For large sets of EOS we must access simultaneously (100 Mb plus), pretabulated
+# 
+#   These will be a different data structure, where we don't necessariliy provide all the EOSConcrete structures, 
+#   Example: https://zenodo.org/record/6502467#.YulOeaRE1Pw 
+###
+
+
+
+###
+### SERVICE 0: General EOS structure
+###
+
+class EOSSequenceLandry:
+    """
+    Class characterizing a sequence of specific EOS solutions, using the Landry format.
+    Assumes user provides (a) EOS realization, (b) precomputed results from TOV solve; and (c) discrete ID
+
+    PENDING
+       - mMax access
+    """
+
+    def __init__(self,name=None,fname=None,load_eos=False,load_ns=False,oned_order_name=None,oned_order_mass=None,no_sort=True,verbose=False):
+        import h5py
+        self.name=name
+        self.fname=fname
+        self.eos_ids = None
+        self.eos_names = None   # note this array can be SORTED, use the oned_order_indx_original for original order
+        self.eos_tables = None
+        self.eos_ns_tov = None
+        self.oned_order_name = None
+        self.oned_order_mass=oned_order_mass
+        self.oned_order_values=None
+        self.oned_order_indx_original = None
+        self.verbose=verbose
+        with h5py.File(self.fname, 'r') as f:
+            names = list(f['ns'].keys())
+            names = natsorted(names)  # sort them sanely
+            self.eos_ids = list(f['id'])
+            self.eos_names = np.array(names,dtype=str)
+            # The following loads a LOT into memory, as a dictionary
+            if load_ns:
+                if verbose:
+                    print(" EOSSequenceLandry: Loading TOV results for {}".format(fname))
+                # Convert to dictionary, so not closed.  Note this sucks up a lot of i/o time, and ideally we don't close the file
+                self.eos_ns_tov = {}
+                for name in names:
+                    self.eos_ns_tov[name] = np.array(f['ns'][name])
+                if verbose:
+                    print(" EOSSequenceLandry: Completed TOV i/o {}".format(fname))
+                create_order = False
+                if oned_order_name == 'R' or oned_order_name=='r':
+                    create_order=True
+                    self.oned_order_name='R'  # key value in fields
+                if oned_order_name == 'Lambda' or oned_order_name=='lambdda':
+                    create_order=True
+                    self.oned_order_name='Lambda'  # key value in fields
+                if not(self.oned_order_mass):
+                    # Can't order if we don't have a reference mass
+                    create_order=False
+                if create_order:
+                    self.oned_order_indx_original = np.arange(len(self.eos_names))
+                    vals = np.zeros(len(self.eos_names))
+                    if self.oned_order_name =='Lambda':
+                        for indx in np.arange(len(self.eos_names)):
+                            vals[indx] =self.lambda_of_m_indx(self.oned_order_mass,indx)
+                    if self.oned_order_name =='R':
+                        for indx in np.arange(len(self.eos_names)):
+                            vals[indx] =self.R_of_m_indx(self.oned_order_mass,indx)
+
+                    # resort 'names' field with new ordering
+                    # is it actually important to do the sorting?  NO, code should work with original lexographic order, since we only use nearest neighbors!
+                    if no_sort:
+                        self.oned_order_values = vals
+                    else:
+                        indx_sorted = np.argsort(vals)
+                        if verbose: 
+                            print(indx_sorted)
+                        self.eos_names = self.eos_names[indx_sorted]  
+                        self.oned_order_values = vals[indx_sorted]
+                        self.oned_order_indx_original =  self.oned_order_indx_original[indx_sorted]
+
+            if load_eos:
+                self.eos_tables = f['eos']
+        return None
+
+    def m_max_of_indx(self,indx):
+        name = self.eos_names[indx]
+        return np.max(self.eos_ns_tov[name]['M'])
+
+    def lambda_of_m_indx(self,m_Msun,indx):
+        """
+        lambda(m) evaluated for a *single* m_Msun value (almost always), for a specific indexed EOS
+        
+        Generally we assume the value is UNIQUE and associated with a single stable phase
+        """
+        if self.eos_ns_tov is None:
+            raise Exception(" Did not load TOV results ")
+        name = self.eos_names[indx]
+        if self.verbose:
+            print(" Loading from {}".format(name))
+        dat = np.array(self.eos_ns_tov[name])
+        # Sort masses
+        indx_sort = np.argsort(dat["M"])
+        # Interpolate versus m, ASSUME single-valued / no phase transition ! 
+        # Interpolate versus *log lambda*, so it is smoother and more stable
+        valLambda = np.log(dat["Lambda"][indx_sort])
+        valM = dat["M"][indx_sort]
+        return np.exp(np.interp(m_Msun, valM, valLambda))
+
+    def R_of_m_indx(self,m_Msun,indx):
+        """
+        R(m) evaluated for a *single* m_Msun value (almost always), for a specific indexed EOS
+        
+        Generally we assume the value is UNIQUE and associated with a single stable phase; should FIX?
+        """
+        if self.eos_ns_tov is None:
+            raise Exception(" Did not load TOV results ")
+        name = self.eos_names[indx]
+        if self.verbose:
+            print(" Loading from {}".format(name))
+        dat = np.array(self.eos_ns_tov[name])
+        # Sort masses
+        indx_sort = np.argsort(dat["M"])
+        # Interpolate versus m, ASSUME single-valued / no phase transition ! 
+        # Interpolate versus *log lambda*, so it is smoother and more stable
+        valR = np.log(dat["R"][indx_sort])
+        valM = dat["M"][indx_sort]
+        return np.exp(np.interp(m_Msun, valM, valR))
+
+    def mmax_of_indx(self,indx):
+        if self.eos_ns_tov is None:
+            raise Exception(" Did not load TOV results ")
+        name = self.eos_names[indx]
+        if self.verbose:
+            print(" Loading from {}".format(name))
+        
+        return np.max(self.eos_ns_tov[name]['M'])
+
+    def lookup_closest(self,order_val):
+        """
+        Given a proposed ordering statistic value, provides the *index* of the closest value.  Assumes *scalar* input
+        Should be using the fact that this is ordered ... but we are not
+        """
+        if self.eos_ns_tov is None:
+            raise Exception(" Did not load TOV results ")
+        if self.oned_order_values is None:
+            raise Exception(" Did not generate ordering statistic ")
+        
+        return np.argmin( np.abs(order_val - self.oned_order_values))
-- 
GitLab


From 9b28e32a948b89de076570d34c17e3e68a4435c7 Mon Sep 17 00:00:00 2001
From: Atul Kedia <atul.kedia@ldas-osg.ligo.caltech.edu>
Date: Wed, 22 Feb 2023 09:28:23 -0800
Subject: [PATCH 02/12] added demo files for testing

---
 .../Code/RIFT/physics/EOSPlotUtilities.py     | 52 ++++++++++++++++
 .../Code/RIFT/physics/demo_mass_radius.py     | 59 +++++++++++++++++++
 .../Code/RIFT/physics/demo_new_spectral.py    | 52 ++++++++++++++++
 3 files changed, 163 insertions(+)
 create mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py
 create mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py
 create mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py
new file mode 100644
index 000000000..175c336db
--- /dev/null
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py
@@ -0,0 +1,52 @@
+#
+# GOAL
+#    Library to facilitate making various plots of equation-of-state-related quantities.
+
+
+# from matplotlib import pyplot as plt
+# import EOSManager
+# import EOSPlotUtilities
+# my_eos = EOSManager.EOSLALSimulation('SLy')
+# EOSPlotUtilities.render_eos(my_eos.eos,'rest_mass_density', 'pressure')
+
+import numpy as np
+import EOSManager
+import lalsimulation as lalsim
+import lal
+import matplotlib
+import matplotlib.pyplot as plt
+
+
+matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
+matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
+matplotlib.rcParams['xtick.labelsize'] = 15.0
+matplotlib.rcParams['ytick.labelsize'] = 15.0
+matplotlib.rcParams['axes.labelsize'] = 25.0
+matplotlib.rcParams['lines.linewidth'] = 2.0
+plt.style.use('seaborn-v0_8-whitegrid')
+
+
+def render_eos(eos, xvar='energy_density', yvar='pressure',units='cgs',npts=100,label=None):
+
+    min_pseudo_enthalpy = 0.005
+    max_pseudo_enthalpy = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
+    hvals = max_pseudo_enthalpy* 10**np.linspace( np.log10(min_pseudo_enthalpy/max_pseudo_enthalpy),  0,num=npts)
+    
+    print(hvals,min_pseudo_enthalpy, max_pseudo_enthalpy)
+
+    qry = EOSManager.QueryLS_EOS(eos)
+    
+    xvals = qry.extract_param(xvar,hvals)
+    yvals = qry.extract_param(yvar,hvals)
+    print(np.c_[xvals,yvals])
+    #qry.convert(xvals, 'rest_mass_density') # using QueryLS_EOS.convert
+    
+    plt.loglog(xvals, yvals)
+    plt.xlabel(xvar)
+    plt.ylabel(yvar)
+    
+    return None
+
+
+
+
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py
new file mode 100644
index 000000000..7ba20c73f
--- /dev/null
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py
@@ -0,0 +1,59 @@
+import numpy as np
+import matplotlib
+import matplotlib.pyplot as plt
+import argparse
+
+#from lalinference.rapid_pe import lalsimutils
+import RIFT.lalsimutils as lalsimutils
+import EOSManager
+import lalsimulation as lalsim
+#import lalsim_EOS_tools as let
+from scipy.integrate import nquad
+#import EOS_param as ep
+import os
+from EOSPlotUtilities import render_eos
+
+matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
+matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
+matplotlib.rcParams['xtick.labelsize'] = 15.0
+matplotlib.rcParams['ytick.labelsize'] = 15.0
+matplotlib.rcParams['axes.labelsize'] = 25.0
+matplotlib.rcParams['lines.linewidth'] = 2.0
+plt.style.use('seaborn-v0_8-whitegrid')
+
+#spec_params = {'gamma1': -0.701593,'gamma2':-0.239194,'gamma3':0.062016,'gamma4':-0.003556}
+
+eoss = np.genfromtxt('../20221207-ROSKedia-SpectralRepresentation/names_laleos_improvedPBCS_indices_physical_EOS.txt', dtype='str')
+
+def M_1_4():
+    print('M_1.4')
+
+for i in range(0,len(eoss[:])):
+    try:
+        spec_params = {'gamma1': eoss[i][1].astype(float),
+                       'gamma2': eoss[i][2].astype(float),
+                       'gamma3': eoss[i][3].astype(float),
+                       'gamma4': eoss[i][4].astype(float),
+                       'p0': 5.3716e32,  # picked from LALSimNeutronStarEOSSpectralDecomposition.c
+                       'epsilon0' : 1e14, # 1.1555e35 / c**2? ~ 0.5nsat
+                       'xmax' : 50.0}
+        neweos = EOSManager.EOSLindblomSpectralSoundSpeedVersusPressure(spec_params = spec_params)
+        
+        m_r_L_data = EOSManager.make_mr_lambda_lal(neweos.eos, n_bins=200)
+        choose_M_R_L = 'M-R' # 'M-R', 'M-L'
+        
+        if choose_M_R_L == 'M-R':
+            plt.plot(m_r_L_data[:,1], m_r_L_data[:,0])
+        elif choose_M_R_L == 'M-L':
+            plt.plot(m_r_L_data[:,0], m_r_L_data[:,2])
+        
+    except:
+        continue
+    #plt.xlabel(xvar)
+    #plt.ylabel(yvar)
+
+
+plt.legend()
+plt.show()
+
+
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
new file mode 100644
index 000000000..76467892c
--- /dev/null
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
@@ -0,0 +1,52 @@
+import numpy as np
+import matplotlib
+import matplotlib.pyplot as plt
+import argparse
+
+#from lalinference.rapid_pe import lalsimutils
+import RIFT.lalsimutils as lalsimutils
+import EOSManager
+import lalsimulation as lalsim
+#import lalsim_EOS_tools as let
+from scipy.integrate import nquad
+#import EOS_param as ep
+import os
+from EOSPlotUtilities import render_eos
+
+matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
+matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
+matplotlib.rcParams['xtick.labelsize'] = 15.0
+matplotlib.rcParams['ytick.labelsize'] = 15.0
+matplotlib.rcParams['axes.labelsize'] = 25.0
+matplotlib.rcParams['lines.linewidth'] = 2.0
+plt.style.use('seaborn-v0_8-whitegrid')
+
+#spec_params = {'gamma1': -0.701593,'gamma2':-0.239194,'gamma3':0.062016,'gamma4':-0.003556}
+
+eoss = np.genfromtxt('../20221207-ROSKedia-SpectralRepresentation/names_laleos_improvedPBCS_indices_physical_EOS.txt', dtype='str')
+
+for i in range(0,len(eoss[:])):
+    spec_params = {'gamma1': eoss[i][1].astype(float),
+                   'gamma2': eoss[i][2].astype(float),
+                   'gamma3': eoss[i][3].astype(float),
+                   'gamma4': eoss[i][4].astype(float),
+                   'p0': 5.3716e32,  # picked from LALSimNeutronStarEOSSpectralDecomposition.c
+                   'epsilon0' : 1e14, # 1.1555e35 / c**2? ~ 0.5nsat
+                   'xmax' : 50.0}
+    neweos = EOSManager.EOSLindblomSpectralSoundSpeedVersusPressure(spec_params = spec_params)
+    xvar, yvar='energy_density', 'pressure'
+    new_eos_vals = neweos.make_spec_param_eos(xvar=xvar, yvar=yvar)
+    #xvar, yvar ='energy_density', 'pressure', 'rest_mass_density', 'sound_speed_over_c', 'pseudo_enthalpy'
+    
+    plt.loglog(new_eos_vals[:,0], new_eos_vals[:,1])
+    plt.xlabel(xvar)
+    plt.ylabel(yvar)
+    
+    #render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
+    #render_eos variable names: pseudo_enthalpy, rest_mass_density, baryon_density, pressure, energy_density, sound_speed_over_c
+
+
+plt.legend()
+plt.show()
+
+
-- 
GitLab


From 0eae05c4c7914e58cd10e2680de18a80b22bf9c8 Mon Sep 17 00:00:00 2001
From: Atul Kedia <atul.kedia@ldas-osg.ligo.caltech.edu>
Date: Wed, 22 Feb 2023 10:52:52 -0800
Subject: [PATCH 03/12] minor comments

---
 MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
index 694872746..f1cee6e0b 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
@@ -32,7 +32,7 @@ except:
 from RIFT.physics import MonotonicSpline as ms
 
 
-C_CGS=lal.C_SI*100        # Argh, Monica!
+C_CGS=lal.C_SI*100
 DENSITY_CGS_IN_MSQUARED=7.42591549e-25  # g/cm^3 m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom)
 
 
@@ -594,7 +594,7 @@ class EOSLindblomSpectral(EOSConcrete):
 
 class EOSLindblomSpectralSoundSpeedVersusPressure(EOSConcrete):
     """
-    Based on https://journals.aps.org/prd/abstract/10.1103/PhysRevD.105.063031  <-> https://arxiv.org/pdf/2202.12285.pdf
+    Based on Lindblom (2022) https://journals.aps.org/prd/abstract/10.1103/PhysRevD.105.063031  <-> https://arxiv.org/pdf/2202.12285.pdf
     
     EOS spectral representation of sound speed versus pressure, as expansion of Upsilon(p): see Eq. (11).
     Uses function call to lalsuite to implement low-level interface
-- 
GitLab


From a36530257412080ea53eca2feb55b637bd01baff Mon Sep 17 00:00:00 2001
From: Atul Kedia <atul.kedia@ldas-osg.ligo.caltech.edu>
Date: Thu, 2 Mar 2023 07:14:21 -0800
Subject: [PATCH 04/12] eos tabular demo for EOSManager

---
 .../Code/RIFT/physics/EOSManager.py           |  47 +--
 .../Code/RIFT/physics/EOSPlotUtilities.py     |   6 +-
 .../Code/RIFT/physics/demo_mass_radius.py     |   2 +-
 .../Code/RIFT/physics/demo_new_spectral.py    |  15 +-
 .../Code/RIFT/physics/eos_manager.txt         | 302 ++++++++++++++++++
 .../physics/eos_manager_phase_transition.txt  | 302 ++++++++++++++++++
 6 files changed, 646 insertions(+), 28 deletions(-)
 create mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager.txt
 create mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager_phase_transition.txt

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
index f1cee6e0b..3fe4e0386 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
@@ -245,24 +245,30 @@ class EOSFromTabularData(EOSConcrete):
 
     def __init__(self,name=None,eos_data=None,eos_units=None,reject_phase_transitions=True,debug=False, add_low_density=False):
         eos_name = name
-        if not(eos_data):
+        if eos_data is None:
             raise Exception("EOS data required to use EOSFromTabularData")
         if not(name):
             eos_name="default"
 
         # Assume CGS for now
-        bdens = eos_data["baryon_density"]
-        press = eos_data["pressure"]
-        edens = eos_data["energy_density"]
-
-        # Convert to 
-        press *= DENSITY_CGS_IN_MSQUARED
-        edens *= DENSITY_CGS_IN_MSQUARED
+        try:
+            bdens = eos_data["baryon_density"]
+            press = eos_data["pressure"]
+            edens = eos_data["energy_density"]
+            # Convert to geometerized units
+            press *= DENSITY_CGS_IN_MSQUARED/(lal.C_SI*100)**2
+            edens *= DENSITY_CGS_IN_MSQUARED
+            #press *= 0.1                    #Converts CGS to Pascals
+            #edens *= 0.1*(lal.C_SI*100)**2  #Converts CGS to SI J/m^3
+        except:
+            press = eos_data[:,0]      #LALSim EOS format
+            edens = eos_data[:,1]
         
         if reject_phase_transitions:   # Normally lalsuite can't handle regions of constant pressure. Using a pressure/density only approach isn't suited to phase transitions
             if not np.all(np.diff(press) > 0):    # BLOCKS PHASE TRANSITIONS
                 keep_idx = np.where(np.diff(press) > 0)[0] + 1
                 keep_idx = np.concatenate(([0], keep_idx))
+                print(keep_idx)
                 press = press[keep_idx]
                 edens = edens[keep_idx]
             assert np.all(np.diff(press) > 0)
@@ -272,16 +278,16 @@ class EOSFromTabularData(EOSConcrete):
                 press = press[keep_idx]
                 edens = edens[keep_idx]
             assert np.all(np.diff(edens) > 0)
-    
+        
         # Create temporary file
         # Creating temporary file in suitable units
         if debug:
                 print("Dumping to %s" % self.fname)
         eos_fname = "./" +eos_name + "_geom.dat" # assume write acces
-        np.savetxt(eos_fname, np.transpose((press, edens)), delimiter='\t')
+        np.savetxt(eos_fname, np.transpose((press, edens)), delimiter='\t', header='pressure\t energy_density')
         eos = lalsim.SimNeutronStarEOSFromFile(eos_fname)
         fam = lalsim.CreateSimNeutronStarFamily(eos)
-
+        
         self.name = eos_name
         self.eos =eos
         self.eos_family =fam
@@ -594,7 +600,7 @@ class EOSLindblomSpectral(EOSConcrete):
 
 class EOSLindblomSpectralSoundSpeedVersusPressure(EOSConcrete):
     """
-    Based on Lindblom (2022) https://journals.aps.org/prd/abstract/10.1103/PhysRevD.105.063031  <-> https://arxiv.org/pdf/2202.12285.pdf
+    Based on https://journals.aps.org/prd/abstract/10.1103/PhysRevD.105.063031  <-> https://arxiv.org/pdf/2202.12285.pdf
     
     EOS spectral representation of sound speed versus pressure, as expansion of Upsilon(p): see Eq. (11).
     Uses function call to lalsuite to implement low-level interface
@@ -1051,13 +1057,13 @@ class QueryLS_EOS:
         self.eos = eos
         # Primitive extractors.  Assume I need to vectorize these, and that it isn't available
         extraction_dict_lalsim_raw = {
-            'pseudo_enthalpy': lambda x: x,
-            'rest_mass_density': lambda x: lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*.001,  # g cm^-3
-            'baryon_density': lambda x: (lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*.001)/(lal.AMU_SI*1e3),  #  cm^-3
-           'pressure': lambda x: lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(x, eos)*10,    # dyn cm^-2 ~ g cm^-1 s^-2
-           'energy_density': lambda x: lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(x,eos)*10/(lal.C_SI*100)**2 , # J m^-3 *10/c^2 = g cm^-3
-           'sound_speed_over_c':lambda x: lalsim.SimNeutronStarEOSSpeedOfSound(x,eos)/lal.C_SI
-          }
+            'pseudo_enthalpy'   : lambda x: x,
+            'rest_mass_density' : lambda x: lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*.001,  # g cm^-3
+            'baryon_density'    : lambda x: (lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*.001)/(lal.AMU_SI*1e3),  #  cm^-3
+            'pressure'          : lambda x: lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(x, eos)*10,    # dyn cm^-2 ~ g cm^-1 s^-2
+            'energy_density'    : lambda x: lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(x,eos)*10/(lal.C_SI*100)**2 , # J m^-3 *10/c^2 = g cm^-3
+            'sound_speed_over_c': lambda x: lalsim.SimNeutronStarEOSSpeedOfSound(x,eos)/lal.C_SI
+            }
         self.extraction_dict_lalsim = {}
         for name in         extraction_dict_lalsim_raw:
             self.extraction_dict_lalsim[name] = np.vectorize(extraction_dict_lalsim_raw[name])
@@ -1080,8 +1086,7 @@ class QueryLS_EOS:
         # IN PROGRESS
         #   - adiabatic index
         #Gamma = (self.extraction_dict_lalsim['energy_density']()*(lal.C_SI*100)**2 + self.extraction_dict_lalsim['pressure']())/(self.extraction_dict_lalsim['pressure']()) *np.square(self.extraction_dict_lalsim['sound_speed_over_c']())
-
-
+    
     def extract_param(self, p, pseudo_enthalpy):
         return self.extraction_dict_lalsim[p](pseudo_enthalpy)
 
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py
index 175c336db..d9864a3c9 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py
@@ -27,19 +27,19 @@ plt.style.use('seaborn-v0_8-whitegrid')
 
 
 def render_eos(eos, xvar='energy_density', yvar='pressure',units='cgs',npts=100,label=None):
-
+    
     min_pseudo_enthalpy = 0.005
     max_pseudo_enthalpy = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
     hvals = max_pseudo_enthalpy* 10**np.linspace( np.log10(min_pseudo_enthalpy/max_pseudo_enthalpy),  0,num=npts)
     
     print(hvals,min_pseudo_enthalpy, max_pseudo_enthalpy)
-
+    
     qry = EOSManager.QueryLS_EOS(eos)
     
     xvals = qry.extract_param(xvar,hvals)
     yvals = qry.extract_param(yvar,hvals)
     print(np.c_[xvals,yvals])
-    #qry.convert(xvals, 'rest_mass_density') # using QueryLS_EOS.convert
+    #xvals = qry.convert(xvals, 'rest_mass_density') # using QueryLS_EOS.convert
     
     plt.loglog(xvals, yvals)
     plt.xlabel(xvar)
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py
index 7ba20c73f..84b38100f 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py
@@ -23,7 +23,7 @@ plt.style.use('seaborn-v0_8-whitegrid')
 
 #spec_params = {'gamma1': -0.701593,'gamma2':-0.239194,'gamma3':0.062016,'gamma4':-0.003556}
 
-eoss = np.genfromtxt('../20221207-ROSKedia-SpectralRepresentation/names_laleos_improvedPBCS_indices_physical_EOS.txt', dtype='str')
+eoss = np.genfromtxt('/home/atul.kedia/rift-testing/RIT-matters/communications/20221207-ROSKedia-SpectralRepresentation/names_laleos_improvedPBCS_indices_physical_EOS.txt', dtype='str')
 
 def M_1_4():
     print('M_1.4')
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
index 76467892c..fa4d86055 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
@@ -23,7 +23,16 @@ plt.style.use('seaborn-v0_8-whitegrid')
 
 #spec_params = {'gamma1': -0.701593,'gamma2':-0.239194,'gamma3':0.062016,'gamma4':-0.003556}
 
-eoss = np.genfromtxt('../20221207-ROSKedia-SpectralRepresentation/names_laleos_improvedPBCS_indices_physical_EOS.txt', dtype='str')
+eoss = np.genfromtxt('/home/atul.kedia/rift-testing/RIT-matters/communications/20221207-ROSKedia-SpectralRepresentation/names_laleos_improvedPBCS_indices_physical_EOS.txt', dtype='str')
+
+'''
+eoss = np.array([['AP4', '-0.592110', '-0.264530', '0.085421', '-0.008334'],
+        ['SLY4', '-0.779775', '-0.144165', '0.054823', '-0.005143'],
+        ['PAL6', '-2.336417', '0.961124', '-0.178733', '0.010829'],
+        ['AP3', '-0.463822', '-0.466598', '0.147791', '-0.013972'],
+        ['MPA1', '-1.247626', '0.207047', '-0.030886', '0.000749'],
+        ['WFF1', '0.233772', '-0.764008', '0.193810', '-0.016393']], dtype=str)
+'''
 
 for i in range(0,len(eoss[:])):
     spec_params = {'gamma1': eoss[i][1].astype(float),
@@ -38,11 +47,11 @@ for i in range(0,len(eoss[:])):
     new_eos_vals = neweos.make_spec_param_eos(xvar=xvar, yvar=yvar)
     #xvar, yvar ='energy_density', 'pressure', 'rest_mass_density', 'sound_speed_over_c', 'pseudo_enthalpy'
     
-    plt.loglog(new_eos_vals[:,0], new_eos_vals[:,1])
+    plt.loglog(new_eos_vals[:,0], new_eos_vals[:,1], label = eoss[i][0])
     plt.xlabel(xvar)
     plt.ylabel(yvar)
     
-    #render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
+    #plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
     #render_eos variable names: pseudo_enthalpy, rest_mass_density, baryon_density, pressure, energy_density, sound_speed_over_c
 
 
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager.txt b/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager.txt
new file mode 100644
index 000000000..2a1c77d46
--- /dev/null
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager.txt
@@ -0,0 +1,302 @@
+# baryon_density pressure energy_density
+6.294999999999999937e+28 5.165347142000000369e+20 1.042782668627668463e+05
+6.985358165731020154e+28 6.166458480847186821e+20 1.157151306250155612e+05
+7.751426323041308748e+28 7.377918698718484234e+20 1.284064586129412928e+05
+8.601507412505002415e+28 8.846061893030260244e+20 1.424898735194982728e+05
+9.544814939084625418e+28 1.062768641128689828e+21 1.581181021415382565e+05
+1.059157283163244364e+29 1.261398350214372786e+21 1.754584631611361692e+05
+1.175312625375353433e+29 1.485408293169513103e+21 1.946986092775386642e+05
+1.304206456704128682e+29 1.753806904898457960e+21 2.160483197536182706e+05
+1.447235777940795062e+29 2.076048307660254085e+21 2.397388398945541412e+05
+1.605950795738970580e+29 2.463684413519224635e+21 2.660267505057482049e+05
+1.782071724349078316e+29 2.930840493769161703e+21 2.951967401758864289e+05
+1.977507429960316862e+29 3.494799838784604602e+21 3.275646827058025519e+05
+2.194376119724712341e+29 4.176722490156965167e+21 3.634810460901324986e+05
+2.435028299698835548e+29 5.002527203760150675e+21 4.033346776634584530e+05
+2.702072250530163932e+29 5.892333298708114309e+21 4.475790000887386850e+05
+2.998402297003348584e+29 6.908898423491679748e+21 4.966879713464012020e+05
+3.327230177842571599e+29 8.122636605744099623e+21 5.511881657099396689e+05
+3.692119855767956042e+29 9.574996539893564310e+21 6.116721119411712280e+05
+4.097026145090759623e+29 1.131655979640099229e+22 6.787976168395495042e+05
+4.546337575508057181e+29 1.340910188938168736e+22 7.532949942248150473e+05
+5.044923956671163998e+29 1.592812934674910282e+22 8.359750993889740203e+05
+5.598189159050828772e+29 1.896599219245485235e+22 9.277382688889581477e+05
+6.212129683158470508e+29 2.263571341215911851e+22 1.029584259293717681e+06
+6.893399651919155353e+29 2.643140419722350376e+22 1.142498452732925303e+06
+7.649382930608554618e+29 3.083884099221510003e+22 1.267775161095064366e+06
+8.488273156017465996e+29 3.607870289969677546e+22 1.406786405555349775e+06
+9.419162542230662313e+29 4.232304317650667622e+22 1.561037431739235995e+06
+1.045214042553117107e+30 4.978146612511713631e+22 1.732198334886844503e+06
+1.159840261649745390e+30 5.870957377684263823e+22 1.922122082617670996e+06
+1.287037274449349100e+30 6.941933102760417506e+22 2.132864507089901716e+06
+1.428183690972987446e+30 8.229180031294750327e+22 2.366706471757432912e+06
+1.584809310230663535e+30 9.772799639550402809e+22 2.626181067109444644e+06
+1.758611700769866740e+30 1.131394987247661503e+23 2.914222943381906487e+06
+1.951474599574726767e+30 1.313271371838366658e+23 3.233861726632961072e+06
+2.165488328730102235e+30 1.528466211293808736e+23 3.588564429986020550e+06
+2.402972451134239791e+30 1.783727334770808245e+23 3.982178716367234010e+06
+2.666500910811318002e+30 2.087258453860299928e+23 4.418974740352245048e+06
+2.958929930304216832e+30 2.449044331484340132e+23 4.903691604199388064e+06
+3.283428967510163103e+30 2.881250106323136823e+23 5.441588941430862062e+06
+3.643515067481317813e+30 3.398711545722846870e+23 6.038504187433504499e+06
+4.043090981508281263e+30 3.994084513997780314e+23 6.700931869425583631e+06
+4.486487466635793050e+30 4.561446550687552939e+23 7.436141897442588583e+06
+4.978510224068978277e+30 5.220954352209997962e+23 8.252058042672330514e+06
+5.524491985206610571e+30 6.026257726417550537e+23 9.157127533225657418e+06
+6.130350309829796782e+30 6.975570249957073549e+23 1.016145236971424147e+07
+6.802651722885029795e+30 8.095722728123233049e+23 1.127593857291039824e+07
+7.548682885000656204e+30 9.420889942752078500e+23 1.251267176713720337e+07
+8.376529568110140368e+30 1.099256652677204566e+24 1.388506401921731792e+07
+9.295164292150200218e+30 1.286119592228581074e+24 1.540799953863635287e+07
+1.031454357267399647e+31 1.498814017068945946e+24 1.709801247436551750e+07
+1.144571583338629346e+31 1.726639982547876249e+24 1.897346352026350796e+07
+1.270094115319805651e+31 1.994132054658340444e+24 2.105467225973089784e+07
+1.409382414566500753e+31 2.309036986525123510e+24 2.336422247097013891e+07
+1.563946141100843213e+31 2.680736808942375736e+24 2.592717899943273142e+07
+1.735460515885987659e+31 3.120610412940436076e+24 2.877136084667658806e+07
+1.925784477513574776e+31 3.642475903973184846e+24 3.192764446715832129e+07
+2.136980830093327678e+31 4.205290379566238904e+24 3.542856988159487396e+07
+2.371338600715342095e+31 4.836502153627852291e+24 3.931238560759986192e+07
+2.631397848803825946e+31 5.576275175894791993e+24 4.362177093094854802e+07
+2.919977196255576085e+31 6.445616996951186559e+24 4.840331390418393165e+07
+3.240204376745395294e+31 7.469943322244621521e+24 5.370869253934999555e+07
+3.595550135303548088e+31 8.680051523629571952e+24 5.959522858162413538e+07
+3.989865845581876323e+31 1.010506875087315266e+25 6.612681462651485950e+07
+4.427425252518930058e+31 1.158202545139873542e+25 7.338190168885791302e+07
+4.912970792827137564e+31 1.330627280163583039e+25 8.143335731377996504e+07
+5.451764995341231958e+31 1.532467065196200909e+25 9.036868400106081367e+07
+6.049647518324608522e+31 1.769378256279272897e+25 1.002850188882630020e+08
+6.713098441925846426e+31 2.048200061238148048e+25 1.112901994359344244e+08
+7.449308501773297820e+31 2.377214032348884776e+25 1.235039478270068467e+08
+8.266257024926391146e+31 2.746192498781150683e+25 1.370553822074735761e+08
+9.172798412883392948e+31 3.146068200818694870e+25 1.520881008554103076e+08
+1.017875810898166060e+32 3.612634404991467477e+25 1.687699252766113579e+08
+1.129503909032182568e+32 4.158488578103147774e+25 1.872818252656230330e+08
+1.253374003841630512e+32 4.798832153777370277e+25 2.078246440657068193e+08
+1.390828646934093104e+32 5.552039084262530960e+25 2.306212839966365993e+08
+1.543357624462858633e+32 6.440351359224255747e+25 2.559191333486205637e+08
+1.712614104000772093e+32 7.315534176103794821e+25 2.840197671385089159e+08
+1.900432552204591787e+32 8.264068657843502556e+25 3.152196421561555266e+08
+2.108848617468370116e+32 9.413512537648969385e+25 3.498158202553554773e+08
+2.340121193061676165e+32 1.080377492392429677e+26 3.881775999846838117e+08
+2.596756899881429265e+32 1.242930917786251108e+26 4.307460306894009709e+08
+2.881537254170788066e+32 1.433507568146248251e+26 4.779823542617355585e+08
+3.197548814659263493e+32 1.655136756132743333e+26 5.304001204967349172e+08
+3.548216635870313894e+32 1.896958477990492617e+26 5.885799017197387218e+08
+3.937341390176227941e+32 2.179252879104347483e+26 6.531429068243144751e+08
+4.369140560943326286e+32 2.509686767892577973e+26 7.247898125527240038e+08
+4.848294153234641259e+32 2.897514348835473551e+26 8.042982864777351618e+08
+5.379995417500169477e+32 3.334043502253457473e+26 8.925321820100079775e+08
+5.970007136017519839e+32 3.836150159953974780e+26 9.904493984702121019e+08
+6.624724082137004584e+32 4.312576556420053212e+26 1.099125768921423674e+09
+7.351242329288429869e+32 4.718653535163892684e+26 1.219748644378827572e+09
+8.157436160947172566e+32 5.225941268531537930e+26 1.353596928281055450e+09
+9.052043415139293179e+32 6.004484282431530675e+26 1.502074793670563459e+09
+1.004476018848212219e+33 6.912221847770953695e+26 1.666842074406544447e+09
+1.114634592619911956e+33 7.915714347447511525e+26 1.849667730881092787e+09
+1.236874003711480989e+33 9.086044371490364774e+26 2.052549684997077703e+09
+1.372519129754791655e+33 1.045464686649291233e+27 2.277688905832159042e+09
+1.523040144663172084e+33 1.205944404976415460e+27 2.527528071273923397e+09
+1.690068452940276919e+33 1.384774433518954870e+27 2.804945455609254837e+09
+1.875414371467952226e+33 1.587546097178036821e+27 3.112949069844432831e+09
+2.081086750415086011e+33 1.824333122097363011e+27 3.454821356287115574e+09
+2.309314745926394680e+33 2.101590923855381572e+27 3.834297581346822262e+09
+2.562571980571881930e+33 2.421513217345445596e+27 4.255396053567112446e+09
+2.843603353417206204e+33 2.773241141044943385e+27 4.722251476064086914e+09
+3.155454790292771230e+33 3.183477904656233432e+27 5.240346561189462662e+09
+3.501506256706381314e+33 3.663252315644170908e+27 5.815310062971747398e+09
+3.885508391206065761e+33 4.225869911896249537e+27 6.453390205504040718e+09
+4.311623156239506076e+33 4.777947483055280573e+27 7.161411504350040436e+09
+4.784468947099695984e+33 5.376751065610691527e+27 7.947112620680989265e+09
+5.309170647864869901e+33 6.119733623216651456e+27 8.817724873351537704e+09
+5.891415176858192836e+33 7.032206282933378178e+27 9.782458272739786148e+09
+6.537513123650205288e+33 8.085139337613389238e+27 1.085528350580601692e+10
+7.254467145649511099e+33 9.287285723835153615e+27 1.205150645161280441e+10
+8.050047865590185856e+33 1.068491032048416860e+28 1.337889434963222694e+10
+8.932878092521999972e+33 1.226239386950930406e+28 1.484433476382813263e+10
+9.912526279122840605e+33 1.410673866420962835e+28 1.647007202313125801e+10
+1.099961022825958281e+34 1.618872017588819029e+28 1.828035967803216934e+10
+1.220591217280882326e+34 1.861666562530063102e+28 2.029063201215296936e+10
+1.354450647601679915e+34 2.110505129120199887e+28 2.251830857884699631e+10
+1.502990133646396049e+34 2.381167164739957577e+28 2.498893758925205612e+10
+1.667819603348691168e+34 2.704354276315120405e+28 2.773268601504651260e+10
+1.850725541734400614e+34 3.092577186042517652e+28 3.078021258867486191e+10
+2.053690353531589750e+34 3.543574686794249570e+28 3.416098211200037384e+10
+2.278913849233506444e+34 4.067206352198093962e+28 3.790726270624259949e+10
+2.528837087488608057e+34 4.667769171321674143e+28 4.206522442892446136e+10
+2.806168832230658997e+34 5.226299079536023225e+28 4.668979636220603180e+10
+3.113914911301399794e+34 5.856868890106270833e+28 5.182416633400325775e+10
+3.455410794765817660e+34 6.699214996788812689e+28 5.751105760011439514e+10
+3.834357746016285709e+34 7.702001398251428439e+28 6.382009333553183746e+10
+4.254862937485122634e+34 8.845233050429101515e+28 7.082954603853540039e+10
+4.721483965755040564e+34 1.016400954419972109e+29 7.861496419139753723e+10
+5.239278248539326095e+34 1.167957259653945684e+29 8.724768711238674927e+10
+5.813857838915186420e+34 1.341321188428274853e+29 9.681453897342863464e+10
+6.451450250907942562e+34 1.542231672487229490e+29 1.074409808102410736e+11
+7.158965955677083153e+34 1.770335880354263798e+29 1.192752127938576202e+11
+7.944073279853740413e+34 2.035535190426246950e+29 1.324172360026489410e+11
+8.815281517806501624e+34 2.272849675516221820e+29 1.469236737655426331e+11
+9.782033158638187572e+34 2.539447736538703479e+29 1.630174232918174133e+11
+1.085480622750514232e+35 2.834161249313151809e+29 1.809693535214535217e+11
+1.204522785047354846e+35 3.150626886028104514e+29 2.008278968910747986e+11
+1.336620027377221718e+35 3.566924093964861710e+29 2.228872671068214722e+11
+1.483204070328688704e+35 4.097881163433249748e+29 2.474099195602670898e+11
+1.645863647993009095e+35 4.675180237383062727e+29 2.746266281294648132e+11
+1.826361727273679436e+35 5.263271468064955134e+29 3.048222922056145020e+11
+2.026654615598063382e+35 5.928443689643093528e+29 3.383443103573421631e+11
+2.248913164127782883e+35 6.660241614351612660e+29 3.755466155208320923e+11
+2.495546296276408869e+35 7.491181980950670312e+29 4.168512223713275757e+11
+2.769227116545546965e+35 8.354890690443169521e+29 4.624469924893273926e+11
+3.072921882656903219e+35 9.206102751476656203e+29 5.131863640802401733e+11
+3.409922154991412500e+35 1.013561551354342926e+30 5.694957293153978271e+11
+3.783880471783379948e+35 1.114853360920056628e+30 6.319872145884324951e+11
+4.198849936731084632e+35 1.224971607181139856e+30 7.013403723333323975e+11
+4.659328148089541666e+35 1.344356397863777823e+30 7.783096440563981934e+11
+5.170305945365794691e+35 1.473373812761378091e+30 8.637326575508997803e+11
+5.737321501952119103e+35 1.612279689975440968e+30 9.585394530717751465e+11
+6.366520349973851686e+35 1.761172663564104038e+30 1.063762746255796143e+12
+7.064721987924157516e+35 1.919934393472977400e+30 1.180549345243035645e+12
+7.839493793004843199e+35 2.088152527653006931e+30 1.310172856437592285e+12
+8.699233039263547783e+35 2.265023482064908918e+30 1.454047829225046631e+12
+9.653257910471280334e+35 2.449230157321329733e+30 1.613745505851289062e+12
+1.071190849417285629e+36 2.638786449431165501e+30 1.791011367479669189e+12
+1.188665885152245279e+36 2.830842990000272562e+30 1.987784687780635742e+12
+1.319024137756017198e+36 3.021442584795782804e+30 2.206220333517662109e+12
+1.463678479979398388e+36 3.205215593695609359e+30 2.448713084065665039e+12
+1.624196731076863850e+36 3.374997388433615126e+30 2.717924772374655762e+12
+1.802318649433105825e+36 3.521354316858286545e+30 3.016814596280232422e+12
+1.999974788731826606e+36 3.631989415893279058e+30 3.348672989928392578e+12
+2.219307422037178289e+36 4.166541247521724958e+30 3.716341586894569336e+12
+2.462693760571066537e+36 4.791304287700583583e+30 4.124430305948428223e+12
+2.732771718840338952e+36 5.523413048842315044e+30 4.577394892917429688e+12
+3.032468505366188821e+36 6.382441800388788158e+30 5.080168675995340820e+12
+3.365032348893066296e+36 7.382304341528081485e+30 5.638096448424265625e+12
+3.734067703937921693e+36 8.561208748124174740e+30 6.257395355668807617e+12
+4.143574317251031495e+36 9.946277558358492511e+30 6.944782725406486328e+12
+4.597990578605691399e+36 1.156693610258714716e+31 7.707693864420269531e+12
+5.102241625769272732e+36 1.347999175789679893e+31 8.554538233984585938e+12
+5.661792725035759666e+36 1.571357737532060210e+31 9.494457086702732422e+12
+6.282708505878480423e+36 1.835954692105069707e+31 1.053778136998549414e+13
+6.971718691730893878e+36 2.149840671451791603e+31 1.169588855987116797e+13
+7.736291039310880035e+36 2.512469813336011363e+31 1.298137064535030273e+13
+8.584712277032879994e+36 2.940350214072720701e+31 1.440832949675453516e+13
+9.526177919749477850e+36 3.443838149024896332e+31 1.599235171223742773e+13
+1.057089193326903209e+37 4.033943525107494818e+31 1.775075624285680859e+13
+1.173017732885162958e+37 4.727905403341851443e+31 1.970278483858347656e+13
+1.301659888634894917e+37 5.533843736314825691e+31 2.186981278257176953e+13
+1.444409933610848864e+37 6.478177858927889376e+31 2.427552204629973828e+13
+1.602815047563389987e+37 7.573383933218675981e+31 2.694634292323234766e+13
+1.778592085886176786e+37 8.845263427457890404e+31 2.991147610119188672e+13
+1.973646187553546846e+37 1.030495241891500315e+32 3.320346577422444531e+13
+2.190091423747587717e+37 1.198294085420827316e+32 3.685840409389389844e+13
+2.430273710972626631e+37 1.388362255016434658e+32 4.091633508270321094e+13
+2.696796236998263779e+37 1.601567006363779311e+32 4.542179385438157812e+13
+2.992547675207070442e+37 1.839729587663832682e+32 5.042413696713809375e+13
+3.320733493144891266e+37 2.104218429326042950e+32 5.597817761637072656e+13
+3.684910694607810056e+37 2.393648357144748130e+32 6.214475890907849219e+13
+4.089026371813857209e+37 2.708364392940562441e+32 6.899135759501764844e+13
+4.537460485502687135e+37 3.013613985527547037e+32 7.659273708806068750e+13
+5.035073336630347560e+37 3.371716075091777995e+32 8.503185645830560938e+13
+5.587258244175588525e+37 3.750038734872313329e+32 9.440105625353439062e+13
+6.199999999999986184e+37 4.147200335999991463e+32 1.048025763494627500e+14
+6.544012399999999797e+37 4.176787846084300410e+32 1.106436243014349219e+14
+6.742657899999999657e+37 4.505894094680140264e+32 1.140169235146369062e+14
+6.947333399999999245e+37 4.853836291708117644e+32 1.174937658587942500e+14
+7.158221799999999491e+37 5.221854198702269117e+32 1.210773578276822969e+14
+7.375511899999998492e+37 5.611325210001689304e+32 1.247710134003582969e+14
+7.599397799999999484e+37 6.023783526992610027e+32 1.285781450575731250e+14
+7.830079900000000385e+37 6.460945829349889484e+32 1.325022808725620469e+14
+8.067764299999998941e+37 6.924737782325394546e+32 1.365470560465101719e+14
+8.312663800000000209e+37 7.417326466489878386e+32 1.407162302193905312e+14
+8.564997299999999979e+37 7.941154689937977729e+32 1.450136792617317812e+14
+8.824990400000000412e+37 8.498981840638593274e+32 1.494434061570005625e+14
+9.092875699999998496e+37 9.093929164207096740e+32 1.540095477411290312e+14
+9.368892799999999273e+37 9.729530864719819524e+32 1.587163770151503125e+14
+9.653288399999999394e+37 1.040979050941616662e+33 1.635683061396751250e+14
+9.946316999999999545e+37 1.113924691018881530e+33 1.685699011697816562e+14
+1.024824000000000035e+38 1.192304247077376123e+33 1.737258688284273125e+14
+1.055932899999999912e+38 1.276701082714305417e+33 1.790411162246842500e+14
+1.087986099999999889e+38 1.367775338497083142e+33 1.845206713701507188e+14
+1.121012200000000021e+38 1.466274541097519953e+33 1.901697493400887500e+14
+1.155040899999999914e+38 1.573045119530039719e+33 1.959937897078371562e+14
+1.190102499999999895e+38 1.689042823930879812e+33 2.019983761152837500e+14
+1.226228399999999837e+38 1.815347429134675342e+33 2.081893267307620938e+14
+1.263450999999999743e+38 1.953176885910319488e+33 2.145726835592829688e+14
+1.301803399999999946e+38 2.103901962378143950e+33 2.211546668857090312e+14
+1.341320099999999934e+38 2.269066144814640035e+33 2.279418029187489688e+14
+1.382036299999999906e+38 2.450401439961647772e+33 2.349408116672644688e+14
+1.423988399999999985e+38 2.649850800520896242e+33 2.421587015753798125e+14
+1.467213999999999837e+38 2.869589583174719842e+33 2.496027802910953125e+14
+1.511751699999999823e+38 3.112048753051311362e+33 2.572806302293722812e+14
+1.557641399999999839e+38 3.379940777994816073e+33 2.652001733570514688e+14
+1.604924099999999902e+38 3.676285108486223503e+33 2.733696494373690625e+14
+1.653642099999999945e+38 4.004439071906591052e+33 2.817976661619926250e+14
+1.703838900000000012e+38 4.368124699960174808e+33 2.904931969967976250e+14
+1.755559499999999863e+38 4.771465220228640142e+33 2.994656522691256875e+14
+1.808849999999999943e+38 5.219013259392000113e+33 3.087248272117512500e+14
+1.863758199999999832e+38 5.715791241637407694e+33 3.182810298130898125e+14
+1.920333199999999783e+38 6.267325405377919430e+33 3.281450318304651250e+14
+1.978625499999999958e+38 6.879684979041039901e+33 3.383281132944153125e+14
+2.038687300000000033e+38 7.559524922572896193e+33 3.488421394731748125e+14
+2.100572199999999595e+38 8.314127280628670508e+33 3.596995404982125625e+14
+2.164335699999999619e+38 9.151452329260910267e+33 3.709134284257751875e+14
+2.230034799999999852e+38 1.008018439226489650e+34 3.824975621431327500e+14
+2.297728199999999929e+38 1.110978495692678352e+34 3.944664206157361250e+14
+2.367476499999999744e+38 1.225055752914991855e+34 4.068352756730983750e+14
+2.439341999999999837e+38 1.351370450108447721e+34 4.196202031333028125e+14
+2.513388899999999493e+38 1.491140310311097143e+34 4.328381617609762500e+14
+2.589683599999999743e+38 1.645688695028178833e+34 4.465071011428784375e+14
+2.668294299999999616e+38 1.816452658292831690e+34 4.606459419742203125e+14
+2.749291200000000278e+38 2.004992529057792265e+34 4.752746755531966250e+14
+2.832746699999999733e+38 2.213002864044772267e+34 4.904144596611195625e+14
+2.918735699999999979e+38 2.442324761818987113e+34 5.060877491065353750e+14
+3.007334799999999883e+38 2.694956294128761227e+34 5.223182240244966250e+14
+3.098623300000000029e+38 2.973068273755347329e+34 5.391310557921419375e+14
+3.192682999999999706e+38 3.279018563110367896e+34 5.565529636196520625e+14
+3.289597899999999573e+38 3.615365885266371088e+34 5.746122548559611250e+14
+3.389454700000000119e+38 3.984887419908601685e+34 5.933390276255341250e+14
+3.492342599999999779e+38 4.390593903143154921e+34 6.127652458447495000e+14
+3.598353699999999450e+38 4.835747510043711794e+34 6.329249415206125000e+14
+3.707582899999999848e+38 5.323877267264752335e+34 6.538543271425423750e+14
+3.820127700000000013e+38 5.858793184601405623e+34 6.755919038409673750e+14
+3.936088799999999532e+38 6.444602906208767228e+34 6.981787227274886250e+14
+4.055570000000000064e+38 7.085722543396799510e+34 7.216585344161030000e+14
+4.178678100000000050e+38 7.786889083084463534e+34 7.460779330040896250e+14
+4.305523199999999989e+38 8.553165701634047388e+34 7.714865970400578750e+14
+4.436218699999999410e+38 9.389948928667200788e+34 7.979374723208910000e+14
+4.570881399999999138e+38 1.030297071974569336e+35 8.254869865301522500e+14
+4.709631999999999747e+38 1.129829941161984090e+35 8.541953462782542500e+14
+4.852594299999999344e+38 1.238233148946121384e+35 8.841265792026993750e+14
+4.999896299999999546e+38 1.356179152261012818e+35 9.153489684880531250e+14
+5.151669699999999467e+38 1.484372598593958103e+35 9.479351594940230000e+14
+5.308050199999999474e+38 1.623549025036284791e+35 9.819624411026782500e+14
+5.469177699999999665e+38 1.774475054792372887e+35 1.017512989478104375e+15
+5.635196299999999870e+38 1.937947614095631825e+35 1.054674146931147750e+15
+5.806254400000000398e+38 2.114793924598271855e+35 1.093538601576421375e+15
+5.982505099999998990e+38 2.305872357123191547e+35 1.134204763274132000e+15
+6.164105799999999911e+38 2.512072534650841528e+35 1.176776913424821750e+15
+6.351219199999999532e+38 2.734318353945394896e+35 1.221365664659901750e+15
+6.544012399999999230e+38 2.973568346821471764e+35 1.268088058071735000e+15
+6.742657899999999280e+38 3.230820266318532735e+35 1.317068086403385750e+15
+6.947333399999998868e+38 3.507113163819618144e+35 1.368436924768349750e+15
+7.158221799999999869e+38 3.803532033927135439e+35 1.422333261400725750e+15
+7.375511900000000004e+38 4.121212188182810991e+35 1.478903867296315000e+15
+7.599397799999998917e+38 4.461343570011302574e+35 1.538303760441225250e+15
+7.830079899999998874e+38 4.825176866693842444e+35 1.600696910844022250e+15
+8.067764299999998752e+38 5.214027999424102138e+35 1.666256501780876500e+15
+8.312663799999998509e+38 5.629285251361474168e+35 1.735165666840627750e+15
+8.564997299999999224e+38 6.072413704313394625e+35 1.807617822977759250e+15
+8.824990400000000034e+38 6.544962632659532083e+35 1.883817357046999000e+15
+9.092875699999999630e+38 7.048571884808650518e+35 1.963980319726244750e+15
+9.368892799999999273e+38 7.584978411203327629e+35 2.048335005411468750e+15
+9.653288399999999772e+38 8.156022748122413826e+35 2.137122597182751750e+15
+9.946316999999999923e+38 8.763656940610561420e+35 2.230598161766946750e+15
+1.024823999999999959e+39 9.409950529155839483e+35 2.329030998352703000e+15
+1.055932899999999950e+39 1.009710442550620811e+36 2.432706580232024000e+15
+1.087986099999999851e+39 1.082744757426860624e+36 2.541925729778268000e+15
+1.121012199999999945e+39 1.160345361327644916e+36 2.657006736487105000e+15
+1.155040899999999839e+39 1.242775385798273497e+36 2.778286962337194000e+15
+1.190102500000000008e+39 1.330313388268119935e+36 2.906122147729318500e+15
+1.226228400000000102e+39 1.423255522449369833e+36 3.040889134229467000e+15
+1.263451000000000007e+39 1.521916262691664139e+36 3.182986744146438000e+15
+1.301803400000000021e+39 1.626628697015804830e+36 3.332835789104209000e+15
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager_phase_transition.txt b/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager_phase_transition.txt
new file mode 100644
index 000000000..9c00d0086
--- /dev/null
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager_phase_transition.txt
@@ -0,0 +1,302 @@
+# baryon_density pressure energy_density
+6.294999999999999937e+28 5.165347142000000369e+20 1.042782668627668463e+05
+6.985358165731020154e+28 6.166458480847186821e+20 1.157151306250155612e+05
+7.751426323041308748e+28 7.377918698718484234e+20 1.284064586129412928e+05
+8.601507412505002415e+28 8.846061893030260244e+20 1.424898735194982728e+05
+9.544814939084625418e+28 1.062768641128689828e+21 1.581181021415382565e+05
+1.059157283163244364e+29 1.261398350214372786e+21 1.754584631611361692e+05
+1.175312625375353433e+29 1.485408293169513103e+21 1.946986092775386642e+05
+1.304206456704128682e+29 1.753806904898457960e+21 2.160483197536182706e+05
+1.447235777940795062e+29 2.076048307660254085e+21 2.397388398945541412e+05
+1.605950795738970580e+29 2.463684413519224635e+21 2.660267505057482049e+05
+1.782071724349078316e+29 2.930840493769161703e+21 2.951967401758864289e+05
+1.977507429960316862e+29 3.494799838784604602e+21 3.275646827058025519e+05
+2.194376119724712341e+29 4.176722490156965167e+21 3.634810460901324986e+05
+2.435028299698835548e+29 5.002527203760150675e+21 4.033346776634584530e+05
+2.702072250530163932e+29 5.892333298708114309e+21 4.475790000887386850e+05
+2.998402297003348584e+29 6.908898423491679748e+21 4.966879713464012020e+05
+3.327230177842571599e+29 8.122636605744099623e+21 5.511881657099396689e+05
+3.692119855767956042e+29 9.574996539893564310e+21 6.116721119411712280e+05
+4.097026145090759623e+29 1.131655979640099229e+22 6.787976168395495042e+05
+4.546337575508057181e+29 1.340910188938168736e+22 7.532949942248150473e+05
+5.044923956671163998e+29 1.592812934674910282e+22 8.359750993889740203e+05
+5.598189159050828772e+29 1.896599219245485235e+22 9.277382688889581477e+05
+6.212129683158470508e+29 2.263571341215911851e+22 1.029584259293717681e+06
+6.893399651919155353e+29 2.643140419722350376e+22 1.142498452732925303e+06
+7.649382930608554618e+29 3.083884099221510003e+22 1.267775161095064366e+06
+8.488273156017465996e+29 3.607870289969677546e+22 1.406786405555349775e+06
+9.419162542230662313e+29 4.232304317650667622e+22 1.561037431739235995e+06
+1.045214042553117107e+30 4.978146612511713631e+22 1.732198334886844503e+06
+1.159840261649745390e+30 5.870957377684263823e+22 1.922122082617670996e+06
+1.287037274449349100e+30 6.941933102760417506e+22 2.132864507089901716e+06
+1.428183690972987446e+30 8.229180031294750327e+22 2.366706471757432912e+06
+1.584809310230663535e+30 9.772799639550402809e+22 2.626181067109444644e+06
+1.758611700769866740e+30 1.131394987247661503e+23 2.914222943381906487e+06
+1.951474599574726767e+30 1.313271371838366658e+23 3.233861726632961072e+06
+2.165488328730102235e+30 1.528466211293808736e+23 3.588564429986020550e+06
+2.402972451134239791e+30 1.783727334770808245e+23 3.982178716367234010e+06
+2.666500910811318002e+30 2.087258453860299928e+23 4.418974740352245048e+06
+2.958929930304216832e+30 2.449044331484340132e+23 4.903691604199388064e+06
+3.283428967510163103e+30 2.881250106323136823e+23 5.441588941430862062e+06
+3.643515067481317813e+30 3.398711545722846870e+23 6.038504187433504499e+06
+4.043090981508281263e+30 3.994084513997780314e+23 6.700931869425583631e+06
+4.486487466635793050e+30 4.561446550687552939e+23 7.436141897442588583e+06
+4.978510224068978277e+30 5.220954352209997962e+23 8.252058042672330514e+06
+5.524491985206610571e+30 6.026257726417550537e+23 9.157127533225657418e+06
+6.130350309829796782e+30 6.975570249957073549e+23 1.016145236971424147e+07
+6.802651722885029795e+30 8.095722728123233049e+23 1.127593857291039824e+07
+7.548682885000656204e+30 9.420889942752078500e+23 1.251267176713720337e+07
+8.376529568110140368e+30 1.099256652677204566e+24 1.388506401921731792e+07
+9.295164292150200218e+30 1.286119592228581074e+24 1.540799953863635287e+07
+1.031454357267399647e+31 1.498814017068945946e+24 1.709801247436551750e+07
+1.144571583338629346e+31 1.726639982547876249e+24 1.897346352026350796e+07
+1.270094115319805651e+31 1.994132054658340444e+24 2.105467225973089784e+07
+1.409382414566500753e+31 2.309036986525123510e+24 2.336422247097013891e+07
+1.563946141100843213e+31 2.680736808942375736e+24 2.592717899943273142e+07
+1.735460515885987659e+31 3.120610412940436076e+24 2.877136084667658806e+07
+1.925784477513574776e+31 3.642475903973184846e+24 3.192764446715832129e+07
+2.136980830093327678e+31 4.205290379566238904e+24 3.542856988159487396e+07
+2.371338600715342095e+31 4.836502153627852291e+24 3.931238560759986192e+07
+2.631397848803825946e+31 5.576275175894791993e+24 4.362177093094854802e+07
+2.919977196255576085e+31 6.445616996951186559e+24 4.840331390418393165e+07
+3.240204376745395294e+31 7.469943322244621521e+24 5.370869253934999555e+07
+3.595550135303548088e+31 8.680051523629571952e+24 5.959522858162413538e+07
+3.989865845581876323e+31 1.010506875087315266e+25 6.612681462651485950e+07
+4.427425252518930058e+31 1.158202545139873542e+25 7.338190168885791302e+07
+4.912970792827137564e+31 1.330627280163583039e+25 8.143335731377996504e+07
+5.451764995341231958e+31 1.532467065196200909e+25 9.036868400106081367e+07
+6.049647518324608522e+31 1.769378256279272897e+25 1.002850188882630020e+08
+6.713098441925846426e+31 2.048200061238148048e+25 1.112901994359344244e+08
+7.449308501773297820e+31 2.377214032348884776e+25 1.235039478270068467e+08
+8.266257024926391146e+31 2.746192498781150683e+25 1.370553822074735761e+08
+9.172798412883392948e+31 3.146068200818694870e+25 1.520881008554103076e+08
+1.017875810898166060e+32 3.612634404991467477e+25 1.687699252766113579e+08
+1.129503909032182568e+32 4.158488578103147774e+25 1.872818252656230330e+08
+1.253374003841630512e+32 4.798832153777370277e+25 2.078246440657068193e+08
+1.390828646934093104e+32 5.552039084262530960e+25 2.306212839966365993e+08
+1.543357624462858633e+32 6.440351359224255747e+25 2.559191333486205637e+08
+1.712614104000772093e+32 7.315534176103794821e+25 2.840197671385089159e+08
+1.900432552204591787e+32 8.264068657843502556e+25 3.152196421561555266e+08
+2.108848617468370116e+32 9.413512537648969385e+25 3.498158202553554773e+08
+2.340121193061676165e+32 1.080377492392429677e+26 3.881775999846838117e+08
+2.596756899881429265e+32 1.242930917786251108e+26 4.307460306894009709e+08
+2.881537254170788066e+32 1.433507568146248251e+26 4.779823542617355585e+08
+3.197548814659263493e+32 1.655136756132743333e+26 5.304001204967349172e+08
+3.548216635870313894e+32 1.896958477990492617e+26 5.885799017197387218e+08
+3.937341390176227941e+32 2.179252879104347483e+26 6.531429068243144751e+08
+4.369140560943326286e+32 2.509686767892577973e+26 7.247898125527240038e+08
+4.848294153234641259e+32 2.897514348835473551e+26 8.042982864777351618e+08
+5.379995417500169477e+32 3.334043502253457473e+26 8.925321820100079775e+08
+5.970007136017519839e+32 3.836150159953974780e+26 9.904493984702121019e+08
+6.624724082137004584e+32 4.312576556420053212e+26 1.099125768921423674e+09
+7.351242329288429869e+32 4.718653535163892684e+26 1.219748644378827572e+09
+8.157436160947172566e+32 5.225941268531537930e+26 1.353596928281055450e+09
+9.052043415139293179e+32 6.004484282431530675e+26 1.502074793670563459e+09
+1.004476018848212219e+33 6.912221847770953695e+26 1.666842074406544447e+09
+1.114634592619911956e+33 7.915714347447511525e+26 1.849667730881092787e+09
+1.236874003711480989e+33 9.086044371490364774e+26 2.052549684997077703e+09
+1.372519129754791655e+33 1.045464686649291233e+27 2.277688905832159042e+09
+1.523040144663172084e+33 1.205944404976415460e+27 2.527528071273923397e+09
+1.690068452940276919e+33 1.384774433518954870e+27 2.804945455609254837e+09
+1.875414371467952226e+33 1.587546097178036821e+27 3.112949069844432831e+09
+2.081086750415086011e+33 1.824333122097363011e+27 3.454821356287115574e+09
+2.309314745926394680e+33 2.101590923855381572e+27 3.834297581346822262e+09
+2.562571980571881930e+33 2.421513217345445596e+27 4.255396053567112446e+09
+2.843603353417206204e+33 2.773241141044943385e+27 4.722251476064086914e+09
+3.155454790292771230e+33 3.183477904656233432e+27 5.240346561189462662e+09
+3.501506256706381314e+33 3.663252315644170908e+27 5.815310062971747398e+09
+3.885508391206065761e+33 4.225869911896249537e+27 6.453390205504040718e+09
+4.311623156239506076e+33 4.777947483055280573e+27 7.161411504350040436e+09
+4.784468947099695984e+33 5.376751065610691527e+27 7.947112620680989265e+09
+5.309170647864869901e+33 6.119733623216651456e+27 8.817724873351537704e+09
+5.891415176858192836e+33 7.032206282933378178e+27 9.782458272739786148e+09
+6.537513123650205288e+33 8.085139337613389238e+27 1.085528350580601692e+10
+7.254467145649511099e+33 9.287285723835153615e+27 1.205150645161280441e+10
+8.050047865590185856e+33 1.068491032048416860e+28 1.337889434963222694e+10
+8.932878092521999972e+33 1.226239386950930406e+28 1.484433476382813263e+10
+9.912526279122840605e+33 1.410673866420962835e+28 1.647007202313125801e+10
+1.099961022825958281e+34 1.618872017588819029e+28 1.828035967803216934e+10
+1.220591217280882326e+34 1.861666562530063102e+28 2.029063201215296936e+10
+1.354450647601679915e+34 2.110505129120199887e+28 2.251830857884699631e+10
+1.502990133646396049e+34 2.381167164739957577e+28 2.498893758925205612e+10
+1.667819603348691168e+34 2.704354276315120405e+28 2.773268601504651260e+10
+1.850725541734400614e+34 3.092577186042517652e+28 3.078021258867486191e+10
+2.053690353531589750e+34 3.543574686794249570e+28 3.416098211200037384e+10
+2.278913849233506444e+34 4.067206352198093962e+28 3.790726270624259949e+10
+2.528837087488608057e+34 4.667769171321674143e+28 4.206522442892446136e+10
+2.806168832230658997e+34 5.226299079536023225e+28 4.668979636220603180e+10
+3.113914911301399794e+34 5.856868890106270833e+28 5.182416633400325775e+10
+3.455410794765817660e+34 6.699214996788812689e+28 5.751105760011439514e+10
+3.834357746016285709e+34 7.702001398251428439e+28 6.382009333553183746e+10
+4.254862937485122634e+34 8.845233050429101515e+28 7.082954603853540039e+10
+4.721483965755040564e+34 1.016400954419972109e+29 7.861496419139753723e+10
+5.239278248539326095e+34 1.167957259653945684e+29 8.724768711238674927e+10
+5.813857838915186420e+34 1.341321188428274853e+29 9.681453897342863464e+10
+6.451450250907942562e+34 1.542231672487229490e+29 1.074409808102410736e+11
+7.158965955677083153e+34 1.770335880354263798e+29 1.192752127938576202e+11
+7.944073279853740413e+34 2.035535190426246950e+29 1.324172360026489410e+11
+8.815281517806501624e+34 2.272849675516221820e+29 1.469236737655426331e+11
+9.782033158638187572e+34 2.539447736538703479e+29 1.630174232918174133e+11
+1.085480622750514232e+35 2.834161249313151809e+29 1.809693535214535217e+11
+1.204522785047354846e+35 3.150626886028104514e+29 2.008278968910747986e+11
+1.336620027377221718e+35 3.566924093964861710e+29 2.228872671068214722e+11
+1.483204070328688704e+35 4.097881163433249748e+29 2.474099195602670898e+11
+1.645863647993009095e+35 4.675180237383062727e+29 2.746266281294648132e+11
+1.826361727273679436e+35 5.263271468064955134e+29 3.048222922056145020e+11
+2.026654615598063382e+35 5.928443689643093528e+29 3.383443103573421631e+11
+2.248913164127782883e+35 6.660241614351612660e+29 3.755466155208320923e+11
+2.495546296276408869e+35 7.491181980950670312e+29 4.168512223713275757e+11
+2.769227116545546965e+35 8.354890690443169521e+29 4.624469924893273926e+11
+3.072921882656903219e+35 9.206102751476656203e+29 5.131863640802401733e+11
+3.409922154991412500e+35 1.013561551354342926e+30 5.694957293153978271e+11
+3.783880471783379948e+35 1.114853360920056628e+30 6.319872145884324951e+11
+4.198849936731084632e+35 1.224971607181139856e+30 7.013403723333323975e+11
+4.659328148089541666e+35 1.344356397863777823e+30 7.783096440563981934e+11
+5.170305945365794691e+35 1.473373812761378091e+30 8.637326575508997803e+11
+5.737321501952119103e+35 1.612279689975440968e+30 9.585394530717751465e+11
+6.366520349973851686e+35 1.761172663564104038e+30 1.063762746255796143e+12
+7.064721987924157516e+35 1.919934393472977400e+30 1.180549345243035645e+12
+7.839493793004843199e+35 2.088152527653006931e+30 1.310172856437592285e+12
+8.699233039263547783e+35 2.265023482064908918e+30 1.454047829225046631e+12
+9.653257910471280334e+35 2.449230157321329733e+30 1.613745505851289062e+12
+1.071190849417285629e+36 2.638786449431165501e+30 1.791011367479669189e+12
+1.188665885152245279e+36 2.830842990000272562e+30 1.987784687780635742e+12
+1.319024137756017198e+36 3.021442584795782804e+30 2.206220333517662109e+12
+1.463678479979398388e+36 3.205215593695609359e+30 2.448713084065665039e+12
+1.624196731076863850e+36 3.374997388433615126e+30 2.717924772374655762e+12
+1.802318649433105825e+36 3.521354316858286545e+30 3.016814596280232422e+12
+1.999974788731826606e+36 3.631989415893279058e+30 3.348672989928392578e+12
+2.219307422037178289e+36 4.166541247521724958e+30 3.716341586894569336e+12
+2.462693760571066537e+36 4.791304287700583583e+30 4.124430305948428223e+12
+2.732771718840338952e+36 5.523413048842315044e+30 4.577394892917429688e+12
+3.032468505366188821e+36 6.382441800388788158e+30 5.080168675995340820e+12
+3.365032348893066296e+36 7.382304341528081485e+30 5.638096448424265625e+12
+3.734067703937921693e+36 8.561208748124174740e+30 6.257395355668807617e+12
+4.143574317251031495e+36 9.946277558358492511e+30 6.944782725406486328e+12
+4.597990578605691399e+36 1.156693610258714716e+31 7.707693864420269531e+12
+5.102241625769272732e+36 1.347999175789679893e+31 8.554538233984585938e+12
+5.661792725035759666e+36 1.571357737532060210e+31 9.494457086702732422e+12
+6.282708505878480423e+36 1.835954692105069707e+31 1.053778136998549414e+13
+6.971718691730893878e+36 2.149840671451791603e+31 1.169588855987116797e+13
+7.736291039310880035e+36 2.512469813336011363e+31 1.298137064535030273e+13
+8.584712277032879994e+36 2.940350214072720701e+31 1.440832949675453516e+13
+9.526177919749477850e+36 3.443838149024896332e+31 1.599235171223742773e+13
+1.057089193326903209e+37 4.033943525107494818e+31 1.775075624285680859e+13
+1.173017732885162958e+37 4.727905403341851443e+31 1.970278483858347656e+13
+1.301659888634894917e+37 5.533843736314825691e+31 2.186981278257176953e+13
+1.444409933610848864e+37 6.478177858927889376e+31 2.427552204629973828e+13
+1.602815047563389987e+37 7.573383933218675981e+31 2.694634292323234766e+13
+1.778592085886176786e+37 8.845263427457890404e+31 2.991147610119188672e+13
+1.973646187553546846e+37 1.030495241891500315e+32 3.320346577422444531e+13
+2.190091423747587717e+37 1.198294085420827316e+32 3.685840409389389844e+13
+2.430273710972626631e+37 1.388362255016434658e+32 4.091633508270321094e+13
+2.696796236998263779e+37 1.601567006363779311e+32 4.542179385438157812e+13
+2.992547675207070442e+37 1.839729587663832682e+32 5.042413696713809375e+13
+3.320733493144891266e+37 2.104218429326042950e+32 5.597817761637072656e+13
+3.684910694607810056e+37 2.393648357144748130e+32 6.214475890907849219e+13
+4.089026371813857209e+37 2.708364392940562441e+32 6.899135759501764844e+13
+4.537460485502687135e+37 3.013613985527547037e+32 7.659273708806068750e+13
+5.035073336630347560e+37 3.371716075091777995e+32 8.503185645830560938e+13
+5.587258244175588525e+37 3.750038734872313329e+32 9.440105625353439062e+13
+6.199999999999986184e+37 4.147200335999991463e+32 1.048025763494627500e+14
+6.544012399999999797e+37 4.176787846084300410e+32 1.106436243014349219e+14
+6.742657899999999657e+37 4.505894094680140264e+32 1.140169235146369062e+14
+6.947333399999999245e+37 4.853836291708117644e+32 1.174937658587942500e+14
+7.158221799999999491e+37 5.221854198702269117e+32 1.210773578276822969e+14
+7.375511899999998492e+37 5.611325210001689304e+32 1.247710134003582969e+14
+7.599397799999999484e+37 6.023783526992610027e+32 1.285781450575731250e+14
+7.830079900000000385e+37 6.460945829349889484e+32 1.325022808725620469e+14
+8.067764299999998941e+37 6.924737782325394546e+32 1.365470560465101719e+14
+8.312663800000000209e+37 7.417326466489878386e+32 1.407162302193905312e+14
+8.564997299999999979e+37 7.941154689937977729e+32 1.450136792617317812e+14
+8.824990400000000412e+37 8.498981840638593274e+32 1.494434061570005625e+14
+9.092875699999998496e+37 9.093929164207096740e+32 1.540095477411290312e+14
+9.368892799999999273e+37 9.729530864719819524e+32 1.587163770151503125e+14
+9.653288399999999394e+37 1.040979050941616662e+33 1.635683061396751250e+14
+9.946316999999999545e+37 1.113924691018881530e+33 1.685699011697816562e+14
+1.024824000000000035e+38 1.192304247077376123e+33 1.737258688284273125e+14
+1.055932899999999912e+38 1.276701082714305417e+33 1.790411162246842500e+14
+1.087986099999999889e+38 1.367775338497083142e+33 1.845206713701507188e+14
+1.121012200000000021e+38 1.466274541097519953e+33 1.901697493400887500e+14
+1.155040899999999914e+38 1.573045119530039719e+33 1.959937897078371562e+14
+1.190102499999999895e+38 1.689042823930879812e+33 2.019983761152837500e+14
+1.226228399999999837e+38 1.815347429134675342e+33 2.081893267307620938e+14
+1.263450999999999743e+38 1.953176885910319488e+33 2.145726835592829688e+14
+1.301803399999999946e+38 2.103901962378143950e+33 2.211546668857090312e+14
+1.341320099999999934e+38 2.269066144814640035e+33 2.279418029187489688e+14
+1.382036299999999906e+38 2.450401439961647772e+33 2.349408116672644688e+14
+1.423988399999999985e+38 2.649850800520896242e+33 2.421587015753798125e+14
+1.467213999999999837e+38 2.869589583174719842e+33 2.496027802910953125e+14
+1.511751699999999823e+38 3.112048753051311362e+33 2.572806302293722812e+14
+1.557641399999999839e+38 3.379940777994816073e+33 2.652001733570514688e+14
+1.604924099999999902e+38 3.676285108486223503e+33 2.733696494373690625e+14
+1.604924099999999902e+38 3.676285108486223503e+33 2.817976661619926250e+14
+1.604924099999999902e+38 3.676285108486223503e+33 2.904931969967976250e+14
+1.604924099999999902e+38 3.676285108486223503e+33 2.994656522691256875e+14
+1.604924099999999902e+38 3.676285108486223503e+33 3.087248272117512500e+14
+1.604924099999999902e+38 3.676285108486223503e+33 3.182810298130898125e+14
+1.604924099999999902e+38 3.676285108486223503e+33 3.281450318304651250e+14
+1.604924099999999902e+38 3.676285108486223503e+33 3.383281132944153125e+14
+1.604924099999999902e+38 3.676285108486223503e+33 3.488421394731748125e+14
+1.604924099999999902e+38 3.676285108486223503e+33 3.596995404982125625e+14
+2.164335699999999619e+38 9.151452329260910267e+33 3.709134284257751875e+14
+2.230034799999999852e+38 1.008018439226489650e+34 3.824975621431327500e+14
+2.297728199999999929e+38 1.110978495692678352e+34 3.944664206157361250e+14
+2.367476499999999744e+38 1.225055752914991855e+34 4.068352756730983750e+14
+2.439341999999999837e+38 1.351370450108447721e+34 4.196202031333028125e+14
+2.513388899999999493e+38 1.491140310311097143e+34 4.328381617609762500e+14
+2.589683599999999743e+38 1.645688695028178833e+34 4.465071011428784375e+14
+2.668294299999999616e+38 1.816452658292831690e+34 4.606459419742203125e+14
+2.749291200000000278e+38 2.004992529057792265e+34 4.752746755531966250e+14
+2.832746699999999733e+38 2.213002864044772267e+34 4.904144596611195625e+14
+2.918735699999999979e+38 2.442324761818987113e+34 5.060877491065353750e+14
+3.007334799999999883e+38 2.694956294128761227e+34 5.223182240244966250e+14
+3.098623300000000029e+38 2.973068273755347329e+34 5.391310557921419375e+14
+3.192682999999999706e+38 3.279018563110367896e+34 5.565529636196520625e+14
+3.289597899999999573e+38 3.615365885266371088e+34 5.746122548559611250e+14
+3.389454700000000119e+38 3.984887419908601685e+34 5.933390276255341250e+14
+3.492342599999999779e+38 4.390593903143154921e+34 6.127652458447495000e+14
+3.598353699999999450e+38 4.835747510043711794e+34 6.329249415206125000e+14
+3.707582899999999848e+38 5.323877267264752335e+34 6.538543271425423750e+14
+3.820127700000000013e+38 5.858793184601405623e+34 6.755919038409673750e+14
+3.936088799999999532e+38 6.444602906208767228e+34 6.981787227274886250e+14
+4.055570000000000064e+38 7.085722543396799510e+34 7.216585344161030000e+14
+4.178678100000000050e+38 7.786889083084463534e+34 7.460779330040896250e+14
+4.305523199999999989e+38 8.553165701634047388e+34 7.714865970400578750e+14
+4.436218699999999410e+38 9.389948928667200788e+34 7.979374723208910000e+14
+4.570881399999999138e+38 1.030297071974569336e+35 8.254869865301522500e+14
+4.709631999999999747e+38 1.129829941161984090e+35 8.541953462782542500e+14
+4.852594299999999344e+38 1.238233148946121384e+35 8.841265792026993750e+14
+4.999896299999999546e+38 1.356179152261012818e+35 9.153489684880531250e+14
+5.151669699999999467e+38 1.484372598593958103e+35 9.479351594940230000e+14
+5.308050199999999474e+38 1.623549025036284791e+35 9.819624411026782500e+14
+5.469177699999999665e+38 1.774475054792372887e+35 1.017512989478104375e+15
+5.635196299999999870e+38 1.937947614095631825e+35 1.054674146931147750e+15
+5.806254400000000398e+38 2.114793924598271855e+35 1.093538601576421375e+15
+5.982505099999998990e+38 2.305872357123191547e+35 1.134204763274132000e+15
+6.164105799999999911e+38 2.512072534650841528e+35 1.176776913424821750e+15
+6.351219199999999532e+38 2.734318353945394896e+35 1.221365664659901750e+15
+6.544012399999999230e+38 2.973568346821471764e+35 1.268088058071735000e+15
+6.742657899999999280e+38 3.230820266318532735e+35 1.317068086403385750e+15
+6.947333399999998868e+38 3.507113163819618144e+35 1.368436924768349750e+15
+7.158221799999999869e+38 3.803532033927135439e+35 1.422333261400725750e+15
+7.375511900000000004e+38 4.121212188182810991e+35 1.478903867296315000e+15
+7.599397799999998917e+38 4.461343570011302574e+35 1.538303760441225250e+15
+7.830079899999998874e+38 4.825176866693842444e+35 1.600696910844022250e+15
+8.067764299999998752e+38 5.214027999424102138e+35 1.666256501780876500e+15
+8.312663799999998509e+38 5.629285251361474168e+35 1.735165666840627750e+15
+8.564997299999999224e+38 6.072413704313394625e+35 1.807617822977759250e+15
+8.824990400000000034e+38 6.544962632659532083e+35 1.883817357046999000e+15
+9.092875699999999630e+38 7.048571884808650518e+35 1.963980319726244750e+15
+9.368892799999999273e+38 7.584978411203327629e+35 2.048335005411468750e+15
+9.653288399999999772e+38 8.156022748122413826e+35 2.137122597182751750e+15
+9.946316999999999923e+38 8.763656940610561420e+35 2.230598161766946750e+15
+1.024823999999999959e+39 9.409950529155839483e+35 2.329030998352703000e+15
+1.055932899999999950e+39 1.009710442550620811e+36 2.432706580232024000e+15
+1.087986099999999851e+39 1.082744757426860624e+36 2.541925729778268000e+15
+1.121012199999999945e+39 1.160345361327644916e+36 2.657006736487105000e+15
+1.155040899999999839e+39 1.242775385798273497e+36 2.778286962337194000e+15
+1.190102500000000008e+39 1.330313388268119935e+36 2.906122147729318500e+15
+1.226228400000000102e+39 1.423255522449369833e+36 3.040889134229467000e+15
+1.263451000000000007e+39 1.521916262691664139e+36 3.182986744146438000e+15
+1.301803400000000021e+39 1.626628697015804830e+36 3.332835789104209000e+15
-- 
GitLab


From 77918e923bb4ab65a70f9232ce4a4ae3bdb8fac7 Mon Sep 17 00:00:00 2001
From: Atul Kedia <atul.kedia@ldas-osg.ligo.caltech.edu>
Date: Thu, 2 Mar 2023 07:23:03 -0800
Subject: [PATCH 05/12] demo_eos_tabular added

---
 .../Code/RIFT/physics/demo_eos_tabular.py     | 56 +++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
new file mode 100644
index 000000000..94c9fb3c3
--- /dev/null
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
@@ -0,0 +1,56 @@
+import numpy as np
+import matplotlib
+import matplotlib.pyplot as plt
+import argparse
+
+#from lalinference.rapid_pe import lalsimutils
+import RIFT.lalsimutils as lalsimutils
+import EOSManager
+import lalsimulation as lalsim
+#import lalsim_EOS_tools as let
+from scipy.integrate import nquad
+#import EOS_param as ep
+import os
+from EOSPlotUtilities import render_eos
+
+matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
+matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
+matplotlib.rcParams['xtick.labelsize'] = 15.0
+matplotlib.rcParams['ytick.labelsize'] = 15.0
+matplotlib.rcParams['axes.labelsize'] = 25.0
+matplotlib.rcParams['lines.linewidth'] = 2.0
+plt.style.use('seaborn-v0_8-whitegrid')
+
+
+'''
+data = np.genfromtxt("/home/atul.kedia/rift-testing/RIT-matters/communications/20221207-ROSKedia-SpectralRepresentation/eos_manager_phase_transition.txt", delimiter = " ", names=True, dtype=None)
+#data = np.genfromtxt("/home/atul.kedia/rift-testing/RIT-matters/communications/20221207-ROSKedia-SpectralRepresentation/eos_manager_phase_transition.txt", delimiter = " ", names=True, dtype=None)
+
+neweos = EOSManager.EOSFromTabularData(eos_data=data)
+
+plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
+'''
+
+
+eos_names =  ['LALSimNeutronStarEOS_AP4.dat',
+              #'LALSimNeutronStarEOS_SLY4.dat',    # Erroneous for unknown reasons
+              'LALSimNeutronStarEOS_PAL6.dat',
+              'LALSimNeutronStarEOS_AP3.dat',
+              'LALSimNeutronStarEOS_MPA1.dat',
+              'LALSimNeutronStarEOS_WFF1.dat']
+
+
+for name in eos_names:
+    data = np.loadtxt("/home/atul.kedia/lalsuite_dir/lalsuite/lalsimulation/lib/"+name, delimiter = "\t")
+    
+    
+    import pdb
+    #pdb.set_trace()
+    
+    neweos = EOSManager.EOSFromTabularData(eos_data=data)
+    
+    
+    plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
+
+plt.show()
+
-- 
GitLab


From 27057254dcb408671983d3b46e191901226e278d Mon Sep 17 00:00:00 2001
From: Atul Kedia <atul.kedia@ldas-osg.ligo.caltech.edu>
Date: Thu, 2 Mar 2023 08:17:45 -0800
Subject: [PATCH 06/12] eos file linked to the one in directory

---
 .../Code/RIFT/physics/demo_eos_tabular.py              | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
index 94c9fb3c3..bf2219126 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
@@ -23,8 +23,8 @@ plt.style.use('seaborn-v0_8-whitegrid')
 
 
 '''
-data = np.genfromtxt("/home/atul.kedia/rift-testing/RIT-matters/communications/20221207-ROSKedia-SpectralRepresentation/eos_manager_phase_transition.txt", delimiter = " ", names=True, dtype=None)
-#data = np.genfromtxt("/home/atul.kedia/rift-testing/RIT-matters/communications/20221207-ROSKedia-SpectralRepresentation/eos_manager_phase_transition.txt", delimiter = " ", names=True, dtype=None)
+data = np.genfromtxt("eos_manager.txt", delimiter = " ", names=True, dtype=None)
+#data = np.genfromtxt("eos_manager_phase_transition.txt", delimiter = " ", names=True, dtype=None)
 
 neweos = EOSManager.EOSFromTabularData(eos_data=data)
 
@@ -42,11 +42,7 @@ eos_names =  ['LALSimNeutronStarEOS_AP4.dat',
 
 for name in eos_names:
     data = np.loadtxt("/home/atul.kedia/lalsuite_dir/lalsuite/lalsimulation/lib/"+name, delimiter = "\t")
-    
-    
-    import pdb
-    #pdb.set_trace()
-    
+        
     neweos = EOSManager.EOSFromTabularData(eos_data=data)
     
     
-- 
GitLab


From 42b7e60f52accc5a95dfd67ef6e995e82b0eafc7 Mon Sep 17 00:00:00 2001
From: Atul Kedia <atul.kedia@ldas-osg.ligo.caltech.edu>
Date: Tue, 7 Mar 2023 07:46:35 -0800
Subject: [PATCH 07/12] unit conversions documented in eosmanager

---
 .../Code/RIFT/physics/EOSManager.py           | 82 +++++++++++++------
 .../Code/RIFT/physics/demo_eos_tabular.py     | 13 ++-
 .../Code/RIFT/physics/demo_new_spectral.py    | 30 +++++--
 3 files changed, 92 insertions(+), 33 deletions(-)

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
index 3fe4e0386..d633e1119 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
@@ -33,7 +33,8 @@ from RIFT.physics import MonotonicSpline as ms
 
 
 C_CGS=lal.C_SI*100
-DENSITY_CGS_IN_MSQUARED=7.42591549e-25  # g/cm^3 m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom)
+DENSITY_CGS_IN_MSQUARED=1000*lal.G_SI/lal.C_SI**2  # g/cm^3 -> 1/m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom). lal.G_SI/lal.C_SI**2 takes kg/m^3 -> 1/m^2  ||  https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/_l_a_l_sim_neutron_star_8h_source.html
+PRESSURE_CGS_IN_MSQUARED = DENSITY_CGS_IN_MSQUARED/(lal.C_SI*100)**2
 
 
 def make_compactness_from_lambda_approximate(lambda_vals):
@@ -249,17 +250,45 @@ class EOSFromTabularData(EOSConcrete):
             raise Exception("EOS data required to use EOSFromTabularData")
         if not(name):
             eos_name="default"
-
-        # Assume CGS for now
+        
+        # Assuming CGS
         try:
             bdens = eos_data["baryon_density"]
             press = eos_data["pressure"]
             edens = eos_data["energy_density"]
-            # Convert to geometerized units
-            press *= DENSITY_CGS_IN_MSQUARED/(lal.C_SI*100)**2
+            # Convert to geometerized units 1/m^2
+            #press is in dyn/cm^2 
+            #edens is in gm/cm^3 and needs to be made to 1/m^2. The conversion factor is 
+            press *= PRESSURE_CGS_IN_MSQUARED
             edens *= DENSITY_CGS_IN_MSQUARED
-            #press *= 0.1                    #Converts CGS to Pascals
-            #edens *= 0.1*(lal.C_SI*100)**2  #Converts CGS to SI J/m^3
+            # Convert to SI units
+            # press *= 0.1                    #Converts CGS -> SI, i.e., [Ba] -> [Pa]
+            # edens *= 0.1*(lal.C_SI*100)**2
+            
+            
+            '''
+            Use https://www.seas.upenn.edu/~amyers/NaturalUnits.pdf for reference
+            Convert Pressure in CGS to SI.
+            Ba -> Pa is a factor of 0.1 because [Ba] = g/(cm s^2) = 0.1 kg/(m s^2) = 0.1 Pa
+            
+            Convert Density in CGS-mass density [Mass/Volume] to SI-energy density [Energy/Volume].
+            Converts CGS -> SI, i.e., mass density units to energy density units g/cm^3 -> J/m^3. 
+            Steps: 1 g/cm^3 -> 1000 kg/m^3 . Now multiply by c^2 to get 1000kg/m^3 * c^2 = 1000*lal.C_SI^2 J/m^3. 
+            OR Steps:  1 g/cm^3 multiplied by c^2 to get 1 g/cm^3 * c^2 = (lal.C_SI*100)^2 (g cm^2/s^2)/cm^3 = (lal.C_SI*100)^2 erg/cm^3 = (lal.C_SI*100)^2 *0.1 J/m^3. QED.
+            
+            Convert Pressure in CGS to Geometerized Units.
+            First Convert Pressure in CGS to SI units. I.e.,
+            Ba = 0.1 Pa
+            Then to go from Pa = kg/(m s^2) to 1/m^2 multiply by lal.G_SI/lal.C_SI^4
+            Hence, to go from Ba to 1/m^2, multiply by 0.1 lal.G_SI/lal.C_SI^4, or DENSITY_CGS_IN_MSQUARED/(lal.C_SI*100)**2 = 1000*lal.G_SI/lal.C_SI**2/(lal.C_SI*100)**2
+            
+            Convert Density in CGS to Geometerized Units
+            First convert CGS-mass density to  SI-energy density as above:
+            1 g/cm^3 -> 1000*lal.C_SI^2 J/m^3
+            Then to go from J/m^3 = kg/(m s^2) to 1/m^2 multiply by lal.G_SI/lal.C_SI^4
+            Hence, to go from g/cm^3 to 1/m^2, multiply by 1000 lal.G_SI/lal.C_SI^2
+            '''
+            
         except:
             press = eos_data[:,0]      #LALSim EOS format
             edens = eos_data[:,1]
@@ -645,10 +674,9 @@ class EOSLindblomSpectralSoundSpeedVersusPressure(EOSConcrete):
         spec_params = self.spec_params
         if not 'gamma3' in spec_params:
             spec_params['gamma3']=spec_params['gamma4']=0
-        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
         
         try :
-            eos = lalsim.SimNeutronStarEOS4ParamCausalSpectralDecomposition(coefficients[0],coefficients[1],coefficients[2],coefficients[3])
+            eos = lalsim.SimNeutronStarEOS4ParamCausalSpectralDecomposition(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'])
         except:
             raise Exception(" Did not load LALSimulation with Causal Spectral parameterization.")
         
@@ -658,30 +686,31 @@ class EOSLindblomSpectralSoundSpeedVersusPressure(EOSConcrete):
         enthalpy_index = 0.005
         enthalpy, rho, epsilon, press, speed = [], [], [], [], []
         
+        Den_SI_to_CGS = 0.001 # kg m^-3 -> g cm^-3
+        Energy_SI_to_CGS = 10/(lal.C_SI*100)**2 # J m^-3 *10 -> erg/cm^3 /c^2 -> g cm^-3
+        Press_SI_to_CGS = 10 # Pa -> Ba ~ g cm^-1 s^-2
+        
         while enthalpy_index < maxenthalpy:
-            rho.append(lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(enthalpy_index, eos)*.001)  # g cm^-3
-            epsilon.append(lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(enthalpy_index, eos)*10/(lal.C_SI*100)**2)  # J m^-3 *10/c^2 = g cm^-3
-            press.append(lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(enthalpy_index, eos)*10)    # dyn cm^-2 ~ g cm^-1 s^-2
-            speed.append(lalsim.SimNeutronStarEOSSpeedOfSound(enthalpy_index,eos)*100)
+            rho.append(lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(enthalpy_index, eos)*Den_SI_to_CGS)
+            epsilon.append(lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(enthalpy_index, eos)*Energy_SI_to_CGS) 
+            press.append(lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(enthalpy_index, eos)*Press_SI_to_CGS)
+            speed.append(lalsim.SimNeutronStarEOSSpeedOfSound(enthalpy_index,eos)*100)    # meters -> cm
             enthalpy.append(enthalpy_index)
             enthalpy_index = enthalpy_index*1.01
         
         enthalpy, rho, epsilon, press, speed  = np.array(enthalpy), np.array(rho), np.array(epsilon), np.array(press), np.array(speed)
         
-        new_eos_vals = np.column_stack((epsilon, press)) # CGS units
-        
         extraction_dict_lalsim_raw = {
             'pseudo_enthalpy': enthalpy,
-            'rest_mass_density': rho,  # g cm^-3
-            'baryon_density': rho/(lal.AMU_SI*1e3),  #  cm^-3
-            'pressure': press,    # dyn cm^-2 ~ g cm^-1 s^-2
-            'energy_density': epsilon, # J m^-3 *10/c^2 = g cm^-3
+            'rest_mass_density': rho,                     # g cm^-3
+            'baryon_density': rho/(lal.AMU_SI*1e3),       # cm^-3
+            'pressure': press,                            # dyn cm^-2 ~ g cm^-1 s^-2
+            'energy_density': epsilon,                    # g cm^-3
             'sound_speed_over_c': speed/(lal.C_SI*100)    # [c]
             }
         
         new_eos_vals = np.column_stack((extraction_dict_lalsim_raw[xvar], extraction_dict_lalsim_raw[yvar])) # CGS units
         
-        
         return new_eos_vals
 
 
@@ -1056,12 +1085,17 @@ class QueryLS_EOS:
     def __init__(self,eos):
         self.eos = eos
         # Primitive extractors.  Assume I need to vectorize these, and that it isn't available
+        
+        Den_SI_to_CGS = 0.001 # kg m^-3 -> g cm^-3
+        Energy_SI_to_CGS = 10/(lal.C_SI*100)**2 # J m^-3 *10 -> erg/cm^3 /c^2 -> g cm^-3
+        Press_SI_to_CGS = 10 # Pa -> Ba ~ g cm^-1 s^-2
+        
         extraction_dict_lalsim_raw = {
             'pseudo_enthalpy'   : lambda x: x,
-            'rest_mass_density' : lambda x: lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*.001,  # g cm^-3
-            'baryon_density'    : lambda x: (lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*.001)/(lal.AMU_SI*1e3),  #  cm^-3
-            'pressure'          : lambda x: lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(x, eos)*10,    # dyn cm^-2 ~ g cm^-1 s^-2
-            'energy_density'    : lambda x: lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(x,eos)*10/(lal.C_SI*100)**2 , # J m^-3 *10/c^2 = g cm^-3
+            'rest_mass_density' : lambda x: lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*Den_SI_to_CGS,
+            'baryon_density'    : lambda x: lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(x, eos)*Den_SI_to_CGS/(lal.AMU_SI*1e3),  #  cm^-3
+            'pressure'          : lambda x: lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(x, eos)*Press_SI_to_CGS,
+            'energy_density'    : lambda x: lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(x,eos)*Energy_SI_to_CGS,
             'sound_speed_over_c': lambda x: lalsim.SimNeutronStarEOSSpeedOfSound(x,eos)/lal.C_SI
             }
         self.extraction_dict_lalsim = {}
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
index bf2219126..310b5d359 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
@@ -12,6 +12,7 @@ from scipy.integrate import nquad
 #import EOS_param as ep
 import os
 from EOSPlotUtilities import render_eos
+import lal
 
 matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
 matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
@@ -21,6 +22,9 @@ matplotlib.rcParams['axes.labelsize'] = 25.0
 matplotlib.rcParams['lines.linewidth'] = 2.0
 plt.style.use('seaborn-v0_8-whitegrid')
 
+DENSITY_CGS_IN_MSQUARED=1000*lal.G_SI/lal.C_SI**2  # g/cm^3 -> 1/m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom). lal.G_SI/lal.C_SI**2 takes kg/m^3 -> 1/m^2  ||  https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/_l_a_l_sim_neutron_star_8h_source.html
+PRESSURE_CGS_IN_MSQUARED = DENSITY_CGS_IN_MSQUARED/(lal.C_SI*100)**2
+
 
 '''
 data = np.genfromtxt("eos_manager.txt", delimiter = " ", names=True, dtype=None)
@@ -28,9 +32,11 @@ data = np.genfromtxt("eos_manager.txt", delimiter = " ", names=True, dtype=None)
 
 neweos = EOSManager.EOSFromTabularData(eos_data=data)
 
+plt.loglog(data['energy_density']/DENSITY_CGS_IN_MSQUARED,data['pressure']/PRESSURE_CGS_IN_MSQUARED, label = ' raw')
+
 plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
-'''
 
+'''
 
 eos_names =  ['LALSimNeutronStarEOS_AP4.dat',
               #'LALSimNeutronStarEOS_SLY4.dat',    # Erroneous for unknown reasons
@@ -42,11 +48,12 @@ eos_names =  ['LALSimNeutronStarEOS_AP4.dat',
 
 for name in eos_names:
     data = np.loadtxt("/home/atul.kedia/lalsuite_dir/lalsuite/lalsimulation/lib/"+name, delimiter = "\t")
-        
-    neweos = EOSManager.EOSFromTabularData(eos_data=data)
     
+    neweos = EOSManager.EOSFromTabularData(eos_data=data)
     
+    plt.loglog(data[:,1]/DENSITY_CGS_IN_MSQUARED,data[:,0]/PRESSURE_CGS_IN_MSQUARED, label = name+' raw', ls = 'dashed')
     plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
 
+
 plt.show()
 
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
index fa4d86055..61706bb46 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
@@ -12,6 +12,7 @@ from scipy.integrate import nquad
 #import EOS_param as ep
 import os
 from EOSPlotUtilities import render_eos
+import lal
 
 matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
 matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
@@ -21,8 +22,11 @@ matplotlib.rcParams['axes.labelsize'] = 25.0
 matplotlib.rcParams['lines.linewidth'] = 2.0
 plt.style.use('seaborn-v0_8-whitegrid')
 
-#spec_params = {'gamma1': -0.701593,'gamma2':-0.239194,'gamma3':0.062016,'gamma4':-0.003556}
+DENSITY_CGS_IN_MSQUARED=1000*lal.G_SI/lal.C_SI**2  # g/cm^3 -> 1/m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom). lal.G_SI/lal.C_SI**2 takes kg/m^3 -> 1/m^2  ||  https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/_l_a_l_sim_neutron_star_8h_source.html
+PRESSURE_CGS_IN_MSQUARED = DENSITY_CGS_IN_MSQUARED/(lal.C_SI*100)**2
 
+#spec_params = {'gamma1': -0.701593,'gamma2':-0.239194,'gamma3':0.062016,'gamma4':-0.003556}
+'''
 eoss = np.genfromtxt('/home/atul.kedia/rift-testing/RIT-matters/communications/20221207-ROSKedia-SpectralRepresentation/names_laleos_improvedPBCS_indices_physical_EOS.txt', dtype='str')
 
 '''
@@ -32,7 +36,7 @@ eoss = np.array([['AP4', '-0.592110', '-0.264530', '0.085421', '-0.008334'],
         ['AP3', '-0.463822', '-0.466598', '0.147791', '-0.013972'],
         ['MPA1', '-1.247626', '0.207047', '-0.030886', '0.000749'],
         ['WFF1', '0.233772', '-0.764008', '0.193810', '-0.016393']], dtype=str)
-'''
+
 
 for i in range(0,len(eoss[:])):
     spec_params = {'gamma1': eoss[i][1].astype(float),
@@ -47,13 +51,27 @@ for i in range(0,len(eoss[:])):
     new_eos_vals = neweos.make_spec_param_eos(xvar=xvar, yvar=yvar)
     #xvar, yvar ='energy_density', 'pressure', 'rest_mass_density', 'sound_speed_over_c', 'pseudo_enthalpy'
     
-    plt.loglog(new_eos_vals[:,0], new_eos_vals[:,1], label = eoss[i][0])
-    plt.xlabel(xvar)
-    plt.ylabel(yvar)
+    #plt.loglog(new_eos_vals[:,0], new_eos_vals[:,1], label = eoss[i][0])
+    #plt.xlabel(xvar)
+    #plt.ylabel(yvar)
     
-    #plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
+    plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
     #render_eos variable names: pseudo_enthalpy, rest_mass_density, baryon_density, pressure, energy_density, sound_speed_over_c
 
+'''
+eos_names =  ['LALSimNeutronStarEOS_AP4.dat',
+              #'LALSimNeutronStarEOS_SLY4.dat',    # Erroneous for unknown reasons
+              'LALSimNeutronStarEOS_PAL6.dat',
+              'LALSimNeutronStarEOS_AP3.dat',
+              'LALSimNeutronStarEOS_MPA1.dat',
+              'LALSimNeutronStarEOS_WFF1.dat']
+
+
+for name in eos_names:
+    data = np.loadtxt("/home/atul.kedia/lalsuite_dir/lalsuite/lalsimulation/lib/"+name, delimiter = "\t")
+    
+    plt.loglog(data[:,1]/DENSITY_CGS_IN_MSQUARED,data[:,0]/PRESSURE_CGS_IN_MSQUARED, label = name+' raw', ls = 'dashed')
+'''
 
 plt.legend()
 plt.show()
-- 
GitLab


From 5ffee4dd879a5df657f4e2341bdce92ee71a1e1d Mon Sep 17 00:00:00 2001
From: Atul Kedia <atulkedia93@gmail.com>
Date: Thu, 16 Mar 2023 19:45:42 -0700
Subject: [PATCH 08/12] readying for first merge request

---
 MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
index d633e1119..134ec58b6 100644
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
+++ b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager.py
@@ -88,7 +88,7 @@ class EOSConcrete:
         but lalsuite doesn't provide access to this low-level info
         """
         r1p4 =lalsim.SimNeutronStarRadius(1.4*lal.MSUN_SI, self.eos_fam)/1e3
-        return m + (1./r1p4)*m**2 #(m/lal.MSUN_SI)
+        return m + (1./r1p4)*m**2
 
     def pressure_density_on_grid_alternate(self,logrho_grid,enforce_causal=False):
         """
-- 
GitLab


From ce2b81c236468755471d08f74ab9b76811f3b473 Mon Sep 17 00:00:00 2001
From: Atul Kedia <atulkedia93@gmail.com>
Date: Thu, 16 Mar 2023 19:48:47 -0700
Subject: [PATCH 09/12] remove an eos file

---
 .../Code/RIFT/physics/eos_manager.txt         | 302 ------------------
 1 file changed, 302 deletions(-)
 delete mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager.txt

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager.txt b/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager.txt
deleted file mode 100644
index 2a1c77d46..000000000
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager.txt
+++ /dev/null
@@ -1,302 +0,0 @@
-# baryon_density pressure energy_density
-6.294999999999999937e+28 5.165347142000000369e+20 1.042782668627668463e+05
-6.985358165731020154e+28 6.166458480847186821e+20 1.157151306250155612e+05
-7.751426323041308748e+28 7.377918698718484234e+20 1.284064586129412928e+05
-8.601507412505002415e+28 8.846061893030260244e+20 1.424898735194982728e+05
-9.544814939084625418e+28 1.062768641128689828e+21 1.581181021415382565e+05
-1.059157283163244364e+29 1.261398350214372786e+21 1.754584631611361692e+05
-1.175312625375353433e+29 1.485408293169513103e+21 1.946986092775386642e+05
-1.304206456704128682e+29 1.753806904898457960e+21 2.160483197536182706e+05
-1.447235777940795062e+29 2.076048307660254085e+21 2.397388398945541412e+05
-1.605950795738970580e+29 2.463684413519224635e+21 2.660267505057482049e+05
-1.782071724349078316e+29 2.930840493769161703e+21 2.951967401758864289e+05
-1.977507429960316862e+29 3.494799838784604602e+21 3.275646827058025519e+05
-2.194376119724712341e+29 4.176722490156965167e+21 3.634810460901324986e+05
-2.435028299698835548e+29 5.002527203760150675e+21 4.033346776634584530e+05
-2.702072250530163932e+29 5.892333298708114309e+21 4.475790000887386850e+05
-2.998402297003348584e+29 6.908898423491679748e+21 4.966879713464012020e+05
-3.327230177842571599e+29 8.122636605744099623e+21 5.511881657099396689e+05
-3.692119855767956042e+29 9.574996539893564310e+21 6.116721119411712280e+05
-4.097026145090759623e+29 1.131655979640099229e+22 6.787976168395495042e+05
-4.546337575508057181e+29 1.340910188938168736e+22 7.532949942248150473e+05
-5.044923956671163998e+29 1.592812934674910282e+22 8.359750993889740203e+05
-5.598189159050828772e+29 1.896599219245485235e+22 9.277382688889581477e+05
-6.212129683158470508e+29 2.263571341215911851e+22 1.029584259293717681e+06
-6.893399651919155353e+29 2.643140419722350376e+22 1.142498452732925303e+06
-7.649382930608554618e+29 3.083884099221510003e+22 1.267775161095064366e+06
-8.488273156017465996e+29 3.607870289969677546e+22 1.406786405555349775e+06
-9.419162542230662313e+29 4.232304317650667622e+22 1.561037431739235995e+06
-1.045214042553117107e+30 4.978146612511713631e+22 1.732198334886844503e+06
-1.159840261649745390e+30 5.870957377684263823e+22 1.922122082617670996e+06
-1.287037274449349100e+30 6.941933102760417506e+22 2.132864507089901716e+06
-1.428183690972987446e+30 8.229180031294750327e+22 2.366706471757432912e+06
-1.584809310230663535e+30 9.772799639550402809e+22 2.626181067109444644e+06
-1.758611700769866740e+30 1.131394987247661503e+23 2.914222943381906487e+06
-1.951474599574726767e+30 1.313271371838366658e+23 3.233861726632961072e+06
-2.165488328730102235e+30 1.528466211293808736e+23 3.588564429986020550e+06
-2.402972451134239791e+30 1.783727334770808245e+23 3.982178716367234010e+06
-2.666500910811318002e+30 2.087258453860299928e+23 4.418974740352245048e+06
-2.958929930304216832e+30 2.449044331484340132e+23 4.903691604199388064e+06
-3.283428967510163103e+30 2.881250106323136823e+23 5.441588941430862062e+06
-3.643515067481317813e+30 3.398711545722846870e+23 6.038504187433504499e+06
-4.043090981508281263e+30 3.994084513997780314e+23 6.700931869425583631e+06
-4.486487466635793050e+30 4.561446550687552939e+23 7.436141897442588583e+06
-4.978510224068978277e+30 5.220954352209997962e+23 8.252058042672330514e+06
-5.524491985206610571e+30 6.026257726417550537e+23 9.157127533225657418e+06
-6.130350309829796782e+30 6.975570249957073549e+23 1.016145236971424147e+07
-6.802651722885029795e+30 8.095722728123233049e+23 1.127593857291039824e+07
-7.548682885000656204e+30 9.420889942752078500e+23 1.251267176713720337e+07
-8.376529568110140368e+30 1.099256652677204566e+24 1.388506401921731792e+07
-9.295164292150200218e+30 1.286119592228581074e+24 1.540799953863635287e+07
-1.031454357267399647e+31 1.498814017068945946e+24 1.709801247436551750e+07
-1.144571583338629346e+31 1.726639982547876249e+24 1.897346352026350796e+07
-1.270094115319805651e+31 1.994132054658340444e+24 2.105467225973089784e+07
-1.409382414566500753e+31 2.309036986525123510e+24 2.336422247097013891e+07
-1.563946141100843213e+31 2.680736808942375736e+24 2.592717899943273142e+07
-1.735460515885987659e+31 3.120610412940436076e+24 2.877136084667658806e+07
-1.925784477513574776e+31 3.642475903973184846e+24 3.192764446715832129e+07
-2.136980830093327678e+31 4.205290379566238904e+24 3.542856988159487396e+07
-2.371338600715342095e+31 4.836502153627852291e+24 3.931238560759986192e+07
-2.631397848803825946e+31 5.576275175894791993e+24 4.362177093094854802e+07
-2.919977196255576085e+31 6.445616996951186559e+24 4.840331390418393165e+07
-3.240204376745395294e+31 7.469943322244621521e+24 5.370869253934999555e+07
-3.595550135303548088e+31 8.680051523629571952e+24 5.959522858162413538e+07
-3.989865845581876323e+31 1.010506875087315266e+25 6.612681462651485950e+07
-4.427425252518930058e+31 1.158202545139873542e+25 7.338190168885791302e+07
-4.912970792827137564e+31 1.330627280163583039e+25 8.143335731377996504e+07
-5.451764995341231958e+31 1.532467065196200909e+25 9.036868400106081367e+07
-6.049647518324608522e+31 1.769378256279272897e+25 1.002850188882630020e+08
-6.713098441925846426e+31 2.048200061238148048e+25 1.112901994359344244e+08
-7.449308501773297820e+31 2.377214032348884776e+25 1.235039478270068467e+08
-8.266257024926391146e+31 2.746192498781150683e+25 1.370553822074735761e+08
-9.172798412883392948e+31 3.146068200818694870e+25 1.520881008554103076e+08
-1.017875810898166060e+32 3.612634404991467477e+25 1.687699252766113579e+08
-1.129503909032182568e+32 4.158488578103147774e+25 1.872818252656230330e+08
-1.253374003841630512e+32 4.798832153777370277e+25 2.078246440657068193e+08
-1.390828646934093104e+32 5.552039084262530960e+25 2.306212839966365993e+08
-1.543357624462858633e+32 6.440351359224255747e+25 2.559191333486205637e+08
-1.712614104000772093e+32 7.315534176103794821e+25 2.840197671385089159e+08
-1.900432552204591787e+32 8.264068657843502556e+25 3.152196421561555266e+08
-2.108848617468370116e+32 9.413512537648969385e+25 3.498158202553554773e+08
-2.340121193061676165e+32 1.080377492392429677e+26 3.881775999846838117e+08
-2.596756899881429265e+32 1.242930917786251108e+26 4.307460306894009709e+08
-2.881537254170788066e+32 1.433507568146248251e+26 4.779823542617355585e+08
-3.197548814659263493e+32 1.655136756132743333e+26 5.304001204967349172e+08
-3.548216635870313894e+32 1.896958477990492617e+26 5.885799017197387218e+08
-3.937341390176227941e+32 2.179252879104347483e+26 6.531429068243144751e+08
-4.369140560943326286e+32 2.509686767892577973e+26 7.247898125527240038e+08
-4.848294153234641259e+32 2.897514348835473551e+26 8.042982864777351618e+08
-5.379995417500169477e+32 3.334043502253457473e+26 8.925321820100079775e+08
-5.970007136017519839e+32 3.836150159953974780e+26 9.904493984702121019e+08
-6.624724082137004584e+32 4.312576556420053212e+26 1.099125768921423674e+09
-7.351242329288429869e+32 4.718653535163892684e+26 1.219748644378827572e+09
-8.157436160947172566e+32 5.225941268531537930e+26 1.353596928281055450e+09
-9.052043415139293179e+32 6.004484282431530675e+26 1.502074793670563459e+09
-1.004476018848212219e+33 6.912221847770953695e+26 1.666842074406544447e+09
-1.114634592619911956e+33 7.915714347447511525e+26 1.849667730881092787e+09
-1.236874003711480989e+33 9.086044371490364774e+26 2.052549684997077703e+09
-1.372519129754791655e+33 1.045464686649291233e+27 2.277688905832159042e+09
-1.523040144663172084e+33 1.205944404976415460e+27 2.527528071273923397e+09
-1.690068452940276919e+33 1.384774433518954870e+27 2.804945455609254837e+09
-1.875414371467952226e+33 1.587546097178036821e+27 3.112949069844432831e+09
-2.081086750415086011e+33 1.824333122097363011e+27 3.454821356287115574e+09
-2.309314745926394680e+33 2.101590923855381572e+27 3.834297581346822262e+09
-2.562571980571881930e+33 2.421513217345445596e+27 4.255396053567112446e+09
-2.843603353417206204e+33 2.773241141044943385e+27 4.722251476064086914e+09
-3.155454790292771230e+33 3.183477904656233432e+27 5.240346561189462662e+09
-3.501506256706381314e+33 3.663252315644170908e+27 5.815310062971747398e+09
-3.885508391206065761e+33 4.225869911896249537e+27 6.453390205504040718e+09
-4.311623156239506076e+33 4.777947483055280573e+27 7.161411504350040436e+09
-4.784468947099695984e+33 5.376751065610691527e+27 7.947112620680989265e+09
-5.309170647864869901e+33 6.119733623216651456e+27 8.817724873351537704e+09
-5.891415176858192836e+33 7.032206282933378178e+27 9.782458272739786148e+09
-6.537513123650205288e+33 8.085139337613389238e+27 1.085528350580601692e+10
-7.254467145649511099e+33 9.287285723835153615e+27 1.205150645161280441e+10
-8.050047865590185856e+33 1.068491032048416860e+28 1.337889434963222694e+10
-8.932878092521999972e+33 1.226239386950930406e+28 1.484433476382813263e+10
-9.912526279122840605e+33 1.410673866420962835e+28 1.647007202313125801e+10
-1.099961022825958281e+34 1.618872017588819029e+28 1.828035967803216934e+10
-1.220591217280882326e+34 1.861666562530063102e+28 2.029063201215296936e+10
-1.354450647601679915e+34 2.110505129120199887e+28 2.251830857884699631e+10
-1.502990133646396049e+34 2.381167164739957577e+28 2.498893758925205612e+10
-1.667819603348691168e+34 2.704354276315120405e+28 2.773268601504651260e+10
-1.850725541734400614e+34 3.092577186042517652e+28 3.078021258867486191e+10
-2.053690353531589750e+34 3.543574686794249570e+28 3.416098211200037384e+10
-2.278913849233506444e+34 4.067206352198093962e+28 3.790726270624259949e+10
-2.528837087488608057e+34 4.667769171321674143e+28 4.206522442892446136e+10
-2.806168832230658997e+34 5.226299079536023225e+28 4.668979636220603180e+10
-3.113914911301399794e+34 5.856868890106270833e+28 5.182416633400325775e+10
-3.455410794765817660e+34 6.699214996788812689e+28 5.751105760011439514e+10
-3.834357746016285709e+34 7.702001398251428439e+28 6.382009333553183746e+10
-4.254862937485122634e+34 8.845233050429101515e+28 7.082954603853540039e+10
-4.721483965755040564e+34 1.016400954419972109e+29 7.861496419139753723e+10
-5.239278248539326095e+34 1.167957259653945684e+29 8.724768711238674927e+10
-5.813857838915186420e+34 1.341321188428274853e+29 9.681453897342863464e+10
-6.451450250907942562e+34 1.542231672487229490e+29 1.074409808102410736e+11
-7.158965955677083153e+34 1.770335880354263798e+29 1.192752127938576202e+11
-7.944073279853740413e+34 2.035535190426246950e+29 1.324172360026489410e+11
-8.815281517806501624e+34 2.272849675516221820e+29 1.469236737655426331e+11
-9.782033158638187572e+34 2.539447736538703479e+29 1.630174232918174133e+11
-1.085480622750514232e+35 2.834161249313151809e+29 1.809693535214535217e+11
-1.204522785047354846e+35 3.150626886028104514e+29 2.008278968910747986e+11
-1.336620027377221718e+35 3.566924093964861710e+29 2.228872671068214722e+11
-1.483204070328688704e+35 4.097881163433249748e+29 2.474099195602670898e+11
-1.645863647993009095e+35 4.675180237383062727e+29 2.746266281294648132e+11
-1.826361727273679436e+35 5.263271468064955134e+29 3.048222922056145020e+11
-2.026654615598063382e+35 5.928443689643093528e+29 3.383443103573421631e+11
-2.248913164127782883e+35 6.660241614351612660e+29 3.755466155208320923e+11
-2.495546296276408869e+35 7.491181980950670312e+29 4.168512223713275757e+11
-2.769227116545546965e+35 8.354890690443169521e+29 4.624469924893273926e+11
-3.072921882656903219e+35 9.206102751476656203e+29 5.131863640802401733e+11
-3.409922154991412500e+35 1.013561551354342926e+30 5.694957293153978271e+11
-3.783880471783379948e+35 1.114853360920056628e+30 6.319872145884324951e+11
-4.198849936731084632e+35 1.224971607181139856e+30 7.013403723333323975e+11
-4.659328148089541666e+35 1.344356397863777823e+30 7.783096440563981934e+11
-5.170305945365794691e+35 1.473373812761378091e+30 8.637326575508997803e+11
-5.737321501952119103e+35 1.612279689975440968e+30 9.585394530717751465e+11
-6.366520349973851686e+35 1.761172663564104038e+30 1.063762746255796143e+12
-7.064721987924157516e+35 1.919934393472977400e+30 1.180549345243035645e+12
-7.839493793004843199e+35 2.088152527653006931e+30 1.310172856437592285e+12
-8.699233039263547783e+35 2.265023482064908918e+30 1.454047829225046631e+12
-9.653257910471280334e+35 2.449230157321329733e+30 1.613745505851289062e+12
-1.071190849417285629e+36 2.638786449431165501e+30 1.791011367479669189e+12
-1.188665885152245279e+36 2.830842990000272562e+30 1.987784687780635742e+12
-1.319024137756017198e+36 3.021442584795782804e+30 2.206220333517662109e+12
-1.463678479979398388e+36 3.205215593695609359e+30 2.448713084065665039e+12
-1.624196731076863850e+36 3.374997388433615126e+30 2.717924772374655762e+12
-1.802318649433105825e+36 3.521354316858286545e+30 3.016814596280232422e+12
-1.999974788731826606e+36 3.631989415893279058e+30 3.348672989928392578e+12
-2.219307422037178289e+36 4.166541247521724958e+30 3.716341586894569336e+12
-2.462693760571066537e+36 4.791304287700583583e+30 4.124430305948428223e+12
-2.732771718840338952e+36 5.523413048842315044e+30 4.577394892917429688e+12
-3.032468505366188821e+36 6.382441800388788158e+30 5.080168675995340820e+12
-3.365032348893066296e+36 7.382304341528081485e+30 5.638096448424265625e+12
-3.734067703937921693e+36 8.561208748124174740e+30 6.257395355668807617e+12
-4.143574317251031495e+36 9.946277558358492511e+30 6.944782725406486328e+12
-4.597990578605691399e+36 1.156693610258714716e+31 7.707693864420269531e+12
-5.102241625769272732e+36 1.347999175789679893e+31 8.554538233984585938e+12
-5.661792725035759666e+36 1.571357737532060210e+31 9.494457086702732422e+12
-6.282708505878480423e+36 1.835954692105069707e+31 1.053778136998549414e+13
-6.971718691730893878e+36 2.149840671451791603e+31 1.169588855987116797e+13
-7.736291039310880035e+36 2.512469813336011363e+31 1.298137064535030273e+13
-8.584712277032879994e+36 2.940350214072720701e+31 1.440832949675453516e+13
-9.526177919749477850e+36 3.443838149024896332e+31 1.599235171223742773e+13
-1.057089193326903209e+37 4.033943525107494818e+31 1.775075624285680859e+13
-1.173017732885162958e+37 4.727905403341851443e+31 1.970278483858347656e+13
-1.301659888634894917e+37 5.533843736314825691e+31 2.186981278257176953e+13
-1.444409933610848864e+37 6.478177858927889376e+31 2.427552204629973828e+13
-1.602815047563389987e+37 7.573383933218675981e+31 2.694634292323234766e+13
-1.778592085886176786e+37 8.845263427457890404e+31 2.991147610119188672e+13
-1.973646187553546846e+37 1.030495241891500315e+32 3.320346577422444531e+13
-2.190091423747587717e+37 1.198294085420827316e+32 3.685840409389389844e+13
-2.430273710972626631e+37 1.388362255016434658e+32 4.091633508270321094e+13
-2.696796236998263779e+37 1.601567006363779311e+32 4.542179385438157812e+13
-2.992547675207070442e+37 1.839729587663832682e+32 5.042413696713809375e+13
-3.320733493144891266e+37 2.104218429326042950e+32 5.597817761637072656e+13
-3.684910694607810056e+37 2.393648357144748130e+32 6.214475890907849219e+13
-4.089026371813857209e+37 2.708364392940562441e+32 6.899135759501764844e+13
-4.537460485502687135e+37 3.013613985527547037e+32 7.659273708806068750e+13
-5.035073336630347560e+37 3.371716075091777995e+32 8.503185645830560938e+13
-5.587258244175588525e+37 3.750038734872313329e+32 9.440105625353439062e+13
-6.199999999999986184e+37 4.147200335999991463e+32 1.048025763494627500e+14
-6.544012399999999797e+37 4.176787846084300410e+32 1.106436243014349219e+14
-6.742657899999999657e+37 4.505894094680140264e+32 1.140169235146369062e+14
-6.947333399999999245e+37 4.853836291708117644e+32 1.174937658587942500e+14
-7.158221799999999491e+37 5.221854198702269117e+32 1.210773578276822969e+14
-7.375511899999998492e+37 5.611325210001689304e+32 1.247710134003582969e+14
-7.599397799999999484e+37 6.023783526992610027e+32 1.285781450575731250e+14
-7.830079900000000385e+37 6.460945829349889484e+32 1.325022808725620469e+14
-8.067764299999998941e+37 6.924737782325394546e+32 1.365470560465101719e+14
-8.312663800000000209e+37 7.417326466489878386e+32 1.407162302193905312e+14
-8.564997299999999979e+37 7.941154689937977729e+32 1.450136792617317812e+14
-8.824990400000000412e+37 8.498981840638593274e+32 1.494434061570005625e+14
-9.092875699999998496e+37 9.093929164207096740e+32 1.540095477411290312e+14
-9.368892799999999273e+37 9.729530864719819524e+32 1.587163770151503125e+14
-9.653288399999999394e+37 1.040979050941616662e+33 1.635683061396751250e+14
-9.946316999999999545e+37 1.113924691018881530e+33 1.685699011697816562e+14
-1.024824000000000035e+38 1.192304247077376123e+33 1.737258688284273125e+14
-1.055932899999999912e+38 1.276701082714305417e+33 1.790411162246842500e+14
-1.087986099999999889e+38 1.367775338497083142e+33 1.845206713701507188e+14
-1.121012200000000021e+38 1.466274541097519953e+33 1.901697493400887500e+14
-1.155040899999999914e+38 1.573045119530039719e+33 1.959937897078371562e+14
-1.190102499999999895e+38 1.689042823930879812e+33 2.019983761152837500e+14
-1.226228399999999837e+38 1.815347429134675342e+33 2.081893267307620938e+14
-1.263450999999999743e+38 1.953176885910319488e+33 2.145726835592829688e+14
-1.301803399999999946e+38 2.103901962378143950e+33 2.211546668857090312e+14
-1.341320099999999934e+38 2.269066144814640035e+33 2.279418029187489688e+14
-1.382036299999999906e+38 2.450401439961647772e+33 2.349408116672644688e+14
-1.423988399999999985e+38 2.649850800520896242e+33 2.421587015753798125e+14
-1.467213999999999837e+38 2.869589583174719842e+33 2.496027802910953125e+14
-1.511751699999999823e+38 3.112048753051311362e+33 2.572806302293722812e+14
-1.557641399999999839e+38 3.379940777994816073e+33 2.652001733570514688e+14
-1.604924099999999902e+38 3.676285108486223503e+33 2.733696494373690625e+14
-1.653642099999999945e+38 4.004439071906591052e+33 2.817976661619926250e+14
-1.703838900000000012e+38 4.368124699960174808e+33 2.904931969967976250e+14
-1.755559499999999863e+38 4.771465220228640142e+33 2.994656522691256875e+14
-1.808849999999999943e+38 5.219013259392000113e+33 3.087248272117512500e+14
-1.863758199999999832e+38 5.715791241637407694e+33 3.182810298130898125e+14
-1.920333199999999783e+38 6.267325405377919430e+33 3.281450318304651250e+14
-1.978625499999999958e+38 6.879684979041039901e+33 3.383281132944153125e+14
-2.038687300000000033e+38 7.559524922572896193e+33 3.488421394731748125e+14
-2.100572199999999595e+38 8.314127280628670508e+33 3.596995404982125625e+14
-2.164335699999999619e+38 9.151452329260910267e+33 3.709134284257751875e+14
-2.230034799999999852e+38 1.008018439226489650e+34 3.824975621431327500e+14
-2.297728199999999929e+38 1.110978495692678352e+34 3.944664206157361250e+14
-2.367476499999999744e+38 1.225055752914991855e+34 4.068352756730983750e+14
-2.439341999999999837e+38 1.351370450108447721e+34 4.196202031333028125e+14
-2.513388899999999493e+38 1.491140310311097143e+34 4.328381617609762500e+14
-2.589683599999999743e+38 1.645688695028178833e+34 4.465071011428784375e+14
-2.668294299999999616e+38 1.816452658292831690e+34 4.606459419742203125e+14
-2.749291200000000278e+38 2.004992529057792265e+34 4.752746755531966250e+14
-2.832746699999999733e+38 2.213002864044772267e+34 4.904144596611195625e+14
-2.918735699999999979e+38 2.442324761818987113e+34 5.060877491065353750e+14
-3.007334799999999883e+38 2.694956294128761227e+34 5.223182240244966250e+14
-3.098623300000000029e+38 2.973068273755347329e+34 5.391310557921419375e+14
-3.192682999999999706e+38 3.279018563110367896e+34 5.565529636196520625e+14
-3.289597899999999573e+38 3.615365885266371088e+34 5.746122548559611250e+14
-3.389454700000000119e+38 3.984887419908601685e+34 5.933390276255341250e+14
-3.492342599999999779e+38 4.390593903143154921e+34 6.127652458447495000e+14
-3.598353699999999450e+38 4.835747510043711794e+34 6.329249415206125000e+14
-3.707582899999999848e+38 5.323877267264752335e+34 6.538543271425423750e+14
-3.820127700000000013e+38 5.858793184601405623e+34 6.755919038409673750e+14
-3.936088799999999532e+38 6.444602906208767228e+34 6.981787227274886250e+14
-4.055570000000000064e+38 7.085722543396799510e+34 7.216585344161030000e+14
-4.178678100000000050e+38 7.786889083084463534e+34 7.460779330040896250e+14
-4.305523199999999989e+38 8.553165701634047388e+34 7.714865970400578750e+14
-4.436218699999999410e+38 9.389948928667200788e+34 7.979374723208910000e+14
-4.570881399999999138e+38 1.030297071974569336e+35 8.254869865301522500e+14
-4.709631999999999747e+38 1.129829941161984090e+35 8.541953462782542500e+14
-4.852594299999999344e+38 1.238233148946121384e+35 8.841265792026993750e+14
-4.999896299999999546e+38 1.356179152261012818e+35 9.153489684880531250e+14
-5.151669699999999467e+38 1.484372598593958103e+35 9.479351594940230000e+14
-5.308050199999999474e+38 1.623549025036284791e+35 9.819624411026782500e+14
-5.469177699999999665e+38 1.774475054792372887e+35 1.017512989478104375e+15
-5.635196299999999870e+38 1.937947614095631825e+35 1.054674146931147750e+15
-5.806254400000000398e+38 2.114793924598271855e+35 1.093538601576421375e+15
-5.982505099999998990e+38 2.305872357123191547e+35 1.134204763274132000e+15
-6.164105799999999911e+38 2.512072534650841528e+35 1.176776913424821750e+15
-6.351219199999999532e+38 2.734318353945394896e+35 1.221365664659901750e+15
-6.544012399999999230e+38 2.973568346821471764e+35 1.268088058071735000e+15
-6.742657899999999280e+38 3.230820266318532735e+35 1.317068086403385750e+15
-6.947333399999998868e+38 3.507113163819618144e+35 1.368436924768349750e+15
-7.158221799999999869e+38 3.803532033927135439e+35 1.422333261400725750e+15
-7.375511900000000004e+38 4.121212188182810991e+35 1.478903867296315000e+15
-7.599397799999998917e+38 4.461343570011302574e+35 1.538303760441225250e+15
-7.830079899999998874e+38 4.825176866693842444e+35 1.600696910844022250e+15
-8.067764299999998752e+38 5.214027999424102138e+35 1.666256501780876500e+15
-8.312663799999998509e+38 5.629285251361474168e+35 1.735165666840627750e+15
-8.564997299999999224e+38 6.072413704313394625e+35 1.807617822977759250e+15
-8.824990400000000034e+38 6.544962632659532083e+35 1.883817357046999000e+15
-9.092875699999999630e+38 7.048571884808650518e+35 1.963980319726244750e+15
-9.368892799999999273e+38 7.584978411203327629e+35 2.048335005411468750e+15
-9.653288399999999772e+38 8.156022748122413826e+35 2.137122597182751750e+15
-9.946316999999999923e+38 8.763656940610561420e+35 2.230598161766946750e+15
-1.024823999999999959e+39 9.409950529155839483e+35 2.329030998352703000e+15
-1.055932899999999950e+39 1.009710442550620811e+36 2.432706580232024000e+15
-1.087986099999999851e+39 1.082744757426860624e+36 2.541925729778268000e+15
-1.121012199999999945e+39 1.160345361327644916e+36 2.657006736487105000e+15
-1.155040899999999839e+39 1.242775385798273497e+36 2.778286962337194000e+15
-1.190102500000000008e+39 1.330313388268119935e+36 2.906122147729318500e+15
-1.226228400000000102e+39 1.423255522449369833e+36 3.040889134229467000e+15
-1.263451000000000007e+39 1.521916262691664139e+36 3.182986744146438000e+15
-1.301803400000000021e+39 1.626628697015804830e+36 3.332835789104209000e+15
-- 
GitLab


From 8bf4007c4c2b18594f4ea968eca88dec3d1d3aa2 Mon Sep 17 00:00:00 2001
From: Atul Kedia <atulkedia93@gmail.com>
Date: Thu, 16 Mar 2023 19:49:48 -0700
Subject: [PATCH 10/12] remove another eos file

---
 .../physics/eos_manager_phase_transition.txt  | 302 ------------------
 1 file changed, 302 deletions(-)
 delete mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager_phase_transition.txt

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager_phase_transition.txt b/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager_phase_transition.txt
deleted file mode 100644
index 9c00d0086..000000000
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/eos_manager_phase_transition.txt
+++ /dev/null
@@ -1,302 +0,0 @@
-# baryon_density pressure energy_density
-6.294999999999999937e+28 5.165347142000000369e+20 1.042782668627668463e+05
-6.985358165731020154e+28 6.166458480847186821e+20 1.157151306250155612e+05
-7.751426323041308748e+28 7.377918698718484234e+20 1.284064586129412928e+05
-8.601507412505002415e+28 8.846061893030260244e+20 1.424898735194982728e+05
-9.544814939084625418e+28 1.062768641128689828e+21 1.581181021415382565e+05
-1.059157283163244364e+29 1.261398350214372786e+21 1.754584631611361692e+05
-1.175312625375353433e+29 1.485408293169513103e+21 1.946986092775386642e+05
-1.304206456704128682e+29 1.753806904898457960e+21 2.160483197536182706e+05
-1.447235777940795062e+29 2.076048307660254085e+21 2.397388398945541412e+05
-1.605950795738970580e+29 2.463684413519224635e+21 2.660267505057482049e+05
-1.782071724349078316e+29 2.930840493769161703e+21 2.951967401758864289e+05
-1.977507429960316862e+29 3.494799838784604602e+21 3.275646827058025519e+05
-2.194376119724712341e+29 4.176722490156965167e+21 3.634810460901324986e+05
-2.435028299698835548e+29 5.002527203760150675e+21 4.033346776634584530e+05
-2.702072250530163932e+29 5.892333298708114309e+21 4.475790000887386850e+05
-2.998402297003348584e+29 6.908898423491679748e+21 4.966879713464012020e+05
-3.327230177842571599e+29 8.122636605744099623e+21 5.511881657099396689e+05
-3.692119855767956042e+29 9.574996539893564310e+21 6.116721119411712280e+05
-4.097026145090759623e+29 1.131655979640099229e+22 6.787976168395495042e+05
-4.546337575508057181e+29 1.340910188938168736e+22 7.532949942248150473e+05
-5.044923956671163998e+29 1.592812934674910282e+22 8.359750993889740203e+05
-5.598189159050828772e+29 1.896599219245485235e+22 9.277382688889581477e+05
-6.212129683158470508e+29 2.263571341215911851e+22 1.029584259293717681e+06
-6.893399651919155353e+29 2.643140419722350376e+22 1.142498452732925303e+06
-7.649382930608554618e+29 3.083884099221510003e+22 1.267775161095064366e+06
-8.488273156017465996e+29 3.607870289969677546e+22 1.406786405555349775e+06
-9.419162542230662313e+29 4.232304317650667622e+22 1.561037431739235995e+06
-1.045214042553117107e+30 4.978146612511713631e+22 1.732198334886844503e+06
-1.159840261649745390e+30 5.870957377684263823e+22 1.922122082617670996e+06
-1.287037274449349100e+30 6.941933102760417506e+22 2.132864507089901716e+06
-1.428183690972987446e+30 8.229180031294750327e+22 2.366706471757432912e+06
-1.584809310230663535e+30 9.772799639550402809e+22 2.626181067109444644e+06
-1.758611700769866740e+30 1.131394987247661503e+23 2.914222943381906487e+06
-1.951474599574726767e+30 1.313271371838366658e+23 3.233861726632961072e+06
-2.165488328730102235e+30 1.528466211293808736e+23 3.588564429986020550e+06
-2.402972451134239791e+30 1.783727334770808245e+23 3.982178716367234010e+06
-2.666500910811318002e+30 2.087258453860299928e+23 4.418974740352245048e+06
-2.958929930304216832e+30 2.449044331484340132e+23 4.903691604199388064e+06
-3.283428967510163103e+30 2.881250106323136823e+23 5.441588941430862062e+06
-3.643515067481317813e+30 3.398711545722846870e+23 6.038504187433504499e+06
-4.043090981508281263e+30 3.994084513997780314e+23 6.700931869425583631e+06
-4.486487466635793050e+30 4.561446550687552939e+23 7.436141897442588583e+06
-4.978510224068978277e+30 5.220954352209997962e+23 8.252058042672330514e+06
-5.524491985206610571e+30 6.026257726417550537e+23 9.157127533225657418e+06
-6.130350309829796782e+30 6.975570249957073549e+23 1.016145236971424147e+07
-6.802651722885029795e+30 8.095722728123233049e+23 1.127593857291039824e+07
-7.548682885000656204e+30 9.420889942752078500e+23 1.251267176713720337e+07
-8.376529568110140368e+30 1.099256652677204566e+24 1.388506401921731792e+07
-9.295164292150200218e+30 1.286119592228581074e+24 1.540799953863635287e+07
-1.031454357267399647e+31 1.498814017068945946e+24 1.709801247436551750e+07
-1.144571583338629346e+31 1.726639982547876249e+24 1.897346352026350796e+07
-1.270094115319805651e+31 1.994132054658340444e+24 2.105467225973089784e+07
-1.409382414566500753e+31 2.309036986525123510e+24 2.336422247097013891e+07
-1.563946141100843213e+31 2.680736808942375736e+24 2.592717899943273142e+07
-1.735460515885987659e+31 3.120610412940436076e+24 2.877136084667658806e+07
-1.925784477513574776e+31 3.642475903973184846e+24 3.192764446715832129e+07
-2.136980830093327678e+31 4.205290379566238904e+24 3.542856988159487396e+07
-2.371338600715342095e+31 4.836502153627852291e+24 3.931238560759986192e+07
-2.631397848803825946e+31 5.576275175894791993e+24 4.362177093094854802e+07
-2.919977196255576085e+31 6.445616996951186559e+24 4.840331390418393165e+07
-3.240204376745395294e+31 7.469943322244621521e+24 5.370869253934999555e+07
-3.595550135303548088e+31 8.680051523629571952e+24 5.959522858162413538e+07
-3.989865845581876323e+31 1.010506875087315266e+25 6.612681462651485950e+07
-4.427425252518930058e+31 1.158202545139873542e+25 7.338190168885791302e+07
-4.912970792827137564e+31 1.330627280163583039e+25 8.143335731377996504e+07
-5.451764995341231958e+31 1.532467065196200909e+25 9.036868400106081367e+07
-6.049647518324608522e+31 1.769378256279272897e+25 1.002850188882630020e+08
-6.713098441925846426e+31 2.048200061238148048e+25 1.112901994359344244e+08
-7.449308501773297820e+31 2.377214032348884776e+25 1.235039478270068467e+08
-8.266257024926391146e+31 2.746192498781150683e+25 1.370553822074735761e+08
-9.172798412883392948e+31 3.146068200818694870e+25 1.520881008554103076e+08
-1.017875810898166060e+32 3.612634404991467477e+25 1.687699252766113579e+08
-1.129503909032182568e+32 4.158488578103147774e+25 1.872818252656230330e+08
-1.253374003841630512e+32 4.798832153777370277e+25 2.078246440657068193e+08
-1.390828646934093104e+32 5.552039084262530960e+25 2.306212839966365993e+08
-1.543357624462858633e+32 6.440351359224255747e+25 2.559191333486205637e+08
-1.712614104000772093e+32 7.315534176103794821e+25 2.840197671385089159e+08
-1.900432552204591787e+32 8.264068657843502556e+25 3.152196421561555266e+08
-2.108848617468370116e+32 9.413512537648969385e+25 3.498158202553554773e+08
-2.340121193061676165e+32 1.080377492392429677e+26 3.881775999846838117e+08
-2.596756899881429265e+32 1.242930917786251108e+26 4.307460306894009709e+08
-2.881537254170788066e+32 1.433507568146248251e+26 4.779823542617355585e+08
-3.197548814659263493e+32 1.655136756132743333e+26 5.304001204967349172e+08
-3.548216635870313894e+32 1.896958477990492617e+26 5.885799017197387218e+08
-3.937341390176227941e+32 2.179252879104347483e+26 6.531429068243144751e+08
-4.369140560943326286e+32 2.509686767892577973e+26 7.247898125527240038e+08
-4.848294153234641259e+32 2.897514348835473551e+26 8.042982864777351618e+08
-5.379995417500169477e+32 3.334043502253457473e+26 8.925321820100079775e+08
-5.970007136017519839e+32 3.836150159953974780e+26 9.904493984702121019e+08
-6.624724082137004584e+32 4.312576556420053212e+26 1.099125768921423674e+09
-7.351242329288429869e+32 4.718653535163892684e+26 1.219748644378827572e+09
-8.157436160947172566e+32 5.225941268531537930e+26 1.353596928281055450e+09
-9.052043415139293179e+32 6.004484282431530675e+26 1.502074793670563459e+09
-1.004476018848212219e+33 6.912221847770953695e+26 1.666842074406544447e+09
-1.114634592619911956e+33 7.915714347447511525e+26 1.849667730881092787e+09
-1.236874003711480989e+33 9.086044371490364774e+26 2.052549684997077703e+09
-1.372519129754791655e+33 1.045464686649291233e+27 2.277688905832159042e+09
-1.523040144663172084e+33 1.205944404976415460e+27 2.527528071273923397e+09
-1.690068452940276919e+33 1.384774433518954870e+27 2.804945455609254837e+09
-1.875414371467952226e+33 1.587546097178036821e+27 3.112949069844432831e+09
-2.081086750415086011e+33 1.824333122097363011e+27 3.454821356287115574e+09
-2.309314745926394680e+33 2.101590923855381572e+27 3.834297581346822262e+09
-2.562571980571881930e+33 2.421513217345445596e+27 4.255396053567112446e+09
-2.843603353417206204e+33 2.773241141044943385e+27 4.722251476064086914e+09
-3.155454790292771230e+33 3.183477904656233432e+27 5.240346561189462662e+09
-3.501506256706381314e+33 3.663252315644170908e+27 5.815310062971747398e+09
-3.885508391206065761e+33 4.225869911896249537e+27 6.453390205504040718e+09
-4.311623156239506076e+33 4.777947483055280573e+27 7.161411504350040436e+09
-4.784468947099695984e+33 5.376751065610691527e+27 7.947112620680989265e+09
-5.309170647864869901e+33 6.119733623216651456e+27 8.817724873351537704e+09
-5.891415176858192836e+33 7.032206282933378178e+27 9.782458272739786148e+09
-6.537513123650205288e+33 8.085139337613389238e+27 1.085528350580601692e+10
-7.254467145649511099e+33 9.287285723835153615e+27 1.205150645161280441e+10
-8.050047865590185856e+33 1.068491032048416860e+28 1.337889434963222694e+10
-8.932878092521999972e+33 1.226239386950930406e+28 1.484433476382813263e+10
-9.912526279122840605e+33 1.410673866420962835e+28 1.647007202313125801e+10
-1.099961022825958281e+34 1.618872017588819029e+28 1.828035967803216934e+10
-1.220591217280882326e+34 1.861666562530063102e+28 2.029063201215296936e+10
-1.354450647601679915e+34 2.110505129120199887e+28 2.251830857884699631e+10
-1.502990133646396049e+34 2.381167164739957577e+28 2.498893758925205612e+10
-1.667819603348691168e+34 2.704354276315120405e+28 2.773268601504651260e+10
-1.850725541734400614e+34 3.092577186042517652e+28 3.078021258867486191e+10
-2.053690353531589750e+34 3.543574686794249570e+28 3.416098211200037384e+10
-2.278913849233506444e+34 4.067206352198093962e+28 3.790726270624259949e+10
-2.528837087488608057e+34 4.667769171321674143e+28 4.206522442892446136e+10
-2.806168832230658997e+34 5.226299079536023225e+28 4.668979636220603180e+10
-3.113914911301399794e+34 5.856868890106270833e+28 5.182416633400325775e+10
-3.455410794765817660e+34 6.699214996788812689e+28 5.751105760011439514e+10
-3.834357746016285709e+34 7.702001398251428439e+28 6.382009333553183746e+10
-4.254862937485122634e+34 8.845233050429101515e+28 7.082954603853540039e+10
-4.721483965755040564e+34 1.016400954419972109e+29 7.861496419139753723e+10
-5.239278248539326095e+34 1.167957259653945684e+29 8.724768711238674927e+10
-5.813857838915186420e+34 1.341321188428274853e+29 9.681453897342863464e+10
-6.451450250907942562e+34 1.542231672487229490e+29 1.074409808102410736e+11
-7.158965955677083153e+34 1.770335880354263798e+29 1.192752127938576202e+11
-7.944073279853740413e+34 2.035535190426246950e+29 1.324172360026489410e+11
-8.815281517806501624e+34 2.272849675516221820e+29 1.469236737655426331e+11
-9.782033158638187572e+34 2.539447736538703479e+29 1.630174232918174133e+11
-1.085480622750514232e+35 2.834161249313151809e+29 1.809693535214535217e+11
-1.204522785047354846e+35 3.150626886028104514e+29 2.008278968910747986e+11
-1.336620027377221718e+35 3.566924093964861710e+29 2.228872671068214722e+11
-1.483204070328688704e+35 4.097881163433249748e+29 2.474099195602670898e+11
-1.645863647993009095e+35 4.675180237383062727e+29 2.746266281294648132e+11
-1.826361727273679436e+35 5.263271468064955134e+29 3.048222922056145020e+11
-2.026654615598063382e+35 5.928443689643093528e+29 3.383443103573421631e+11
-2.248913164127782883e+35 6.660241614351612660e+29 3.755466155208320923e+11
-2.495546296276408869e+35 7.491181980950670312e+29 4.168512223713275757e+11
-2.769227116545546965e+35 8.354890690443169521e+29 4.624469924893273926e+11
-3.072921882656903219e+35 9.206102751476656203e+29 5.131863640802401733e+11
-3.409922154991412500e+35 1.013561551354342926e+30 5.694957293153978271e+11
-3.783880471783379948e+35 1.114853360920056628e+30 6.319872145884324951e+11
-4.198849936731084632e+35 1.224971607181139856e+30 7.013403723333323975e+11
-4.659328148089541666e+35 1.344356397863777823e+30 7.783096440563981934e+11
-5.170305945365794691e+35 1.473373812761378091e+30 8.637326575508997803e+11
-5.737321501952119103e+35 1.612279689975440968e+30 9.585394530717751465e+11
-6.366520349973851686e+35 1.761172663564104038e+30 1.063762746255796143e+12
-7.064721987924157516e+35 1.919934393472977400e+30 1.180549345243035645e+12
-7.839493793004843199e+35 2.088152527653006931e+30 1.310172856437592285e+12
-8.699233039263547783e+35 2.265023482064908918e+30 1.454047829225046631e+12
-9.653257910471280334e+35 2.449230157321329733e+30 1.613745505851289062e+12
-1.071190849417285629e+36 2.638786449431165501e+30 1.791011367479669189e+12
-1.188665885152245279e+36 2.830842990000272562e+30 1.987784687780635742e+12
-1.319024137756017198e+36 3.021442584795782804e+30 2.206220333517662109e+12
-1.463678479979398388e+36 3.205215593695609359e+30 2.448713084065665039e+12
-1.624196731076863850e+36 3.374997388433615126e+30 2.717924772374655762e+12
-1.802318649433105825e+36 3.521354316858286545e+30 3.016814596280232422e+12
-1.999974788731826606e+36 3.631989415893279058e+30 3.348672989928392578e+12
-2.219307422037178289e+36 4.166541247521724958e+30 3.716341586894569336e+12
-2.462693760571066537e+36 4.791304287700583583e+30 4.124430305948428223e+12
-2.732771718840338952e+36 5.523413048842315044e+30 4.577394892917429688e+12
-3.032468505366188821e+36 6.382441800388788158e+30 5.080168675995340820e+12
-3.365032348893066296e+36 7.382304341528081485e+30 5.638096448424265625e+12
-3.734067703937921693e+36 8.561208748124174740e+30 6.257395355668807617e+12
-4.143574317251031495e+36 9.946277558358492511e+30 6.944782725406486328e+12
-4.597990578605691399e+36 1.156693610258714716e+31 7.707693864420269531e+12
-5.102241625769272732e+36 1.347999175789679893e+31 8.554538233984585938e+12
-5.661792725035759666e+36 1.571357737532060210e+31 9.494457086702732422e+12
-6.282708505878480423e+36 1.835954692105069707e+31 1.053778136998549414e+13
-6.971718691730893878e+36 2.149840671451791603e+31 1.169588855987116797e+13
-7.736291039310880035e+36 2.512469813336011363e+31 1.298137064535030273e+13
-8.584712277032879994e+36 2.940350214072720701e+31 1.440832949675453516e+13
-9.526177919749477850e+36 3.443838149024896332e+31 1.599235171223742773e+13
-1.057089193326903209e+37 4.033943525107494818e+31 1.775075624285680859e+13
-1.173017732885162958e+37 4.727905403341851443e+31 1.970278483858347656e+13
-1.301659888634894917e+37 5.533843736314825691e+31 2.186981278257176953e+13
-1.444409933610848864e+37 6.478177858927889376e+31 2.427552204629973828e+13
-1.602815047563389987e+37 7.573383933218675981e+31 2.694634292323234766e+13
-1.778592085886176786e+37 8.845263427457890404e+31 2.991147610119188672e+13
-1.973646187553546846e+37 1.030495241891500315e+32 3.320346577422444531e+13
-2.190091423747587717e+37 1.198294085420827316e+32 3.685840409389389844e+13
-2.430273710972626631e+37 1.388362255016434658e+32 4.091633508270321094e+13
-2.696796236998263779e+37 1.601567006363779311e+32 4.542179385438157812e+13
-2.992547675207070442e+37 1.839729587663832682e+32 5.042413696713809375e+13
-3.320733493144891266e+37 2.104218429326042950e+32 5.597817761637072656e+13
-3.684910694607810056e+37 2.393648357144748130e+32 6.214475890907849219e+13
-4.089026371813857209e+37 2.708364392940562441e+32 6.899135759501764844e+13
-4.537460485502687135e+37 3.013613985527547037e+32 7.659273708806068750e+13
-5.035073336630347560e+37 3.371716075091777995e+32 8.503185645830560938e+13
-5.587258244175588525e+37 3.750038734872313329e+32 9.440105625353439062e+13
-6.199999999999986184e+37 4.147200335999991463e+32 1.048025763494627500e+14
-6.544012399999999797e+37 4.176787846084300410e+32 1.106436243014349219e+14
-6.742657899999999657e+37 4.505894094680140264e+32 1.140169235146369062e+14
-6.947333399999999245e+37 4.853836291708117644e+32 1.174937658587942500e+14
-7.158221799999999491e+37 5.221854198702269117e+32 1.210773578276822969e+14
-7.375511899999998492e+37 5.611325210001689304e+32 1.247710134003582969e+14
-7.599397799999999484e+37 6.023783526992610027e+32 1.285781450575731250e+14
-7.830079900000000385e+37 6.460945829349889484e+32 1.325022808725620469e+14
-8.067764299999998941e+37 6.924737782325394546e+32 1.365470560465101719e+14
-8.312663800000000209e+37 7.417326466489878386e+32 1.407162302193905312e+14
-8.564997299999999979e+37 7.941154689937977729e+32 1.450136792617317812e+14
-8.824990400000000412e+37 8.498981840638593274e+32 1.494434061570005625e+14
-9.092875699999998496e+37 9.093929164207096740e+32 1.540095477411290312e+14
-9.368892799999999273e+37 9.729530864719819524e+32 1.587163770151503125e+14
-9.653288399999999394e+37 1.040979050941616662e+33 1.635683061396751250e+14
-9.946316999999999545e+37 1.113924691018881530e+33 1.685699011697816562e+14
-1.024824000000000035e+38 1.192304247077376123e+33 1.737258688284273125e+14
-1.055932899999999912e+38 1.276701082714305417e+33 1.790411162246842500e+14
-1.087986099999999889e+38 1.367775338497083142e+33 1.845206713701507188e+14
-1.121012200000000021e+38 1.466274541097519953e+33 1.901697493400887500e+14
-1.155040899999999914e+38 1.573045119530039719e+33 1.959937897078371562e+14
-1.190102499999999895e+38 1.689042823930879812e+33 2.019983761152837500e+14
-1.226228399999999837e+38 1.815347429134675342e+33 2.081893267307620938e+14
-1.263450999999999743e+38 1.953176885910319488e+33 2.145726835592829688e+14
-1.301803399999999946e+38 2.103901962378143950e+33 2.211546668857090312e+14
-1.341320099999999934e+38 2.269066144814640035e+33 2.279418029187489688e+14
-1.382036299999999906e+38 2.450401439961647772e+33 2.349408116672644688e+14
-1.423988399999999985e+38 2.649850800520896242e+33 2.421587015753798125e+14
-1.467213999999999837e+38 2.869589583174719842e+33 2.496027802910953125e+14
-1.511751699999999823e+38 3.112048753051311362e+33 2.572806302293722812e+14
-1.557641399999999839e+38 3.379940777994816073e+33 2.652001733570514688e+14
-1.604924099999999902e+38 3.676285108486223503e+33 2.733696494373690625e+14
-1.604924099999999902e+38 3.676285108486223503e+33 2.817976661619926250e+14
-1.604924099999999902e+38 3.676285108486223503e+33 2.904931969967976250e+14
-1.604924099999999902e+38 3.676285108486223503e+33 2.994656522691256875e+14
-1.604924099999999902e+38 3.676285108486223503e+33 3.087248272117512500e+14
-1.604924099999999902e+38 3.676285108486223503e+33 3.182810298130898125e+14
-1.604924099999999902e+38 3.676285108486223503e+33 3.281450318304651250e+14
-1.604924099999999902e+38 3.676285108486223503e+33 3.383281132944153125e+14
-1.604924099999999902e+38 3.676285108486223503e+33 3.488421394731748125e+14
-1.604924099999999902e+38 3.676285108486223503e+33 3.596995404982125625e+14
-2.164335699999999619e+38 9.151452329260910267e+33 3.709134284257751875e+14
-2.230034799999999852e+38 1.008018439226489650e+34 3.824975621431327500e+14
-2.297728199999999929e+38 1.110978495692678352e+34 3.944664206157361250e+14
-2.367476499999999744e+38 1.225055752914991855e+34 4.068352756730983750e+14
-2.439341999999999837e+38 1.351370450108447721e+34 4.196202031333028125e+14
-2.513388899999999493e+38 1.491140310311097143e+34 4.328381617609762500e+14
-2.589683599999999743e+38 1.645688695028178833e+34 4.465071011428784375e+14
-2.668294299999999616e+38 1.816452658292831690e+34 4.606459419742203125e+14
-2.749291200000000278e+38 2.004992529057792265e+34 4.752746755531966250e+14
-2.832746699999999733e+38 2.213002864044772267e+34 4.904144596611195625e+14
-2.918735699999999979e+38 2.442324761818987113e+34 5.060877491065353750e+14
-3.007334799999999883e+38 2.694956294128761227e+34 5.223182240244966250e+14
-3.098623300000000029e+38 2.973068273755347329e+34 5.391310557921419375e+14
-3.192682999999999706e+38 3.279018563110367896e+34 5.565529636196520625e+14
-3.289597899999999573e+38 3.615365885266371088e+34 5.746122548559611250e+14
-3.389454700000000119e+38 3.984887419908601685e+34 5.933390276255341250e+14
-3.492342599999999779e+38 4.390593903143154921e+34 6.127652458447495000e+14
-3.598353699999999450e+38 4.835747510043711794e+34 6.329249415206125000e+14
-3.707582899999999848e+38 5.323877267264752335e+34 6.538543271425423750e+14
-3.820127700000000013e+38 5.858793184601405623e+34 6.755919038409673750e+14
-3.936088799999999532e+38 6.444602906208767228e+34 6.981787227274886250e+14
-4.055570000000000064e+38 7.085722543396799510e+34 7.216585344161030000e+14
-4.178678100000000050e+38 7.786889083084463534e+34 7.460779330040896250e+14
-4.305523199999999989e+38 8.553165701634047388e+34 7.714865970400578750e+14
-4.436218699999999410e+38 9.389948928667200788e+34 7.979374723208910000e+14
-4.570881399999999138e+38 1.030297071974569336e+35 8.254869865301522500e+14
-4.709631999999999747e+38 1.129829941161984090e+35 8.541953462782542500e+14
-4.852594299999999344e+38 1.238233148946121384e+35 8.841265792026993750e+14
-4.999896299999999546e+38 1.356179152261012818e+35 9.153489684880531250e+14
-5.151669699999999467e+38 1.484372598593958103e+35 9.479351594940230000e+14
-5.308050199999999474e+38 1.623549025036284791e+35 9.819624411026782500e+14
-5.469177699999999665e+38 1.774475054792372887e+35 1.017512989478104375e+15
-5.635196299999999870e+38 1.937947614095631825e+35 1.054674146931147750e+15
-5.806254400000000398e+38 2.114793924598271855e+35 1.093538601576421375e+15
-5.982505099999998990e+38 2.305872357123191547e+35 1.134204763274132000e+15
-6.164105799999999911e+38 2.512072534650841528e+35 1.176776913424821750e+15
-6.351219199999999532e+38 2.734318353945394896e+35 1.221365664659901750e+15
-6.544012399999999230e+38 2.973568346821471764e+35 1.268088058071735000e+15
-6.742657899999999280e+38 3.230820266318532735e+35 1.317068086403385750e+15
-6.947333399999998868e+38 3.507113163819618144e+35 1.368436924768349750e+15
-7.158221799999999869e+38 3.803532033927135439e+35 1.422333261400725750e+15
-7.375511900000000004e+38 4.121212188182810991e+35 1.478903867296315000e+15
-7.599397799999998917e+38 4.461343570011302574e+35 1.538303760441225250e+15
-7.830079899999998874e+38 4.825176866693842444e+35 1.600696910844022250e+15
-8.067764299999998752e+38 5.214027999424102138e+35 1.666256501780876500e+15
-8.312663799999998509e+38 5.629285251361474168e+35 1.735165666840627750e+15
-8.564997299999999224e+38 6.072413704313394625e+35 1.807617822977759250e+15
-8.824990400000000034e+38 6.544962632659532083e+35 1.883817357046999000e+15
-9.092875699999999630e+38 7.048571884808650518e+35 1.963980319726244750e+15
-9.368892799999999273e+38 7.584978411203327629e+35 2.048335005411468750e+15
-9.653288399999999772e+38 8.156022748122413826e+35 2.137122597182751750e+15
-9.946316999999999923e+38 8.763656940610561420e+35 2.230598161766946750e+15
-1.024823999999999959e+39 9.409950529155839483e+35 2.329030998352703000e+15
-1.055932899999999950e+39 1.009710442550620811e+36 2.432706580232024000e+15
-1.087986099999999851e+39 1.082744757426860624e+36 2.541925729778268000e+15
-1.121012199999999945e+39 1.160345361327644916e+36 2.657006736487105000e+15
-1.155040899999999839e+39 1.242775385798273497e+36 2.778286962337194000e+15
-1.190102500000000008e+39 1.330313388268119935e+36 2.906122147729318500e+15
-1.226228400000000102e+39 1.423255522449369833e+36 3.040889134229467000e+15
-1.263451000000000007e+39 1.521916262691664139e+36 3.182986744146438000e+15
-1.301803400000000021e+39 1.626628697015804830e+36 3.332835789104209000e+15
-- 
GitLab


From c82400d1695f88e6f82e4ffd48ca37919c112862 Mon Sep 17 00:00:00 2001
From: Atul Kedia <atulkedia93@gmail.com>
Date: Thu, 16 Mar 2023 19:51:48 -0700
Subject: [PATCH 11/12] removed demo files

---
 .../Code/RIFT/physics/demo_eos_tabular.py     | 59 --------------
 .../Code/RIFT/physics/demo_mass_radius.py     | 59 --------------
 .../Code/RIFT/physics/demo_new_spectral.py    | 79 -------------------
 3 files changed, 197 deletions(-)
 delete mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
 delete mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py
 delete mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
deleted file mode 100644
index 310b5d359..000000000
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_eos_tabular.py
+++ /dev/null
@@ -1,59 +0,0 @@
-import numpy as np
-import matplotlib
-import matplotlib.pyplot as plt
-import argparse
-
-#from lalinference.rapid_pe import lalsimutils
-import RIFT.lalsimutils as lalsimutils
-import EOSManager
-import lalsimulation as lalsim
-#import lalsim_EOS_tools as let
-from scipy.integrate import nquad
-#import EOS_param as ep
-import os
-from EOSPlotUtilities import render_eos
-import lal
-
-matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
-matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
-matplotlib.rcParams['xtick.labelsize'] = 15.0
-matplotlib.rcParams['ytick.labelsize'] = 15.0
-matplotlib.rcParams['axes.labelsize'] = 25.0
-matplotlib.rcParams['lines.linewidth'] = 2.0
-plt.style.use('seaborn-v0_8-whitegrid')
-
-DENSITY_CGS_IN_MSQUARED=1000*lal.G_SI/lal.C_SI**2  # g/cm^3 -> 1/m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom). lal.G_SI/lal.C_SI**2 takes kg/m^3 -> 1/m^2  ||  https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/_l_a_l_sim_neutron_star_8h_source.html
-PRESSURE_CGS_IN_MSQUARED = DENSITY_CGS_IN_MSQUARED/(lal.C_SI*100)**2
-
-
-'''
-data = np.genfromtxt("eos_manager.txt", delimiter = " ", names=True, dtype=None)
-#data = np.genfromtxt("eos_manager_phase_transition.txt", delimiter = " ", names=True, dtype=None)
-
-neweos = EOSManager.EOSFromTabularData(eos_data=data)
-
-plt.loglog(data['energy_density']/DENSITY_CGS_IN_MSQUARED,data['pressure']/PRESSURE_CGS_IN_MSQUARED, label = ' raw')
-
-plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
-
-'''
-
-eos_names =  ['LALSimNeutronStarEOS_AP4.dat',
-              #'LALSimNeutronStarEOS_SLY4.dat',    # Erroneous for unknown reasons
-              'LALSimNeutronStarEOS_PAL6.dat',
-              'LALSimNeutronStarEOS_AP3.dat',
-              'LALSimNeutronStarEOS_MPA1.dat',
-              'LALSimNeutronStarEOS_WFF1.dat']
-
-
-for name in eos_names:
-    data = np.loadtxt("/home/atul.kedia/lalsuite_dir/lalsuite/lalsimulation/lib/"+name, delimiter = "\t")
-    
-    neweos = EOSManager.EOSFromTabularData(eos_data=data)
-    
-    plt.loglog(data[:,1]/DENSITY_CGS_IN_MSQUARED,data[:,0]/PRESSURE_CGS_IN_MSQUARED, label = name+' raw', ls = 'dashed')
-    plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
-
-
-plt.show()
-
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py
deleted file mode 100644
index 84b38100f..000000000
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_mass_radius.py
+++ /dev/null
@@ -1,59 +0,0 @@
-import numpy as np
-import matplotlib
-import matplotlib.pyplot as plt
-import argparse
-
-#from lalinference.rapid_pe import lalsimutils
-import RIFT.lalsimutils as lalsimutils
-import EOSManager
-import lalsimulation as lalsim
-#import lalsim_EOS_tools as let
-from scipy.integrate import nquad
-#import EOS_param as ep
-import os
-from EOSPlotUtilities import render_eos
-
-matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
-matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
-matplotlib.rcParams['xtick.labelsize'] = 15.0
-matplotlib.rcParams['ytick.labelsize'] = 15.0
-matplotlib.rcParams['axes.labelsize'] = 25.0
-matplotlib.rcParams['lines.linewidth'] = 2.0
-plt.style.use('seaborn-v0_8-whitegrid')
-
-#spec_params = {'gamma1': -0.701593,'gamma2':-0.239194,'gamma3':0.062016,'gamma4':-0.003556}
-
-eoss = np.genfromtxt('/home/atul.kedia/rift-testing/RIT-matters/communications/20221207-ROSKedia-SpectralRepresentation/names_laleos_improvedPBCS_indices_physical_EOS.txt', dtype='str')
-
-def M_1_4():
-    print('M_1.4')
-
-for i in range(0,len(eoss[:])):
-    try:
-        spec_params = {'gamma1': eoss[i][1].astype(float),
-                       'gamma2': eoss[i][2].astype(float),
-                       'gamma3': eoss[i][3].astype(float),
-                       'gamma4': eoss[i][4].astype(float),
-                       'p0': 5.3716e32,  # picked from LALSimNeutronStarEOSSpectralDecomposition.c
-                       'epsilon0' : 1e14, # 1.1555e35 / c**2? ~ 0.5nsat
-                       'xmax' : 50.0}
-        neweos = EOSManager.EOSLindblomSpectralSoundSpeedVersusPressure(spec_params = spec_params)
-        
-        m_r_L_data = EOSManager.make_mr_lambda_lal(neweos.eos, n_bins=200)
-        choose_M_R_L = 'M-R' # 'M-R', 'M-L'
-        
-        if choose_M_R_L == 'M-R':
-            plt.plot(m_r_L_data[:,1], m_r_L_data[:,0])
-        elif choose_M_R_L == 'M-L':
-            plt.plot(m_r_L_data[:,0], m_r_L_data[:,2])
-        
-    except:
-        continue
-    #plt.xlabel(xvar)
-    #plt.ylabel(yvar)
-
-
-plt.legend()
-plt.show()
-
-
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
deleted file mode 100644
index 61706bb46..000000000
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/demo_new_spectral.py
+++ /dev/null
@@ -1,79 +0,0 @@
-import numpy as np
-import matplotlib
-import matplotlib.pyplot as plt
-import argparse
-
-#from lalinference.rapid_pe import lalsimutils
-import RIFT.lalsimutils as lalsimutils
-import EOSManager
-import lalsimulation as lalsim
-#import lalsim_EOS_tools as let
-from scipy.integrate import nquad
-#import EOS_param as ep
-import os
-from EOSPlotUtilities import render_eos
-import lal
-
-matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
-matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
-matplotlib.rcParams['xtick.labelsize'] = 15.0
-matplotlib.rcParams['ytick.labelsize'] = 15.0
-matplotlib.rcParams['axes.labelsize'] = 25.0
-matplotlib.rcParams['lines.linewidth'] = 2.0
-plt.style.use('seaborn-v0_8-whitegrid')
-
-DENSITY_CGS_IN_MSQUARED=1000*lal.G_SI/lal.C_SI**2  # g/cm^3 -> 1/m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom). lal.G_SI/lal.C_SI**2 takes kg/m^3 -> 1/m^2  ||  https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/_l_a_l_sim_neutron_star_8h_source.html
-PRESSURE_CGS_IN_MSQUARED = DENSITY_CGS_IN_MSQUARED/(lal.C_SI*100)**2
-
-#spec_params = {'gamma1': -0.701593,'gamma2':-0.239194,'gamma3':0.062016,'gamma4':-0.003556}
-'''
-eoss = np.genfromtxt('/home/atul.kedia/rift-testing/RIT-matters/communications/20221207-ROSKedia-SpectralRepresentation/names_laleos_improvedPBCS_indices_physical_EOS.txt', dtype='str')
-
-'''
-eoss = np.array([['AP4', '-0.592110', '-0.264530', '0.085421', '-0.008334'],
-        ['SLY4', '-0.779775', '-0.144165', '0.054823', '-0.005143'],
-        ['PAL6', '-2.336417', '0.961124', '-0.178733', '0.010829'],
-        ['AP3', '-0.463822', '-0.466598', '0.147791', '-0.013972'],
-        ['MPA1', '-1.247626', '0.207047', '-0.030886', '0.000749'],
-        ['WFF1', '0.233772', '-0.764008', '0.193810', '-0.016393']], dtype=str)
-
-
-for i in range(0,len(eoss[:])):
-    spec_params = {'gamma1': eoss[i][1].astype(float),
-                   'gamma2': eoss[i][2].astype(float),
-                   'gamma3': eoss[i][3].astype(float),
-                   'gamma4': eoss[i][4].astype(float),
-                   'p0': 5.3716e32,  # picked from LALSimNeutronStarEOSSpectralDecomposition.c
-                   'epsilon0' : 1e14, # 1.1555e35 / c**2? ~ 0.5nsat
-                   'xmax' : 50.0}
-    neweos = EOSManager.EOSLindblomSpectralSoundSpeedVersusPressure(spec_params = spec_params)
-    xvar, yvar='energy_density', 'pressure'
-    new_eos_vals = neweos.make_spec_param_eos(xvar=xvar, yvar=yvar)
-    #xvar, yvar ='energy_density', 'pressure', 'rest_mass_density', 'sound_speed_over_c', 'pseudo_enthalpy'
-    
-    #plt.loglog(new_eos_vals[:,0], new_eos_vals[:,1], label = eoss[i][0])
-    #plt.xlabel(xvar)
-    #plt.ylabel(yvar)
-    
-    plot_render = render_eos(eos=neweos.eos, xvar='energy_density', yvar='pressure')
-    #render_eos variable names: pseudo_enthalpy, rest_mass_density, baryon_density, pressure, energy_density, sound_speed_over_c
-
-'''
-eos_names =  ['LALSimNeutronStarEOS_AP4.dat',
-              #'LALSimNeutronStarEOS_SLY4.dat',    # Erroneous for unknown reasons
-              'LALSimNeutronStarEOS_PAL6.dat',
-              'LALSimNeutronStarEOS_AP3.dat',
-              'LALSimNeutronStarEOS_MPA1.dat',
-              'LALSimNeutronStarEOS_WFF1.dat']
-
-
-for name in eos_names:
-    data = np.loadtxt("/home/atul.kedia/lalsuite_dir/lalsuite/lalsimulation/lib/"+name, delimiter = "\t")
-    
-    plt.loglog(data[:,1]/DENSITY_CGS_IN_MSQUARED,data[:,0]/PRESSURE_CGS_IN_MSQUARED, label = name+' raw', ls = 'dashed')
-'''
-
-plt.legend()
-plt.show()
-
-
-- 
GitLab


From de00b1f60570d9063a1ed4144d8583151b206e37 Mon Sep 17 00:00:00 2001
From: Atul Kedia <atulkedia93@gmail.com>
Date: Thu, 16 Mar 2023 19:52:28 -0700
Subject: [PATCH 12/12] last set of eos demo files

---
 .../Code/RIFT/physics/EOSManager_old.py       | 880 ------------------
 .../Code/RIFT/physics/EOSPlotUtilities.py     |  52 --
 2 files changed, 932 deletions(-)
 delete mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager_old.py
 delete mode 100644 MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py

diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager_old.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager_old.py
deleted file mode 100644
index 7332f332f..000000000
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSManager_old.py
+++ /dev/null
@@ -1,880 +0,0 @@
-#
-#  EOSManager.py 
-#
-# SEE ALSO
-#   - util_WriteXMLWithEOS
-#   - gwemlightcurves.KNTable
-
-# SERIOUS LIMITATIONS
-#   - EOSFromFile  : File i/o for each EOS creation will slow things donw.  This command is VERY trivial, so we should be able
-#          to directly create the structure ourselves, using eos_alloc_tabular
-#           https://github.com/lscsoft/lalsuite/blob/master/lalsimulation/src/LALSimNeutronStarEOSTabular.c
-
-rosDebug=False
-
-import numpy as np
-import os
-import sys
-import lal
-import lalsimulation as lalsim
-from scipy.integrate import quad
-import scipy.interpolate as interp
-import scipy
-
-try:
-    from natsort import natsorted
-except:
-    print(" - no natsorted - ")
-
-#import gwemlightcurves.table as gw_eos_table
-
-from . import MonotonicSpline as ms
-
-
-C_CGS=2.997925*10**10 # Argh, Monica!
-DENSITY_CGS_IN_MSQUARED=7.42591549e-25  # g/cm^3 m^2 //GRUnits. Multiply by this to convert from CGS -> 1/m^2 units (_geom)
-
-
-def make_compactness_from_lambda_approximate(lambda_vals):
-    """
-    make_compactness_from_lambda_approximate
-    Eq (B1) from https://arxiv.org/pdf/1812.04803.pdf, based on Maselli et al 2013, Yagi and Yunes 2017
-
-    Note this will yield *extreme* compactnesses for poorly-constrained GW observations, as the 'lambda' inferred will be wildly large/prior-dominated
-    """
-
-    return 0.371 -0.0391*np.log(lambda_vals) + 0.001056*np.log(lambda_vals)**2
-
-
-###
-### SERVICE 0: General EOS structure
-###
-
-class EOSConcrete:
-    """
-    Class characterizing a specific EOS solution.  This structure *SHOULD* 
-        - auto-build the mass-radius via a TOV solve
-         - provides ability to query the lambda(m) relationship and (in the future) higher-order multipole moments; etc
-    As many of these features are already provided by lalsimulation, 
-    """
-
-    def __init__(self,name=None):
-        self.name=name
-        self.eos = None
-        self.eos_fam = None
-        return None
-
-    def lambda_from_m(self, m):
-        eos_fam = self.eos_fam
-        if m<10**15:
-            m=m*lal.MSUN_SI
-
-        k2=lalsim.SimNeutronStarLoveNumberK2(m, eos_fam)
-        r=lalsim.SimNeutronStarRadius(m, eos_fam)
-
-        m=m*lal.G_SI/lal.C_SI**2
-        lam=2./(3*lal.G_SI)*k2*r**5
-        dimensionless_lam=lal.G_SI*lam*(1/m)**5
-
-        return dimensionless_lam
-
-    def estimate_baryon_mass_from_mg(self,m):
-        """
-        Estimate m_b = m_g + m_g^2/(R_{1.4}/km) based on https://arxiv.org/pdf/1905.03784.pdf Eq. (6)
-        """
-        r1p4 =lalsim.SimNeutronStarRadius(1.4*lal.MSUN_SI, self.eos_fam)/1e3
-        return m + (1./r1p4)*m**2 #(m/lal.MSUN_SI)
-
-    def pressure_density_on_grid_alternate(self,logrho_grid,enforce_causal=False):
-        """ 
-        pressure_density_on_grid.
-        Input and output grid units are in SI (rho: kg/m^3; p = N/m^2)
-        Pressure provided by lalsuite (=EOM integration)
-        Density computed by m*n = (epsilon+p)/c^2mn exp(-h), which does NOT rely on lalsuite implementation 
-        """
-        dat_out = np.zeros(len(logrho_grid))
-        fam = self.eos_fam
-        eos = self.eos
-        npts_internal = 10000
-        p_internal = np.zeros(npts_internal)
-        rho_internal = np.zeros(npts_internal)
-        epsilon_internal = np.zeros(npts_internal)
-        hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
-        if enforce_causal:
-            # strip out everything except the causal part.
-            hmax = lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos)
-        h = np.linspace(0.0001,hmax,npts_internal)
-        for indx in np.arange(npts_internal):
-            p_internal[indx] = lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10 to get CGS
-            epsilon_internal[indx] =lalsim.SimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(h[indx],eos)  # SI. Note factor of C^2 needed to get mass density
-            rho_internal[indx] =np.exp(-h[indx])* (epsilon_internal[indx]+p_internal[indx])/(lal.C_SI**2)  # 
-#        print epsilon_internal[10],rho_internal[10], p_internal[10], h[10]
-        logp_of_logrho = interp.interp1d(np.log10(rho_internal),np.log10(p_internal),kind='linear',bounds_error=False,fill_value=np.inf)  # should change to Monica's spline
- #       print logrho_grid,
-        return logp_of_logrho(logrho_grid)
-
-    def pressure_density_on_grid(self,logrho_grid,reference_pair=None,enforce_causal=False):
-        """ 
-        pressure_density_on_grid.
-        Input and output grid units are in SI (rho: kg/m^3; p = N/m^2)
-        POTENTIAL PROBLEMS OF USING LALSUITE
-            - lalinference_o2 / master: Unless patched, the *rest mass* density is not reliable.  
-              To test with the unpatched LI version, use reference_pair to specify a low-density EOS.
-              This matching is highly suboptimal, so preferably test either (a) a patched code or (b) the alternative code below
-        """
-        dat_out = np.zeros(len(logrho_grid))
-        fam = self.eos_fam
-        eos = self.eos
-        npts_internal = 10000
-        p_internal = np.zeros(npts_internal)
-        rho_internal = np.zeros(npts_internal)
-        hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
-        if enforce_causal:
-            # strip out everything except the causal part.
-            hmax = lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos)
-        h = np.linspace(0.0001,hmax,npts_internal)
-        for indx in np.arange(npts_internal):
-            rho_internal[indx] = lalsim.SimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10^(-3) to get CGS
-            p_internal[indx] = lalsim.SimNeutronStarEOSPressureOfPseudoEnthalpy(h[indx],eos)  # SI. Multiply by 10 to get CGS
-        if not (reference_pair is None):
-            indx_match = np.argmin( np.abs(np.log10(p_internal) - np.log10(reference_pair[1]))) # force agreement of densities at target pressure, if requested! Addresses bug /ambiguity in scaling of rest mass estimate; intend to apply in highly nonrelativistic regime
-            delta_rho = np.log10(reference_pair[0]) -np.log10(rho_internal[indx_match]) 
-            rho_internal *= np.power(10, delta_rho)
-#            print  np.log10(np.c_[rho_internal,p_internal])
-        logp_of_logrho = interp.interp1d(np.log10(rho_internal),np.log10(p_internal),kind='linear',bounds_error=False,fill_value=np.inf)  # should change to Monica's spline
- #       print logrho_grid,
-        return logp_of_logrho(logrho_grid)
-
-    def test_speed_of_sound_causal(self, test_only_under_mmax=True,fast_test=True):
-        """
-        Test if EOS satisfies speed of sound.
-        Relies on low-level lalsimulation interpolation routines to get v(h) and as such is not very reliable
-
-        By DEFAULT, we are testing the part of the EOS that is
-             - at the largest pressure (assuming monotonic sound speed)
-             - associated with the maximum mass NS that is stable
-        We can also test the full table that is provided to us.
-        https://git.ligo.org/lscsoft/lalsuite/blob/lalinference_o2/lalinference/src/LALInference.c#L2513
-        """
-        npts_internal = 1000
-        eos = self.eos
-        fam = self.eos_fam
-        # Largest NS provides largest attained central pressure
-        m_max_SI = self.mMaxMsun*lal.MSUN_SI
-        if not test_only_under_mmax:
-            hmax = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
-        else:
-            try:
-                pmax = lalsim.SimNeutronStarCentralPressure(m_max_SI,fam)  
-                hmax = lalsim.SimNeutronStarEOSPseudoEnthalpyOfPressure(pmax,eos)
-            except:
-                # gatch gsl interpolation errors for example
-                return False  
-        if fast_test: 
-            # https://git.ligo.org/lscsoft/lalsuite/blob/lalinference_o2/lalinference/src/LALInference.c#L2513
-            try:
-                vsmax = lalsim.SimNeutronStarEOSSpeedOfSoundGeometerized(hmax, eos)
-                return vsmax <1.1
-            except:
-                # catch gsl interpolation errors for example
-                return False
-        else:
-            if rosDebug:
-                print(" performing comprehensive test ")
-        h = np.linspace(0.0001,hmax,npts_internal)
-#        h = np.linspace(0.0001,lalsim.SimNeutronStarEOSMinAcausalPseudoEnthalpy(eos),npts_internal)
-        vs_internal = np.zeros(npts_internal)
-        for indx in np.arange(npts_internal):
-            vs_internal[indx] =  lalsim.SimNeutronStarEOSSpeedOfSoundGeometerized(h[indx],eos)
-            if rosDebug:
-                print(h[indx], vs_internal[indx])
-        return not np.any(vs_internal>1.1)   # allow buffer, so we have some threshold
-
-###
-### SERVICE 1: lalsimutils structure
-###
-#  See https://github.com/lscsoft/lalsuite/tree/master/lalsimulation/src for available types
-class EOSLALSimulation(EOSConcrete):
-    def __init__(self,name):
-        self.name=name
-        self.eos = None
-        self.eos_fam = None
-        self.mMaxMsun=None
-
-
-        eos = lalsim.SimNeutronStarEOSByName(name)
-        fam = lalsim.CreateSimNeutronStarFamily(eos)
-        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
-        self.eos = eos
-        self.eos_fam = fam
-        self.mMaxMsun = mmass
-        return None
-
-
-
-
-
-###
-### SERVICE 2: EOSFromFile
-###
-
-# Example directory: EOS_Tables
-#dirEOSTablesBase = os.environ["EOS_TABLES"]
-dirLALSimulationBase = os.environ["LALSIMULATION_DATADIR"]  # LAL table data
-## Add routines to find, parse standard directory of EOS files and load suitable metadata into memory
-## Follow framework of NRWaveformCatalogManager3
-
-
-class EOSFromDataFile(EOSConcrete):
-    """ 
-    FromDataFileEquationOfState
-    (just accepts filename...not attempting to parse a catalog)
-    
-    """
-    def __init__(self,name=None,fname=None):
-        self.name=name
-        self.fname=fname
-        self.eos = None
-        self.eos_fam = None
-        self.mMax = None
-
-        self.eos, self.eos_fam = self.eos_ls()
-        return None
-
-    def eos_ls(self):
-        # From Monica, but using code from GWEMLightcurves
-        #  https://gwemlightcurves.github.io/_modules/gwemlightcurves/KNModels/table.html
-        """
-        EOS tables described by Ozel `here <https://arxiv.org/pdf/1603.02698.pdf>`_ and downloadable `here <http://xtreme.as.arizona.edu/NeutronStars/data/eos_tables.tar>`_. LALSim utilizes this tables, but needs some interfacing (i.e. conversion to SI units, and conversion from non monotonic to monotonic pressure density tables)
-    """
-        obs_max_mass = 2.01 - 0.04  # used
-        print("Checking %s" % self.name)
-        eos_fname = ""
-        if os.path.exists(self.fname):
-            # NOTE: Adapted from code by Monica Rizzo
-            print("Loading from %s" % self.fname)
-            bdens, press, edens = np.loadtxt(self.fname, unpack=True)
-            press *= DENSITY_CGS_IN_MSQUARED
-            edens *= DENSITY_CGS_IN_MSQUARED
-            eos_name = self.name
-
-            if not np.all(np.diff(press) > 0):
-                keep_idx = np.where(np.diff(press) > 0)[0] + 1
-                keep_idx = np.concatenate(([0], keep_idx))
-                press = press[keep_idx]
-                edens = edens[keep_idx]
-            assert np.all(np.diff(press) > 0)
-            if not np.all(np.diff(edens) > 0):
-                keep_idx = np.where(np.diff(edens) > 0)[0] + 1
-                keep_idx = np.concatenate(([0], keep_idx))
-                press = press[keep_idx]
-                edens = edens[keep_idx]
-            assert np.all(np.diff(edens) > 0)
-
-            # Creating temporary file in suitable units
-            print("Dumping to %s" % self.fname)
-            eos_fname = "./" +eos_name + "_geom.dat" # assume write acces
-            np.savetxt(eos_fname, np.transpose((press, edens)), delimiter='\t')
-            eos = lalsim.SimNeutronStarEOSFromFile(eos_fname)
-            fam = lalsim.CreateSimNeutronStarFamily(eos)
-
-        else:
-            print(" No such file ", self.fname)
-            sys.exit(0)
-
-        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
-        self.mMaxMsun = mmass
-        return eos, fam
-
-    def p_rho_arrays(self):
-        print(self.fname)
-        dat_file = np.array(np.loadtxt(self.fname))
-        nb=dat_file[:,0]
-        p=dat_file[:,1]
-        rho=dat_file[:,2] 
-        return nb,p,rho
-    def interp_eos_p_of_rho(self):
-        nb,p,rho=self.p_rho_arrays()
-        n=len(p)
-        p=np.log10(p)
-        rho=np.log10(rho)
-        consts=ms.interpolate(rho,p)
-        line_const=ms.lin_extrapolate(rho,p)
-        #linearly interpolate anything outside range
-        line_lower=line_const[0,:]
-        line_upper=line_const[1,:]
-        return consts,line_upper,line_lower
-
-   #interpolates Log10 of data
-    def interp_eos_rho_of_p(self):
-        nb,p,rho=self.p_rho_arrays()
-        n=len(p)
-        p=np.log10(p)
-        rho=np.log10(rho)
-        consts=ms.interpolate(p,rho)  
-        line_const=ms.lin_extrapolate(p,rho)
-       #linearly interpolate anything outside range
-        line_lower=line_const[0,:]
-        line_upper=line_const[1,:]
-        return consts,line_upper,line_lower
-    def interp_eos_nb_of_p(model_name):
-        nb,p,rho=self.p_rho_arrays()
-        n=len(p)
-        p=np.log10(p)
-        nb=np.log10(nb)
-        consts=ms.interpolate(p,nb)
-        line_const=ms.lin_extrapolate(p,nb)
-        #linearly interpolate anything outside range
-        line_lower=line_const[0,:]
-        line_upper=line_const[1,:]
-        return consts,line_upper,line_lower
-
-
-
-
-
-###
-### SERVICE 2: Parameterized EOS (specify functions)
-###
-
-# COMMON POLYTROPE TABLE
-# eos logP1 gamma1 gamma2 gamma3
-# PAL6 34.380 2.227 2.189 2.159 
-# SLy 34.384 3.005 2.988 2.851 
-# AP1 33.943 2.442 3.256 2.908 
-# AP2 34.126 2.643 3.014 2.945
-# AP3 34.392 3.166 3.573 3.281  
-# AP4 34.269 2.830 3.445 3.348 
-# FPS 34.283 2.985 2.863 2.600 
-# WFF1 34.031 2.519 3.791 3.660 
-# WFF2 34.233 2.888 3.475 3.517  
-# WFF3 34.283 3.329 2.952 2.589  
-# BBB2 34.331 3.418 2.835 2.832 
-# BPAL12 34.358 2.209 2.201 2.176 
-# ENG 34.437 3.514 3.130 3.168 
-# MPA1 34.495 3.446 3.572 2.887 
-# MS1 34.858 3.224 3.033 1.325 
-# MS2 34.605 2.447 2.184 1.855 
-# MS1b 34.855 3.456 3.011 1.425 
-# PS 34.671 2.216 1.640 2.365 
-# GS1 34.504 2.350 1.267 2.421 
-# GS2 34.642 2.519 1.571 2.314 
-# BGN1H1 34.623 3.258 1.472 2.464 
-# GNH3 34.648 2.664 2.194 2.304 
-# H1 34.564 2.595 1.845 1.897
-# H2 34.617 2.775 1.855 1.858
-# H3 34.646 2.787 1.951 1.901
-# H4 34.669 2.909 2.246 2.144
-# H5 34.609 2.793 1.974 1.915
-# H6 34.593 2.637 2.121 2.064
-# H7 34.559 2.621 2.048 2.006
-# PCL2 34.507 2.554 1.880 1.977 
-# ALF1 34.055 2.013 3.389 2.033 
-# ALF2 34.616 4.070 2.411 1.890 
-# ALF3 34.283 2.883 2.653 1.952 
-# ALF4 34.314 3.009 3.438 1.803
-
-# Rizzo code: EOS_param.py
-class EOSPiecewisePolytrope(EOSConcrete):
-    def __init__(self,name,param_dict=None):
-        self.name=name
-        self.eos = None
-        self.eos_fam = None
-        self.mMaxMsun=None
-
-
-        eos=self.eos=lalsim.SimNeutronStarEOS4ParameterPiecewisePolytrope(param_dict['logP1'], param_dict['gamma1'], param_dict['gamma2'], param_dict['gamma3'])
-        eos_fam=self.eos_fam=lalsim.CreateSimNeutronStarFamily(eos)
-        self.mMaxMsun = lalsim.SimNeutronStarMaximumMass(eos_fam) / lal.MSUN_SI
-
-        return None
-
-
-class EOSLindblomSpectral(EOSConcrete):
-    def __init__(self,name=None,spec_params=None,verbose=False,use_lal_spec_eos=False):
-        if name is None:
-            self.name = 'spectral'
-        else:
-            self.name=name
-        self.eos = None
-        self.eos_fam = None
-
-        self.spec_params = spec_params
-#        print spec_params
-
-        if use_lal_spec_eos:
-#            self.eos=lalsim.SimNeutronStarEOS4ParameterSpectralDecomposition(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'])   # Should have this function! but only on master
-            self.eos=lalsim.SimNeutronStarEOSSpectralDecomposition_for_plot(spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4'],4)
-        else:
-            # Create data file
-            self.make_spec_param_eos(500,save_dat=True,ligo_units=True,verbose=verbose)
-            # Use data file
-            #print " Trying to load ",name+"_geom.dat"
-            import os; #print os.listdir('.')
-            cwd = os.getcwd()
-            self.eos=eos = lalsim.SimNeutronStarEOSFromFile(cwd+"/"+name+"_geom.dat")
-        self.eos_fam = fam=lalsim.CreateSimNeutronStarFamily(self.eos)
-        mmass = lalsim.SimNeutronStarMaximumMass(fam) / lal.MSUN_SI
-        self.mMaxMsun = mmass
-
-        return None
-
-    def test_bounded_adiabatic_index(self,bounds=[0.6,4.5]):
-        """
-        Gamma(p) \in bounds
-        Uses xmax and other parameters from spectral result
-        """
-        spec_params =self.spec_params
-        if not 'gamma3' in spec_params:
-            spec_params['gamma3']=spec_params['gamma4']=0
-        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
-        xmax = self.spec_params['xmax']
-        xvals = np.linspace(0,xmax,500)
-        gamma_vals = gamma_of_x(xvals, coefficients)
-        if rosDebug:
-            print("  Spectral EOS debug test limits: Gamma bounds", np.min(gamma_vals), np.max(gamma_vals))
-        return  not( np.any(gamma_vals < bounds[0]) or np.any(gamma_vals>bounds[1]) )
-            
-
-    def make_spec_param_eos(self, npts=500, plot=False, verbose=False, save_dat=False,ligo_units=False,interpolate=False,eosname_lalsuite="SLY4"):
-        """
-        Load values from table of spectral parameterization values
-        Table values taken from https://arxiv.org/pdf/1009.0738.pdf
-        Comments:
-            - eos_vals is recorded as *pressure,density* pairs, because the spectral representation is for energy density vs pressure
-            - units swap between geometric and CGS
-            - eosname_lalsuite is used for the low-density EOS
-        """
-
-        spec_params = self.spec_params
-        if not 'gamma3' in spec_params:
-            spec_params['gamma3']=spec_params['gamma4']=0
-        coefficients=np.array([spec_params['gamma1'], spec_params['gamma2'], spec_params['gamma3'], spec_params['gamma4']])
-        p0=spec_params['p0']
-        eps0=spec_params['epsilon0']
-        xmax=spec_params['xmax'] 
-
-        x_range=np.linspace(0,xmax,npts)
-        p_range=p0*np.exp(x_range)
-       
-        eos_vals=np.zeros((npts,2))
-        eos_vals[:,1]=p_range
-
-        eos_vals[:,0] = epsilon(x_range,p0,eps0, coefficients)
-        # for i in range(0, len(x_range)):
-        #    eos_vals[i,0]=epsilon(x_range[i], p0, eps0, coefficients)
-        #    if verbose==True:
-        #        print "x:",x_range[i],"p:",p_range[i],"p0",p0,"epsilon:",eos_vals[i,0]
-  
-    #doing as those before me have done and using SLY4 as low density region
-        # THIS MUST BE FIXED TO USE STANDARD LALSUITE ACCESS, do not assume the file exists
-#        low_density=np.loadtxt(dirEOSTablesBase+"/LALSimNeutronStarEOS_SLY4.dat")
-        low_density = np.loadtxt(dirLALSimulationBase+"/LALSimNeutronStarEOS_"+ eosname_lalsuite+".dat")
-        low_density[:,0]=low_density[:,0]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
-        low_density[:,1]=low_density[:,1]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
-        low_density[:,[0, 1]] = low_density[:,[1, 0]]  # reverse order
-
-        cutoff=eos_vals[0,:]   
-        if verbose:
-            print(" cutoff ", cutoff)
- 
-        break_pt=0
-        for i in range(0, len(low_density)):
-            if low_density[i,0] > cutoff[0] or low_density[i,1] > cutoff[1]:   
-                break_pt=i
-                break 
-    
-        eos_vals=np.vstack((low_density[0:break_pt,:], eos_vals)) 
-
-        if not interpolate:
-#            print eos_vals
-            if ligo_units:
-                eos_vals *= DENSITY_CGS_IN_MSQUARED/(C_CGS**2)  # converts to geometric units: first convert from cgs energy density to g/cm^2, then to 1/m^2.
- #               print " Rescaled "
-#                print eos_vals
-            
-            if save_dat == True:
-                np.savetxt(self.name+"_geom.dat", eos_vals[:,[1,0]])  #NOTE ORDER
-
-            return eos_vals
-        
-        # Optional: interpolate in the log, to generate a denser EOS model
-        # Will produce better M(R) models for LAL
-        p_of_epsilon = ms.interpolate(np.log10(eos_vals[1:,0]), np.log10(eos_vals[1:,1]))
-  
-        new_eos_vals = np.zeros((resample_pts, 2))
-        epsilon_range = np.linspace(min(np.log10(eos_vals[1:,0])), max(np.log10(eos_vals[1:,0])), resample_pts)
-        new_eos_vals[:, 0] = 10**epsilon_range 
- 
-        for i in range(0, resample_pts):
-            if verbose == True:
-                print("epsilon", 10**epsilon_range[i])
-
-            new_eos_vals[i,1] = 10**ms.interp_func(epsilon_range[i], np.log10(eos_vals[1:,0]), np.log10(eos_vals[1:,1]), p_of_epsilon)
-
-            if verbose == True:
-                print("p", new_eos_vals[i,1])
-    
-        new_eos_vals = check_monotonicity(new_eos_vals)
-        new_eos_vals = np.vstack((np.array([0.,0.]), new_eos_vals))
-        return new_eos_vals
-
-
-
-def gamma_of_x(x, coeffs):
-        """
-        Eq 6 from https://arxiv.org/pdf/1009.0738.pdf
-        """
-        gamma=0
-        # Equivalent to np.polyval(coeffs[::-1],x)
-        gamma=np.polyval(coeffs[::-1],x)
-        # for i in range(0,len(coeffs)):
-        #     gamma+=coeffs[i]*x**i 
-        gamma=np.exp(gamma)  
-        return gamma
-  
-def mu(x, coeffs):
-        """
-        Eq 8 from https://arxiv.org/pdf/1009.0738.pdf
-        """
-
-
-        # very inefficient: does integration multiple times. Should change to ODE solve
-        if isinstance(x, (list, np.ndarray)):
-            def int_func(dummy,x_prime):
-              return (gamma_of_x(x_prime, coeffs))**(-1)    
-            y = scipy.integrate.odeint(int_func,[0],x,full_output=False).T  # x=0 needs to be value in array
-            return np.exp(-1.*y)
-#            val=np.zeros(len(x))
-#            for i in range(0,len(x)):
-#                tmp=quad(int_func, 0, x[i])
-#                val[i]=tmp[0]  
-#            return np.exp(-1.*val)
-        else:    
-            def int_func(x_prime):
-              return (gamma_of_x(x_prime, coeffs))**(-1)    
-            val=quad(int_func, 0, x)
-
-        return np.exp(-1.*val[0])
-
-def epsilon(x, p0, eps0, coeffs,use_ode=True):
-        """
-        Eq. 7 from https://arxiv.org/pdf/1009.0738.pdf
-        """
-        mu_of_x=mu(x, coeffs)  
-        if use_ode and isinstance(x, (list,np.ndarray)):
-          mu_intp = scipy.interpolate.interp1d(x,mu_of_x,bounds_error=False,fill_value=0)
-          def int_func(dummy,x_prime):
-            num = mu_intp(x_prime)*np.exp(x_prime)
-            denom = gamma_of_x(x_prime, coeffs)
-            return num / denom
-          y= scipy.integrate.odeint(int_func,0,x,full_output=False).T  # x=0 needs to be value in array
-          eps=(eps0*C_CGS**2)/mu_of_x + p0/mu_of_x * y
-          return eps
-        else:
-          def int_func(x_prime):
-            num = mu(x_prime, coeffs)*np.exp(x_prime)
-            denom = gamma_of_x(x_prime, coeffs)
-            return num / denom
-          
-        # very inefficient: does integration multiple times. Should change to ODE solve
-        # Would require lookup interpolation of mu_of_x
-        val=quad(int_func, 0, x)
-        #val=romberg(int_func, 0, x, show=True)   
-        eps=(eps0*C_CGS**2)/mu_of_x + p0/mu_of_x * val[0]
- 
-        return eps
-
-
-
-
-###
-### Utilities
-###
-
-# Les-like
-def make_mr_lambda_lal(eos,n_bins=100):
-    """
-    Construct mass-radius curve from EOS
-    Based on modern code resources (https://git.ligo.org/publications/gw170817/bns-eos/blob/master/scripts/eos-params.py) which access low-level structures
-    """
-    fam=lalsim.CreateSimNeutronStarFamily(eos)
-    max_m = lalsim.SimNeutronStarMaximumMass(fam)/lal.MSUN_SI
-    min_m = lalsim.SimNeutronStarFamMinimumMass(fam)/lal.MSUN_SI
-    mgrid = np.linspace(min_m,max_m, n_bins)
-    mrL_dat = np.zeros((n_bins,3))
-    mrL_dat[:,0] = mgrid
-    for indx in np.arange(n_bins):
-       mass_now = mgrid[indx]
-       r = lalsim.SimNeutronStarRadius(mass_now*lal.MSUN_SI,fam)/1000.
-       mrL_dat[indx,1] = r
-       k = lalsim.SimNeutronStarLoveNumberK2(mass_now*lal.MSUN_SI,fam)
-       c = mass_now * lal.MRSUN_SI / (r*1000.)
-       mrL_dat[indx,2] = (2. / 3.) * k / c**5.
-
-    return mrL_dat
-
-# Rizzo
-def make_mr_lambda(eos,use_lal=False):
-   """
-   construct mass-radius curve from EOS    
-   DOES NOT YET WORK RELIABLY
-   """
-   if use_lal:
-       make_mr_lambda_lal(eos)
-
-   fam=lalsim.CreateSimNeutronStarFamily(eos)
- 
-   r_cut = 40   # Some EOS we consider for PE purposes will have very large radius!
-
-   #set p_nuc max
-   #   - start at a fiducial nuclear density
-   #   - not sure what these termination conditions are designed to do ... generally this pushes to  20 km
-   #   - generally this quantity is the least reliable
-   p_nuc=3.*10**33   # consistent with examples
-   fac_min=0
-   r_fin=0
-   while r_fin > r_cut+8 or r_fin < r_cut:
-       # Generally tries to converge to density corresponding to 20km radius
-      try: 
-         answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_min)*p_nuc, eos)      # r(SI), m(SI), lambda
-      except:
-          # If failure, backoff
-         fac_min=-0.05
-         break 
-      r_fin=answer[0]
-      r_fin=r_fin*10**-3  # convert to SI
-#      print "R: ",r_fin
-      if r_fin<r_cut:
-         fac_min-=0.05
-      elif r_fin>r_cut+8:
-         fac_min+=0.01
-   answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_min)*p_nuc, eos)      # r(SI), m(SI), lambda
-   m_min = answer[1]/lal.MSUN_SI
-
-   #set p_nuc min
-   #   - tries to converge to central pressure corresponding to maximum NS mass
-   #   - very frustrating...this data is embedded in the C code
-   fac_max=1.6
-   r_fin=20.
-   m_ref = lalsim.SimNeutronStarMaximumMass(fam)/lal.MSUN_SI
-   r_ref = lalsim.SimNeutronStarRadius(lalsim.SimNeutronStarMaximumMass(fam), fam)/(10**3)
-   answer=None
-   while r_fin > r_ref  or r_fin < 7:
-       #print "Trying min:"
-#       print "p_c: ",(10**fac_max)*p_nuc
-       try:
-          answer=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)         
-          if answer[0]*10**-3 < r_ref:
-             break 
-       except:
-          fac_max-=0.05
-          working=False
-          while working==False:
-             try:
-                answer_tmp=lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)
-                working=True
-             except:
-                fac_max-=0.05
-          break
-          #print lalsim.SimNeutronStarTOVODEIntegrate((10**fac_max)*p_nuc, eos)
-       r_fin=answer[0]/10**3 # convert to km
-       if rosDebug:
-           print("R: ",r_fin, r_ref, " M: ", answer[1]/lal.MSUN_SI, m_ref , m_min) # should converge to maximum mass
-       if r_fin>8:
-          fac_max+=0.05
-       if r_fin<6:
-          fac_max-=0.01
-#       print 10**fac_max
-
-   #generate mass-radius curve
-   npts_out = 1000
-   scale=np.logspace(fac_min,fac_max,npts_out)
-   
-   mr_array=np.zeros((npts_out,3))
-   for s,i in zip(scale,range(0,len(scale))):
-#       print s
-       mr_array[i,:]=lalsim.SimNeutronStarTOVODEIntegrate(s*p_nuc, eos)
-      
-   mr_array[:,0]=mr_array[:,0]/10**3 
-   mr_array[:,1]=mr_array[:,1]/lal.MSUN_SI
-   mr_array[:,2]=2./(3*lal.G_SI)*mr_array[:,2]*(mr_array[:,0]*10**3)**5
-   mr_array[:,2]=lal.G_SI*mr_array[:,2]*(1/(mr_array[:,1]*lal.MSUN_SI*lal.G_SI/lal.C_SI**2))**5
-
-#   print mr_array[:,1]
-
-   return mr_array
-
-
-
-def LookupCrustEpsilonAtPressure(p_ref,eosname_lalsuite="SLY4"):
-    """
-    Tool for spectral EOS manager to find epsilon(p) via lookup tables from the lalsuite data files.
-    Units are *CGS*
-    Uses linear interpolation in the log. 
-
-    Warning: lalsuite files use lal units (epsilon, p in 1/m^2), but we will presume p and epsilon are in energy density
-
-    """
-    lal_dat =np.loadtxt(dirLALSimulationBase+"/LALSimNeutronStarEOS_"+ eosname_lalsuite+".dat")
-    lal_dat[:,0]=lal_dat[:,0]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
-    lal_dat[:,1]=lal_dat[:,1]*C_CGS**2/(DENSITY_CGS_IN_MSQUARED)   # converts to energy density in CGS
-#    lal_dat[:,[0, 1]] = lal_dat[:,[1, 0]]  # reverse order
-    
-    # Interpolate in log
-    lal_dat_log = np.log10(lal_dat)   # note first sample is zero,and causes problems nominally with this interpolation
-    eps_out = np.power(10.,np.interp(np.log10(p_ref),  lal_dat_log[:,0], lal_dat_log[:,1]))
-    return eps_out
-
-
-
-###
-###  EOSSequence : For large sets of EOS we must access simultaneously (100 Mb plus), pretabulated
-# 
-#   These will be a different data structure, where we don't necessariliy provide all the EOSConcrete structures, 
-#   Example: https://zenodo.org/record/6502467#.YulOeaRE1Pw 
-###
-
-
-
-###
-### SERVICE 0: General EOS structure
-###
-
-class EOSSequenceLandry:
-    """
-    Class characterizing a sequence of specific EOS solutions, using the Landry format.
-    Assumes user provides (a) EOS realization, (b) precomputed results from TOV solve; and (c) discrete ID
-
-    PENDING
-       - mMax access
-    """
-
-    def __init__(self,name=None,fname=None,load_eos=False,load_ns=False,oned_order_name=None,oned_order_mass=None,no_sort=True,verbose=False):
-        import h5py
-        self.name=name
-        self.fname=fname
-        self.eos_ids = None
-        self.eos_names = None   # note this array can be SORTED, use the oned_order_indx_original for original order
-        self.eos_tables = None
-        self.eos_ns_tov = None
-        self.oned_order_name = None
-        self.oned_order_mass=oned_order_mass
-        self.oned_order_values=None
-        self.oned_order_indx_original = None
-        self.verbose=verbose
-        with h5py.File(self.fname, 'r') as f:
-            names = list(f['ns'].keys())
-            names = natsorted(names)  # sort them sanely
-            self.eos_ids = list(f['id'])
-            self.eos_names = np.array(names,dtype=str)
-            # The following loads a LOT into memory, as a dictionary
-            if load_ns:
-                if verbose:
-                    print(" EOSSequenceLandry: Loading TOV results for {}".format(fname))
-                # Convert to dictionary, so not closed.  Note this sucks up a lot of i/o time, and ideally we don't close the file
-                self.eos_ns_tov = {}
-                for name in names:
-                    self.eos_ns_tov[name] = np.array(f['ns'][name])
-                if verbose:
-                    print(" EOSSequenceLandry: Completed TOV i/o {}".format(fname))
-                create_order = False
-                if oned_order_name == 'R' or oned_order_name=='r':
-                    create_order=True
-                    self.oned_order_name='R'  # key value in fields
-                if oned_order_name == 'Lambda' or oned_order_name=='lambdda':
-                    create_order=True
-                    self.oned_order_name='Lambda'  # key value in fields
-                if not(self.oned_order_mass):
-                    # Can't order if we don't have a reference mass
-                    create_order=False
-                if create_order:
-                    self.oned_order_indx_original = np.arange(len(self.eos_names))
-                    vals = np.zeros(len(self.eos_names))
-                    if self.oned_order_name =='Lambda':
-                        for indx in np.arange(len(self.eos_names)):
-                            vals[indx] =self.lambda_of_m_indx(self.oned_order_mass,indx)
-                    if self.oned_order_name =='R':
-                        for indx in np.arange(len(self.eos_names)):
-                            vals[indx] =self.R_of_m_indx(self.oned_order_mass,indx)
-
-                    # resort 'names' field with new ordering
-                    # is it actually important to do the sorting?  NO, code should work with original lexographic order, since we only use nearest neighbors!
-                    if no_sort:
-                        self.oned_order_values = vals
-                    else:
-                        indx_sorted = np.argsort(vals)
-                        if verbose: 
-                            print(indx_sorted)
-                        self.eos_names = self.eos_names[indx_sorted]  
-                        self.oned_order_values = vals[indx_sorted]
-                        self.oned_order_indx_original =  self.oned_order_indx_original[indx_sorted]
-
-            if load_eos:
-                self.eos_tables = f['eos']
-        return None
-
-    def m_max_of_indx(self,indx):
-        name = self.eos_names[indx]
-        return np.max(self.eos_ns_tov[name]['M'])
-
-    def lambda_of_m_indx(self,m_Msun,indx):
-        """
-        lambda(m) evaluated for a *single* m_Msun value (almost always), for a specific indexed EOS
-        
-        Generally we assume the value is UNIQUE and associated with a single stable phase
-        """
-        if self.eos_ns_tov is None:
-            raise Exception(" Did not load TOV results ")
-        name = self.eos_names[indx]
-        if self.verbose:
-            print(" Loading from {}".format(name))
-        dat = np.array(self.eos_ns_tov[name])
-        # Sort masses
-        indx_sort = np.argsort(dat["M"])
-        # Interpolate versus m, ASSUME single-valued / no phase transition ! 
-        # Interpolate versus *log lambda*, so it is smoother and more stable
-        valLambda = np.log(dat["Lambda"][indx_sort])
-        valM = dat["M"][indx_sort]
-        return np.exp(np.interp(m_Msun, valM, valLambda))
-
-    def R_of_m_indx(self,m_Msun,indx):
-        """
-        R(m) evaluated for a *single* m_Msun value (almost always), for a specific indexed EOS
-        
-        Generally we assume the value is UNIQUE and associated with a single stable phase; should FIX?
-        """
-        if self.eos_ns_tov is None:
-            raise Exception(" Did not load TOV results ")
-        name = self.eos_names[indx]
-        if self.verbose:
-            print(" Loading from {}".format(name))
-        dat = np.array(self.eos_ns_tov[name])
-        # Sort masses
-        indx_sort = np.argsort(dat["M"])
-        # Interpolate versus m, ASSUME single-valued / no phase transition ! 
-        # Interpolate versus *log lambda*, so it is smoother and more stable
-        valR = np.log(dat["R"][indx_sort])
-        valM = dat["M"][indx_sort]
-        return np.exp(np.interp(m_Msun, valM, valR))
-
-    def mmax_of_indx(self,indx):
-        if self.eos_ns_tov is None:
-            raise Exception(" Did not load TOV results ")
-        name = self.eos_names[indx]
-        if self.verbose:
-            print(" Loading from {}".format(name))
-        
-        return np.max(self.eos_ns_tov[name]['M'])
-
-    def lookup_closest(self,order_val):
-        """
-        Given a proposed ordering statistic value, provides the *index* of the closest value.  Assumes *scalar* input
-        Should be using the fact that this is ordered ... but we are not
-        """
-        if self.eos_ns_tov is None:
-            raise Exception(" Did not load TOV results ")
-        if self.oned_order_values is None:
-            raise Exception(" Did not generate ordering statistic ")
-        
-        return np.argmin( np.abs(order_val - self.oned_order_values))
diff --git a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py b/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py
deleted file mode 100644
index d9864a3c9..000000000
--- a/MonteCarloMarginalizeCode/Code/RIFT/physics/EOSPlotUtilities.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# GOAL
-#    Library to facilitate making various plots of equation-of-state-related quantities.
-
-
-# from matplotlib import pyplot as plt
-# import EOSManager
-# import EOSPlotUtilities
-# my_eos = EOSManager.EOSLALSimulation('SLy')
-# EOSPlotUtilities.render_eos(my_eos.eos,'rest_mass_density', 'pressure')
-
-import numpy as np
-import EOSManager
-import lalsimulation as lalsim
-import lal
-import matplotlib
-import matplotlib.pyplot as plt
-
-
-matplotlib.rcParams.update({'font.size': 12.0,  'mathtext.fontset': 'stix'})
-matplotlib.rcParams['figure.figsize'] = (9.0, 7.0)
-matplotlib.rcParams['xtick.labelsize'] = 15.0
-matplotlib.rcParams['ytick.labelsize'] = 15.0
-matplotlib.rcParams['axes.labelsize'] = 25.0
-matplotlib.rcParams['lines.linewidth'] = 2.0
-plt.style.use('seaborn-v0_8-whitegrid')
-
-
-def render_eos(eos, xvar='energy_density', yvar='pressure',units='cgs',npts=100,label=None):
-    
-    min_pseudo_enthalpy = 0.005
-    max_pseudo_enthalpy = lalsim.SimNeutronStarEOSMaxPseudoEnthalpy(eos)
-    hvals = max_pseudo_enthalpy* 10**np.linspace( np.log10(min_pseudo_enthalpy/max_pseudo_enthalpy),  0,num=npts)
-    
-    print(hvals,min_pseudo_enthalpy, max_pseudo_enthalpy)
-    
-    qry = EOSManager.QueryLS_EOS(eos)
-    
-    xvals = qry.extract_param(xvar,hvals)
-    yvals = qry.extract_param(yvar,hvals)
-    print(np.c_[xvals,yvals])
-    #xvals = qry.convert(xvals, 'rest_mass_density') # using QueryLS_EOS.convert
-    
-    plt.loglog(xvals, yvals)
-    plt.xlabel(xvar)
-    plt.ylabel(yvar)
-    
-    return None
-
-
-
-
-- 
GitLab