0%

CODE contribution policy

Everybody is encouraged to help improve the quality of the code.
You can help by reporting issues or even better fix issues yourself.

If you have a patch for CODE we use the github pull request system.

Also to keep the CODE code quality high we have written down some guidelines for contributing, see below.

General considerations

If you have problems or questions with/about git or github, first check [1].
If you modify any code, make sure the test suite still runs (make test). If it fails, fix the code or the relevant test.
If you change a function/method signature, update the doxygen documentation accordingly.
If you add a function or method, add a test for it add it to the doxygen documentation.
The tested code coverage line count should increase, not decrease.
Follow the google style code as much as possible [2].

Contribution procedure

Create a github account, setup SSH keys.
Fork the CODE repository on github [3].
Create a branch and commit your changes to this branch.
Push your branch to your github fork (not the original CODE, you probably don’t have permission).
Issue a pull request [4].
When the pull request is reviewed and there are no problems it will be accepted. Merging a pull request should always happen by someone else.
It can happen there are some mistakes here and there, we use the github commenting system to discuss these issues.
If there is a problem with the commit, you need to fix it. You can commit to the same branch, the PR will be updated automatically.

General notes about Pull requests

Please create descriptive commits containing atomic changes. Use short commit messages (try 50 characters, max is 70 characters); longer commit messages are possible in the body of the commit message (separated from the subject by an empty line). See [5].
If you fix an existing github issue, reference it in the commit message body, e.g. ‘Fixes #41’.
If your Pull request does not refer to an existing github issue, it is not necessary to create one (because github will present the PR just like an issue).
You can rewrite the history of the commits in your branch using rebase, but don’t rewrite the history before the first commit of your new branch.
We like to keep the history clean, and prevent a lot of ‘fix typo’ messages.
If you rewrite your history of your branch you can force push those changes to your branch. The PR will be updated. See e.g. [6].

[1] http://help.github.com
[2] https://google-styleguide.googlecode.com/svn/trunk/cppguide.html
[3] https://help.github.com/articles/fork-a-repo/
[4] https://help.github.com/articles/creating-a-pull-request/
[5] https://chris.beams.io/posts/git-commit
[6] https://developer.atlassian.com/blog/2015/04/force-with-lease/

Refer

https://github.com/casacore/casacore/blob/master/CONTRIBUTING.md

CASA

CASA : The Common Astronomy Software Applications packages

  • Single Dish
  • ALMA and VLA
  • CASA VLBI

Download

  • CASA 6.1 -python3
  • CASA 5.7 -python2.7

Data Format

MS : the standard CASA data format

Starting CASA

1
casa

The output from CASA commands is sent to the file casa-YYYYMMDD-HHMMSS.log.

CASA tasks

Just like tget listobs in aips

1
2
CASA <1> : default ('listobs')
CASA <2> : inp

CASA tasks : Python scripts

Standard input

1
listobs (vis='EXMPL.ms', listfile='EXMPL.listfile')

Outside CASA, using casa -c yourfile.py.

CASA PlotMS

PlotMS

  • can diplay X-Y plots of visibility data and calibration tables
  • can be started inside a CASA shell or as a stand-alone executable

CASA Viewer

Can display both images and MS file

CASA vs AIPS

CASA calibration tables

Plot tools in CASA

Why ploting

What should we look at ?

  • Actual (visibility) data or calibration solutions
  • Antenna- or baseline-based data
  • Multi-dimensional data : baselines,source,times,frequenciese(subbands,channels),polarizations,…

plotms

Inside the CASA

Outside the CASA

viewer

Inside CASA

1
viewer(vis='n14c3.ms')

Outside

1
casaviewer vis="n14c3.ms"

plotcal

Only in CASA 5.7-

Other tools …

  • jplotter
  • AOFlagger
  • CARTA : possible future replacement for DS9,kvis(casaviewer)

如何在CentOS上安装DiFX

如果只是使用,那么可以使用下面一个命令来获取DiFX的运行环境(需要安装docker):

