MACOS 脉冲星天文软件安装psrcat pgplot tempo tempo2 psrchive等

需要安装的包括pgplot,psrcat,tempo, tmepo2,psrchive等等。

准备工作

设置路径:

我使用的终端是iterm,花里胡哨,彩的,好定位,喜欢喜欢。

各种天文软件基于其落后性,基本要手动设置路径才能成功调用。

我把所有下载的天文软件放进了一个文件夹,设置了一个总路径。然后根据需求再设置各个路径。编辑 ~/.bash_profile[具体编辑哪个文件需要根据自己的系统,比如ubantu一般是bashrc,一定要搞清楚是哪个文件],可以vim,open啥的看个人习惯。这里的user要改成自己,也就是xxxx要改自己的用户名。

# Path to the pulsar software installation directory eg:
export PSRSOFT_DIR=/Users/XXXXXXX/Desktop/pulsar_software(这里是放软件的文件夹)

# OSTYPE
export OSTYPE=macOS

再在终端

source ~/.bash_profile

这里随着软件的安装需要随时添加需要的路径。后续会将具体的设置。

PSRCAT

用于查询脉冲星的各类参数,可以直接从网页上调取The ATNF Pulsar Catalogue,安装后的所有功能网页版均能实现,不一定非要安装。但安装后,可以输出表格,弄成csv格式,易于编程调用。

下载网页:The ATNF Pulsar Catalogue | Download

需要注意的是macos系统,自从六十几版本往后不能较好的使用,只有最最最基础的功能,是源代码的问题。具体解决方案见 https://blog.csdn.net/Kassisong1996/article/details/129590709?spm=1001.2014.3001.5501 

其实不同版本就是隔一段时间把新发现的脉冲星更新进来,如果研究一些比较“知名的”脉冲星,如0332+5434等,安装62版本甚至更早是完全没问题的。

[题外话:psrcat的安装说明是我个人最喜欢的一个,成功后还有一些例子,可以帮新手快速入手]

按照README解压文件,进入路径:

To unpack the distribution

> gunzip psrcat_pkg.tar.gz
> tar -xvf psrcat_pkg.tar

This will make a directory called psrcat_tar containing the source files
and the public catalogue.  

To produce the binary (checked on linux with gcc v2.95.4, solaris and Mac OS X 10.3):

> cd psrcat_tar
> source makeit

This will produce a binary file "psrcat" which can be run as follows:

> psrcat -db_file psrcat.db

For help type:

> psrcat -h

理论上psrcat是最好安装的天文软件,基本不存在安装失败的情况。但会安装后,使用psrcat -h,说没这个命令,而且example里需要一直输入.db,很麻烦。需要设置路径。

在前文准备好的$PSRSOFT_DIR基础上,在~/.bash_profile里添加路径,第一行默认调用.db文件,以后直接psrcat -c ’name ...就可以啦!第二行是任何时间!任何地点!直接调用psrcat,再也不会出现zsh: command not found: psrcat啦!(大概)

export PSRCAT_FILE=$PSRSOFT_DIR/psrcat_tar/psrcat.db
export PATH="$PSRSOFT_DIR/psrcat_tar:$PATH"

pgplot

我最讨厌的软件之一,非常难搞。版本极其落后,没有维护。而且ubantu挺难装的,要改各种文件,装完还经常画不出图。需要研究半天才能出结果图。但各种软件又非常依赖这个画图,真的不能吃点好的么??

首先看看官网:

PGPLOT Graphics Subroutine Library

最新版本是2001年的,再也没有更新,20多年没维护的软件,还是脉冲星画图必不可少的软件,我谢。

看官方安装说明:

https://sites.astro.caltech.edu/~tjp/pgplot/install.html

可以说是毫无用处。

去谷歌查了一下,找到一个好人13年在mac上安装的经历,虽然他/她是x86,但我还是决定按这个网页试一下:
How I did install PGPLOT

p.s.以及本杰明大佬的文档:Compiling PGPLOT on Mac OS X

按照说明,拥有 MacPorts 的情况下,一键成功(以下是成功后的output):

sudo port install pgplot
Password:
--->  Computing dependencies for pgplot
--->  Cleaning pgplot
--->  Scanning binaries for linking errors
--->  No broken files found.
--->  No broken ports found.
port installed pgplot
The following ports are currently installed:
  pgplot @5.2.2_13+gcc12+x11 (active)

接着还要安装x11用于画图,参照说明,我安装后的版本是:

port installed xorg-server
The following ports are currently installed:
  xorg-server @1.20.11_1 (active)

接着是设置路径,需要根据安装成功的内容check,找不到可以先用pkg-config --variable=xxxxxx找,再用find找具体路径。

我的pgplot路径和文档里一样是:

export PGPLOT_DIR=/opt/local/lib

lib里有几个有关pgplot的文件,长这样:

还要在bash里设置PGPLOT_DEV用于画图,说明里说的位置是:

export PGPLOT_DEV=/Xserve

我的不是,我的是:

PGPLOT_DEV=/opt/local/lib/X11/xserver

 source ~/.bash_profile后,就可以测试demo了:

在pgplot的examples路径下找想画图的demo,但不能像文档直接调用,一定要先把demo编译一下,不然会提示没有文件

编译语句见文档测试下面一部分,修改input和output的文件名

gfortran -o pgdemo1 pgdemo1.f -L/opt/local/lib -lpgplot -lX11

编译完demo1,开始画图,直接输入./pgdemo1,会让你选择画图的工具,可以使用"?"看看有哪些选项,我的提示与选择:

然后就可以等x11把图画出来啦!

P.S.使用control+c退出,这里我也想吐槽交互性问题…… 图形界面的小叉叉是摆设,hhh

