#!/usr/bin/perl -I/mdisw/perl require 'date2int.pl'; require 'tstamp.pl'; ############################## # find-c3-deep-2 # # Page through the entire C3 catalog structure, # finding hours in which there are lots of Clear/Clear # exposures of the outer corona. # # This is a one-time hack. It runs in ~zowie on ajax.nrl.navy.mil, # where the symbolic link "CATALOG" points to the main catalog # directory over there. # # Written: Craig DeForest, 17-Jan-1999 # # Shit. Like most one-time hacks, this one is being reworked # into something else. OK, now I want to find the 4 hour # period containing the most seconds of exposure. So I'll # start with each exposure and count hours into the future. # This requires a little thought to make it a one-pass operation: # we'll need an array of "actively counted" intervals, indexed # by start time (which will be the times of the exposures that # start them). Each time we read in an exposure (presumably in # chronological order) we'll retire exposures appropriately. # # The same boneheaded filtering scheme will be applied. # # I also want to exclude the runs before 1-march-1996, which # have lousy f corona models compared to the later ones. # # Here's the definition of the interval, in seconds $search_window = 60 * 60 * 4; # Here's the shortest total exposure we'll consider, in seconds $min_total_exp = 200; # ############################## $| = 1; #Purge stdout writes $secsperhour = 60*60; print "Changing to CATALOG/daily...\n"; chdir "CATALOG/daily" || die "Couldn't change dir"; ############################## # Read in the individual daily filenames print "Listing daily dir catalog..."; @a = `ls`; print "Found $#a lines..."; @dayfiles = sort (grep(/^c3_/,@a)); chop @dayfiles; print "Found $#dayfiles days.\n"; ### Loop through the dayfiles, snarfing 'em a line at a time foreach $dayfile(@dayfiles) { next if (($dayfile =~ m/c3_95/) || ($dayfile =~ m/c3_960[12]/)); open (FOO,"<$dayfile") || die "Couldn't open $dayfile for reading...\n"; print "$dayfile..."; @lines = ; print $#lines+1," lines..."; chop @lines; ### Fields are multiple-space-delimited. Interpretations are mine (I haven't ### done the proper research into the file definition, only looked at the actual ### files and guessed.) foreach $_(@lines) { ($fname,$date,$time,$cam,$exptime,$naxis1,$naxis2,$a,$b,$filt1,$filt2,$c,$d,$e) = split (/\s\s+/); ### Interpret the time $when = &date2int("$date $time"); ### Ignore lines that don't fit the search criteria if ( ($naxis1 == 1024) && ($naxis2 == 1024) && ($filt1 =~ m/Clear/) && ($filt2 eq "Clear") && ($c !~ /(Dark|Lamp|PW)/) ) { ### This line fits the search criteria -- define a new interval, ### retire old intervals, and increment surviving ones. $active_ints{$when} = 0; # Define this interval in the hash foreach $_ ( keys %active_ints ) { if($_ < $when - $search_window) { $retired_ints{$_} = $active_ints{$_} if($active_ints{$_} > $min_total_exp); delete $active_ints{$_}; } $active_ints{$when} += $exptime; } ## Do some bookkeeping $dayexpct{$date}++; $dayexp{$date}+=$exptime; } } printf "%d OK exps (%d secs total). %d act; %d ret.\n",$dayexpct{$date},$dayexp{$date},scalar(keys %active_ints),scalar(keys %retired_ints); } print "Done scanning days..."; foreach $_(keys %active_ints) { $retired_ints{$_} = $active_ints{$_} if($active_ints{$_} > $min_total_exp); } @intervals = keys %retired_ints; print "Binning $#intervals intervals...\n"; @exps = values %retired_ints; while($h = shift @intervals) { $exp = int shift @exps; $byexptime{$exp} .= ($byexptime{$exp} ? "," : "").$h; } @byexptime = keys %byexptime; print "Sorting $#byexptime exposure times....\n"; @byexptime = sort {$b <=> $a} keys %byexptime; print "\n\n"; foreach $exptime(@byexptime) { @times = sort(split(/,/,$byexptime{$exptime})); print "$exptime:\t"; foreach $_(@times) { $a = &tstamp('%yymmdd',$_); print $a."\t" if( ! ($listed_days{$a} ) ); $listed_days{$a}=1; } print "\n"; }