1
$ docker run -it shaoguangleo/centos-difx

如果希望运行图形界面,运行下述命令:

1
$ docker run -it -e DISPLAY=unix$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix shaoguangleo/centos-difx

如果希望体验一下DiFX的安装,那就开始吧。

最简单的安装方法可以参考一步安装DiFX,star或者follow后提供比较大的压缩包。

操作系统

  • CentOS 6.3
  • CentOS-7.0
  • CentOS-8.0

DiFX版本

  • DiFX-2.1
  • DiFX-2.4
  • DiFX-2.5.1
  • DiFX-2.6.2
  • DiFX-2.7.0
  • DiFX-2.8.1

前提配置:

首先更新系统;

1
2
$ yum update
$ yum upgrade

安装依赖软件包

1
2
3
4
5
6
7
$ yum install pkgconfig bison  
$ yum install fftw-devel openmpi-dev openmpi-bin
$ yum install openmpi gcc-gfortran libgfortan libgfortan-static expat expat-devel expat-static
$ yum install subversion doxygen
$ yum install automake autoconf
$ yum install libtool* flex*
$ yum install libfftw3-dev libopenmpi-dev libexpat1-dev

安装步骤:

(一)、安装 Intel.Integrated.Performance.Primitives(IPP)

一路默认安装就可以了,默认安装到/opt/intel/ipp中(假设安装的路径为:/opt/intel/ipp/5.3/ia32/)。
添加环境变量:

如果是以前的版本,需要自己指定IPPROOT及相应信息,如下所示:

1
export IPPROOT=/opt/intel/ipp/5.3/ia32

对于比较新的版本,可以只指定

1
export IPPROOT=/opt/intel/

剩下的交给DiFX去处理。

在安装DiFX的时候出现这个问题。

运行install.sh出现:

1
2
3
4
5
6
*ERROR: Unable to find rpm tool, please add its location to your PATH and restart installation
Installation failed.
Please see /var/log/ipp_em64t_install.log for details.*

*Installation is complete:* *
Thank you for using Intel Software Development Products, tools for improving application performance.

解决方法为: **/install/install --nonrpm**

这个bug在ipp5.3和ipp6.0都是存在的,从ipp6.1开始修复,对于全新的IPP,多个版本可以共存安装。

(二)、pgplot5.2.tar.gz的安装.

参考 Ubuntu/Debain/Fedora/Mac/CentOS 安装PGPLOT

添加环境变量:

1
2
$ export  PGPLOT_DIR=/usr/local/pgplot/
$ export PGPLOT_DEV=/xwindow

(三)、mpich的安装

1
2
3
$./configure --prefix=/usr/local/mpich 2>&1 | tee c.txt
$ make 2>&1 | tee m.txt
$ make install 2>&1 | tee mi.txt

添加环境变量:

1
2
PATH=/usr/local/mpich/bin:$PATH; export PATH
export MPICXX=/usr/local/mpich/bin/mpicxx

(四)、 fftw的的安装

1
2
3
4
5
6
7
8
9
10
11
12
13
$ ./configure --enable-shared --enable-threads --enable-float
$ make -j 2
$ make install
$ make clean
$ ./configure --enable-shared --enable-threads --enable-long-double
$ make -j 4
$ make install
$ make clean
$ ./configure --enable-sse2
$ make -j 4
$ make install
$ make clean
$ updatedb

(五)、 DiFX‐2.4.1的安装

执行./genipppc

修改setup.bash文件的如下部分(深红的部分)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
####### DIFX VERSION ########################
export DIFX_VERSION=DiFX-2.1.1

####### ROOT PATHS ##########################
export DIFXROOT=/usr/local/difx
export DIFX_PREFIX=$DIFXROOT
export PGPLOTDIR=/usr/local/pgplot
export IPPROOT=/opt/intel/ipp/5.3/ia32

####### COMPILER ############################
export MPICXX=/usr/local/mpich/bin/mpicxx

