Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

iterative use of pgplot producing large files

by nseymour (Initiate)
on May 06, 2015 at 05:06 UTC ( [id://1125794]=perlquestion: print w/replies, xml ) Need Help??

nseymour has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have a perl script which reads in a file and then loops over each line and makes a plot with pgplot. I have this odd effect where the plot files gradually get bigger although they all appear similar. The output postscripts increase from ~25K by on average 0.5K. As I repeat this 1,000s of times the postscript files get very large. I must not be resetting some parameter each time. The relevant parts of the code after readingh the input catalogue are"
$dev="/cps"; for($i=1;$i<=$end;$i++) { pgbegin(0,$dev,1,1); pgenv($ra[$i]-0.05,$ra[$i]+0.05,$dec[$i]-0.05,$dec[$i]+0.05,1,0); pglabel('RA (J2000)','dec. (J2000)',$name[$i]); [plot stuff] pgend; system "mv pgplot.ps $name[$i]_dist.ps" }
thanks!

Replies are listed 'Best First'.
Re: iterative use of pgplot producing large files
by jeffa (Bishop) on May 06, 2015 at 17:44 UTC

    Looking over your code snippet:

    $dev="/cps"; for($i=1;$i&lt;=$end;$i++) { pgbegin(0,$dev,1,1); pgenv($ra[$i]-0.05,$ra[$i]+0.05,$dec[$i]-0.05,$dec[$i]+0.05,1,0); pglabel('RA (J2000)','dec. (J2000)',$name[$i]); #plot stuff pgend; system "mv pgplot.ps $name[$i]_dist.ps" }

    Referring to the last line, how do you know for certain that pgplot.ps is being overwritten? If data is being appended to it each run, this could account for the increase in size. Rather than using a system call to move the placeholder file to its final destination, why don't you just directly write to that final destination? ($name[$i]_dist.ps)

    Perhaps changing the system call to the following will help? (Granted, this is not an ideal solution.)

    system "mv pgplot.ps $name[$i]_dist.ps && rm pgplot.ps";

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: iterative use of pgplot producing large files
by vinoth.ree (Monsignor) on May 06, 2015 at 05:11 UTC

    So, What is your problem ?


    All is well. I learn by answering your questions...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1125794]
Approved by GotToBTru
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-23 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found