PyFerret/Example

From ScientificComputing
Jump to: navigation, search

As an example for using PyFerret, we run the bar_chart_demo.jnl script, that is part of the PyFerret installation.

[leonhard@euler08 ~]$ cat bar_chart_demo.jnl 
! bar_chart.jnl
! *sh* 6/99
! *acm* 7/01 update /xlimits to /hlimits

! Description: demonstrate usage of bar charts

set mode verify

! most basic example -- no overlay, no axes
let a = RANDN(I[i=1:8]) + 1
go bar_chart3 poly/line/fill/nolabel/noaxis a a
label/nouser 0.5,-.1,1,90,.16 @CRItem 1
label/nouser 1.5,-.1,1,90,.16 @CRItem 2
label/nouser 2.5,-.1,1,90,.16 @CRItem 3
\pause

! overlay two variables on auto-formatted axes
let a = 1+RANDU(I[i=1:10])
ppl axset 0,1,1,0  ! remove top and right axes
plot/hlimits=0.5:10.5/sym/ylim=0:2/title="My Bars" 0*a+0.5
go bar_chart3 poly/line/palette=red/overlay/title="My reds" a
let b = RANDU(I[i=1:10]+1)
go bar_chart3 poly/line/palette=blue/overlayy/title="My blues" b
ppl axset 1,1,1,1  ! restore normal axes
\pause

! time series colored by magnitude
let a = RANDN(T[T=2-jan-1990:1-jun-1990:24])
plot/ylim=-3:3/title="hist-style plot" 0*a
go bar_chart3 poly/over/palette=no_green_centered/levels=(-3,3,.5)/nolab a a

[leonhard@euler08 ~]$ module load gcc/4.8.2 pyferret/1.0.2
Autoloading openblas/0.2.13_seq
[leonhard@euler08 ~]$ bsub -n 1 -W 0:15 -R "rusage[mem=512]" "pyferret -batch -script bar_chart_demo.jnl"
Generic job.
Job <36553098> is submitted to queue <normal.4h>.
[leonhard@euler08 ~]$ bjobs
JOBID      USER       STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
36553098   leonhard   PEND  normal.4h  euler08                 *_demo.jnl Jan 30 09:56
[leonhard@euler08 ~]$ bjobs
JOBID      USER       STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
36553098   leonhard   RUN   normal.4h  euler08     e1339       *_demo.jnl Jan 30 09:56
[leonhard@euler08 ~]$ bjobs
No unfinished job found
[leonhard@euler08 ~]$ ls
bar_chart_demo.jnl  ferret.png  lsf.o36553098

The demo script creates a bar chart and saves the result as .png. If no name for the file is given the file will be saved as ferret.png.

Bar chart example