Pulsar Software Install 脉冲星软件安装


#Persus X

所安装的的软件

系统环境 : macOS Catalina
Psrcat
tempo
tempo2
psrchive
sigproc
dspsr
presto

环境的搭建

将以下信息添加到~/.bash_profile 或者 ~/.zshrc

# Path to the pulsar software installation directory e.g:
export ASTROSOFT=/Users/Astro/psrsoft

# OSTYPE
export OSTYPE= bsd

# PSRCAT
export PSRCAT_RUNDIR=$ASTROSOFT/psrcat
export PSRCAT_FILE=$ASTROSOFT/psrcat/psrcat.db

# TEMPO
export TEMPO=$ASTROSOFT/tempo

# TEMPO2
export TEMPO2=$ASTROSOFT/tempo2/T2runtime

# PGPLOT
export PGPLOT_DIR=$ASTROSOFT/pgplot
export PGPLOT_DEV=/xwindow

# PRESTO
export PRESTO=$ASTROSOFT/presto

# LD_LIBRARY_PATH
export LD_LIBRARY=$LD_LIBRARY:$ASTROSOFT/lib:$PRESTO/lib

# PATH
# Some Presto executables match sigproc executables so keep separate -
# all other executables are found in $ASTROSOFT/bin
export PATH=$PATH:/usr/local/bin:$ASTROSOFT/bin:$PRESTO/bin

# PYTHONPATH
export PYTHONPATH=$PRESTO/lib/python:/Users/Astro/opt/anaconda3/lib/python3.9/site-packages:$ASTROSOFT/lib/python3.9/site-packages

配置

安装brew

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
  1. 下载源选择:清华大学下载源
  2. 镜像选择:中科大国内源

安装anaconda

下载地址:https://www.anaconda.com/products/distribution

根据电脑的cpu类型选择下载,M1版本或者intel版本,目前command版本安装会有问题,需要安装Graphical版本

安装依赖

brew install gcc
brew install glib
brew install wget
brew install autoconf
brew install automake
brew install libtool
brew install libpng
brew install zlib
brew install swig
brew install cmake
brew install fftw
brew install cfitsio
brew install gsl
brew install pkg-config

最新版本的presto,已经是使用的是PYTHON3环境。并且其中需要一些相关的模块,比如scipy,numpy,astropy等等。用户可以直接安装Anaconda,这样PYTHON环境就会比较容易的搭建完成,Presto所需的模块也会一并装好,省去一些不必要的麻烦。

安装XQuartz

wget https://github.com/XQuartz/XQuartz/releases/download/XQuartz-2.8.1/XQuartz-2.8.1.dmg

~ 点击安装包安装

注意

在MacOS中安装软件的时候,如果已经安装过Xcode,那么在编译的时候很可能会报错,因为在用gcc编译的时候会默认为用clang编译,本文中brew安装的gcc是11.3.0版本,所以需要在配置环境或者make的时候添加 CC=gcc-11 CXX=g+±11,

验证gcc默编译方式如下

$ gcc 

如果出现以下结果则表示默认用clang编译

clang: error: no input files

安装pgplot

在官方下载的安装包,以及教程中可能并不能生成pgplot的动态库(linux 系统下libpgplot.solibcpgplot.so文件,mac系统下libpgplot.dyliblibcpgplot.dylib文件),需要下载特殊版本的 pgplot安装包,下载地址为:https://download.csdn.net/download/weixin_43990846/85461221

下载后将pgplot安装包解压后放在 /Users/Astro/psrsoft/src/,如果没有这个目录则创建目录,创建命令和解压命令如下:

gunzip -c pgplot_psrmac.tar.gz | tar xvf -
mkdir -p /Users/Astro/psrsoft/src

在安装psr软件的目录创建shell执行脚本,可命名为install_pgplot.csh,内容如下:

