Skip to content

Commit

Permalink
Merge branch 'numpy2'
Browse files Browse the repository at this point in the history
  • Loading branch information
scottransom committed Jun 22, 2024
2 parents 91cffd4 + 64b66f3 commit 9dfa4be
Show file tree
Hide file tree
Showing 11 changed files with 382 additions and 400 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Version 5.0.2:
* Updated the C wrappers for PGPLOT for the Numpy 2.0 C API
* Python v3.9 or newer is now required.
* Several minor bug fixes, including to `injectpsr.py`, thanks to @remsforian

## Version 5.0.1:
* Minor improvements over v5.0.0
* Some clarifications and improvements to the build process
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ PRESTO is a large suite of pulsar search and analysis software developed primari

**PRESTO has discovered well over 1000 pulsars, including ~400 recycled and/or binary pulsars!**

## Version 5.0.2:
* Updated the C wrappers for PGPLOT for the Numpy 2.0 C API (with thanks to Tom Marsh)
* Python v3.9 or newer is now required.
* Several minor bug fixes, including to `injectpsr.py`, thanks to @remsforian

## Version 5.0.1:
* Minor improvements over v5.0.0
* Some clarifications and improvements to the build process
Expand Down
2 changes: 1 addition & 1 deletion bin/DDplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def dm_steps(loDM, hiDM, obs, cohdm=0.0, numsub=0, numprocs=1,
ppgplot.pgsch(1.1)
ppgplot.pgsci(1)
if (numsub):
ppgplot.pgmtxt("t", 1.5, 0.6/10.0, 0.5, "\(2156)\dctr\\u = %g MHz" % obs.f_ctr)
ppgplot.pgmtxt("t", 1.5, 0.6/10.0, 0.5, "\\(2156)\\dctr\\u = %g MHz" % obs.f_ctr)
if (dtms < 0.1):
ppgplot.pgmtxt("t", 1.5, 2.8/10.0, 0.5, "dt = %g \\gms" % (dtms*1000))
else:
Expand Down
2 changes: 1 addition & 1 deletion bin/single_pulse_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def main():
info.telescope)
ppgplot.pgmtxt('T', -2.4, 0.33, 0.0, 'DEC (J2000):')
ppgplot.pgmtxt('T', -2.4, 0.5, 0.0, info.DEC)
ppgplot.pgmtxt('T', -2.4, 0.73, 0.0, 'Sampling time: %.2f \gms'%\
ppgplot.pgmtxt('T', -2.4, 0.73, 0.0, r'Sampling time: %.2f \gms'%\
(orig_dt*1e6))
# third row
if info.instrument.find("pigot") >= 0:
Expand Down
12 changes: 6 additions & 6 deletions examplescripts/ffdot_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
pffdot = presto.spectralpower(ffdot.flat)
theo_max_pow = N**2.0/4.0
frp = max(pffdot) / theo_max_pow # Fraction of recovered power
print("Fraction of recovered signal power = %f" % frp)
print(f"Recovered {frp:.3f} of theoretical signal power in F-Fdot plane")
a = time.perf_counter()
[maxpow, rmax, zmax, rd] = presto.maximize_rz(ft, r+norm(1)[0]/5.0,
z+norm(1)[0], norm=1.0)
print("Time for rz:", time.perf_counter()-a)
print(r, rmax, z, zmax, theo_max_pow, maxpow)
print(f"Time for rz optimization {time.perf_counter()-a:.3g} s")
print(f" Optimization recovered {maxpow / theo_max_pow:.3f} of theoretical signal power")
a = time.perf_counter()
[maxpow, rmax, zmax, wmax, rd] = presto.maximize_rzw(ft, r+norm(1)[0]/5.0,
z+norm(1)[0],
w+norm(1)[0]*5.0,
norm=1.0)
print("Time for rzw:", time.perf_counter()-a)
print(r, rmax, z, zmax, w, wmax, theo_max_pow, maxpow)
#print "Raw power should be ~%.2e" % theo_max_pow
print(f"Time for rzw optimization {time.perf_counter()-a:.3g} s")
print(f" Optimization recovered {maxpow / theo_max_pow:.3f} of theoretical signal power")
print(" Recovered power fraction should be near 1.0.")
pffdot = pffdot / theo_max_pow
pffdot.shape = (np, np)
rs = num.arange(np) * dr - np//2*dr
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('PRESTO', 'c',
version: '5.0.1',
version: '5.0.2',
license: 'GPL-2.0',
default_options: [
'buildtype=release',
Expand Down
2 changes: 1 addition & 1 deletion python/fftfit_src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fftfit_module = custom_target('fftfit_module',
py3.extension_module('fftfit',
[fftfit_module, fortranobject_c, 'brent.f', 'cprof.f', 'fccf.f', 'ffft.f', 'fftfit.f'],
include_directories: [inc_np, inc_f2py],
c_args: [numpy_nodepr_api, '-Wno-unused-variable'],
c_args: ['-Wno-unused-variable'],
dependencies : py3_dep,
link_language: 'fortran',
subdir: 'presto',
Expand Down
13 changes: 1 addition & 12 deletions python/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('PRESTO_python', 'c', 'fortran',
version: '5.0.1',
version: '5.0.2',
license: 'GPL-2.0',
default_options: [
'buildtype=release',
Expand Down Expand Up @@ -41,17 +41,6 @@ incdir_numpy = run_command(py3,
).stdout().strip()

inc_np = include_directories(incdir_numpy)

# Don't use the deprecated NumPy C API. Define this to a fixed version instead of
# NPY_API_VERSION in order not to break compilation for released SciPy versions
# when NumPy introduces a new deprecation. Use in a meson.build file::
#
# py3.extension_module('_name',
# 'source_fname',
# numpy_nodepr_api)
#
numpy_nodepr_api = '-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION'

incdir_f2py = incdir_numpy / '..' / '..' / 'f2py' / 'src'
inc_f2py = include_directories(incdir_f2py)
fortranobject_c = incdir_f2py / 'fortranobject.c'
Expand Down
Loading

0 comments on commit 9dfa4be

Please sign in to comment.