在 gnuplot 中读取右 ascension/declination 坐标

Reading right ascension/declination coordinates in gnuplot

我有一个包含右 ascension/declination 坐标的两列文件:

18:42:21.8 -23:04:52
20:55:00.8 -17:23:19

我可以读取指定数据为 'timefmt' 的第一列,但似乎无法对 angular 数据进行类似的读取。我当然可以删除 : 和 plot ($2+$3/60+$3/3600),但我想知道是否有更优雅的方法。

您可以定义一个函数来为您完成这项工作,这在 plot 命令中可能更方便、更短。

  • 通过strptime()timecolumn() 将您的时、分、秒或度、分、秒转换为秒。在 gnuplot 控制台类型检查 help strptimehelp timecolumnhelp time_specifiers。使用 %tH:%tM:%tS,而不是 %H:%M:%S

但是,你要小心:

如果您的输入时间是例如 -00:17:56.7,gnuplot 会将其解释为 +00:17:56.7,这不是您所期望的。显然,-00 等于 +00,因此 17 被解释为正数,尽管您打算将其解释为负数。这种特殊情况下的解决方法如下:

创建一个函数 myTimeSign(s) 检查小时数是否为 0 以及您时间的第一个字符是否为 - 并且将 return -1, 1 否则。

myTimeSign(s) = strptime("%tH",s)==0 && s[1:1] eq '-' ? -1 : 1 

用你的时间乘以这个。这将在此处作为解决方法,但通常不会。

更新: 这已被报告为错误 (https://sourceforge.net/p/gnuplot/bugs/2245/),并且已在 gnuplot 的开发版本中修复。

代码:

### time / angle conversion
reset session
set size square
set object 1 rect from graph 0,0 to graph 1,1 fc rgb "black"

$Orion <<EOD
05:55:10.29   +07:24:25.3   0.42   Betelgeuse
05:14:32.27   -08:12:05.9   0.18   Rigel
05:25:07.87   +06:20:59.0   1.64   Bellatrix
05:32:00.40   -00:17:56.7   2.20   Mintaka
05:36:12.81   -01:12:06.9   1.69   Alnilam
05:40:45.52   -01:56:33.3   1.88   Alnitak
05:47:45.39   -09:40:10.6   2.07   Saiph
05:35:08.28   +09:56:03.0   3.47   Meissa
EOD

myTimeFmt = "%tH:%tM:%tS"

RA(n) = timecolumn(n,myTimeFmt)
myTimeSign(s) = strptime("%tH",s)==0 && s[1:1] eq '-' ? -1 : 1   # returns -1 if hours are -00
Dec(n) = timecolumn(n,myTimeFmt)*myTimeSign(strcol(n))

set xrange[strptime(myTimeFmt,"06:12"):strptime(myTimeFmt,"05:00")] reverse
set format x "%H^h%M^m" time
set yrange[strptime(myTimeFmt,"-12:00"):strptime(myTimeFmt,"+12:00")]
set format y "%tH°%tM'" time
set tics out

plot $Orion u (RA(1)):(Dec(2)):(-log10()+1.5) w p pt 7 ps var lc rgb "yellow" notitle
### end of code

结果: