#!/usr/bin/perl -w # RWB January 5, 2002 # Manage PSM data. use strict; my $iyear=2001; # year (can be changed interactively) my $iday1=245; # first day (ditto) my $iday2=245; # last day (ditto) my $iftp=0; # flag for ftp transfer (ditto) my $icalcbw=0; # flag to calc b and w files (ditto) my $idet=0; # flag for quadrature detection (ditto) my $iplotd=0; # flag to plot detected signal (ditto) my $imkwebd=0; # flag to make d-signal web page (ditto) # **** Set default paths for different types of data. # **** abdus:/usr/data/bland/ is hdb1; abdus:/usr/data/mild/ is hdc1. my $fname='r0124506.27m'; # 2-hr PSM raw-data file my $mpath='/usr/data/mild/pioneer/2001/'; # m files (raw data) my $bpath='/usr/data/bland/pioneer/2001/'; # b files (beam-formed arrays) my $wpath='/usr/data/bland/pioneer/2001/'; # w files (Webb-filtered arrays) my $dpath='/usr/data/bland/pioneer/2001/'; # d files (matched-filter output) init(); # initialization if($icalcbw) { calcbw(); } if($idet) { rdetect(); } if($iplotd) {plotd(); } if($imkwebd) {mkwebd(); } # END of main script sub init() { pbanner(); # Print an introductory banner. askval(); # Set parameters interactively. } sub pbanner() { print "This PERL script manages data from Pioneer Seamount. The\n"; print "first operation is to update the SFSU raw data files by\n"; print "downloading files from PMEL via ftp. The next operation\n"; print "is to calculate beam-formed time series and mixed, down-\n"; print "sampled time series. Then quadrature detection with RAFOS\n"; print "replicas is carried out. Finally various plots are made\n"; print "and stored, printed, posted, etc. The operations to be\n"; print "carried out and the time period are selected interactively\n"; print "or through command-line arguments.\n"; print "RWB, January 5, 2002\n"; } # Subroutine to prompt for parameters. sub askval() { my $a; ; print "\$iyear, \$iday1, \$iday2 = $iyear, $iday1, $iday2\n"; print "year: $iyear: "; $a=; chomp($a); if(length($a) gt 0) {$iyear=$a}; print "first day: $iday1: "; $a=; chomp($a); if(length($a) gt 0) {$iday1=$a; $iday2=$iday1;} print "last day: $iday2: "; $a=; chomp($a); if(length($a) gt 0) {$iday2=$a}; print "iftp (0->don't ftp): $iftp: "; $a=; chomp($a); if(length($a) gt 0) {$iftp=$a}; print "icalcbw (0->don't calcbw): $icalcbw: "; $a=; chomp($a); if(length($a) gt 0) {$icalcbw=$a}; print "idet (0->don't detect): $idet: "; $a=; chomp($a); if(length($a) gt 0) {$idet=$a}; print "iplotd (0->don't plotd): $iplotd: "; $a=; chomp($a); if(length($a) gt 0) {$iplotd=$a}; print "imkwebd (0->don't mkwebd): $imkwebd: "; $a=; chomp($a); if(length($a) gt 0) {$imkwebd=$a}; } ### END of subroutine askval() sub calcbw() { # Use m-files (raw 2-hour PSM data files) to calculate beam-formed # arrays (b-files) and mixed, downsampled arrays (w files). my $nextname=''; my $id; my @a=(); my $files = '/usr/data/mild/pioneer/2001/r01246??.??m'; # template # for searching for files my ($idlcom,$stat1); # command and return status for spawned IDL job. substr($files,-17,4) = sprintf("%04d",$iyear); # year into the path for ($id=$iday1; $id <= $iday2; $id++) { substr($files,-11,5) = sprintf("%02d%03d",$iyear%100,$id); print "Files to be processed: $files\n"; @a=glob($files); print "The number of files found is ".@a."\n"; if(!defined(@a)) {print "No files found.\n";} while (defined($nextname = glob($files))) { print "next file name is $nextname\n"; $fname=substr($nextname,-12,12); # Abstract the file name. open( TEMP,'>ptemp1.tmp' ); print TEMP ".rnew get2hrs\n"; print TEMP ".rnew get2hrs\n"; print TEMP "get2hrs,'$fname','$mpath','$bpath'\n"; print TEMP "exit\n"; close( TEMP ); $idlcom = "idl ptemp1.tmp"; # IDL command system($idlcom); unlink( "ptemp1.tmp" ); } } } # End of subroutine calcbw. sub rdetect() { # Use w-files (2-hour PSM data files with beam-formed, mixed and down- # sampled time series) to carry out quadrature cross-correlation # detection using RAFOS replicas. my $nextname=''; my $id; my @a=(); my $files = '/usr/data/bland/pioneer/2001/r01246??.??w'; # template # for searching for files my ($idlcom,$stat1); # command and return status for spawned IDL job. substr($files,-17,4) = sprintf("%04d",$iyear); # year into the path for ($id=$iday1; $id <= $iday2; $id++) { substr($files,-11,5) = sprintf("%02d%03d",$iyear%100,$id); print "Files to be processed: $files\n"; @a=glob($files); print "The number of files found is ".@a."\n"; if(!defined(@a)) {print "No files found.\n";} while (defined($nextname = glob($files))) { print "next file name is $nextname\n"; open( TEMP,'>ptemp1.tmp' ); print TEMP ".rnew rafdet\n"; print TEMP ".rnew rafdet\n"; print TEMP "rafdet,'$nextname'\n"; print TEMP "exit\n"; close( TEMP ); $idlcom = "idl ptemp1.tmp"; # IDL command system($idlcom); unlink( "ptemp1.tmp" ); } } } # End of subroutine rdetect. sub plotd() { # Use d-files (2-hour PSM data files of quadrature-cross-correlation # output) to make plots and image files, for posting on the web. my $nextname=''; my $id; my @a=(); my $files = '/usr/data/bland/pioneer/2001/r01246??.??d'; # template # for searching for files my ($idlcom,$stat1); # command and return status for spawned IDL job. my $fnpart1 = 'r012450627'; # first part of graphics-image file name my $fnpng = 'r012450627.png'; # template for full-size .png image file my $fnpngt = 'r012450627t.png'; # template for .png thumbnail file substr($files,-17,4) = sprintf("%04d",$iyear); # year into the path for ($id=$iday1; $id <= $iday2; $id++) { substr($files,-11,5) = sprintf("%02d%03d",$iyear%100,$id); print "Files to be processed: $files\n"; @a=glob($files); print "The number of files found is ".@a."\n"; if(!defined(@a)) {print "No files found.\n";} while (defined($nextname = glob($files))) { print "next file name is $nextname\n"; $fnpart1=substr($nextname,-12,8).substr($nextname,-3,2); substr($fnpng,0,10)=$fnpart1; substr($fnpngt,0,10)=$fnpart1; print "\$fnpng, \$fnpngt = $fnpng, $fnpngt\n"; open( TEMP,'>ptemp1.tmp' ); print TEMP ".rnew plt2hd\n"; print TEMP ".rnew plt2hd\n"; print TEMP "set_plot,'Z'\n"; print TEMP "device,set_resolution=[700,350]\n"; print TEMP "plt2hd,'$nextname'\n"; print TEMP "write_png,'$fnpng',tvrd()\n"; print TEMP "device,set_resolution=[150,100]\n"; print TEMP "plt2hd,'$nextname',charsize=0.6\n"; print TEMP "write_png,'$fnpngt',tvrd()\n"; print TEMP "exit\n"; close( TEMP ); $idlcom = "idl ptemp1.tmp"; # IDL command system($idlcom); unlink( "ptemp1.tmp" ); } } } # End of subroutine plotd. sub mkwebd() { # Make a web page to display plots of the "d" signal (quadrature-cross- # correlation output). my $nextname=''; my $id; my @a=(); my $files = '/usr/data/bland/pioneer/2001/r01246??.??d'; # template # for searching for files my ($idlcom,$stat1); # command and return status for spawned IDL job. my $fnhtml = 'day245.html'; # template for html file name my $fnd = 'r0124506.27d'; # template for 'd' data file my $fnpart1 = 'r012450627'; # first part of graphics-image file name my $fnpng = 'r012450627.png'; # template for full-size .png image file my $fnpngt = 'r012450627t.png'; # template for .png thumbnail file substr($files,-17,4) = sprintf("%04d",$iyear); # year into the path for ($id=$iday1; $id <= $iday2; $id++) { substr($fnhtml,3,3) = sprintf("%03d",$id); # Insert correct day no. open( TEMP,">$fnhtml" ); print TEMP " RAFOS signal for day $id of $iyear
RAFOS quadrature-cross-correlation signal for $iyear, day $id\n"; substr($files,-11,5) = sprintf("%02d%03d",$iyear%100,$id); print "Files to be processed: $files\n"; @a=glob($files); print "The number of files found is ".@a."\n"; if(!defined(@a)) {print "No files found.\n";} while (defined($nextname = glob($files))) { print "next file name is $nextname\n"; $fnd=substr($nextname,-12,12); # file name w/o path $fnpart1=substr($nextname,-12,8).substr($nextname,-3,2); substr($fnpng,0,10)=$fnpart1; substr($fnpngt,0,10)=$fnpart1; print TEMP "

$fnd
\n"; } print TEMP "
\n"; close( TEMP ); } } # End of subroutine mkwebd.