#!/bin/csh -ef
# install pgplot
## Astro is  user name
setenv PGPLOT_DIR /Users/Astro/psrsoft/pgplot
setenv PGPLOT_SRC /Users/Astro/psrsoft/src/pgplot


mkdir -p /Users/Astro/psrsoft/pgplot
cd /Users/Astro/psrsoft/src/pgplot

cd $PGPLOT_DIR 
cp $PGPLOT_SRC/drivers.list ./
# select Postscript
perl -pi -e 's/! PSDRIV/  PSDRIV/' drivers.list
# select X windows
perl -pi -e 's/! XWDRIV/  XWDRIV/' drivers.list

./../src/pgplot/makemake ../src/pgplot psrmac psrpgplot
perl -pi -e 's|pgplot.doc: $(PG_SOURCE)|#pgplot.doc: $(PG_SOURCE)|g' makefile
make 
make cpg
make clean

mkdir -p  /Users/Astro/psrsoft/lib
mkdir -p  /Users/Astro/psrsoft/include
ln -s *.dylib *.a ../lib/
ln -s *.h ../include/

terminal中执行:

chmod +x install_pgplot.csh
./install_pgplot.csh

安装epsic

创建执行脚本,可命名为install_epsic.csh,(在treminal中逐条执行也可),内容如下:

#!/bin/csh -ef
cd /Users/Astro/psrsoft/src
if ( ! -d epsic ) then
  echo "Downloading EPSIC source code from github"
  setenv EPSIC_GIT https://github.com/straten/epsic.git
  git clone $EPSIC_GIT
	git pull
endif

#scp -r parkes:/u/xie028/epsic ./
cd epsic/src
./bootstrap
./configure --prefix=/Users/Astro/psrsoft/ CC=gcc-11 CXX=g++-11

make
make install

echo
echo
echo "EPSIC library installation completed"
echo
echo "------>"

terminal中执行:

chmod +x install_epsic.csh
./install_epsic.csh

安装psrcat

脚本内容如下:

#!/bin/csh -ef
# install psrcat

cd /Users/Astro/psrsoft/src
setenv URL http://www.atnf.csiro.au/research/pulsar/psrcat/downloads
if ( ! -f psrcat.tar.gz ) then
  /Users/Astro/opt/anaconda3/bin/wget ${URL}/psrcat_pkg.tar.gz
endif

gunzip -c psrcat_pkg.tar.gz | tar xvf -
cd psrcat_tar
csh makeit
mkdir -p /Users/Astro/psrsoft/bin
mv psrcat /Users/Astro/psrsoft/bin
mkdir -p /Users/Astro/psrsoft/psrcat
mv psrcat.db /Users/Astro/psrsoft/psrcat

echo
echo
echo "PSRCAT installation completed"
echo
echo "To use psrcat, please set the environment variable"
echo

执行脚本!
注意;1.67版本的psrcat.db存在问题,需要下载老版本中的psrcat.db替换。

安装tempo

脚本内容如下:

#!/bin/csh -ef
cd /Users/Astro/psrsoft/


if ( ! -d tempo ) then

    echo "Downloading tempo source code ..."
    git clone git://git.code.sf.net/p/tempo/tempo
endif


cd tempo

./prepare
./configure F77=gfortran --prefix=/Users/Astro/psrsoft CC=gcc-11
make
make install

echo
echo
echo "tempo installation completed"
echo
echo
echo

如果是M1芯片,在使用gfortran 将不再支持real *10的数据类型,在执行安装tempo的脚本,会报错,这是因为gfortran编译器导致的,所以要将/tempo/src/bnrydds.f

第45行由

real*10 frb, tt0, tt, orbits

改为:

real*16 frb, tt0, tt, orbits

相关的解释:

相比于C++,Fortran中的数据类型有整型(integer)、实型(real)、复数型(complex)、逻辑型(logical)、字符型(character)等,没有类似于C++中的修饰符。

