I've written a small perl script to create a series of .gif files, from a series of text datafiles, using PGPLOT. The code is shown below. It takes the 100 text files and turns them into 100 .gif images called 'frame_xxx.gif' from 001 to 100. These then form the frames of an animated gif.

The code sucessfully creates frame 1 and frames 3-100 as files in the $animdir directory (so it looks like its working), but for frame 2 it creates the gif file in the current directory with a filename of pgplot10922.gif and creates an empty frame_002.gif file in the $animdir directory. This is accompanied by the onscreen message "PGPLOT, Writing new GIF image as: pgplot10922.gif"

I'm very confused. This file is correct, but not called the right thing or in the right place! And why does it work for all the other frames but not that one? Any ideas?
# -------------- System variables my $currentdir = getcwd(); my $logdir = "Logs"; my $outdir = "Windoutput"; my $specdir = "Specfiles"; my $animdir = "Animfiles"; # -------------- End system variables # -------------- Main program variables my $framenumber = 1; my $frameplot; my $emin=300; my $emax=13000; my $xmin = log10($emin/1000); my $xmax = log10($emax/1000); my $ymin = log10(6E2); my $ymin2 = log10(2E4); my $ymax = log10(6E6); my $filename; # -------------- Prompted Variables print " Please enter number of frames (default = 100): "; my $nframes = <STDIN>; chomp $nframes; $nframes = 100 if ($nframes eq ""); print " Processing frame:\n "; # -------------- Main program loop until ($framenumber>$nframes) { print "${framenumber}: "; $filename = "$animdir/frame_00${framenumber}.gif/gif" if ($framenu +mber<10); $filename = "$animdir/frame_0${framenumber}.gif/gif" if (($framenu +mber>9) and ($framenumber<100)); $filename = "$animdir/frame_${framenumber}.gif/gif" if $framenumbe +r>99; print "$filename\n"; $frameplot = PDL::Graphics::PGPLOT::Window->new(Device => $filenam +e, AxisColour => 'black', Font => 'Roman', WindowXSize => 8 , WindowY +Size => 9.23, HardLW => 4); $frameplot = PDL::Graphics::PGPLOT::Window->new(Device => '/xs', A +xisColour => 'black', Font => 'Roman', WindowXSize => 8 , WindowYSize + => 9.23) if ($debug_level==1); # Prepare space for transmitted spectrum plot $frameplot->env($xmin,$xmax,$ymin,$ymax, { PlotPosition => [0.06, 0.99, 0.06, 0.639], Charsize => 0.8, Axis => 'LogXY', Xtitle => 'Energy (keV)', Ytitle => 'E L\dE\u [erg(erg/s/erg)]', }); my ($energy, $trans) = rcols "$animdir/${framenumber}_trans_spect. +txt", {LINES => '4:-1'}; my ($junk, $emit) = rcols "$animdir/${framenumber}_emit_spect.txt" +, {LINES => '4:-1'}; my ($incenergy, $inclumin) = rcols "${xscortpath}/powerlaw.dat", { +LINES => '2:-1'}; my $plotmask = which(($incenergy>$emin) & ($incenergy<$emax)); my $x = $incenergy->dice($plotmask); my $y = $inclumin->dice($plotmask); $frameplot->line(log10($x/1000), log10($y*1.60217646E-12*$x), {Col +our => 'black'}); $plotmask = which(($energy>$emin) & ($energy<$emax)); $x = $energy->dice($plotmask); $y = $trans->dice($plotmask); $frameplot->line(log10($x/1000), log10($y*1.60217646E-12*$x), {Col +our => 'blue'}); $y = $emit->dice($plotmask); $frameplot->line(log10($x/1000), log10($y*1.60217646E-12*$x), {Col +our => 'red'}); $frameplot->env($xmin,$xmax,$ymin2,$ymax, { PlotPosition => [0.06, 0.99, 0.639, 0.99], Charsize => 0.8, Axis => ['BCSTL','BCNSTL'], Ytitle => 'E L\dE\u [erg(erg/s/erg)]', }); $plotmask = which(($incenergy>$emin) & ($incenergy<$emax)); $x = $incenergy->dice($plotmask); $y = $inclumin->dice($plotmask); $frameplot->line(log10($x/1000), log10($y*1.60217646E-12*$x), {Col +our => 'black'}); $y = ($emit+$trans)->dice($plotmask); $frameplot->line(log10($x/1000), log10($y*1.60217646E-12*$x), {Col +our => 'dark green'}); if ($debug_level==1) { print "Press return to continue..."; my $pause = <STDIN>; } $frameplot->close(); $framenumber++; }

In reply to PGPLOT perl module weirdness... by nickschurch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.