#!/usr/bin/perl # Routine to collect the LSPN data from the HAL_0001-19 disks and # redistribute it and the corresponding browse files in to a parallel # date-hierarchical directory trees (one for data, one for browse). # The PDS labels contain almost no meta-data, so the date must be found # in the FITS extension headers. No DATA_SET_ID is in the labels, # either, but we are not going to attempt to update or correct the # labes (or uncompress the image data, either). This is just a # reorganization to fit our single-volume/one-data-set website paradigm. # #============================================================================ # # This list of directories (there's one per volume)holding observational data: @vollist = ("/sbnarch01/volume/hal_0001/c85sep21", "/sbnarch01/volume/hal_0002/c85dec07", "/sbnarch01/volume/hal_0003/c85dec14", "/sbnarch01/volume/hal_0004/c86jan05", "/sbnarch01/volume/hal_0005/c86jan12", "/sbnarch01/volume/hal_0006/c86mar07", "/sbnarch01/volume/hal_0007/c86mar11", "/sbnarch01/volume/hal_0008/c86mar15", "/sbnarch01/volume/hal_0009/c86mar18", "/sbnarch01/volume/hal_0010/c86mar20", "/sbnarch01/volume/hal_0011/c86mar22", "/sbnarch01/volume/hal_0012/c86apr05", "/sbnarch01/volume/hal_0013/c86apr09", "/sbnarch01/volume/hal_0014/c86apr12", "/sbnarch01/volume/hal_0015/c86apr15", "/sbnarch01/volume/hal_0016/c86apr17", "/sbnarch01/volume/hal_0017/c86apr29", "/sbnarch01/volume/hal_0018/c86may08"); #-------------------------------------------------------------- # Loop through the volume list: foreach $volume (@vollist) { # Open the firectory and loop through contents: opendir(DATA,$volume) || die "Could not open directory $volume for reading ($!)"; foreach $file (sort readdir(DATA)) { next if ($file !~ /hdr$/); # Only interested in FITS headers # Now we'll open the header by piping it through 'brkstrm', # looking for the 'DATE-OBS' line: open(HDR,"brkstrm < $volume/$file |") || die "Could not open brkstrm pipe for $volume/$file ($!)\n"; $line = ; # First line is not the one we're looking for. $line = while ($line !~ /^DATE-OBS/); $line =~ /^DATE-OBS=\s*'(.*)\/(.*)\/(.*)\s*'/; $day = $1; $month = $2; $year = 1900 + $3; close(HDR); # Done with this now. $datadir = "data/$year/$month/$day"; $browdir = "browse/$year/$month/$day"; # We do need to create these directories if they don't already # exists, so we better check before copying: mkdir "data/$year" if (! -d "data/$year"); mkdir "data/$year/$month" if (! -d "data/$year/$month"); mkdir "data/$year/$month/$day" if (! -d "data/$year/$month/$day"); mkdir "browse/$year" if (! -d "browse/$year"); mkdir "browse/$year/$month" if (! -d "browse/$year/$month"); mkdir "browse/$year/$month/$day" if (! -d "browse/$year/$month/$day"); # All the volume browse directories have the same name, so we'll # create it from the data directory name: $volume =~ /^(.*)\/c8/; $browse = "$1/browse"; # And we'll need to replace the file extension with ".*": $file =~ s/\.hdr/.*/; # And now we're ready to copy: system "cp -p $volume/$file $datadir"; system "cp -p $browse/$file $browdir"; # On to the next file.... } closedir(DATA); # Next directory... }