5 from contextlib
import contextmanager
13 lal.swig_redirect_standard_output_error(
True)
16 state = lal.swig_redirect_standard_output_error(
False)
18 lal.swig_redirect_standard_output_error(state)
20 warnings.warn(
"""Wswiglal-redir-stdio:
22 SWIGLAL standard output/error redirection is enabled in IPython.
23 This may lead to performance penalties. To disable locally, use:
25 with lal.no_swig_redirect_standard_output_error():
28 To disable globally, use:
30 lal.swig_redirect_standard_output_error(False)
32 Note however that this will likely lead to error messages from
33 LAL functions being either misdirected or lost when called from
36 To suppress this warning, use:
39 warnings.filterwarnings("ignore", "Wswiglal-redir-stdio")
43 __version__ =
"7.5.0.1"
46 """This package provides Python wrappings and extensions to LAL"""
57 cached_detector_by_prefix = dict((cd.frDetector.prefix, cd)
for cd
in CachedDetectors)
59 assert len(cached_detector_by_prefix) == len(CachedDetectors)
62 cached_detector_by_name = dict((cd.frDetector.name, cd)
for cd
in CachedDetectors)
64 assert len(cached_detector_by_name) == len(CachedDetectors)
67 name_to_prefix = dict((name, detector.frDetector.prefix)
for name, detector
in cached_detector_by_name.items())
68 prefix_to_name = dict((prefix, name)
for name, prefix
in name_to_prefix.items())
81 numpy_to_lal_types = {
'char':
'CHAR',
90 'complex64':
'COMPLEX8',
91 'complex128':
'COMPLEX16'}
95 return LIGOTimeGPS, (obj.gpsSeconds, obj.gpsNanoSeconds)
99 return Unit, (str(obj),)
103 lal_type = numpy_to_lal_types[data.dtype.name]
104 creator = globals()[
'Create{}Vector'.format(lal_type)]
105 result = creator(len(data))
111 return unpickle_vector, (obj.data,)
115 lal_type = numpy_to_lal_types[attrs[
'data'].data.dtype.name]
116 kind =
'Frequency' if 'deltaF' in attrs
else 'Time'
117 creator = globals()[
'{}{}Series'.format(lal_type, kind)]
119 for key, value
in attrs.items():
120 setattr(result, key, value)
125 attrs = {
'name': obj.name,
'epoch': obj.epoch,
'f0': obj.f0,
126 'sampleUnits': obj.sampleUnits,
'data': obj.data}
127 if hasattr(obj,
'deltaF'):
128 attrs[
'deltaF'] = obj.deltaF
130 attrs[
'deltaT'] = obj.deltaT
131 return unpickle_series, (attrs,)
134 copyreg.pickle(LIGOTimeGPS, pickle_gps)
135 copyreg.pickle(Unit, pickle_unit)
136 for datatype
in numpy_to_lal_types.values():
137 clazz = globals().get(
'{}Vector'.format(datatype))
139 copyreg.pickle(clazz, pickle_vector)
140 clazz = globals().get(
'{}FrequencySeries'.format(datatype))
142 copyreg.pickle(clazz, pickle_series)
143 clazz = globals().get(
'{}TimeSeries'.format(datatype))
145 copyreg.pickle(clazz, pickle_series)
def no_swig_redirect_standard_output_error()
def unpickle_vector(data)
def unpickle_series(attrs)