由于C++中可通过修饰符控制变量的精度范围,类似地,在Fortran中,可通过Kind值来控制精度范围,对于Real来说,其Kind值一般为4、8、16,对于大多数编译器,Kind 默认是 4,占有 4 个字节。不同的Kind值,其取值范围不一样。由于某些编译器不支持Kind=16,而M1芯片下安装的gfortran不支持Kind=10,而某些编译器用1、2、3表示,为了代码的适用性和统一性,可以使用函数Selected_Real_Kind,即k = Selected_Real_Kind(r,p) 来选择能满足要求的Kind,其中r 表示需要最大的十进制位数 , p 表示最小的有效位数,k 表示返回的能满足范围的最小的Kind值。为了保证足够的精度范围,改为real*16是合理的。

在更改参数后,继续执行以下命令:

make clean
make 
make install

安装tempo2

#!/bin/csh -ef
# install tempo2


if ( ! $?TEMPO2 ) setenv TEMPO2 /Users/Astro/psrsoft/tempo2


cd /Users/psrsoft

if ( ! -d tempo2 ) then

  echo "Downloading TEMPO2 source code from bitbucket"

  setenv TEMPO2_GIT https://bitbucket.org/psrsoft/tempo2.git
  git clone $TEMPO2_GIT

endif

cd tempo2
git pull

mkdir -p $TEMPO2
#rsync -at T2runtime/* $TEMPO2

make clean
./bootstrap
./configure  F77=gfortran --prefix=$ASTROSOFT --with-cfitsio-dir=$ASTROSOFT --with-fftw3-dir=$ASTROSOFT  CFLAGS=-fPIC FFLAGS=-fPIC CXXFLAGS="-I$ASTROSOFT/include -I$PGPLOT_DIR" LDFLAGS=-L$PGPLOT_DIR CC=gcc-11 CXX=g++-11
make
echo "make done"
make install
echo "make install done"
make plugins && make plugins-install
echo "make plugins done"

## 如果以下命令失败,需手动设置./unsupported_plugins/makefile中的FCLIBS和CPPFLAGS参数
perl -pi -e 's|CPPFLAGS = -I//include -I/usr/local/include|CPPFLAGS = -I//include -I/usr/local/include -I/opt/homebrew/include|g' ./unsupported_plugins/makefile
perl -pi -e 's|FCLIBS =  -L/usr/local/lib -L/Users/Astro/psrsoft/pgplot -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11 -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11/../../.. -lgfortran -lgomp -lemutls_w -lquadmath|FCLIBS =  -L/usr/local/lib -L/Users/Astro/psrsoft/pgplot -L/opt/homebrew/lib -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11 -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11/../../.. -lgfortran -lgomp -lemutls_w -lquadmath|g' ./unsupported_plugins/makefile



## 如果以下命令失败,需手动设置./unsupported_plugins/toasim/makefile中的FCLIBS和CPPFLAGS参数
perl -pi -e 's|CPPFLAGS = -I//include -I/usr/local/include|CPPFLAGS = -I//include -I/usr/local/include -I/opt/homebrew/include -I/Users/Astro/psrsoft/pgplot|g' ./unsupported_plugins/toasim/makefile
perl -pi -e 's|FCLIBS =  -L//lib -L/usr/local/lib -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11 -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11/../../.. -lgfortran -lgomp -lemutls_w -lquadmath|FCLIBS =  -L/usr/local/lib -L/Users/Astro/psrsoft/pgplot -L/opt/homebrew/lib -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11 -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11/../../.. -lgfortran -lgomp -lemutls_w -lquadmath|g' ./unsupported_plugins/toasim/makefile