####### USE GFORTRAN IN PREFERENCE TO G77? ##
####### Comment out if not desired ##########

$ mkdir /usr/local/difx
$ Source setup.bash
$ ./install-difx
$ ./install-difx --withhops
$ ./install-difx --withfb
1
$ cp init.d/calcserver  /etc/init.d

注:若不能运行成功则应向:DiFX-2.1/mpifxcorr/src/fxmanager.cppDiFX-2.1/mpifxcorr/utils/dedisperse_difx.cpp 中添加语句 #include <cstring> 若还不能成功运行则可根据错误提示安装相应的软件。

(六)、最后安装 portmap 程序包以启动rpc (yum install portmap 、yum install rpc)

(七)、总结如下:

DiFX的安装顺序如下:

  • difxio
  • difxmessage
  • mark5access
  • vdifio
  • mpifxcorr
  • calcserver
  • calcif2
  • difx2fits
  • vex2difx
  • difx2mark4
  • pulsar/difx2profile
  • misc
  • vsi2screen

OUTPUT

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
\u@\h DiFX-2.4.1 \W> source setup.bash
DiFX version DiFX-2.4.1 is selected
\u@\h DiFX-2.4.1 \W> ./install-difx
************************************
Getting environmental variables

************************************
Setting up directories

/home/AstroSoft/DiFX2.4.1/lib/pkgconfig/ipp.pc already exists



************************************
Building difxio/

libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
difxio/Makefile.am:43: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
tests/Makefile.am:1: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
utils/Makefile.am:1: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
Building page list...
Search for main page...
Computing page relations...
Determining the scope of groups...
Sorting lists...
Freeing entry tree
Determining which enums are documented
Computing member relations...
Building full member lists recursively...
Adding members to member groups.
Computing member references...
Inheriting documentation...
Generating disk names...
Adding source references...
Adding xrefitems...
Sorting member lists...
Computing dependencies between directories...
Generating citations page...
Counting data structures...
Resolving user defined references...
Finding anchors and sections in the documentation...
Transferring function references...
Combining using relations...
Adding members to index pages...
Generating style sheet...
Generating example documentation...
Generating file sources...
Generating file documentation...
Generating docs for file src/alert.cpp...
Generating docs for file src/alert.h...
Generating docs for file src/architecture.h...
Generating docs for file src/configuration.cpp...
Generating docs for file src/configuration.h...
Generating docs for file src/core.cpp...
Generating docs for file src/core.h...
Generating docs for file src/datamuxer.cpp...
Generating docs for file src/datamuxer.h...
Generating docs for file src/datastream.cpp...
Generating docs for file src/datastream.h...
Generating docs for file src/fxmanager.cpp...
Generating docs for file src/fxmanager.h...
Generating docs for file src/mark5bfile.cpp...
Generating docs for file src/mark5bfile.h...
Generating docs for file src/mark5bmark5.cpp...
Generating docs for file src/mark5bmark5.h...
Generating docs for file src/mark5bmark5_stubs.cpp...
Generating docs for file src/mark5dir.cpp...
Generating docs for file src/mark5dir.h...
Generating docs for file src/mark5directorystructs.cpp...
Generating docs for file src/mark5directorystructs.h...
Generating docs for file src/mark5utils.cpp...
Generating docs for file src/mark5utils.h...
Generating docs for file src/mk5.cpp...
Generating docs for file src/mk5.h...
Generating docs for file src/mk5mode.cpp...
Generating docs for file src/mk5mode.h...
Generating docs for file src/mode.cpp...
Generating docs for file src/mode.h...
Generating docs for file src/model.cpp...
Generating docs for file src/model.h...
Generating docs for file src/mpifxcorr.cpp...
Generating docs for file src/mpifxcorr.h...
Generating docs for file src/nativemk5.cpp...
Generating docs for file src/nativemk5.h...
Generating docs for file src/nativemk5_stubs.cpp...
Generating docs for file src/pcal.cpp...
Generating docs for file src/pcal.h...
Generating docs for file src/pcal_impl.h...
Generating docs for file src/polyco.cpp...
Generating docs for file src/polyco.h...
Generating docs for file src/pthreadbarrier.h...
Generating docs for file src/switchedpower.cpp...
Generating docs for file src/switchedpower.h...
Generating docs for file src/vdiffake.cpp...
Generating docs for file src/vdiffake.h...
Generating docs for file src/vdiffile.cpp...
Generating docs for file src/vdiffile.h...
Generating docs for file src/vdifmark5.cpp...
Generating docs for file src/vdifmark5.h...
Generating docs for file src/vdifmark5_stubs.cpp...
Generating docs for file src/vdifnetwork.cpp...
Generating docs for file src/vdifnetwork.h...
Generating docs for file src/visibility.cpp...
Generating docs for file src/visibility.h...
Generating docs for file src/watchdog.cpp...
Generating docs for file src/watchdog.h...
Generating page documentation...
Generating group documentation...
Generating class documentation...
Generating docs for compound Alert...
Generating docs for compound Configuration...
Generating docs for nested compound Configuration::baselinedata...
Generating docs for nested compound Configuration::configdata...
Generating docs for nested compound Configuration::datastreamdata...
Generating docs for nested compound Configuration::freqdata...
Generating docs for nested compound Configuration::ruledata...
Generating docs for nested compound Configuration::telescopedata...
Generating docs for compound Core...
Generating docs for nested compound Core::processslot...
Generating docs for nested compound Core::processthreadinfo...
Generating docs for nested compound Core::threadscratchspace...
Generating docs for compound DataMuxer...
Generating docs for compound DataStream...
Generating docs for nested compound DataStream::readinfo...
Generating docs for compound DriveInformation...
Generating docs for compound FxManager...
Generating docs for compound LBA16BitMode...
Generating docs for compound LBA8BitMode...
Generating docs for compound LBAMode...
Generating docs for compound Mark5BDataStream...
Generating docs for compound Mark5BMark5DataStream...
Generating docs for compound Mark5DirectoryHeaderVer1...
Generating docs for compound Mark5DirectoryInfo...
Generating docs for compound Mark5DirectoryLegacyBodyVer1...
Generating docs for compound Mark5DirectoryScanHeaderVer1...
Generating docs for compound Mark5DirectoryVDIFBodyVer1...
Generating docs for compound Mark5LegacyDirectory...
Generating docs for compound Mark5Module...
Generating docs for compound Mark5NeoLegacyDirectory...
Generating docs for compound Mark5Scan...
Generating docs for compound Mk5DataStream...
Generating docs for compound Mk5Mode...
/home/leo/Downloads/DiFX_Install/DiFX-2.4.1/mpifxcorr/src/mk5mode.h:36: warning: The following parameters of Mk5Mode::Mk5Mode(Configuration *conf, int confindex, int dsindex, int recordedbandchan, int chanstoavg, int bpersend, int gsamples, int nrecordedfreqs, double recordedbw, double *recordedfreqclkoffs, double *recordedfreqclkoffsdelta, double *recordedfreqphaseoffs, double *recordedfreqlooffs, int nrecordedbands, int nzoombands, int nbits, Configuration::datasampling sampling, Configuration::complextype tcomplex, bool fbank, bool linear2circular, int fringerotorder, int arraystridelen, bool cacorrs, int framebytes, int framesamples, Configuration::dataformat format) are not documented:
parameter 'recordedfreqclkoffsdelta'
parameter 'recordedfreqphaseoffs'
Generating docs for compound Mode...
Generating docs for compound Model...
Generating docs for nested compound Model::eop...
Generating docs for nested compound Model::scan...
Generating docs for nested compound Model::source...
Generating docs for nested compound Model::spacecraft...
Generating docs for nested compound Model::station...
Generating docs for compound NativeMk5DataStream...
Generating docs for compound PCal...
/home/leo/Downloads/DiFX_Install/DiFX-2.4.1/mpifxcorr/src/pcal.cpp:252: warning: argument 'pcalout' of command @param is not found in the argument list of PCal::extractAndIntegrate_reference(f32 const *data, const size_t len, cf32 *out, const uint64_t sampleoffset)
Generating docs for compound pcal_config_pimpl...
Generating docs for compound PCalExtractorComplex...
Generating docs for compound PCalExtractorDummy...
/home/leo/Downloads/DiFX_Install/DiFX-2.4.1/mpifxcorr/src/pcal.cpp:1248: warning: argument 'pointer' of command @param is not found in the argument list of PCalExtractorDummy::getFinalPCal(cf32 *out)
Generating docs for compound PCalExtractorImplicitShift...
Generating docs for compound PCalExtractorShifting...
Generating docs for compound PCalExtractorTrivial...
Generating docs for compound Polyco...
Generating docs for compound pthread_barrier_t...
Generating docs for compound SwitchedPower...
Generating docs for compound VDIFDataStream...
Generating docs for compound VDIFFakeDataStream...
Generating docs for compound VDIFMark5DataStream...
Generating docs for compound VDIFMuxer...
Generating docs for compound VDIFNetworkDataStream...
Generating docs for compound Visibility...
Generating namespace index...
Generating docs for namespace fxcorr
Generating graph info page...
Generating directory documentation...
Generating index page...
Generating page index...
Generating module index...
Generating namespace index...
Generating namespace member index...
Generating annotated compound index...
Generating alphabetical compound index...
Generating hierarchical class index...
Generating member index...
Generating file index...
Generating file member index...
Generating example index...
finalizing index lists...
lookup cache used 2381/65536 hits=8086 misses=2456
finished...
Done!

