Skip to content

FrequencySeries.from_lal throws ValueError with np.complex128

Created by: deepchatterjeeligo

GWPy and lalsuite versions:

$ pip list | grep gwpy
gwpy                   2.1.3
$ pip list | grep lal
lalsuite               7.3

Steps to reproduce

import lal
import lalsimulation
from gwpy import frequencyseries
params=dict(
    m1=20*lal.MSUN_SI,
    m2=10*lal.MSUN_SI,
    S1x=0,
    S1y=0,
    S1z=0,
    S2x=0,
    S2y=0,
    S2z=0,
    distance=3e24,
    inclination=1.0,
    phiRef=0.,
    longAscNodes=0.,
    eccentricity=0.,
    meanPerAno=0.,
    deltaF=1./1024.,
    f_min=10.,
    f_max=512.,
    f_ref=50.,
    approximant=lalsimulation.TaylorF2,
    LALpars=None
)
hp, hc = lalsimulation.SimInspiralChooseFDWaveform(**params)
hp_gwpy = frequencyseries.FrequencySeries.from_lal(hp)

Full traceback

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/miniconda3/envs/test/lib/python3.7/site-packages/gwpy/utils/enum.py in find(cls, type_)
     49             try:
---> 50                 return cls[numpy.dtype(type_).name.upper()]
     51             except (KeyError, TypeError):

~/miniconda3/envs/test/lib/python3.7/enum.py in __getitem__(cls, name)
    356     def __getitem__(cls, name):
--> 357         return cls._member_map_[name]
    358 

KeyError: 'COMPLEX128'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-1-14a34fda2b87> in <module>
     26 hp, hc = lalsimulation.SimInspiralChooseFDWaveform(**params)
     27 
---> 28 hp_gwpy = frequencyseries.FrequencySeries.from_lal(hp)

~/miniconda3/envs/test/lib/python3.7/site-packages/gwpy/frequencyseries/frequencyseries.py in from_lal(cls, lalfs, copy)
    355             unit = None
    356         channel = Channel(lalfs.name, unit=unit,
--> 357                           dtype=lalfs.data.data.dtype)
    358         return cls(lalfs.data.data, channel=channel, f0=lalfs.f0,
    359                    df=lalfs.deltaF, epoch=float(lalfs.epoch),

~/miniconda3/envs/test/lib/python3.7/site-packages/gwpy/detector/channel.py in __init__(self, name, **params)
    121         # set metadata
    122         for key, value in params.items():
--> 123             setattr(self, key, value)
    124 
    125     def _init_from_channel(self, other):

~/miniconda3/envs/test/lib/python3.7/site-packages/gwpy/detector/channel.py in dtype(self, type_)
    294             self._dtype = None
    295         else:
--> 296             self._dtype = io_nds2.Nds2DataType.find(type_).dtype
    297 
    298     @property

~/miniconda3/envs/test/lib/python3.7/site-packages/gwpy/utils/enum.py in find(cls, type_)
     50                 return cls[numpy.dtype(type_).name.upper()]
     51             except (KeyError, TypeError):
---> 52                 raise exc

~/miniconda3/envs/test/lib/python3.7/site-packages/gwpy/utils/enum.py in find(cls, type_)
     43         """
     44         try:
---> 45             return cls(type_)
     46         except ValueError as exc:
     47             if isinstance(type_, str):

~/miniconda3/envs/test/lib/python3.7/enum.py in __call__(cls, value, names, module, qualname, type, start)
    313         """
    314         if names is None:  # simple value lookup
--> 315             return cls.__new__(cls, value)
    316         # otherwise, functional API: we're creating a new Enum type
    317         return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)

~/miniconda3/envs/test/lib/python3.7/enum.py in __new__(cls, value)
    567                         )
    568             exc.__context__ = ve_exc
--> 569             raise exc
    570 
    571     def _generate_next_value_(name, start, count, last_values):

~/miniconda3/envs/test/lib/python3.7/enum.py in __new__(cls, value)
    551         try:
    552             exc = None
--> 553             result = cls._missing_(value)
    554         except Exception as e:
    555             exc = e

~/miniconda3/envs/test/lib/python3.7/enum.py in _missing_(cls, value)
    799     def _missing_(cls, value):
    800         if not isinstance(value, int):
--> 801             raise ValueError("%r is not a valid %s" % (value, cls.__name__))
    802         new_member = cls._create_pseudo_member_(value)
    803         return new_member

ValueError: dtype('complex128') is not a valid Nds2DataType