## ./unsupported_plugins/glas/makefile
perl -pi -e 's|CPPFLAGS = -I//include -I/usr/local/include|CPPFLAGS = -I//include -I/usr/local/include -I/opt/homebrew/include -I/Users/Astro/psrsoft/pgplot|g' ./unsupported_plugins/glas/makefile
perl -pi -e 's|FCLIBS =  -L//lib -L/usr/local/lib -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11 -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11/../../.. -lgfortran -lgomp -lemutls_w -lquadmath|FCLIBS =  -L//lib -L/usr/local/lib -L/Users/Astro/psrsoft/pgplot -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11 -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc -L/opt/homebrew/Cellar/gcc/11.3.0_1/bin/../lib/gcc/11/gcc/aarch64-apple-darwin21/11/../../.. -lgfortran -lgomp -lemutls_w -lquadmath|g' ./unsupported_plugins/glas/makefile

make unsupported
echo "make umsuppoorted done"
make clean

echo
echo
echo "TEMPO2 library installation completed"
echo
echo
echo 'setenv TEMPO2 /Users/psrsoft/tempo2'
echo
echo

安装Psrchive

## install psrchive
cd /Users/psrsoft

if ( ! -d psrchive ) then

    echo "Downloading psrchive source code ..."
    git clone https://git.code.sf.net/p/psrchive/code psrchive

endif


cd psrchive

make clean
./bootstrap
./configure F77=gfortran --prefix=$ASTROSOFT --enable-shared --with-cfitsio-dir=$ASTROSOFT --with-fftw3-dir=$ASTROSOFT CFLAGS=-fPIC FFLAGS=-fPIC LDFLAGS="-L/usr/local/lib -L/$ASTROSOFT/lib"  CC=gcc-11 CXX=g++-11
make
make install
make clean

echo
echo
echo "psrchive installation completed"
echo
echo

安装dspsr

cd $ARTROSOFT
if ( ! -d dspsr ) then

    echo "Downloading dspsr source code ..."
    git clone https://git.code.sf.net/p/dspsr/code dspsr
    git pull
endif
cd dspsr
echo "apsr asp bcpm bpsr caspsr cpsr2 cpsr dummy fits gmrt guppi kat lbadr64 lbadr lump lwa mark4 mark5 maxim mwa pdev pmdaq s2 sigproc spda1k spigot vdif" > backends.list

./bootstrap
./configure --prefix=$ASTROSOFT --with-cfitsio-dir=$ASTROSOFT CC=gcc-11 CXX=g++-11 F77=gfortran CFLAGS=-fPIC FFLAGS=-fPIC  --with-fftw-dir=$ASTROSOFT  CPPFLAGS="-I$ASTROSOFT/include -I/opt/homebrew/include" LDFLAGS="-L$ASTROSOFT/lib -L$PGPLOT_DIR -L/usr/lib -L/opt/homebrew/lib"
make
make install
make clean


由于不同版本的编译器之间存在差异,在11.3.0的arm版本的g++可能需要对某些函数的名称进行修改,在变编译dspsr的过程中可能出现以下报错信息:

error: no matching function for call to ‘finite(const float&)’

​ ~~~~ (!finite(*from))

这是因为编译器不支持finite函数,但是经过查阅编译器支持的是isfinite函数,所以只需要将以下文件中的finite改为isfinite即可:

./Signal/Pulsar/Archiver.C

./Signal/Statistics/sk_limit_plot.C

./Signal/Statistics/PearsonIV.C

./Signal/General/Dump.C

./Signal/Statistics/sk_distrib_plot.C

./Kernel/Classes/TimeSeries.C

安装 sigproc

M1芯片暂时无法安装

$ cd ..
$ git clone http://github.com/SixByNine/sigproc.git
$ cd sigproc 
$ ./bootstrap
$ ./configure --prefix=$ASTROSOFT --with-cfitsio-dir=$ASTROSOFT --with-fftw-dir=$ASTROSOFT F77=gfortran CFLAGS=-fPIC FFLAGS=-fPIC CPPFLAGS=-I$ASTROSOFT/include LDFLAGS="-L$ASTROSOFT/lib -L$PGPLOT_DIR -L/usr/local/lib" CC=gcc-11 CXX=g++-11



