pgplot 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 00063843df119f6f4b32281e29ff3c2bba9dc0da
4
+ data.tar.gz: 0c4f21010d99906637494418eaace8ecaee33a09
5
+ SHA512:
6
+ metadata.gz: a6481908be3f77382819eb882d2f7a31f9cee64e217f6523bbd35a6e85ae9aba9e371cf8bf5e0f2c6036f1e03fc957382957a123a7edfecb09aa192bb02cb688
7
+ data.tar.gz: 90d7147f8e88ff7fa4aa8be392b125c06d791961b7fe9e7f6fab456e510ceb1cca02b9277443a83ccd1799c53800f2cfc48f4d8fc813432828be60b99a0d723d
data/FuncUsage ADDED
@@ -0,0 +1,46 @@
1
+ Here is a brief overview of Ruby/PGPLOT methods whose argument handling differs
2
+ from the underlying PGPLOT functions.
3
+
4
+ Methods that have the same arguments as the underlying functions are NOT shown
5
+ here.
6
+
7
+ stat = pgopen([device])
8
+ stat = pgbeg([device, [nxsub, [nysub]]])
9
+
10
+ pgask [true|false]
11
+ pgenv xmin,xmax,ymin,ymax [,just, axis]
12
+
13
+ pgline xarray, yarray
14
+ pgpt xarray, yarray [,symbol]
15
+ pgpnts xarray, yarray, symarray
16
+
17
+ pgbin xarray, yarray [,center]
18
+ pghist data, nbin [,range, flag]
19
+
20
+ pgerrb dir, x, y, err [,tlen]
21
+ pgerrx x1, x2, y [,tlen]
22
+ pgerry x, y1, y2 [,tlen]
23
+
24
+ pgcont map, cont [,tr]
25
+ pgcons map, cont [,tr]
26
+ pgconb map, cont [,blank, tr]
27
+ pgconf map, cont_range [,tr]
28
+ pgconl map, cont, label [,intval, minint, tr]
29
+
30
+ pgimag array [,range, tr]
31
+ pggray array [,range, tr]
32
+ pgctab l, r,g,b [,contra,bright]
33
+ pgpixl, array [,x1,x2,y1,y2]
34
+ pgvect x, y [,scale, pos, tr, blank]
35
+
36
+ value = pgqinf(item)
37
+ type, descr, inter = pgqdt([ndev])
38
+
39
+ curs = pgband( mode, [ xref, yref, [x, y, [posn]]])
40
+ n = pgolin( x, y, [sym, [npt]] )
41
+ n = pgncur( x, y, [sym, [npt]] )
42
+ n = pglcur( x, y, [npt] )
43
+
44
+ pgtick x1, y1, x2, y2, v, [str], {"tickl", "tickr", "disp", "orient"}
45
+ pgaxis x1, y1, x2, y2, v1, v2,
46
+ {"opt", "step", "nsub", "tickl", "tickr", "frac", "disp", "orient"}
data/README ADDED
@@ -0,0 +1,107 @@
1
+ = Ruby/PGPLOT
2
+
3
+ Version 0.1.6 by Masahiro TANAKA 2012-02-18
4
+
5
+ == Description
6
+
7
+ * Ruby interface to PGPLOT.
8
+ It provides PGPLOT functions as a Ruby module.
9
+
10
+ == Requirements
11
+
12
+ * {PGPLOT ver 5.2.x}[http://astro.caltech.edu/~tjp/pgplot/]
13
+
14
+ * Libraries which PGPLOT drivers use:
15
+
16
+ * X11 library
17
+ * PNG library
18
+ * {GrWin Graphics Library for MS-Windows
19
+ }[http://spdg1.sci.shizuoka.ac.jp/grwinlib/english/]
20
+
21
+ * Ruby version 1.8.x/1.9.x/2.0.x
22
+
23
+ * {NArray}[http://narray.rubyforge.org/] version 0.5.x/0.6.x
24
+
25
+ == Installation
26
+
27
+ * Install PGPLOT library
28
+
29
+ - FORTRAN77 compiler required for source-compile.
30
+ - C interface library (libcpgplot.a) is also required.
31
+ - On Ubuntu, the required PGPLOT files can be installed via this command:
32
+ $ sudo apt-get install pgplot5
33
+
34
+ * Install Ruby, NArray
35
+
36
+ * Install Ruby/PGPLOT
37
+
38
+ - To install via RubyGems (recommended!):
39
+ $ sudo gem install pgplot
40
+
41
+ - To install manually:
42
+
43
+ - extract distribution.
44
+
45
+ - compile and install by:
46
+
47
+ $ ruby extconf.rb [options (see below)]
48
+ $ make
49
+ $ make site-install
50
+ (or make install)
51
+
52
+ - Options for `ruby extconf.rb':
53
+ --with-pgplot-include=path : path to cpgplot.h
54
+ --with-pgplot-lib=path : path to PGPLOT libraries.
55
+ --with-grwin : for using GrWin (cygwin/mingw).
56
+
57
+ example:
58
+ ruby extconf.rb \
59
+ --with-pgplot-include=/usr/local/pgplot \
60
+ --with-pgplot-lib=/usr/local/pgplot
61
+
62
+ == Usage
63
+
64
+ * Environment variables for PGPLOT (csh)
65
+
66
+ setenv PGPLOT_DIR /usr/local/lib/pgplot/ # pgxwin_server, rgb.txt
67
+ setenv PGPLOT_FONT ${PGPLOT_DIR}/grfont.dat
68
+ setenv PGPLOT_DEV /xwin
69
+
70
+ * To load the Ruby/PGPLOT extension;
71
+
72
+ require "pgplot"
73
+
74
+ * Module name is 'Pgplot'. If you want to omit the module name;
75
+
76
+ include Pgplot
77
+
78
+ * Pgplot module method names are lower case of corresponding
79
+ PGPLOT functions. To start plotting:
80
+
81
+ pgbeg('/xwin')
82
+
83
+ See PGPLOT manual for function usage.
84
+ Arguments are not always same as the FORTRAN PGPLOT.
85
+ {FuncUsage}[link:FuncUsage.html] file includes a list of functions with
86
+ different arguments.
87
+
88
+ == Platforms tested
89
+
90
+ * ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
91
+ * ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
92
+ * NArray 0.6.0.1
93
+ * gcc/gfortran version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC)
94
+
95
+ == License
96
+
97
+ This program is free software.
98
+ You can distribute/modify this program
99
+ under the same terms as Ruby itself.
100
+ NO WARRANTY.
101
+
102
+ == Acknowledgment
103
+
104
+ M.T. thanks to Tim Pearson for developing the useful PGPLOT library
105
+ and giving me the permission to distribute the Ruby version of pgdemos.
106
+ M.T. also thanks to the developers of the Ruby language
107
+ for providing the wonderful language.
data/README.ja ADDED
@@ -0,0 +1,91 @@
1
+ Ruby/PGPLOT ver 0.1.6 by Masahiro TANAKA 2012-02-18
2
+
3
+ = 概要
4
+
5
+ * PGPLOTをRubyから使うための拡張ライブラリ。
6
+
7
+ = 必要なもの
8
+
9
+ * PGPLOT ver 5.2.x
10
+ (http://astro.caltech.edu/~tjp/pgplot/)
11
+ * PGPLOTのドライバが使うライブラリ (必要に応じて):
12
+ ** X11ライブラリ
13
+ ** PNGライブラリ
14
+ ** GrWinグラフィクスライブラリ for MS-Windows (Cygwinでのみ動作確認)
15
+ (http://spdg1.sci.shizuoka.ac.jp/grwinlib/)
16
+ * Ruby ver 1.8.x/1.9.x
17
+ * NArray ver 0.5.x/0.6.x
18
+ (http://www.ruby-lang.org/en/raa-list.rhtml?name=NArray)
19
+
20
+ = インストール方法
21
+
22
+ * PGPLOT をインストール
23
+
24
+ - FORTRAN77が必要です (gfortranでもOK)。
25
+ - C言語インタフェースライブラリ(cpgplot)を作成する必要があります。
26
+
27
+ * Ruby, NArray をインストール
28
+
29
+ * Ruby/PGPLOT をインストール
30
+
31
+ - ソースを展開
32
+
33
+ - コンパイル・インストール:
34
+ ruby extconf.rb [オプション(下記参照)]
35
+ make
36
+ make site-install
37
+ (または make install)
38
+
39
+ - ruby extconf.rb のオプション:
40
+ --with-pgplot-include=path : cpgplot.hのディレクトリ。
41
+ --with-pgplot-lib=path : PGPLOTライブラリのディレクトリ。
42
+ --with-x11-dir=path : X11のpath
43
+ --with-grwin : for using GrWin (cygwin/mingw).
44
+ --with-sunws : PGPLOTをSun WorkShopのf77を使って
45
+ コンパイルした場合。指定しない時はg77。
46
+ 例:
47
+ ruby extconf.rb --with-x11-dir=/usr/X11R6 \
48
+ --with-pgplot-include=/usr/local/pgplot \
49
+ --with-pgplot-lib=/usr/local/pgplot
50
+
51
+ = 使用方法
52
+
53
+ * PGPLOTの環境変数設定(csh)
54
+
55
+ setenv PGPLOT_DIR /usr/local/lib/pgplot/ # pgxwin_server, rgb.txt
56
+ setenv PGPLOT_FONT ${PGPLOT_DIR}/grfont.dat
57
+ setenv PGPLOT_DEV /xwin
58
+
59
+ * 拡張ライブラリをロードするには:
60
+
61
+ require "pgplot"
62
+
63
+ * モジュール名は`Pgplot'です。モジュール名を省略したいときは:
64
+
65
+ include Pgplot
66
+
67
+ * Pgplotモジュールのメソッドは、PGPLOTの関数と同じ名前(小文字)です。
68
+ プロットを開始するには:
69
+
70
+ pgbeg('/xwin')
71
+
72
+ 詳細は PGPLOTのマニュアルを参照して下さい。
73
+ 引数は必ずしもFORTRAN版と同じではありません。
74
+ 引数が違う関数のリストは、"FuncUsage"というファイルにあります。
75
+
76
+ = 動作確認
77
+
78
+ * ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
79
+ * ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
80
+ * NArray 0.6.0.1
81
+ * gcc/gfortran version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC)
82
+
83
+ = 配布条件
84
+
85
+ Ruby本体と同じです。
86
+ 無保証です。
87
+
88
+ = 謝辞
89
+
90
+ PGPLOTを開発し、Ruby版pgdemoの配布許可を下さった Tim Pearson氏
91
+ に感謝します。Ruby開発に携わった皆様に感謝します。
data/demo/pgdemo1.rb ADDED
@@ -0,0 +1,414 @@
1
+ require 'narray'
2
+ require 'pgplot'
3
+ include Pgplot
4
+ include NMath
5
+ PI = Math::PI
6
+ TWOPI = PI*2
7
+ BLACK,WHITE,RED,GREEN,BLUE,CYAN,MAGENT,YELLOW = (0..7).to_a
8
+ FULL,DASH,DOTDSH,DOTTED,FANCY = (1..5).to_a
9
+ NORMAL,ROMAN,ITALIC,SCRIPT = (1..4).to_a
10
+ SOLID,HOLLOW = (1..2).to_a
11
+
12
+ # ====== Utility function ======
13
+
14
+ def indgen arg
15
+ if arg.kind_of?(Range)
16
+ return NArray.sfloat(arg.size).indgen!(arg.first)
17
+ elsif arg.kind_of?(Numeric)
18
+ return NArray.sfloat(arg).indgen!
19
+ else
20
+ raise ArgumentError, "invalid argument"
21
+ end
22
+ end
23
+
24
+ def randomn n=1
25
+ rr = NArray.sfloat(n)
26
+ xx = NArray.sfloat(n)
27
+ idx= NArray.int(n).indgen!
28
+ i = 0
29
+ while i<n
30
+ x = NArray.sfloat(n*4/3).random!(1) * 2 - 1
31
+ y = NArray.sfloat(n*4/3).random!(1) * 2 - 1
32
+ r = x**2 + y**2
33
+ idx = (r<1).where
34
+ siz = [n-i,idx.size-1].min
35
+ rr[i] = r[idx[0...siz]]
36
+ xx[i] = x[idx[0...siz]]
37
+ #printf "i=%d,siz=%d,idx.size=%d\n",i,siz,idx.size
38
+ i += siz
39
+ end
40
+ return xx * sqrt(-2*log(rr)/rr)
41
+ end
42
+
43
+ # ====== Demo function ======
44
+
45
+ def pgex0
46
+ %w(
47
+ version
48
+ state
49
+ user
50
+ now
51
+ device
52
+ file
53
+ type
54
+ dev/type
55
+ hardcopy
56
+ terminal
57
+ cursor
58
+ ).each{|i| print " ",i," = ",pgqinf(i),"\n"}
59
+
60
+ x1,x2,y1,y2 = pgqvsz(1)
61
+ x = x2-x1
62
+ y = y2-y1
63
+ printf " Plot dimensions (x,y; inches): %9.2f, %9.2f
64
+ (mm): %9.2f, %9.2f\n",x, y, x*25.4, y*25.4
65
+ end
66
+
67
+ def pgex1
68
+ pgenv 0, 10, 0, 20, 0, 1
69
+ pglab '(x)', '(y)', 'PGPLOT Example 1: y = x\u2'
70
+
71
+ xs = [1.0,2.0,3.0,4.0,5.0]
72
+ ys = [1.0,4.0,9.0,16.0,25.0]
73
+ pgpt xs,ys,9
74
+
75
+ n = 60
76
+ xr = indgen(n)*0.1
77
+ yr = xr**2
78
+ pgline xr, yr
79
+ end
80
+
81
+ def pgex2
82
+ pgenv -2.0,10.0,-0.4,1.2, 0,1
83
+ pglab '(x)', 'sin(x)/x', 'PGPLOT Example 2: Sinc Function'
84
+
85
+ xr = (indgen(100)-20.5)/6.0
86
+ yr = sin(xr)/xr
87
+ pgline xr, yr
88
+ end
89
+
90
+ def pgex3
91
+ pgenv 0.0,720.0,-2.0,2.0, 0,-2
92
+ pgsave
93
+ pgsci 14
94
+ pgbox 'G',30.0, 0,'G', 0.2, 0
95
+ pgsci 5
96
+ pgbox 'ABCTSN',90.0, 3,'ABCTSNV', 0.0,0
97
+ pgsci 3
98
+ pglab 'x (degrees)','f(x)','PGPLOT Example 3'
99
+
100
+ xr = indgen(360) * 2
101
+ arg= xr/180*PI
102
+ yr = sin(arg) + cos(arg*2)*0.5 + cos(arg*1.5+PI/3)*0.5
103
+
104
+ pgsci 6
105
+ pgsls 2
106
+ pgslw 3
107
+ pgline xr, yr
108
+ pgunsa
109
+ end
110
+
111
+ def pgex4
112
+ seed = -5678921
113
+ data = randomn(1000)
114
+ pgsave
115
+ pghist data, 31, -3.1..3.1, 0
116
+ data = randomn(200)*0.5 + 1
117
+ pgsci 15
118
+ pghist data, 31, -3.1..3.1, 3
119
+ pgsci 0
120
+ pghist data, 31, -3.1..3.1, 1
121
+ pgsci 1
122
+ pgbox 'BST', 0.0, 0, ' ', 0.0, 0
123
+
124
+ pglab 'Variate', ' ','PGPLOT Example 4: Histograms (Gaussian)'
125
+
126
+ x = indgen(620)*0.01 - 3.1
127
+ y = exp(-(x**2)*0.5) * (0.2*1000/sqrt(2*PI))
128
+
129
+ pgline x,y
130
+ pgunsa
131
+ end
132
+
133
+ def pgex5
134
+ np=15
135
+ freq = NArray[ 26.0, 38.0, 80.0, 160.0, 178.0, 318.0, 365.0, 408.0,
136
+ 750.0, 1400.0, 2695.0, 2700.0, 5000.0, 10695.0, 14900.0 ]
137
+ flux = NArray[ 38.0, 66.4, 89.0, 69.8, 55.9, 37.4, 46.8, 42.4, 27.0,
138
+ 15.8, 9.09, 9.17, 5.35, 2.56, 1.73 ]
139
+ err = NArray[ 6.0, 6.0, 13.0, 9.1, 2.9, 1.4, 2.7, 3.0, 0.34, 0.8,
140
+ 0.2, 0.46, 0.15, 0.08, 0.01 ]
141
+ pgsave
142
+ pgsci CYAN
143
+ pgenv -2.0,2.0,-0.5,2.5,1,30
144
+ pglab 'Frequency, \gn (GHz)',
145
+ 'Flux Density, S\d\gn\u (Jy)',
146
+ 'PGPLOT Example 5: Log-Log plot'
147
+ x = indgen(100)*0.03 + 1.3
148
+ xp = x-3
149
+ yp = -x*1.15 - exp(-x)*7.72 + 5.18
150
+ pgsci RED
151
+ pgline xp,yp
152
+
153
+ xp = log10(freq)-3.0
154
+ yp = log10(flux)
155
+ pgsci GREEN
156
+ pgpt xp,yp,17
157
+
158
+ yhi = log10(flux+2*err)
159
+ ylo = log10(flux-2*err)
160
+ pgerry xp,ylo,yhi
161
+ pgunsa
162
+ end
163
+
164
+ def pgex6
165
+ twopi = PI*2
166
+ npol = 6
167
+
168
+ n1 = [ 0, 3, 4, 5, 5, 6, 8 ] # index-0 is dummy
169
+ n2 = [ 0, 1, 1, 1, 2, 1, 3 ]
170
+ lab = [ '', 'Fill style 1 (solid)',
171
+ 'Fill style 2 (outline)',
172
+ 'Fill style 3 (hatched)',
173
+ 'Fill style 4 (cross-hatched)']
174
+ pgbbuf
175
+ pgsave
176
+ pgpage
177
+ pgsvp 0.0, 1.0, 0.0, 1.0
178
+ pgwnad 0.0, 10.0, 0.0, 10.0
179
+ pgsci 1
180
+ pgmtxt 'T', -2.0, 0.5, 0.5,
181
+ 'PGPLOT fill area: routines PGPOLY, PGCIRC, PGRECT'
182
+
183
+ for k in 1..4
184
+ pgsci 1
185
+ y0 = 10.0 - 2.0*k
186
+ pgtext 0.2, y0+0.6, lab[k]
187
+ pgsfs k
188
+ for i in 1..npol
189
+ pgsci i
190
+ angle = indgen(n1[i])*(n2[i]*twopi/n1[i])
191
+ x = cos(angle)*0.5 + i
192
+ y = sin(angle)*0.5 + y0
193
+ pgpoly x,y
194
+ end
195
+ pgsci 7
196
+ pgcirc 7.0, y0, 0.5
197
+ pgsci 8
198
+ pgrect 7.8, 9.5, y0-0.5, y0+0.5
199
+ end
200
+ pgunsa
201
+ pgebuf
202
+ end
203
+
204
+ def pgex7
205
+ pgbbuf
206
+ pgsave
207
+ pgsci 1
208
+ pgenv 0.0,5.0, -0.3,0.6, 0,1
209
+ pglab '\fix', '\fiy', 'PGPLOT Example 7: scatter plot'
210
+
211
+ xs = NArray.sfloat(300).random!(1.0)*5
212
+ ys = randomn(300)*0.05 + xs*exp(-xs)
213
+
214
+ pgsci 3
215
+ pgpt xs[0..99],ys[0..99], 3
216
+ pgpt xs[100..199],ys[100..199], 17
217
+ pgpt xs[200..299],ys[200..299], 21
218
+
219
+ xr = indgen(101)*0.05
220
+ yr = xr*exp(-xr)
221
+ pgsci 2
222
+ pgline xr,yr
223
+
224
+ xp = xs[100]
225
+ yp = ys[100]
226
+ xsig = 0.2
227
+ ysig = 0.1
228
+ pgsci 5
229
+ pgsch 3.0
230
+ pgerr1 5, xp, yp, xsig, 1.0
231
+ pgerr1 6, xp, yp, ysig, 1.0
232
+ pgpt1 xp,yp,21
233
+ pgunsa
234
+ pgebuf
235
+ end
236
+
237
+ def pgex8
238
+ pgpage
239
+ pgbbuf
240
+ pgsave
241
+ pgsvp(0.1,0.6,0.1,0.6)
242
+ pgswin(0.0, 630.0, -2.0, 2.0)
243
+ pgsci(CYAN)
244
+ pgbox('ABCTS', 90.0, 3, 'ABCTSV', 0.0, 0)
245
+ pgsci(RED)
246
+ pgbox('N',90.0, 3, 'VN', 0.0, 0)
247
+ xr = indgen(360)*2
248
+ yr = sin(xr/57.29577951)
249
+ pgsci(MAGENT)
250
+ pgsls(DASH)
251
+ pgline(xr,yr)
252
+ pgswin(90.0, 720.0, -2.0, 2.0)
253
+ pgsci(YELLOW)
254
+ pgsls(DOTTED)
255
+ pgline(xr,yr)
256
+ pgsls(FULL)
257
+ pgsvp(0.45,0.85,0.45,0.85)
258
+ pgswin(0.0, 180.0, -2.0, 2.0)
259
+ pgsci(0)
260
+ pgrect(0.0, 180.0, -2.0, 2.0)
261
+ pgsci(BLUE)
262
+ pgbox('ABCTSM', 60.0, 3, 'VABCTSM', 1.0, 2)
263
+ pgsci(WHITE)
264
+ pgsls(DASH)
265
+ pgline(xr,yr)
266
+ pgunsa
267
+ pgebuf
268
+ end
269
+
270
+ def pgex9
271
+ pgbbuf
272
+ pgsave
273
+ pgsci(5)
274
+ #pgfunt(fx,fy,360,0.0,TWOPI,0) # pgfunt is not implemented
275
+ t = indgen(361)/360*TWOPI
276
+ x = sin(t*5)
277
+ y = sin(t*4)
278
+ pgenv -1,1,-1,1
279
+ pgline x,y
280
+ pgsci(3)
281
+ pglab('x','y','PGPLOT Example 9: routine PGFUNT')
282
+ pgunsa
283
+ pgebuf
284
+ end
285
+
286
+ def bessel_j0 arg
287
+
288
+ r = NArray.sfloat(arg.size)
289
+ x = arg.abs
290
+ idx1,idx2 = (x<=3).where2
291
+ if idx1.size>0 then
292
+ xo3 = x[idx1]/3.0
293
+ t = xo3**2
294
+ r[idx1] = 1.0 +
295
+ t*(-2.2499997 +
296
+ t*( 1.2656208 +
297
+ t*(-0.3163866 +
298
+ t*( 0.0444479 +
299
+ t*(-0.0039444 +
300
+ t*( 0.0002100))))))
301
+ end
302
+ if idx2.size>0 then
303
+ xx = x[idx2]
304
+ t = 3.0/xx
305
+ f0 = 0.79788456 +
306
+ t*(-0.00000077 +
307
+ t*(-0.00552740 +
308
+ t*(-0.00009512 +
309
+ t*( 0.00137237 +
310
+ t*(-0.00072805 +
311
+ t*( 0.00014476))))))
312
+ theta0 = xx - 0.78539816 +
313
+ t*(-0.04166397 +
314
+ t*(-0.00003954 +
315
+ t*( 0.00262573 +
316
+ t*(-0.00054125 +
317
+ t*(-0.00029333 +
318
+ t*( 0.00013558))))))
319
+ r[idx2] = f0*cos(theta0)/sqrt(xx)
320
+ end
321
+ return r
322
+ end
323
+
324
+ def bessel_j1 arg
325
+ r = NArray.sfloat(arg.size)
326
+ x = arg.abs
327
+ idx1,idx2 = (x<=3).where2
328
+ if idx1.size>0 then
329
+ xo3 = x[idx1]/3.0
330
+ t = xo3**2
331
+ f = 0.5 + t*(-0.56249985 +
332
+ t*( 0.21093573 +
333
+ t*(-0.03954289 +
334
+ t*( 0.00443319 +
335
+ t*(-0.00031761 +
336
+ t*( 0.00001109))))))
337
+ r[idx1] = f * arg[idx1]
338
+ end
339
+ if idx2.size>0 then
340
+ xx = x[idx2]
341
+ t = 3.0/xx
342
+ f1 = 0.79788456 +
343
+ t*( 0.00000156 +
344
+ t*( 0.01659667 +
345
+ t*( 0.00017105 +
346
+ t*(-0.00249511 +
347
+ t*( 0.00113653 +
348
+ t*(-0.00020033))))))
349
+ theta1 = xx - 2.35619449 +
350
+ t*( 0.12499612 +
351
+ t*( 0.00005650 +
352
+ t*(-0.00637879 +
353
+ t*( 0.00074348 +
354
+ t*( 0.00079824 +
355
+ t*(-0.00029166))))))
356
+ r[idx2] = f1*cos(theta1)/sqrt(xx)
357
+ end
358
+ idx = (arg<0).where
359
+ #p idx
360
+ #p r[idx]
361
+ r[idx] = -r[idx] if idx.size>0
362
+ return r
363
+ end
364
+
365
+ def pgex10
366
+ pgbbuf
367
+ pgsave
368
+ pgsci(YELLOW)
369
+ # PGFUNX(PGBSJ0,500,0.0,10.0*PI,0)
370
+ x = indgen(500)/50*PI
371
+ y = bessel_j0(x)
372
+ pgenv 0,PI*10, y.min,y.max
373
+ pgline x,y
374
+ pgsci(RED)
375
+ pgsls(DASH)
376
+ # PGFUNX(PGBSJ1,500,0.0,10.0*PI,1)
377
+ pgline x, bessel_j1(x)
378
+ pgsci(GREEN)
379
+ pgsls(FULL)
380
+ pglab('\fix', '\fiy',
381
+ '\frPGPLOT Example 10: routine PGFUNX')
382
+ pgmtxt('T', -4.0, 0.5, 0.5,
383
+ '\frBessel Functions')
384
+ pgarro(8.0, 0.7, 1.0, bessel_j0(NArray[1.0])[0])
385
+ pgarro(12.0, 0.5, 9.0, bessel_j1(NArray[9.0])[0])
386
+ pgstbg(GREEN)
387
+ pgsci(0)
388
+ pgptxt(8.0, 0.7, 0.0, 0.0, ' \fiy = J\d0\u(x)')
389
+ pgptxt(12.0, 0.5, 0.0, 0.0, ' \fiy = J\d1\u(x)')
390
+ pgunsa
391
+ pgebuf
392
+ end
393
+
394
+ # ====== Demo start ======
395
+
396
+ raise "device not found" if pgopen<0
397
+
398
+ pgex0
399
+ pgex1
400
+ pgex2
401
+ pgex3
402
+ pgsubp 2,1
403
+ pgex4
404
+ pgex5
405
+ pgsubp 1,1
406
+ pgex6
407
+ pgex7
408
+ pgex8
409
+ pgex9
410
+ pgex10
411
+
412
+ pgclos
413
+ exit
414
+