之前出问题的版本:问题出在后边demo无法显示,现在没找到问题所在【找到原因是画图的路径没设置对】。但按照说明examples路径下测试了“自己的文件”

gfortran -o outputFileName pgdemo1.f -L/opt/local/lib -lpgplot -lX11
gfortran pgdemo1.f

没报错,而且显示了一堆文件信息。确定装好了。​​​​​​​

Tempo

找到官网Tempo

根据官网选择自己喜欢的方法下载文件:

git clone git://git.code.sf.net/p/tempo/tempo

找到下好的文件夹(万一不在脉冲星软件的文件夹,记得移过去)

~./bash_profile里添加路径:

# Tempo
export TEMPO=$PSRSOFT_DIR/tempo

添加后,要source

source ~/.bash_profile

按照文件夹里的README依次:

  ./prepare
  ./configure
  make
 sudo make install

dbq,当时跑这里忘记记录了,窗口也关了。记得是make时有报错。

(查了history)有一个'*bootstrap*'的文件,53行,好像。有个READ*10的精度不能用了,应该是苹果硬件M1设计的问题,这里要改成unit 8 还是什么。反正按照报错改完后,再make就好了。

[可以随时make clean后再make,可以防止上一轮的问题盖了本轮的make]

注意可能需要sudo权限install,所以按说明make install可能会报错。

可以使用

tempo -h

测试,应该会有说明输出。如果没有,可以再source ~/.bash_profile试试。

TEMPO2

tempo2的安装比较顺利。

找到官网:

https://www.atnf.csiro.au/research/pulsar/tempo2/

找下载文件,今年竟然更新了,感动:

psrsoft / tempo2 / Downloads — Bitbucket

按照官网说明安装(往下拉,看readme): 

https://bitbucket.org/psrsoft/tempo2/src/master/

./bootstrap
./configure
make && make install

这里也有权限问题,要sudo make && make install.可以分开make和sudo make install

make plugins && make plugins-install

bash里添加路径

# Tempo2
export TEMPO2=$PSRSOFT_DIR/tempo2/T2runtime

再source

测试help,有如下输出。

>>tempo2 -h

This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under conditions of GPL license.


Tempo2 2022.01.1

examples: tempo2 mytim.tim
          tempo2 -f mypar.par mytim.tim
          tempo2 -gr plk -f mypar.par mytim.tim

psrchive

非常有用,脉冲星数据处理的神。必须要装XD。

找到官网:

PSRCHIVE

到install目录下的Download链接:

PSRCHIVE: Git Access

按说明下载:

git clone git://git.code.sf.net/p/psrchive/code psrchive

确定文件路径正确后,进去安装说明界面:

PSRCHIVE: Git Build and Installation

按照说明开始安装,但我安装过程中出现了各种莫名奇妙的问题。

首先按照说明

cd psrchive
./bootstrap
./configure

成功configure后,提示我make,然后出现了各种问题,首先是

ReferenceAble.C:56:13: error: reference to 'recursive_mutex' is ambiguous     mutex = recursive_mute
......

按照报错找ReferenceAble.C文件

find /【路径】../.. -name 'ReferenceAble.C'

找到在

....../psrchive/Util/units/ReferenceAble.C

打开这个C文件,把报错的recursive_mutex函数全部(特指2个)改名为Recursive_mutex

然后再make,再报错:

StokesCovariancePlot.C:206:18: warning: unused variable 'e2' [-Wunused-variable]
    const float* e2 = stats->get_eigen_value(2)->get_amps();
                 ^
StokesCovariancePlot.C:282:3: error: reference to 'set' is ambiguous
  set (plotter.plot_sci, plot_colours);
  ^

……………………

然后再find, 找到StokesCovariancePlot.C文件在

.../psrchive/More/Plotting/StokesCovariancePlot.C

这边说set引发了歧义,说是set和默认函数重复了,so要改。那就改,把set改成setVector:

void setVector (vector<int>& to, const std::string& from)
{
  if (from == "")
    return;

  to.resize( from.length() );
  for (unsigned i=0; i<from.length(); i++)
    to[i] = from[i] - '0';
}

// ...

void Pulsar::StokesCovariancePlot::get_profiles (const Archive* data) try
{
  // ...

  setVector (plotter.plot_sci, plot_colours);
  setVector (plotter.plot_sls, plot_lines);
  setVector (plotter.plot_slw, plot_widths);

  // ...
}

再make,终于成功了:

PSRCHIVE 2023-01-24+ successfully compiled.  Remember to "make install"

再按说明:

make check

有一些warning,但没有报错。

继续,记得sudo权限:

sudo make install

成功:

PSRCHIVE 2023-01-24+ has been installed in /usr/local


            If you make use of PSRCHIVE, please cite
             Hotan, van Straten & Manchester (2004)
           http://www.publish.csiro.au/?paper=AS04022

(base) ➜  psrchive git:(master) ✗ psrchive -h

Usage: psrchive [OPTION]

Known values for OPTION are:

  --prefix              installation directory
  --libs                library linking information
  --cppflags            pre-processor flags
  --cflags              pre-processor and compiler flags
  --html                web page layout directory
  --aclocal             autoconf macro directory
  --help                this help message
  --version             version information
  --pgplot-libs         PGPLOT linking information
  --qt-libs             Qt linking information

PRESTO

我与presto相爱相杀多年,各种依赖,目前只在ubantu18上安装成功过,mac目前严重怀疑M芯片不能成功编译,毁灭吧。作者亲自认证过的问题,目前不知道编译失败和这个有没有直接关联,但很可能是硬件的问题导致最终编译失败。我先研究着,留坑。

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值