vallis / libstempo Goto Github PK
View Code? Open in Web Editor NEWlibstempo — a Python wrapper for tempo2
License: MIT License
libstempo — a Python wrapper for tempo2
License: MIT License
As the title says :)
Hi!
I just discovered this library, and I was wondering if it has the functionality generally used within optical/gamma astronomy... Is it currently possible to provide a time array and ephemerides file, and return the phase of each time value according to the ephemerides?
Maybe its a super dumb question... Apologies if that is the case, as I'm definitely not an expert. If it is possible, would it be possible to get a small snippet so I can try to work it out?
Thanks!
Hey
I get that this error means I screwed up somewhere in installation. Or some libraries are not being linked. But, I can't figure out how which library has to be linked and how.
Originally, I wanted to install PAL2 in a virtual environment. Everything went smoothly but when I tried to import libstempo
, I got undefined symbol
error.
I was able to run and import libstempo
in my original environment just fine. I think there is some library not being found/linked when I do it in that virtual environment.
Can you shed some light on this?
Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/shining/anaconda2/envs/pal2_conda/lib/python2.7/site-packages/libstempo/__init__.py", line 8, in <module> from libstempo.libstempo import * ImportError: /home/shining/mega/PDA/lib/libtempo2.so.2: undefined symbol: omp_get_thread_num
Recently it became possible to compile and run tempo2 on Apple M1/M2 processors with an arm architecture. This can be done by using the ./configure --enable-float128
option in the configure script. See here for more details on that.
libstempo cannot be compiled against that version of tempo2, because it then needs to be compiled with the gcc compiler (for the quad precision support), but it hard codes the 'long double' type of clang.
IPTA DR2 release VersionA
uses DMOFF
in it's .par
files. My understanding is that this is similar to DMX
. Neither PINT
nor libstempo
can handle this DM model. It has lines like:
DMMODEL DM 1
_DM 53281.0927574998 0.00145592665025232 5.36854989516535e-05
...
_CM 53341.0927574998 6.08366194548412e-07 1.10834102752821e-07
...
CONSTRAIN DMMODEL
Adding this functionality would allow us to use IPTA DR2 VersionA
in addition to VersionB
.
This may be a tempo2
issue and not a libstempo
issue.
Hi Michele,
I'm trying to install the software in my Anaconda distribution (Python 2.7). I get the following compilation error (on Linux and Mac):
Collecting libstempo
Using cached libstempo-2.2.5.tar.gz
Complete output from command python setup.py egg_info:
Error compiling Cython file:
------------------------------------------------------------
...
# restore the fit state of excluded pars
for par in self.excludepars:
self[par].fit = excludeparstate[par]
return ret[:,(0 if incoffset else 1):]
^
------------------------------------------------------------
libstempo/libstempo.pyx:1052:37: Compiler crash in AnalyseExpressionsTransform
ModuleNode.body = StatListNode(libstempo.pyx:1:0)
StatListNode.stats[25] = StatListNode(libstempo.pyx:480:5)
StatListNode.stats[0] = CClassDefNode(libstempo.pyx:480:5,
as_name = u'tempopulsar',
class_name = u'tempopulsar',
module_name = u'',
visibility = u'private')
CClassDefNode.body = StatListNode(libstempo.pyx:481:4)
StatListNode.stats[36] = DefNode(libstempo.pyx:994:4,
doc = u'tempopulsar.designmatrix(updatebats=True,fixunits=True,incoffset=True)\n\n Returns the design matrix [nobs x (ndim+1)] as a numpy.longdouble array\n for current fit-parameter values. If fixunits=True, adjust the units\n of the design-matrix columns so that they match the tempo2\n parameter units. If fixsigns=True, adjust the sign of the columns\n corresponding to FX (F0, F1, ...) and JUMP parameters, so that\n they match finite-difference derivatives. If incoffset=False, the\n constant phaseoffset column is not included in the designmatrix.',
modifiers = [...]/0,
name = u'designmatrix',
num_required_args = 1,
py_wrapper_required = True,
reqd_kw_flags_cname = '0',
used = True)
File 'Nodes.py', line 429, in analyse_expressions: StatListNode(libstempo.pyx:995:8,
is_terminator = True)
File 'Nodes.py', line 5549, in analyse_expressions: ReturnStatNode(libstempo.pyx:1052:8,
is_terminator = True)
File 'ExprNodes.py', line 3314, in analyse_types: IndexNode(libstempo.pyx:1052:18,
is_subscript = True,
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 3363, in analyse_base_and_index_types: IndexNode(libstempo.pyx:1052:18,
is_subscript = True,
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 7259, in analyse_types: TupleNode(libstempo.pyx:1052:18,
is_sequence_constructor = 1,
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 4830, in analyse_types: SliceNode(libstempo.pyx:1052:18,
is_slice = True,
is_temp = 1,
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 11250, in analyse_types: CondExprNode(libstempo.pyx:1052:22,
is_temp = 1,
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 596, in analyse_types: CoerceToBooleanNode(libstempo.pyx:1052:37,
is_temp = 1,
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 401, in not_implemented: CoerceToBooleanNode(libstempo.pyx:1052:37,
is_temp = 1,
result_is_used = True,
use_managed_ref = True)
Compiler crash traceback from this point on:
File "/Users/meo/anaconda/envs/py27/lib/python2.7/site-packages/Cython/Compiler/ExprNodes.py", line 401, in not_implemented
(self.__class__.__name__, method_name))
InternalError: Internal compiler error: CoerceToBooleanNode.analyse_types not implemented
WARNING: The libstempo API has changed substantially (for the better) from
versions 1.X to 2.X. If you need the older 1.X API, you can get an older libstempo
from https://pypi.python.org/simple/libstempo, or checkout the libstempo1
branch on GitHub - https://github.com/vallis/libstempo/tree/libstempo1
I have not been able to autodetect the location of the tempo2 headers and
libraries. Nevertheless, I will proceed with the installation. If you get
errors, please run setup.py again, but use the option --with-tempo2=...
to point me to the tempo2 install root (e.g., /usr/local if tempo2.h is
in /usr/local/include).
Compiling libstempo/libstempo.pyx because it depends on /Users/meo/anaconda/envs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd.
[1/1] Cythonizing libstempo/libstempo.pyx
analyse_types not implemented
Called from: CoerceToBooleanNode.not_implemented 398
Called from: CoerceToBooleanNode.analyse_types 596
Called from: CondExprNode.analyse_types 11250
Called from: SliceNode.analyse_types 4830
Called from: TupleNode.analyse_types 7259
Called from: IndexNode.analyse_base_and_index_types 3363
Called from: IndexNode.analyse_types 3314
Called from: ReturnStatNode.analyse_expressions 5549
Called from: StatListNode.analyse_expressions 429
Called from: AnalyseExpressionsTransform.visit_FuncDefNode 1993
Called from: AnalyseExpressionsTransform.visit_ModuleNode 1988
Called from: run_pipeline 365
Called from: run_pipeline 492
Called from: compile_multiple 662
Called from: compile 684
Called from: cythonize_one 1017
Called from: cythonize 912
Called from: <module> 84
Called from: <module> 1
----------------------------------------------------------------------
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/sx/yz6cllns2xz4bcpnf7z3mjlm0000gw/T/pip-build-bjNXVD/libstempo/setup.py", line 84, in <module>
library_dirs = [tempo2 + '/lib']))
File "/Users/meo/anaconda/envs/py27/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 912, in cythonize
cythonize_one(*args)
File "/Users/meo/anaconda/envs/py27/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 1034, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: libstempo/libstempo.pyx
Forget about the Tempo2 problem for now, on Linux Tempo2 is installed correctly and it gives exactly the same error.
Could a new PyPI release of libstempo be made, so that Enterprise can be installed from a versioned version of libstempo rather than having to install from the git repo?
I did not have time to debug this, so here it is...
In [1]: import libstempo as lt, matplotlib.pyplot as plt, numpy as np
In [2]: psr = lt.tempopulsar('J
J2322+2057.par J2322+2057.par~ J2322+2057_all.tim
In [2]: psr = lt.tempopulsar('J2322+2057.par', 'J2322+2057_all.tim')
[doFit.C:51] Deprecated call to doFit() -> better to use doFitAll()
In [3]: psr['JUMP3'].fit
Out[3]: True
In [4]: psr['JUMP3'].fit = False
In [5]: psr['JUMP3'].fit
Out[5]: False
In [6]: psr['JUMP3'].fit = True
Segmentation fault: 11
Cloning the git repository and installing libstempo with pip install .
is giving me a bunch of Cython errors like
Error compiling Cython file:
------------------------------------------------------------
...
cdef class tempopulsar:
"""tempopulsar(parfile, timfile=None, warnings=False, fixprefiterrors=True,
dofit=False, maxobs=None, units=False, ephem=None, t2cmethod=None,
toas=None, toaerrs=None, observatory=None, obsfreq=1400)"""
cpdef public object parfile
^
------------------------------------------------------------
libstempo/libstempo.pyx:627:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
This appears to be due to a change in Cython 3.0, released today(!). See here.
For now, changing "Cython>=0.22"
to "Cython>=0.22,<3.0"
in pyproject.toml
seems to work. But a better long-term solution might be to change some cpdef
statements to cdef
.
I was getting build errors when the code tries to import the string std library, the issue seems to be described here. With the fix being modify the setup extension to:
extra_compile_args = ["-Wno-unused-function", "-stdlib=libc++"],
extra_link_args = linkArgs + ["-stdlib=libc++"]
I also needed to modify my LD_LIBRARY_PATH
variable to point to my libopenblas.0.dylib
directory (for me, with openblas installed with brew: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/opt/openblas/lib
). I think I'll add a hook to my anaconda environment to add this on activation.
When importing libstempo.toasim, I get the error:
IOError: [Errno 2] No such file or directory: '/Users/vhaaster/env/dev/lib/python2.7/site-packages/libstempo-2.2.3-py2.7-macosx-10.9-intel.egg/libstempo/ecc_vs_nharm.txt'
I think Justin needs to include ecc_vs_nharm.txt in the repo.
@vallis and @mattpitkin
As I mentioned before it seems worthwhile to have this repo be the single "source of truth". That means that once a release is triggered here both the pypi and conda releases are triggered.
Currently through my latest PRs we have that setup for pypi. I don't use conda myself and did not know the crazy wild-west nature of it. To me it makes more sense to do everything from here instead of using conda forge which requires reviewers and manual merges. Also, all the code (i.e. meta.yaml, build stuff) is sitting right beside the source code.
I have this setup now on a branch. The github workflow now includes the steps to build and push conda packages for both mac and ubuntu for all python versions supported. The conda build info also lives in this repo.
Then, in the README it should be explicitly mentioned that the vallis::libstempo
is the official conda release.
I've gone through this build process on my branch and have jellis1895::libstempo-pulsar
conda packages that you can test out.
Let me know what you think of this idea.
When I import
import libstempo as libs
I get the above mentioned error. Any suggestions what to do?
add_cgw() fails because the Tempo2Pulsar object does not have psr.pars() or psr.toas().
I attempted to add a new argument to tempopulsar cinit so that we could declare the TT(BIPM2XXX) version at load. This does not work, despite me copying basically what was done for the SSE.
I'm trying to install the current code (ba5c332) in a new conda environment. In my environment.yml file I put
- pip:
- git+https://github.com/vallis/libstempo
But this did not work. It gave me the old version that gives the error about units support. So I removed it with
conda uninstall --force libstempo
, and installed it directly with pip install git+https://github.com/vallis/libstempo
. This did work. Both versions are reported by pip list
as version 2.4.6, which I found confusing.
Specifying @ba5c332 does not change anything. It does not work to install it with pip after having already included it in the conda install. So I guess that pip thinks that somehow these are the same version and so it doesn't need to actually install the new version when the old one is installed already. Is this a packaging problem or am I not using pip correctly? Thanks.
I have been encountering intermittent segfaults when running code where I repeatedly (say, many hundreds of times) make calls like
psr = libstempo.tempopulsar(parfile, timfile)
Inspecting the core dumps shows that the segfault is coming from deep in tempo2
and the root cause is that the value of ne_sw_ifuncN
in the pulsar
struct is becoming garbage - the end of the backtrace typically looks like the following:
#0 0x000014fe6096144d in ifunc (mjd=mjd@entry=0x3b257d8, yoffs=yoffs@entry=0x3b27718, t=t@entry=57191.436434533738, N=465682051) at ifunc.C:38
#1 0x000014fe6090c421 in dm_delays (psr=<optimized out>, npsr=<optimized out>, p=<optimized out>, i=<optimized out>, delt=<optimized out>, dt_SSB=<optimized out>) at dm_delays.C:324
#2 0x000014fe608ed430 in calculate_bclt._omp_fn.0(void) () at calculate_bclt.C:143
#3 0x000014fe6060b736 in GOMP_parallel (fn=0x14fe608ed150 <calculate_bclt._omp_fn.0(void)>, data=0x7ffe2e859200, num_threads=1, flags=0) at ../../../libgomp/parallel.c:178
#4 0x000014fe608ed97b in calculate_bclt (psr=0x35c4f10, npsr=1) at calculate_bclt.C:63
#5 0x000014fe6093ac3e in formBatsAll (psr=0x35c4f10, npsr=1) at global.C:148
#6 0x000014fe60c7f2aa in __pyx_pf_9libstempo_9libstempo_11tempopulsar___cinit__ (__pyx_v_obsfreq=<optimized out>, __pyx_v_observatory=<optimized out>, __pyx_v_toaerrs=<optimized out>,
__pyx_v_toas=<optimized out>, __pyx_v_t2cmethod=<optimized out>, __pyx_v_clk=<optimized out>, __pyx_v_ephem=<optimized out>, __pyx_v_units=<optimized out>,
__pyx_v_maxobs=<optimized out>, __pyx_v_dofit=<optimized out>, __pyx_v_fixprefiterrors=<optimized out>, __pyx_v_warnings=<optimized out>, __pyx_v_timfile=0x14fe60e614d0,
__pyx_v_parfile=<optimized out>, __pyx_v_self=0x14fe6112c540) at libstempo/libstempo.cpp:32805
I'm filing this as a libstempo bug because a tentative fix seems to be adding a memset
call to tempopulsar
's __cinit__
to zero out the allocated memory, as I've done here, but I'm not experienced enough with C or Cython to know if this is a good way to handle this, or if this is even really a libstempo
bug as opposed to something going wrong in tempo2
's memory management.
This may also be the cause of nanograv/enterprise#339?
The new fit function in tempo2
is incredibly slow as is the current fit in libstempo
as they both do dense matrix algebra.
We should definitely try to get a fast fit into libstempo that can read the noise parameters from the par file. I can have a go at this soon and submit a PR if we decide to go that route.
libstempo.createGWB() fails as shown below:
Traceback (most recent call last):
File "./sim_pulsar.py", line 181, in
LT.createGWB(psr, Amp=gwA, gam=gwG)
File "/Users/ptb/anaconda/envs/env-pal2/lib/python2.7/site-packages/libstempo/toasim.py", line 838, in createGWB
res_gw.append(f(psr[ll].toas()*86400))
File "/Users/ptb/anaconda/envs/env-pal2/lib/python2.7/site-packages/scipy/interpolate/polyint.py", line 80, in call
y = self._evaluate(x)
File "/Users/ptb/anaconda/envs/env-pal2/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 584, in _evaluate
y_new = self._call(self, x_new)
File "/Users/ptb/anaconda/envs/env-pal2/lib/python2.7/site-packages/scipy/interpolate/interpolate.py", line 528, in _call_linear_np
return np.interp(x_new, self.x, self.y)
File "/Users/ptb/anaconda/envs/env-pal2/lib/python2.7/site-packages/numpy/lib/function_base.py", line 1271, in interp
return compiled_interp(x, xp, fp, left, right)
TypeError: Cannot cast array data from dtype('float128') to dtype('float64') according to the rule 'safe'
Python: 2.7.11
libstempo: 2.2.5
numpy: 1.10.2
scipy: 0.17.0
On a related note I get a depreciation warning from tempopulsar.fit():
[tempo2Util.C:360] Warning: [TIM1] Please place MODE flags in the parameter file
[doFit.C:93] Deprecated call to doFit() -> better to use doFitAll()
[doFit.C:140] OLD FITTER
libstempo appears to be using it's own installation of Tempo2 (2015.9), which differs from my system installation:
$ tempo2 -v
2016.05.0
A friend verified that a similar call to creatGWB() executes successfully with libstempo=2.2.5 and Tempo2=1.11
When loading a tempopulsar with units=True, some functionality does not work well or is wrong.
psr.designmatrix()
fails when a pulsar has units=True
, with the error message pasted below. This seems to stem from the fixunits=True
bit of code. With fixunits=False
the designmatrix is correctly returned.---------------------------------------------------------------------------
UnitConversionError Traceback (most recent call last)
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:982](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:982), in Quantity.to_value(self, unit, equivalencies)
981 try:
--> 982 scale = self.unit._to(unit)
983 except Exception:
984 # Short-cut failed; try default (maybe equivalencies help).
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1159](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1159), in UnitBase._to(self, other)
1157 return self_decomposed.scale [/](https://file+.vscode-resource.vscode-cdn.net/) other_decomposed.scale
-> 1159 raise UnitConversionError(f"'{self!r}' is not a scaled version of '{other!r}'")
UnitConversionError: 'Unit("deg")' is not a scaled version of 'Unit(dimensionless)'
During handling of the above exception, another exception occurred:
UnitConversionError Traceback (most recent call last)
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:1350](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:1350), in Quantity.__float__(self)
1349 try:
-> 1350 return float(self.to_value(dimensionless_unscaled))
1351 except (UnitsError, TypeError):
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:985](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:985), in Quantity.to_value(self, unit, equivalencies)
983 except Exception:
984 # Short-cut failed; try default (maybe equivalencies help).
--> 985 value = self._to_value(unit, equivalencies)
986 else:
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:891](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:891), in Quantity._to_value(self, unit, equivalencies)
889 if not self.dtype.names or isinstance(self.unit, StructuredUnit):
890 # Standard path, let unit to do work.
--> 891 return self.unit.to(
892 unit, self.view(np.ndarray), equivalencies=equivalencies
893 )
895 else:
896 # The .to() method of a simple unit cannot convert a structured
897 # dtype, so we work around it, by recursing.
898 # TODO: deprecate this?
899 # Convert simple to Structured on initialization?
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1195](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1195), in UnitBase.to(self, other, value, equivalencies)
1194 else:
-> 1195 return self._get_converter(Unit(other), equivalencies)(value)
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1124](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1124), in UnitBase._get_converter(self, other, equivalencies)
1122 return lambda v: b(converter(v))
-> 1124 raise exc
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1107](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1107), in UnitBase._get_converter(self, other, equivalencies)
1106 try:
-> 1107 return self._apply_equivalencies(
1108 self, other, self._normalize_equivalencies(equivalencies)
1109 )
1110 except UnitsError as exc:
1111 # Last hope: maybe other knows how to do it?
1112 # We assume the equivalencies have the unit itself as first item.
1113 # TODO: maybe better for other to have a `_back_converter` method?
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1085](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/core.py:1085), in UnitBase._apply_equivalencies(self, unit, other, equivalencies)
1083 other_str = get_err_str(other)
-> 1085 raise UnitConversionError(f"{unit_str} and {other_str} are not convertible")
UnitConversionError: 'deg' (angle) and '' (dimensionless) are not convertible
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
[/Users/vhaasteren/research/projects/combine-ptas/combine-pulsars.ipynb](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/combine-pulsars.ipynb) Cell 20 line 1
----> [1](vscode-notebook-cell:/Users/vhaasteren/research/projects/combine-ptas/combine-pulsars.ipynb#Y133sZmlsZQ%3D%3D?line=0) psr_epta.designmatrix()
File libstempo/libstempo.pyx:1754, in libstempo.libstempo.tempopulsar.designmatrix()
File [~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:1352](https://file+.vscode-resource.vscode-cdn.net/Users/vhaasteren/research/projects/combine-ptas/~/miniconda3/envs/pint/lib/python3.10/site-packages/astropy/units/quantity.py:1352), in Quantity.__float__(self)
1350 return float(self.to_value(dimensionless_unscaled))
1351 except (UnitsError, TypeError):
-> 1352 raise TypeError(
1353 "only dimensionless scalar quantities can be "
1354 "converted to Python scalars"
1355 )
TypeError: only dimensionless scalar quantities can be converted to Python scalars
I'm getting the following error when trying to simulate a free spectrum GWB with the createGWB
function (specifying userSpec
):
TypeError: Cannot cast array data from dtype('float128') to dtype('float64') according to the rule 'safe'
Changing 3 lines of code seems to fix this for me.
Line 799 and 800 (https://github.com/vallis/libstempo/blob/master/libstempo/toasim.py#L799) should have an extra float()
, so they should read:
start = float(N.min([p.toas().min() * 86400 for p in psr]) - 86400)
stop = float(N.max([p.toas().max() * 86400 for p in psr]) + 86400)
And line 898 (https://github.com/vallis/libstempo/blob/master/libstempo/toasim.py#L898) should have an extra type conversion and it should read:
res_gw.append(f(psr[ll].toas().astype(N.float) * 86400))
If people think this is right I can easily make a pull request.
When I try to run libstempo-toasim-demo.ipynb, it shows utf-8 error. The detail info pasted below. Could you help me to check this problem? Thanks. @vallis @mattpitkin
UnicodeDecodeError Traceback (most recent call last)
/tmp/ipykernel_27615/1593190486.py in
1 psr = T.tempopulsar(parfile = T.data + 'B1953+29_NANOGrav_dfg+12.par',
----> 2 timfile = T.data + 'B1953+29_NANOGrav_dfg+12.tim')
3 LP.plotres(psr)
libstempo/libstempo.pyx in libstempo.libstempo.tempopulsar.cinit()
libstempo/libstempo.pyx in libstempo.libstempo.tempopulsar._readflags()
libstempo/libstempo.pyx in libstempo.libstempo.lambda1()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 0: invalid continuation byte
Hey Michele,
I am trying to install libstempo but get different errors on different platforms. This is the OSX error that I get:
WARNING: The libstempo API has changed substantially (for the better) from
versions 1.X to 2.X. If you need the older 1.X API, you can get an older libstempo
from https://pypi.python.org/simple/libstempo, or checkout the libstempo1
branch on GitHub - https://github.com/vallis/libstempo/tree/libstempo1
Found tempo2 install in [u'/Users/vkrishnan/T2runtime/'], will use it.
Traceback (most recent call last):
File "setup.py", line 109, in
extra_link_args = linkArgs))
File "/Users/vkrishnan/anaconda/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 818, in cythonize
aliases=aliases)
File "/Users/vkrishnan/anaconda/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 648, in create_extension_list
elif isinstance(patterns, basestring) or not isinstance(patterns, collections.Iterable):
File "/Users/vkrishnan/anaconda/lib/python2.7/abc.py", line 144, in instancecheck
return cls.subclasscheck(subtype)
File "/Users/vkrishnan/anaconda/lib/python2.7/abc.py", line 180, in subclasscheck
if issubclass(subclass, scls):
File "/Users/vkrishnan/anaconda/lib/python2.7/abc.py", line 180, in subclasscheck
if issubclass(subclass, scls):
File "/Users/vkrishnan/anaconda/lib/python2.7/abc.py", line 161, in subclasscheck
ok = cls.subclasshook(subclass)
File "/Users/vkrishnan/anaconda/lib/python2.7/site-packages/backports_abc.py", line 66, in subclasshook
mro = C.mro
AttributeError: class Extension has no attribute 'mro'
I tried pip install and setup.puy but both give the same error. Can you please tell me how to fix it?
My softwares:
conda 4.3.25
Python 2.7.11 :: Anaconda custom (x86_64)
OSX El Capitan 10.11.6
gcc (GCC) 4.9.2 20141029
g++ (GCC) 4.9.2 20141029
Tempo2 2017.03.1
Thanks,
Vivek
Astropy has split the erfa module, and it's not its own package. Therefore it should be imported from erfa, not astropy.erfa or astropy._erfa. It can be installed as pyerfa. See here.
So for the new astropy (>=5) we should import erfa
I have been trying to load J1713+0747 from the 15 year data and when I try to run 'LT.make_ideal(psr)' it fails and gives me the following errors:
Warning: one or more of the design-matrix columns is null. Disabling renormalization (if active), but fit may fail.
and then fails with the following output
`---------------------------------------------------------------------------
LinAlgError Traceback (most recent call last)
Cell In[5], line 1
----> 1 LT.make_ideal(psr)
File /opt/anaconda3/envs/ent15y/lib/python3.9/site-packages/libstempo/toasim.py:159, in make_ideal(psr)
156 """Adjust the TOAs so that the residuals to zero, then refit."""
158 psr.stoas[:] -= psr.residuals() / 86400.0
--> 159 psr.fit()
File libstempo/libstempo.pyx:2087, in libstempo.libstempo.tempopulsar.fit()
File libstempo/libstempo.pyx:2054, in libstempo.libstempo.tempopulsar._fit()
File /opt/anaconda3/envs/ent15y/lib/python3.9/site-packages/scipy/linalg/_decomp_cholesky.py:154, in cho_factor(a, lower, overwrite_a, check_finite)
94 def cho_factor(a, lower=False, overwrite_a=False, check_finite=True):
95 """
96 Compute the Cholesky decomposition of a matrix, to use in cho_solve
97
(...)
152
153 """
--> 154 c, lower = _cholesky(a, lower=lower, overwrite_a=overwrite_a, clean=False,
155 check_finite=check_finite)
156 return c, lower
File /opt/anaconda3/envs/ent15y/lib/python3.9/site-packages/scipy/linalg/_decomp_cholesky.py:37, in _cholesky(a, lower, overwrite_a, clean, check_finite)
35 c, info = potrf(a1, lower=lower, overwrite_a=overwrite_a, clean=clean)
36 if info > 0:
---> 37 raise LinAlgError("%d-th leading minor of the array is not positive "
38 "definite" % info)
39 if info < 0:
40 raise ValueError('LAPACK reported an illegal value in {}-th argument'
41 'on entry to "POTRF".'.format(-info))
LinAlgError: 19-th leading minor of the array is not positive definite`
I am trying to produce a synthetic data set which matches as close as possible the NG15yr data-- if this is my goal, is it necessary to re fit?
Any help on resolving this would be much appreciated.
We recently added tempo2 to the conda-forge package repository and it would be nice to have libstempo in there too. Would anyone be willing to take this on? Otherwise, I'd be happy to put the recipe together if your happy for me to.
The definition of Tobs is not consistent. I'm flagging this as an issue so that I don't forget.
Hi,
Recently when I trying to import libstempo, I got this error:
Traceback (most recent call last):
File "", line 1, in
File "/Users/jingluo/anaconda2/lib/python2.7/site-packages/libstempo-2.3.3-py2.7-macosx-10.7-x86_64.egg/libstempo/init.py", line 8, in
from libstempo.libstempo import *
ImportError: dlopen(/Users/jingluo/anaconda2/lib/python2.7/site-packages/libstempo-2.3.3-py2.7-macosx-10.7-x86_64.egg/libstempo/libstempo.so, 2): Symbol not found: ___emutls_get_address
Referenced from: /usr/local/opt/gcc/lib/gcc/7/libstdc++.6.dylib
Expected in: /usr/lib/libSystem.B.dylib
in /usr/local/opt/gcc/lib/gcc/7/libstdc++.6.dylib
It looks different from issue #16. Is it still the same problem?
The CI test builds for Mac OS currently fail due to not being able to build tempo2. This should be investigated.
Loading libstempo gives Warning: cannot find astropy, units support will not be available
. I think the problem is that erfa is no longer part of astropy, so importing it fails and the code has a catchall try...except
that prints the above message.
Tempopulsar does not currently work with IPTA DR2 datasets since the .par files include DMMODEL information from the autoDM plugin in tempo2. The designmatrix function throws an error because, although each _DM and DMOFF line is recognized as fitting information, only the initial DMMODEL line is marked with a fit flag set to 1. This creates a conflict: Number of fitinfo parameters (...) does not match fit parameters (...).
A few example lines in a .par file are:
DMMODEL DM 1
DMOFF 48500 -0.00120890526660372 0.000593318894762492
DMOFF 52000 0.000634724170973158 0.000113134549521443
I am attempting to use toa-sim in order to take existing NANOGrav tim and par files to construct a ‘synthetic’ PTA with intrinsic red and white noise parameters of my choice (no GWB yet). I have attempted to read in each tim and par file sequentially and then generate the synthetic files. However, after a few pulsars the code balks and prints (on the terminal) either a message that reads ‘Diagonal element of covariance matrix = 0’ when saving the par files. I can then restart the kernel and get par files for all of the pulsars, but his is quite cumbersome, and I am worried that the files I am saving are possibly incorrect.
My first question is: since I am using the NANOGrav par files to generate the synthetic TOAs, can I use the NANOGrav par files when analyzing the synthetic TOAs? If this is the case, the error when saving the par files from within TOA-sim is moot.
If I do need to use the par files saved from within TOA-sim, is there a way to avoid this error from occurring?
Trying to inject a free spectrum GWB with userSpec
in createGWB
gives the following error on line 813 of toasim.py
:
--> 813 hcf = 10.0**fspec_ex(N.log10(f))
TypeError: Cannot cast array data from dtype('float128') to dtype('float64') according to the rule 'safe'
It might be related to this old issue: #7
I managed to solve this in my local copy by inserting a line converting f
to float64 before line 813:
f = N.float64(f)
but I'm not sure if this is the ultimate desired solution here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.