LAWU

主页:http://astroman.lamost.org

安装pyraf后ipython出现问题的解决

iraf,搞天文观测的人都不陌生吧,pyraf呢?不了解?其实就是在python下运行iraf,想了解更多可自行查询。这里先不介绍如何使用,说一下安装时容易出现的问题。

安装pyraf需要事先装好一些软件包:

  • Tcl/Tk
  • Readline
  • Python
  • Numpy
  • urwid (可选)
  • ipython (可选)
  • matplotlib (可选)

如果你在linux下依次安装的话很有可能会出现如下问题,运行pyraf应该没事,但是当运行ipython时会出现:

WARNING: Readline services not available on this platform.
WARNING: The auto-indent feature requires the readline library

一开始怎么也不明白,明明是安装了readline为什么还提示没有?问题就在于,linux下已经装好该包,如果再次安装就会导致ipython不知道该读取哪个库。

好了,剩下的事就简单了,进入到安装readline文件夹下运行

sudo make uninstall

即可!

说了这么多废话,其实几句话就能搞定:安装前面列出的包时不要安装”Readline”

iraf ubuntu安装

网上有好多关于iraf傻瓜教程,今儿就来个傻瓜之傻瓜教程。没有那些繁琐的创建用户、建立文件夹、复制粘贴能过程,只需要你能上网就能搞定(请事先安装tcsh,在ubuntu11.04已验证顺利通过):

点击链接下载文件:

http://astronomy.nju.edu.cn/galaxy/blog/iraf_install.sh

修改其可执行权限,如(不放心777就换个其他可执行操作):

sudo chmod -R 777 iraf_install.sh

执行:

sudo ./iraf_install.sh

一路按默认回车即可,如果iraf的网络环境有问题就选no,Enjoy!

信息来源:http://sfig.pmo.ac.cn/astrowiki/IRAF

傻瓜式是一种工作态度!

之前内容的更新

上传了精彩进球集锦。
http://astroman.lamost.org/dbs/archives/10578

python升级后的一个小bug解决

上周末闲的无聊,把ubuntu升级到11.04,强烈不建议大家这样玩,浪费时间浪费精力得不偿失啊,这都是题外话。

升级后,系统自带python变成了2.7版的,本以为一切都可以正常,没想到一个小程序暴露出了问题。先看下面的程序(你不要管它在算什么):

import numpy as np
import matplotlib.pylab as pl
T_r0 = 2.73 # K
def T_r(z):
T_rz = T_r0*(1+z)
return T_rz
def T_k(z):
T_kz = (1+z)**2
return T_kz
def T_s(z):
T_sz = 2./(1./T_r(z)+1./T_k(z))
return T_sz
output = open(‘T.dat’,’w’)
#T = [0. for x in range(290)]
for z in range(10,300):
print >> output, T_s(z), z
output.close()
data = np.loadtxt(‘T.dat’)
x = data[:,1]
y = data[:,0]
pl.semilogx(x, y)
pl.show()

程序没问题吧?于是运行,于是出错:

$ python T_s.py

Exception in Tkinter callback

Traceback (most recent call last):

File “/usr/lib/python2.7/lib-tk/Tkinter.py”, line 1413, in __call__    return self.func(*args)

File “/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py”, line 212, in resize    self.show()

File “/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py”, line 215, in draw    FigureCanvasAgg.draw(self)

File “/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py”, line 314, in draw    self.figure.draw(self.renderer)

File “/usr/lib/pymodules/python2.7/matplotlib/artist.py”, line 46, in draw_wrapper    draw(artist, renderer, *args, **kwargs)

File “/usr/lib/pymodules/python2.7/matplotlib/figure.py”, line 773, in draw    for a in self.axes: a.draw(renderer)

File “/usr/lib/pymodules/python2.7/matplotlib/artist.py”, line 46, in draw_wrapper    draw(artist, renderer, *args, **kwargs)

File “/usr/lib/pymodules/python2.7/matplotlib/axes.py”, line 1735, in draw    a.draw(renderer)  File “/usr/lib/pymodules/python2.7/matplotlib/artist.py”, line 46, in draw_wrapper    draw(artist, renderer, *args, **kwargs)

File “/usr/lib/pymodules/python2.7/matplotlib/axis.py”, line 742, in draw    tick.draw(renderer)  File “/usr/lib/pymodules/python2.7/matplotlib/artist.py”, line 46, in draw_wrapper    draw(artist, renderer, *args, **kwargs)

File “/usr/lib/pymodules/python2.7/matplotlib/axis.py”, line 196, in draw    self.label1.draw(renderer)

File “/usr/lib/pymodules/python2.7/matplotlib/text.py”, line 518, in draw    bbox, info = self._get_layout(renderer)

File “/usr/lib/pymodules/python2.7/matplotlib/text.py”, line 280, in _get_layout    clean_line, self._fontproperties, ismath=ismath)

File “/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py”, line 156, in get_text_width_height_descent    self.mathtext_parser.parse(s, self.dpi, prop)

File “/usr/lib/pymodules/python2.7/matplotlib/mathtext.py”, line 2797, in parse    font_output = fontset_class(prop, backend)

File “/usr/lib/pymodules/python2.7/matplotlib/mathtext.py”, line 658, in __init__    self._stix_fallback = StixFonts(*args, **kwargs)

File “/usr/lib/pymodules/python2.7/matplotlib/mathtext.py”, line 900, in __init__    fullpath = findfont(name)

File “/usr/lib/pymodules/python2.7/matplotlib/font_manager.py”, line 1306, in findfont    if not os.path.exists(font):

File “/usr/lib/python2.7/genericpath.py”, line 18, in exists    os.stat(path)

TypeError: coercing to Unicode: need string or buffer, dict found

但如果将程序中的pl.loglog或pl.semilogx(y)换成pl.plot即可完美运行。也就是在调用matplotlib库的时候出了问题。问题貌似是有点冲突,没错!因为是从python2.6升级至2.7(如果系统是完全重装的应该无此问题),2.6中的matplotlib的setting没有删除,导致该问题的出现。

解决办法很简单,把matplotlib中的fontList.cache改名或是直接删除即可:

rm ~/.matplotlib/fontList.cache

或是

mv .matplotlib/fontList.cache .matplotlib/fontList.cache.cp

Done!

参考:https://github.com/matplotlib/matplotlib/issues/198

de.arxiv.org/pdf/1106.4726v1

de.arxiv.org/pdf/1106.4726v1.

porno izle