更改sigproc/src/swap_bytes.c, 修改其中函数int little_endian(),修改内容如下:

int little_endian() /*includefile*/

{

    char *ostype;

    if((ostype = (char *)getenv("OSTYPE")) == NULL )

        error_message("environment variable OSTYPE not set!");

    if (strings_equal(ostype,"linux")) return 1;

    if (strings_equal(ostype,"hpux")) return 0;

    if (strings_equal(ostype,"solaris")) return 0;

    if (strings_equal(ostype,"darwin")) return 0;

    return 0;

}
$ make
$ make install
$ make clean

sigproc 中的fold命令在会与系统中默认存在的fold命令重叠,当运行fold 命令时会默认运行系统中的fold命令,系统中的fold命令是用于限制文件的列宽,并非折叠脉冲,所以需要对其中一个命令进行重命名,以区分两条命令,比如可以进入**/PSRSOFT_DIR/bin目录下,将fold文件改为foldp**,在之后折叠脉冲信号数据的时候运行foldp命令而非fold命令即可。当然,也可以卸载系统默认安装的fold的程序。
这个问题在linux系统中也存在。

安装presto

$ cd .. 
$ git clone https://github.com/scottransom/presto.git
$ cd presto/src 

编辑Makefile,修改内容如下所示:

CC=gcc-11

接下来继续安装presto

$ make 

安装presto的Python部分

首先编辑presto目录下的setup.py文件

extra_compile_args = ["-DUSEFFTW -fPIC CC=gcc-11 CXX=g++-11"]
include_dirs = [numpy.get_include(),"/opt/homebrew/include","/usr/local/include"]
ppgplot_library_dirs = ["/usr/X11R6/lib","\$PGPLOT_DIR"]
presto_library_dirs = ["/Users/ASTRO/psrsoft/lib","/opt/homebrew/lib"]

运行setup.py,因为我在系统中安装了anaconda,并默认python为anaconda中的python,而且此时(2020年7月)的presto中的python部分用的是python3,所以还请注意python版本!

$ python setup.py build
$ python setup.py install

注意

Anaconda中的numpy可能存在不兼容的问题,运行DDplan.py命令错误信息如下:

Traceback (most recent call last):
  File "/Users/Astro/opt/anaconda3/bin/DDplan.py", line 6, in <module>
    from Presto.Pgplot import *
  File "/Users/Astro/opt/anaconda3/lib/python3.9/site-packages/Presto/Pgplot.py", line 22, in <module>
    import _ppgplot as ppgplot
ImportError: dlopen(/Users/Astro/opt/anaconda3/lib/python3.9/site-packages/_ppgplot.cpython-39-darwin.so, 0x0002): Symbol not found: ___addtf3
  Referenced from: /opt/homebrew/Cellar/gcc/11.3.0_1/lib/gcc/11/libgfortran.5.dylib
  Expected in: /Users/Astro/opt/anaconda3/lib/libgcc_s.1.1.dylib

重新安装numpy后问题解决:

pip uninstall numpy
pip install numpy

到此软件安装完毕

另外一种安装方法

此方法是利用conda创建环境,然后安装,具体方法为:

##创建一个新环境:
conda create -n pulsar
##安装dspsr+psrchive+tempo2:
conda install -c conda-forge dspsr
##进入pulsar环境,进入此环境后即可使用dspsr、psrchive和tempo2的相关命令:
conda activate pulsar
##退出pulsar环境:
conda deactivate

Note

如果系统为CentOS Linux,请参照下面链接的文章

链接: http://www.ljtwebdevelopment.com/pulsarref/pulsar-software-install-centos-64bit.html.

Note: 或许将可以使用以下命令,将terminal转成x86的安装会更方便:

arch -x86_64 $SHELL
  • 6
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 12
    评论
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Persus

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值