Package: ringdb
ringdbA gravitational event database that queries and locally saves event strain samples,  detector PSDs and posterior samples.Quick StartfromringdbimportDatabase# Initialise the database in an empty folder you want your data storeddb=Database("./Data")db.initialize()# Pick an event of your choosingevent=db.event("GW190521")# Query it for psds, posteriors and strain data for each detectorpsd=event.psd()posteriors=event.posteriors()strains=event.strain()InstallationFrom pipThis package can be downloaded directly from pip.pipinstallringdb(Will error out for most nonx86-64setups, use Rosetta if on M1)Virtual EnvironmentsFor the latest version, you can usemaketo run and install the required things in a virtual environment. ReplaceVENV_PATHwith any path you're comfortable with making a folder in.  First import once the venv is setup may be slow, but it will be fine after that.gitclonehttps://github.com/Potatoasad/ringdbcdringdb
makeinstallVENV_PATH=/path/to/venv
./path/to/venv/bin/activateUsage:InitializeSet a folder in your computer somewhere where data will be saved (if the folder isn't there it will be created). Initialize aDatabaseobject.fromringdbimportDatabase# Sets up the database inside a folder called Datadb=Database("./Data")db.initialize()Get an object corresponding to a particular event, and query it for psds, posteriors or strainfirst_event=db.event("GW150914")QueryNow you can query a bunch of things from theEventobject. The most important are:event.posteriors()-> pandas Dataframe with all the posterior samplesevent.psd()-> dictionary ofringdown.PowerSpectrumobjects (from theringdown package) for each detectorevent.strain()-> dictionary ofringdown.Dataobjects (from theringdown package) for each detectorGet a PSDfirst_psd=first_event.psd()# Returns a dictionary labelled by detectorstype(first_psd['H1'])# Ringdown.PowerSpectrum objectGet posteriorsfirst_posteriors=first_event.posteriors()# Returns a pandas dataframetype(first_posteriors)# pandas DataFrame with all the posteriorsGet the strain filesfirst_strain=first_event.strain()# Returns a dictionary labelled by detectorstype(first_strain['L1'])# Ringdown.Data objectCustom QueriesThis doesn't work for GWTC-1 events, but will work for the restIf you have a particular object you would like to pull from an hdf5 file that is not covered by the above, you can query it directly.As an example, if I wanted to pullprior samples for the total mass. I know for example in GW200316_215756 they will be found in the directory:/C01:IMRPhenomXPHM/priors/samples/total_massand it needs to read as anarray.In general the path seems to follow/{approximant}/priors/samples/total_mass. I can then call that for this event:event=db.event("GW200316_215756")total_mass_priors=event.read_posterior_file("/{approximant}/priors/samples/total_mass",datatype='array')The database knows how to interpolate things like{approximant},{detector}and{event}, which correspond to the waveform name, the detectors and the event name.If you happen to use a particular query a lot you can save it in the database schema, making subsequent accesses easier:db.update_posterior_schema({'prior_total_mass':{'path':"/{approximant}/priors/samples/total_mass",'type':'array'}})total_mass_priors=event.read_posterior_file_from_schema('prior_total_mass')