Python 虚拟环境 conda

更新镜像更新地址

1
2
$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
$ conda config --set show_channel_urls yes

使用

Conda 是一个开源的软件包管理系统和环境管理系统,用于安装多个版本的软件包及其依赖关系,并在它们之间轻松切换。

安装可以下载一个科学计算包anaconda,怕麻烦的人可以直接安装,自带很多必须包

创建

1
2
3
$ conda create --name AI python=3.7
#or
$ conda create --prefix /the/path/AI python=3.7

使用

1
2
3
4
5
6
7
$ conda env list #查看当前存在的虚拟环境
$ conda activate py3 #激活虚拟环境 activate py3 windows下
# or
$ conda activate /home/share/AI
$ conda install numpy #安装包
$ source deactivate #退出虚拟环境
$ conda remove -n py3 --all #删除虚拟环境

共享环境导出和使用requirement.txt文件

1
2
$ conda list -e > requirements.txt
$ conda install --yes --file requirements.txt

共享环境导出和使用yml文件

1
2
3
4
5
6
$ conda env export > /path/to/environment.yaml
#其中-f表示你要导出文件在本地的路径,所以/path/to/environment.yml要换成你本地的实际路径
$ conda env update -f=/path/to/environment.yml

# 安装yml文件
$ conda env create -f environment.yaml

Troubleshooting

当电脑上安装了Python2 和 python3时,有如下错误:

1
2
3
4
5
raise ImportError('This package should not be accessible on Python 3. '

ImportError: This package should not be accessible on Python 3.

Either you are trying to run from the python-future src folder or your installation of python-future is corrupted

这大概率是因为环境变量PYTHONPATH的原因,重置该环境变量即可。

1
unset PYTHONPATH

即可解决

Python的字符串操作

字符串连接

用+

1
print ('hello' + 'world')

直接连接

1
print ('hello'  ' world')

标准输出的重定向

1
2
3
4
5
6
7
8
9
from io import StringIO
import sys
old_stdout = sys.stdout
result = StringIO()
sys.stdout = result
print('hello','world')
sys.stdout = old_stdout
result_str = result.getvalue()
print(result_str)

格式化输出

1
s = '<%s> <%s>' % ('hello','world')

使用join函数

1
2
s = " ".join(['hello','world'])
print(s)

本篇日志主要讲述了如何在MacOSX和Linux上安装PGPLOT,以避免经历一些不必要的坑。

Ubuntu/Debain/Fedora/Mac/CentOS 安装PGPLOT

最简单的安装方式为使用我提供的docker镜像,参考AstroSoft

只需要下面的一个命令,即可使用。目前支持Ubuntu和CentOS两大发行版。

Ubuntu

1
$ docker run -it -e DISPLAY=unix$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix shaoguangleo/ubuntu-pgplot

CentOS

1
$ docker run -it -e DISPLAY=unix$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix shaoguangleo/centos-pgplot

开始

下面开始正文,源码安装。正常情况下,安装分为两个步骤:

  1. 安装图形库
  2. 配置环境变量
  3. 然后可以使用一些demo来测试程序是否正常运行

Mac 用户

Mac上最方便的安装PGPLOT的方法就是使用port,首先确认已经安装了port,然后执行:

1
$ port installed pgplot

不同的PGPLOT库 (libpgplot.* 和 libcpgplot.*) 安装在 /opt/local/lib 文件夹,X11 服务安装在 /opt/local/bin/pgxwin_server,其他一些文件安装在/opt/local/share/pgplot。

安装完成后,要确定下环境变量是否配置好,可以使用下述命令来检查:

1
2
$ echo $PGPLOT_DIR
$ echo $PGPLOT_DEV

如果环境变量没有设置,可以通过下属命令来设置:

1
2
$ export PGPLOT_DIR=/opt/local/lib
$ export PGPLOT_DEV=/Xserve

当然最好的方法就是把这些环境变量写在.bashrc文件中。

最后确保所有的示例程序工作正常。

1
2
3
4
$ /opt/local/share/pgplot/examples/pgdemo1
$ /opt/local/share/pgplot/examples/pgdemo2
$ /opt/local/share/pgplot/examples/pgdemo3
...

Linux 用户

在Linux系统中,从pgplot下载源码,在Linux里面手动编译的方式比较好,目前最新的版本为pgplot5.2。不过这里比较注意,一个前提条件就是X11文件是可用的,另外一个就是需要安装gfortran编辑器。

不同的系统支持的包不同,详细看下面的命令。

Fedora:

1
2
$ sudo yum install libX11-devel
$ sudo yum install gcc-gfortran

Ubuntu:

1
2
$ sudo apt-get install xorg-dev
$ sudo apt-get install gfortran

CentOS:

1
2
$ sudo yum install libX11-devel
$ sudo yum install gcc-gfortran

OpenSUSE:

1
2
$ sudo zypper install xorg-X11-devel
$ sudo zypper install gcc-fortran

Debian:

1
2
$ sudo apt-get install libX11-dev
$ sudo apt-get install gfortran

详细的安装步骤

  1. 下载源码 pgplot5.2
  2. 解压并将源码放在/usr/local/src/中
1
2
3
# cd /usr/local/src
# mv ~/Downloads/pgplot5.2.tar.gz .
# tar zxvf pgplot5.2.tar.gz
  1. 创建pgplot安装的路径:
1
2
# mkdir /usr/local/pgplot
# cd /usr/local/pgplot
  1. 拷贝 drivers.list 文件到安装目录:
1
# cp /usr/local/src/pgplot/drivers.list .
  1. 编辑drives.list文件,将下面的注释取消:
  • /PS
  • /VPS
  • /CPS
  • /VCPS
  • /XServe
  1. 创建makefile文件
1
# /usr/local/src/pgplot/makemake /usr/local/src/pgplot linux g77_gcc_aout

编辑makefile文件,并将FCOMPL=g77替换为FCOMPL=gfortran

  1. 编译源码:
1
2
3
# make
# make cpg
# make clean

确定环境变量已经设置:

1
2
$ export PGPLOT_DIR=/usr/local/pgplot
$ export PGPLOT_DEV=/Xserve

使用测试用例来检测安装已经完成。

1
2
3
4
$ /usr/local/pgplot/pgdemo1
$ /usr/local/pgplot/pgdemo2
$ /usr/local/pgplot/pgdemo3
...

在MacOSX平台上运行Docker GUI程序

在Linux平台上,运行Docker的GUI是很简单的事情,只要共享DISPLAY变量挂在/tmp/.X11-unix即可。

Mac OS X 稍微有些复杂,如下所示。

安装基础软件

socat

socat用于创建两个节点的双向数据流通信。

1
2
$ brew install socat
$ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

Xquartz

Xquartz为Mac OS X系统上的X窗口系统。

1
$ brew install Caskroom/cask/xquartz

打开Xquartz软件,偏好设置->安全性->勾选允许从网络客户端连接

运行

1
$ docker run -e DISPLAY=192.168.1.4:0 shaoguangleo/ubuntu-astrosoft

其中IP地址为本机的IP地址,注意修

其中IP可用通过下面的命令来获取:

1
IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')

另外一种方法

在MacOSX上运行,

1
2
3
$xhost +127.0.0/1
#或者
$xhost +localhost

确保localhost允许X11转发

然后在docker镜像内部执行显示映射

1
2
$ export DISPLAY=$IP:0
$ docker run -it -e DISPLAY=$IP:0 shaoguangleo/ubuntu-astrosoft

ARM芯片

Apple在2021年发布了搭载ARM芯片的操作系统,会出现linux/arm64/v8不执行的提示,可以通过下面的方式来解决。

1
$ export DOCKER_DEFAULT_PLATFORM=linux/amd64 

或者使用指定的参数--platform=linux/amd64 来编译或者运行amd的镜像与版本。

参考:cflags - How to add ‘-march=’ as default option to gcc? - Stack Overflow

在Linux平台上,运行Docker的GUI是很简单的事情,只要共享DISPLAY变量挂在/tmp/.X11-unix,
并且开放控制X server的访问权限即可。

在宿主机上运行命令

1
$ xhost +

此时就可以使用docker的图形界面了,比如测试如下:

1
2
3
4
5
$ docker run -it -e DISPLAY=unix$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix shaoguangleo/centos-pgplot

然后输入

# /usr/local/pgplot/pgdemo1

见证奇迹。

Docker Data Management

There are two methods to handle Docker data.

Method 1 : Data Volume

1
$ docker run -v /local/path:/docker/path shaoguangleo/ubuntu:lateset

Also , you can mount several directories at the same time.

1
$ docker run -v /local/path:/docker/path -v /local/path2:/docker/path2 -v /local/path3:/docker/path3 shaoguangleo/ubuntu:lateset

By default the data volume can be read and write, you can specify the parameter point out.

For example: Just read

1
$ docker run -v /local/path:/docker/path:ro shaoguangleo/ubuntu:lateset

Method 2 : Data Volume Container

First create a data volume container and mount to /dbdata

1
$ docker run -it -v /dbdata shaoguangleo/ubuntu:lateset

Then we can using --volumes-from to mount the dbdata through many dockers.

1
2
3
$ docker run -it --volumes-from dbdata --name db1 ubuntu
$ docker run -it --volumes-from dbdata --name db2 ubuntu
$ docker run -it --volumes-from dbdata --name db3 ubuntu

So we can modify some file in dbdata which can immediately work in other dockers.

Docker backup/restore data

By the way, we can also using docker to backup or restore data.

backup

1
$ docker run --volumes-from dbdata -v $(pwd):/backup --name worker ubuntu tar cvf /backup/backup.tar /dbdata

restore

1
2
$ docker run -v /dbdata --name dbdata2 ubuntu /bin/bash
$ docker run --volumes-from dbdata2 -v $(pwd):/backup busybox tar xvf /backup/backup.tar