Index: trunk/tools/diskspace/rework/README
===================================================================
--- trunk/tools/diskspace/rework/README	(revision 38749)
+++ trunk/tools/diskspace/rework/README	(revision 38749)
@@ -0,0 +1,3 @@
+The result of query.sql can be fed to result2size.pl, which will
+attempt to calculate the expected disk usage based on the database
+count numbers.
Index: trunk/tools/diskspace/rework/measure_stacks.pl
===================================================================
--- trunk/tools/diskspace/rework/measure_stacks.pl	(revision 38749)
+++ trunk/tools/diskspace/rework/measure_stacks.pl	(revision 38749)
@@ -0,0 +1,85 @@
+#! /usr/local/bin/perl -w
+
+#use DBI;
+use Nebulous::Client;
+# my (    $db, $dbhost, $dbpass, $dbuser);
+# my $conffile = "/home/panstarrs/ipp/ippconfig/nebulous.config";
+# if (-e $conffile) {
+# #    printf STDERR "found config\n";
+#     open(IN,$conffile);
+#     while(<IN>) {
+#         chomp;
+#         if ($_ =~ /NEB_DB\s+/) {
+#             $db = (split /\s+/,$_)[2];
+#         }
+#         elsif ($_ =~ /NEB_DBHOST/) {
+#             $dbhost = (split /\s+/,$_)[2];
+#         }
+#         elsif ($_ =~ /NEB_USER/) {
+#             $dbuser = (split /\s+/,$_)[2];
+#         }
+#         elsif ($_ =~ /NEB_PASS/) {
+#             $dbpass = (split /\s+/,$_)[2];
+#         }
+#     }
+#     close(IN);
+# #    print STDERR  "$db $dbhost $dbuser $dbpass\n";
+# }
+
+# my $dbh = DBI->connect(
+#     "DBI:mysql:database=$db:host=$dbhost",
+#     $dbuser,
+#     $dbpass,
+#     {
+#         RaiseError => 1,
+#         PrintError => 0,
+#         AutoCommit => 0,
+#     },
+#     );
+my $server;
+$server = $ENV{'NEB_SERVER'} unless $server;
+
+
+my $neb = Nebulous::Client->new(
+    proxy => "$server",
+    );
+
+
+
+my @pb = ();
+open(PB,"pb.dat");
+while (<PB>) {
+    chomp;
+    if ($_ =~ /path_base/) {
+	next;
+    }
+    push @pb, "${_}%";
+}
+close(PB);
+
+foreach my $path_base (@pb) {
+    my $size = 0;
+#    print "$path_base $size\n";
+#    die;
+    my $keys = $neb->find_objects_wildcard($path_base);
+
+    foreach my $key (@{ $keys }) {
+	my $uris;
+	eval {$uris = $neb->find_instances($key) };
+	if ($@) { 
+	    print "# $key NO AVAILABLE\n";
+	    next;
+	}
+	my $count = $#{ $uris } + 1;
+	my $psize = 0;
+	if (defined ($uris)) {
+	    my $file = URI->new(@$uris[0])->file;
+	    my @stat = stat($file);
+	    $psize = $count * $stat[7];
+	}
+	print "# $key $count $psize\n";
+	$size += $psize;
+    }
+    print "$path_base $size\n";
+}
+
Index: trunk/tools/diskspace/rework/query.sql
===================================================================
--- trunk/tools/diskspace/rework/query.sql	(revision 38749)
+++ trunk/tools/diskspace/rework/query.sql	(revision 38749)
@@ -0,0 +1,24 @@
+SELECT "raw" AS stage_name,count(exp_id), state FROM rawExp GROUP BY state
+UNION
+SELECT "chip" AS stage_name,count(chip_id),state FROM chipRun WHERE label NOT IN ('LAP.PV3W.20150312','LAP.PV3.20140730','LAP.PV3.20140730.remote') GROUP BY state
+UNION
+SELECT "chip_lies" AS stage_name,count(chip_id),state FROM chipRun  WHERE label IN ('LAP.PV3W.20150312','LAP.PV3.20140730','LAP.PV3.20140730.remote') GROUP BY state
+UNION
+SELECT "cam" AS stage_name,count(cam_id), state FROM camRun GROUP BY state
+UNION
+SELECT "warp" AS stage_name,count(warp_id), state FROM warpRun WHERE label NOT IN ('LAP.PV3W.20150312','LAP.PV3.20140730','LAP.PV3.20140730.remote','LAP.PV3.20140730.final','LAP.PV3.20140730') GROUP BY state
+UNION
+SELECT "warp_lies" AS stage_name,count(warp_id),state FROM warpRun  WHERE label IN ('LAP.PV3W.20150312','LAP.PV3.20140730','LAP.PV3.20140730.remote','LAP.PV3.20140730.final','LAP.PV3.20140730') GROUP BY state
+UNION
+SELECT "diff" AS stage_name,count(diff_id), state FROM diffRun WHERE label NOT IN ('LAP.PV3W.20150312','LAP.PV3.20140730.diff01.done','LAP.PV3.20140730.remote') GROUP BY state 
+UNION
+SELECT "diff_lies" AS stage_name,count(diff_id),state FROM diffRun  WHERE label IN ('LAP.PV3W.20150312','LAP.PV3.20140730.diff01.done','LAP.PV3.20140730.remote') GROUP BY state
+UNION
+SELECT "stack" AS stage_name,count(stack_id), state FROM stackRun GROUP BY state
+UNION 
+SELECT "ssky" AS stage_name, count(sky_id), state FROM staticskyRun GROUP BY state
+UNION
+SELECT "skycal" AS stage_name, count(skycal_id), state FROM skycalRun GROUP BY state
+UNION
+SELECT "ff" AS stage_name, count(ff_id), state FROM fullForceRun GROUP BY state
+;
Index: trunk/tools/diskspace/rework/result2size.pl
===================================================================
--- trunk/tools/diskspace/rework/result2size.pl	(revision 38749)
+++ trunk/tools/diskspace/rework/result2size.pl	(revision 38749)
@@ -0,0 +1,148 @@
+#! /usr/local/bin/perl -w
+
+my %sizes = (
+    raw => {
+	full => 2.3458,
+	lossy => 0.3089,
+	goto_compressed => 2.3458,
+	goto_lossy => 2.64,
+	keep => 2.3458,
+	roc => 1.1729
+    },
+    chip => {
+	full => 2.3811,
+	cleaned => 0.0350,
+	error_cleaned => 0.0350,
+	goto_cleaned => 2.3811,
+	new => 0.0,
+	drop => 0.0,
+	purged => 0.0350,
+	scrubbed => 0.0350,
+	update => 2.3811,
+#	wait.for.now => 0.0
+    },
+    chip_lies => {
+	full => 0.0350,
+	new => 0.0,
+	cleaned => 0.0350,
+    },
+    cam => {
+	full => 0.2824,
+	cleaned => 0.2824,
+	drop => 0.0,
+	error_cleaned => 0.2824,
+	goto_cleaned => 0.2824,
+	goto_purged => 0.2824,
+	new => 0.0,
+	purged => 0.0,
+	update => 0.2824,
+	wait => 0.0
+    },
+    warp => {
+	full => 3.1354,
+	cleaned => 0.0339,
+	drop => 0.0339,
+	keep => 3.1354,
+	error_cleaned => 3.1354,
+	goto_purged => 3.1354,
+	new => 0.0,
+	purged => 0.0339,
+	scrubbed => 0.0339,
+	update => 0.0339
+    },
+    warp_lies => {
+	full => 0.0339,
+	drop => 0.0339,
+	new => 0.0
+    },
+    diff => {
+	full => 8.0601,
+	cleaned => 0.0964,
+	drop => 0.0964,
+	error_cleaned => 8.0601,
+	goto_cleaned => 8.0601,
+	goto_purged => 8.0601,
+	new => 0.0,
+	purged => 0.0964,
+	update => 0.0964,
+	wait => 0.0
+    },
+    diff_lies => {
+	full => 0.0964,
+	cleaned => 0.0964
+    },
+    stack => {
+	# Old full value = 0.5015.  New value from 10k samples = 0.2748
+	full => 0.2748,
+	cleaned => 0.0028,
+	drop => 0.0028,
+	error_cleaned => 0.2748,
+	error_purged => 0.2748,
+	error_scrubbed => 0.2748,
+	goto_cleaned => 0.2748,
+	goto_purged => 0.2748,
+	goto_scrubbed => 0.2748,
+	new => 0.0,
+	purged => 0.0028,
+	scrubbed => 0.0028,
+	wait => 0.0
+    },
+    ssky => {
+	full => 0.2824/8,
+	drop => 0.2824/8,
+	new => 0.0,
+	update => 0.2824/8,
+	wait => 0.0
+    },
+    skycal => {
+	full => 0.2824/40,
+	goto_cleaned => 0.2824/40,
+	drop => 0.2824/40,
+	new => 0.0,
+	update => 0.2824/40,
+	wait => 0.0
+    },
+    ff => {
+	full => 0.2824/3,
+	drop => 0.2824/3,
+	new => 0.0,
+    }
+    );
+    
+
+%sums = ();
+%counts_full = ();
+%counts_total = ();
+while (<>) {
+    chomp;
+
+    my ($stage_name,$count,$state) = split /\s+/;
+    if ($stage_name eq 'stage_name') { next; }
+    my $z = $sizes{$stage_name}{$state};
+    unless (defined($z)) {
+#	print "Skipping undefined: $stage_name $state\n";
+	next;
+    }
+    
+    $sums{$stage_name} += $count * $z;
+    if ($state eq 'full') {
+	$counts_full{$stage_name} += $count;
+    }
+    $counts_total{$stage_name} += $count;
+
+    $sum_total += $count * $z;
+}
+
+foreach my $stage_name ('raw','chip','chip_lies','cam','warp','warp_lies','diff','diff_lies','stack','ssky','skycal','ff') {
+    printf("%10s  %8d  %8d  %1.4e\n",
+	   $stage_name,$counts_full{$stage_name},$counts_total{$stage_name},$sums{$stage_name});
+}
+printf("%10s  %8s  %8s  %1.4e\n",
+       "total","","",$sum_total);
+printf("%10s  %8s  %8s  %1.4e\n",
+       "dvo?","","",4.5e5);
+my $neb;
+chomp($neb = `neb-df | grep '/total'`);
+$neb_size = (split /\s+/,$neb)[2];
+printf("%10s  %8s  %8s  %1.4e\n",
+       "nebulous","","",$neb_size / 1024 / 1024);
