Thread: Saving multiple panels in a single pdf

Started: 2016-01-29 20:57:27
Last activity: 2016-01-31 02:00:41
Topics: SAC Help
Ben Andrews
2016-01-29 20:57:27
I am having difficulty saving an image with multiple panels as a pdf.
I have the command saveimg after the endframe command, but it only
prints the first panel to the pdf (or perhaps it doesnt space the
individual panels correctly in the pdf?).

The reason I have been using saveimg .pdf is that it seems to provide
higher quality, crisper images than using sgf or postscript files. Is
that correct?

Thanks in advance!


** PANEL 3 - particle motion and wavelet comparison **
* restart xwindow so vspace command works OK
sgf number 3
if no ne $plot
if $batch$ eq no
bd $wdev sgf
else
bd sgf
endif
else
bg $wdev
endif
vspace 1.0

**
**
picks off ; xlabel off ; fileid off ; line on increment on list 1 3
setbb id "(substring 3 4 &1,nzyear& )(substring 2 4 (1000 +
&1,nzjday&)) (before @( '&1,kzdate&' ) &1,kstnm&"
plabel 1 on "%id% FAST %FAST%+/-%DFAST% TLAG %TLAG%+/-%DTLAG%" p 0.2
0.97 size small
plabel 2 on "_______________ SPOL %SPOL%+/-%DSPOL%" below size small
beginframe
** top row
yvport 0.55 0.90

cut %WBEG% %WEND%

** Find out whether we need to flip the slow wavelet (purely for show)
r %hfiles%
rotate to %FAST%
correlate master 1
setbb corr1 &2,depmax&
r %hfiles%
rotate to %FAST%
correlate master 1
mul 1 -1
setbb corr2 &2,depmax&
if %corr2% gt %corr1%
setbb polarity -1
else
setbb polarity 1
endif


* Uncorrected fast-slow, normalised
xvport 0.02 0.32
r %hfiles% ;
rotate to %FAST%
div (MAXIMUM &1,depmax (ABSOLUTE &1,depmin ) ) (MAXIMUM &2,depmax
(ABSOLUTE &2,depmin ) )
mul 1 %polarity%
p2 ; ylim off;

** Find out whether we need to flip the slow wavelet (purely for show)
r %hfiles_corr%
rotate to %FAST%
correlate master 1
setbb corr1 &2,depmax&
r %hfiles_corr%
rotate to %FAST%
correlate master 1
mul 1 -1
setbb corr2 &2,depmax&
if %corr2% gt %corr1%
setbb polarity -1
else
setbb polarity 1
endif


* Corrected fast-slow, normalised
xvport 0.35 0.65
r %hfiles_corr% ;
rotate to %FAST%;
div (MAXIMUM &1,depmax (ABSOLUTE &1,depmin ) ) (MAXIMUM &2,depmax
(ABSOLUTE &2,depmin ) )
mul 1 %polarity%
p2 ; ylim off;

* Corrected fast-slow, not normalised
xvport 0.68 0.98
r %hfiles_corr% ; rotate to %FAST%;
mul 1 %polarity%
p2 ; ylim off;

cut off

** bottom row
yvport 0.1 0.45
xvport 0.10 0.45
r $file$.xy1
setbb vmax (MAXIMUM &1,xmaximum &1,ymaximum )
setbb vmin (MINIMUM &1,xminimum &1,yminimum )
xlim %vmin% %vmax% ; ylim %vmin% %vmax%

p1
xlim off; ylim off

xvport 0.55 0.90
r $file$.xy2
setbb vmax (MAXIMUM &1,xmaximum &1,ymaximum )
setbb vmin (MINIMUM &1,xminimum &1,yminimum )
xlim %vmin% %vmax% ; ylim %vmin% %vmax%
p1
xlim off; ylim off

endframe ;
saveimg multiple_panels.pdf














--
Ben Andrews
Graduate Student
Reservoir Characterization Project
Colorado School of Mines
(720) 530 - 7905

  • Milton Plasencia
    2016-01-31 02:00:41
    Hi Ben,

    I tested with other sequence of sac commands and i see the command “save” works,
    see image attached.

    Your script seems OK, the only suggestion from manual for beginframe command, is
    reset commands to default values after endframe, as you does xlim off etc for example, but in your
    script i not see a fileid on.

    I follow the script in the help of beginframe and it works in OSX and 101.6a

    SAC> inicm
    SAC> cut A -0.2 N 512
    SAC> fg seismo
    SAC> beginframe
    SAC> xvport .1 .9
    SAC> yvport .7 .9
    SAC> title 'Seismic trace mmm"
    SAC> fileid off
    SAC> qdp off
    SAC> p
    SAC> fft wmean
    DC level after DFT is -0.50551
    SAC> xvport .1 .45
    SAC> yvport .15 .55
    SAC> title 'Amplitude response'
    SAC> ylim 1e-5 1
    SAC> psp am linlog
    SAC> xvport .55 .9
    SAC> title 'Amplitude response loglog'
    SAC> xlim 1 60
    SAC> psp am loglog
    SAC> endframe
    SAC> cut off
    SAC> fileid on
    SAC> xlim off
    SAC> ylim off
    SAC> save test.pdf
    save file test.pdf [PDF]
    SAC>





    HTH,

    Milton

    On Jan 29, 2016, at 20:58, Ben Andrews <bandrews<at>mymail.mines.edu> wrote:

    I am having difficulty saving an image with multiple panels as a pdf.
    I have the command saveimg after the endframe command, but it only
    prints the first panel to the pdf (or perhaps it doesnt space the
    individual panels correctly in the pdf?).

    The reason I have been using saveimg .pdf is that it seems to provide
    higher quality, crisper images than using sgf or postscript files. Is
    that correct?

    Thanks in advance!


    ** PANEL 3 - particle motion and wavelet comparison **
    * restart xwindow so vspace command works OK
    sgf number 3
    if no ne $plot
    if $batch$ eq no
    bd $wdev sgf
    else
    bd sgf
    endif
    else
    bg $wdev
    endif
    vspace 1.0

    **
    **
    picks off ; xlabel off ; fileid off ; line on increment on list 1 3
    setbb id "(substring 3 4 &1,nzyear& )(substring 2 4 (1000 +
    &1,nzjday&)) (before @( '&1,kzdate&' ) &1,kstnm&"
    plabel 1 on "%id% FAST %FAST%+/-%DFAST% TLAG %TLAG%+/-%DTLAG%" p 0.2
    0.97 size small
    plabel 2 on "_______________ SPOL %SPOL%+/-%DSPOL%" below size small
    beginframe
    ** top row
    yvport 0.55 0.90

    cut %WBEG% %WEND%

    ** Find out whether we need to flip the slow wavelet (purely for show)
    r %hfiles%
    rotate to %FAST%
    correlate master 1
    setbb corr1 &2,depmax&
    r %hfiles%
    rotate to %FAST%
    correlate master 1
    mul 1 -1
    setbb corr2 &2,depmax&
    if %corr2% gt %corr1%
    setbb polarity -1
    else
    setbb polarity 1
    endif


    * Uncorrected fast-slow, normalised
    xvport 0.02 0.32
    r %hfiles% ;
    rotate to %FAST%
    div (MAXIMUM &1,depmax (ABSOLUTE &1,depmin ) ) (MAXIMUM &2,depmax
    (ABSOLUTE &2,depmin ) )
    mul 1 %polarity%
    p2 ; ylim off;

    ** Find out whether we need to flip the slow wavelet (purely for show)
    r %hfiles_corr%
    rotate to %FAST%
    correlate master 1
    setbb corr1 &2,depmax&
    r %hfiles_corr%
    rotate to %FAST%
    correlate master 1
    mul 1 -1
    setbb corr2 &2,depmax&
    if %corr2% gt %corr1%
    setbb polarity -1
    else
    setbb polarity 1
    endif


    * Corrected fast-slow, normalised
    xvport 0.35 0.65
    r %hfiles_corr% ;
    rotate to %FAST%;
    div (MAXIMUM &1,depmax (ABSOLUTE &1,depmin ) ) (MAXIMUM &2,depmax
    (ABSOLUTE &2,depmin ) )
    mul 1 %polarity%
    p2 ; ylim off;

    * Corrected fast-slow, not normalised
    xvport 0.68 0.98
    r %hfiles_corr% ; rotate to %FAST%;
    mul 1 %polarity%
    p2 ; ylim off;

    cut off

    ** bottom row
    yvport 0.1 0.45
    xvport 0.10 0.45
    r $file$.xy1
    setbb vmax (MAXIMUM &1,xmaximum &1,ymaximum )
    setbb vmin (MINIMUM &1,xminimum &1,yminimum )
    xlim %vmin% %vmax% ; ylim %vmin% %vmax%

    p1
    xlim off; ylim off

    xvport 0.55 0.90
    r $file$.xy2
    setbb vmax (MAXIMUM &1,xmaximum &1,ymaximum )
    setbb vmin (MINIMUM &1,xminimum &1,yminimum )
    xlim %vmin% %vmax% ; ylim %vmin% %vmax%
    p1
    xlim off; ylim off

    endframe ;
    saveimg multiple_panels.pdf














    --
    Ben Andrews
    Graduate Student
    Reservoir Characterization Project
    Colorado School of Mines
    (720) 530 - 7905

    ----------------------
    SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)

    Sent via IRIS Message Center (http://ds.iris.edu/message-center/)
    Update subscription preferences at http://ds.iris.edu/account/profile/


    Attachments
17:38:15 v.22510d55