Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on Tuesday 22nd September 2020 starting at approximately 9am MST.It is expected to take around 15 minutes and there will be a short period of downtime towards the end of the maintenance window. Please address any comments, questions, or concerns to computing-help@igwn.org.

...
 
Commits (3)
# lvcnrpy
`lvcnrpy` is a simple Python interface to the LVC-NR Waveform Repository.
`lvcnrpy` is a simple Python interface to the
[`lvcnr-lfs`](https://git.ligo.org/waveforms/lvcnr-lfs) numerical relativity
repository.
## Installation
1. **Install the package locally**
The package can be installed directly from
[git.ligo.org](https://git.ligo.org/) using the following snippet. Use your
LIGO username `albert.einstein` and password when asked for
authorisation
[`git.ligo.org`](https://git.ligo.org/) using the following snippet
```bash
$ pip install git+https://git.ligo.org/edward.fauchon-jones/lvcnrpy.git@v3.0.0#egg=lvcnrpy
$ pip install git+https://git.ligo.org/waveforms/lvcnrpy.git
```
2. **Define LVC-NR Waveform Repository environment variable**
2. **Define [`lvcnr-lfs`](https://git.ligo.org/waveforms/lvcnr-lfs) repository environment variable**
Define the environment variable `LVCNR_DATADIR` as the path to your local
clone of the LVC-NR Waveform Repository. If you are using a virtual
environment this can be defined in your activation script. For a bash shell
this could be done with
To use [`lvcnrjson`](#generating-a-json-dump-of-all-lvcnr-lfs-attributes)
you must define the environment variable `LVCNR_DATADIR` as the path to
a local clone of the
[`lvcnr-lfs`](https://git.ligo.org/waveforms/lvcnr-lfs) repository. If you
are using a virtual environment this can be defined in your activation
script. For a bash shell this could be done with
```bash
export LVCNR_DATADIR=<path-to-lvc-nr-repo>
```
If you do not want to use `lvcnrjson` then you can set the environment
variable to an empty sting. For a bash shell this could be done with
```bash
export LVCNR_DATADIR=""
```
## Usage
### Checking HDF5 NR files against format specifications
A working draft of the possible formats HDF5 NR files may be committed in to the
LVC-NR Waveform Repository is avilable at
A working draft of the possible formats HDF5 NR files may be committed in to
the [`lvcnr-lfs`](https://git.ligo.org/waveforms/lvcnr-lfs) repository is
avilable at
[Numerical Relativity Waveforms](https://www.lsc-group.phys.uwm.edu/ligovirgo/cbcnote/Waveforms/NR#BBH_Waveform_Catalog:_Metadata).
To check a HDF5 NR file against one of the format levels use the included
program `lvcnrcheck`. It is installed as a global program when this package is
......@@ -72,9 +82,27 @@ installed.
To add a coloured output use the `-c` flag
To check against a specific format level use the `-f` option
```bash
$ cd <path-to-lvc-nr-repo>
$ lvcnrcheck -c ./Cardiff-UIB/GW150914-followup/q1.2_base_96.h5
```
### Generating a JSON dump of all [`lvcnr-lfs`](https://git.ligo.org/waveforms/lvcnr-lfs) attributes
To generate a JSON file containing all format level 1 attributes for all
simulations in the [`lvcnr-lfs`](https://git.ligo.org/waveforms/lvcnr-lfs)
repository you can use `lvcnrjson`. This requires that the environment
variable `LVCNR_DATADIR` has been set to the location of a local clone of
[`lvcnr-lfs`](https://git.ligo.org/waveforms/lvcnr-lfs) repository.
- **`lvcnrjson` usage**
```bash
lvcnrjson [-h]
Export format level 1 metadata for all simulations to JSON
optional arguments:
-h, --help show this help message and exit
```
......@@ -273,7 +273,7 @@ def get_waveform_peak(sim):
# Prepare container for piecewise polynomial
amp22 = sim['amp_l2_m2']
tck22 = splrep(amp22['X'][:], amp22['Y'][:], s=0, k=5)
tck22 = splrep(amp22['X'][:], amp22['Y'][:]**2, s=0, k=5)
interiorKnots22 = np.setdiff1d(
interiorKnots, amp22['X'][3:-3])
tck22 = reduce(
......@@ -286,7 +286,7 @@ def get_waveform_peak(sim):
ampKeys = [k for k in ampKeys if k != 'amp_l2_m2']
for k in ampKeys:
amplm = sim[k]
tcklm = splrep(amplm['X'][:], amplm['Y'][:], s=0, k=5)
tcklm = splrep(amplm['X'][:], amplm['Y'][:]**2, s=0, k=5)
interiorKnotslm = np.setdiff1d(
interiorKnots, amplm['X'][3:-3])
tcklm = reduce(
......@@ -296,9 +296,12 @@ def get_waveform_peak(sim):
plm = PPoly.from_spline(tcklm)
pAll.c += plm.c
# Find the global maximum point of the piecewise polynomial
# Find the global maximum point of the piecewise polynomial in domain
dpAll = pAll.derivative()
extremumPoints = dpAll.roots()
t0, t1 = sim['amp_l2_m2/X'][:][np.r_[0, -1]]
mask = (extremumPoints >= t0) * (extremumPoints <= t1)
extremumPoints = extremumPoints[mask]
extremum = pAll(extremumPoints)
idx = np.argmax(extremum)
maximumPoint = extremumPoints[idx]
......
......@@ -70,7 +70,7 @@ templateOutput = """# Format 1
# Format 1 (Interfield)
- [=] mass-ordering (mass1 >= mass2)
- [=] peak-near-zero (waveform peak is at 0.88M which is less than 10.00M from zero)
- [=] peak-near-zero (waveform peak is at 0.05M which is less than 10.00M from zero)
- [=] phase-sense ((2,2) phase is decreasing on average)
# Format 2
......@@ -1869,7 +1869,7 @@ class TestPeakNearZero(TestInterfield):
def test_invalid_peak_location(self):
self.setOutput(
('- [INVALID INTERFIELD] peak-near-zero (waveform peak is at '
'-99.12M which is greater than 10.00M from zero)'))
'-99.95M which is greater than 10.00M from zero)'))
nr = h5.File(self.f.name)
keys = [k for k in nr.keys() if k.startswith('amp_l')]
......
......@@ -19,7 +19,7 @@ from distutils.core import setup
from setuptools import find_packages
setup(name='lvcnrpy',
version='3.0.0',
version='4.0.0',
description='Thin Python API to interact with the LVC NR catalogue',
author='Edward Fauchon-Jones',
author_email='edward.fauchon-jones@ligo.org',
......