DRAORed.pm - a perl module of useful subroutines for handling DRAO data.
Put this file in your perl's @INC path, and in your perl program put
use DRAORed.pm
or
use DRAORed.pm qw(desired functions)
near the top.
July 27, 2005: cookiecutter() and lnrget() now return the madr index # of their
results, or hopefully 0 on failure.
July 12, 2005: lnrget() now supports cubes.
June 8, 2005: survey() now works with the Planck Deep Field and Perseus region.
Nov. 25, 2004: latestimageindex() should now work for either 21 or 74 cm maps.
Nov. 22, 2004: survey() now works with the Cas A (xQ) fields.
June 2004: Finds old logs and reorganizes them (possibly gzipped) into an HTML
directory.
- survey([filename])
-
Get survey (field) code.
-
With no argument:
Looks for a valid .TBL file in the current directory. Returns -1 if none is
found, and dies if more than 1 is found.
-
With argument: If the above fails, guesses the pointing code from the
initial characters of $filename.
- visfilenames($stokes, $band)
-
Get visibility filenames for $stokes and $band.
- latestviscode($stokes, $band)
-
Get latest visibility code. Subroutinized by RR from polproc.step2 (by RK).
- finalviscode()
-
Get visibility code used to make the latest CLEANed image in a
directory, by reading the clean log, or die!
- fileindex(madr_pattern)
-
madr index of files matching argument.
- rfileindex(madr_pattern, rdir[, exactmatch])
-
madr index of files in remote directory rdir matching madr_pattern.
- printhash(%hash)
-
Prints the contents of %hash.
- readdef($madr_index)
-
Returns a description of a madr definition.
- altreaddef($madr_index)
-
Returns a description of a madr definition. Instead of doing the obvious thing
like
readdef() and using s f$madr_index, this does def f$madr_index with a long
string of newlines, and reads the definition from the defaults. This detects
the kind of velocity coordinate, which unfortunately does not always show up in
the output of s, even though anything writing a definition needs to know.
- writedef($templateind, $ind, %mdef)
-
Write madr definition %mdef to madr index $ind in the current directory.
$ind may or may not be already defined.
-
Returns 0 on success, 1 on failure.
- madrrget($rdir, $madr_index_in_rdir[, $docopy])
-
Use madr to rget a file from another directory. Returns success of opening and
closing madr, optionally multiplied by the success of the verification.
- superrename($op, \@flist)
-
Basically Larry Wall's rename (script, not the function) as a function.
Renames the filenames in \@flist according to $op, which is usually a s/x/y/ type pattern.
- symlinkmf($src, $dest)
-
symlink does not support the -f option of ln. This function assumes it.
Returns 1 on success, 0 on failure.
- lnrget($rd, $madr_ind_in_rd, $pathless_filnam, [$newnam], [$doundef])
-
Like madrrget, but links to the file in the remote directory rd instead of
copying it, AND uses the name of the file as well as its index. Known to work
for clean. Optionally renames the link to $newnam and specifies whether or not
undefined data is allowed.
-
Now returns the resulting local madr index on success, and 0 on failure. This
should be compatible with existing calls.
- madrrename($oldname, $newname)
-
Rename $oldname to $newname in the current directory both on the filesystem and
in madr.
- latestfile($ls_pattern)
-
Return the name of the most recently modified file matching the given pattern.
- latestimageindex()
-
madr index of most recently produced image.
- remove_file($filename)
-
Delete a file from both the directory and madr.
- get_first_slot()
-
Returns lowest available madr index.
From Dave Del Rizzo, logfile behavior modified by RR.
5/16/2004: RR made regex more specific.
- get_phase_center($stokes, $band)
-
Returns the R.A. and declination (as strings) of the phase tracking center of
the latest visibility file for $stokes and $band.
- freq_out($imagefilename)
-
Returns the frequency of the given image.
- get_stokesandbandfromdir()
-
Guesses the Stokes parameter and band from the path of the current directory.
It assumes your path is something like
-
field/Stokes/band/
-
i.e.
-
y5/q/a
-
Case does not matter, but both stokes and more importantly band must be single
letters.
- convreals($ind)
-
Flip the endianness of the floats in the file referred to by madr index $ind.
- cookiecutter($size, $destfile)
-
Cuts the latest image down to a central square $size pixels on a side, and
renames it to $destfile.
- cookiemonster($size, $file)
-
Like cookiecutter(), but cuts $file down to $size in place (using a
temporary copy).
-
Technically this function should somehow lock madr to ensure it has exclusive
access until it is done. Of course, flock does not work on processes, and what
I really want is to prevent any other (madr) processes from altering $indnum or
$destnum.
- makeimage
-
Makes an image.
-
Default arguments:
STOKES => ``I'',
BAND => ``ABCD'',
XSIZE => 1024,
YSIZE => 1024,
MINSPAC => 3,
MAXSPAC => 144,
PIXXS => 0.3333333,
PIXYS => 0.3333333
-
Override any of the above with makeimage(BAND => "BC", YSIZE => 512), etc..
-
Returns the names of the logfile produced by ph2, and the resulting image.
- mclatim($survey, $visibs, $map, $band, $minspacing, $maxspacing)
-
Remove latest image from latest visibilities in a directory.
ptsrcs script from xxx_modcal by Bulent Uyaniker, improved automation by Rob
Reid.
-
Returns the names of the logfile produced by ptsrcs, and the resulting
visibility file.
- getextrema($madr_index)
-
Returns the maximum and minimum (in that order) of the given map index.
- leapyear($year)
-
Returns 1 if $_[0] (an integer) is a leapyear, 0 otherwise.
- decy2ymd($decimalyear)
-
Convert a decimal year, i.e. 1999.54, to YYYYMMDD
- getbeam($madr_index)
-
Returns (in arcminutes) the major and minor axes, and the position angle (in
degrees), in that order, of the spatial resolution of $madr_index.
- hreffn($fh, $fn)
-
Make a hyperlink in the filehandle $fh to the file $fn, using the filename $fn
as the link label.
- addmisclogtologs($instring, $fh)
-
Add an entry for the first argument (``filesize filename.LOG'') to the second
argument (a logs/index.html filehandle). Returns 1 if it gzipped the log, 0
otherwise.
- parseconfusionremoval($rclfn)
-
Returns an array of pairs with the relevant info from an old-style
(preHTMLization) confusionremoval.log. Each pair has the filename of the
first PH2 .LOG, and the HTMLized body of the entry.
- add_remove_confsrc_entry($fh, $body)
-
Reconstruct a remove_confsrc command line from $body, append it to the
filehandle $fh, and link it to a file containing $body.
Returns the number of .LOGs mentioned in $body.
- checklogd($scrpat)
-
If necessary, create a logs/ directory and initialize its index.html.
Returns the number of times $scr(pat) has been run since logs/ was created.
- mvlogww($clog)
-
mv $clog logs/, and warn if mv complains. Does not check if logs/ exists.
- mprint($string, FILEHANDLE1, FILEHANDLE2, ...)
-
Print $string to FILEHANDLE1, FILEHANDLE2, ...
- liprint(\*FH1, \*FH2, `` Destroy Earth now? [Y]: n'')
-
Prints a string to the first filehandle, and only the part after the 1st ``: ''
to the second filehandle.
- manip($command)
-
Run $command through madr's manip.
- scitodec($numstr)
-
Returns $numstr, a number in string form, possibly in scientific notation,
as a decimal number.
Rob Reid, <rob.reid@nrc-cnrc.gc.ca>, with contributions as noted above.
GNU General Public Licence, version 2.