Scripts

These scripts are available under the GNU General Public License.

Note that there is no warranty! Although I have put some effort into making them generally useful, they were mainly written to help with a task at hand. So they may not yet work for all cases, and you may have some fixing to do. Please send me any fixes or enhancements.


The whole shebang (108.6kb)


Sort by last modification time.


17.6kb, last modified Mon Jan 12 13:57:31 1998
symbolic link to `../../software/COPYING.GPL'
3.2kb, last modified Wed Jan 7 17:06:12 2009
class TerminalController
A class taken from epydoc that can be used to portably generate formatted output to a terminal. See U{http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475116} for documentation. (This is a somewhat stripped-down version.)
3.2kb, last modified Wed Jan 7 17:06:12 2009
Function objects for primary beams of circular apertures.
class airypat
Returns the normalized* intensity value at salfa = sin(alfa) for a circular aperture. The aperture radius and frequency should be set when the airypat instance is created. * i.e. airypat(salfa = 0) = 1.
class pb_of_circaper
Returns the normalized* intensity value at r arcseconds for a possibly blocked circular aperture. The aperture radii and frequency should be set when the pb_of_blockeddisk instance is created. * i.e. pb_of_blockeddisk(r = 0) = 1.
6.4kb, last modified Wed Jan 7 17:06:12 2009
readantenna(antab=None, pl=None)
Read a text antenna table antab with columns X, Y, Z, and Diameter (all in m).
mul_scal_qa(scal, q, qa=None)
Returns the product of a dimensionless number scal and quantity q.
calc_pointings(direction, spacing, imsize, cell, relmargin=0.5)
If direction is a list, simply returns direction and the number of pointings in it. Otherwise, returns a hexagonally packed list of pointings separated by spacing and fitting inside an image specified by direction, imsize and cell, and the number of pointings. The hexagonal packing starts with a horizontal row centered on direction, and the other rows alternate being horizontally offset by a half spacing. All of the pointings will be within a rectangle relmargin * spacing smaller than the image on all sides, unless none can fit. In that case direction is returned (i.e. single pointing).
plot_pointings(pointings, img, beamsize, dolab = True)
average_direction(directions)
Returns the average of directions as a string.
direction_splitter(direction, qa=None)
Given a direction, return its epoch, x, and y parts. Epoch will be '' if absent, or '%s ' % epoch if present. x and y will be angle qa's in degrees.
wrapang(ang, target, period = 360.0, pl=None)
Returns ang wrapped so that it is within +-period/2 of target.
4.7kb, last modified Wed Jan 7 17:06:12 2009
annular_mask(template, outer, inner=None, center=None, output=None, overwrite=False, name=None)
NOTE: setting center doesn't work yet! It defaults to the center of template. Also, it only masks the first xy plane. Returns the name of a float "mask" based on template with pixel values of 1 for positions with distances from center between outer and inner and 0 elsewhere. center will default to the center of template if not specified. The output name will be template.mask if not specified. template will get a new mask corresponding to masktool. If name is not supplied, it will default to something like 'mask0'. No antialiasing attempt is made, partly because I don't know if it would do any good. The annulus is circular in template's projection, not necessarily on the sky. Example: masktool = annular_mask('fascinating.im', '5arcsec', center='J2000 18h00m00.03s -23d0m0.0s', output='fascinating_5arcsec_disk.mask') sets masktool to an open ia tool containing a mask which is a disk (inner defaults to 0) centered around J2000 18h00m00.03s -23d0m0.0s with radius 5 arcseconds. The mask will be written to fascinating_5arcsec_disk.mask on disk when masktool.close() or .done() is called.
4.9kb, last modified Wed Jan 7 17:09:52 2009
2.6kb, last modified Wed Jan 7 17:06:12 2009
beam_minus_gaussian(beam, bmaj=None, bmin=None, bpa=None, x=None, y=None)
Returns an image of beam with a gaussian of FWHM bmaj and bmin and position angle bpa subtracted. The gaussian will be fit to beam if its parameters are not specified. Any specifcations should have units. x and y are assumed to be in J2000. Do not specify them unless you are sure they are close to the correct values!
quantity_or_nothing(q, qa=None)
If q is a quantity, or a string which can be turned into a quantity, returns q as a quantity. Otherwise returns None.
0.8kb, last modified Tue Apr 7 14:14:13 2009
pickle's interface is annoying in that it doesn't include opening and closing the pickle file. brine does that, which is very convenient for using it with readline in ipython (This way, you see the file and the object on the same line). This hasn't been tested with multiobject pickles!
brine(obj, filename)
cPickle.dump(obj) into filename.
debrine(filename)
return cPickle.load(filename)
1.0kb, last modified Wed Jan 7 17:06:12 2009
cfgsummary(cfgfile, freq)
Essentially translates avgsep < cfgfile's output into a python structure.
0.6kb, last modified Wed Jan 7 17:06:12 2009
cleansim(project, nfld=1, alg='clark',imsize=[512,512], cell='0.0015arcsec', direction="J2000 18h00m00.0 -23d00m0.00")
4.0kb, last modified Wed Jan 7 17:06:12 2009
coherence(vis=None, deltal=None, deltam=None, nvisperbin=50)
Analyze phase noise of an ALMA dataset: Keyword arguments: vis -- Name of measurement set. Example: vis='mysim.ms' deltal -- East-west component of (peak position - phase tracking center), in arcsec. deltam -- North-south component of (peak position - phase tracking center), in arcsec. nvisperbin -- How many visibilities to include in each bin for determining phase dispersions.
0.4kb, last modified Tue Apr 7 14:15:15 2009
Use like: print textprops['blue'] + 'This is blue.' + textprops['normal']
9.9kb, last modified Wed Jan 7 17:06:12 2009
12/13/2007: Added logging, inclusion of a component list if used, and the ability to use an image with a different name from the project.
calc_fidelity(project = None, image = None, mod_w_complist = None)
Calculates both the image and uv plane fidelities for the specified simulation project as in http://www.alma.nrao.edu/memos/html-memos/alma398/memo398.pdf If project is given it can be used to find image and the component list (if any), assuming the information is in project.almasimmos. Otherwise image and vis must be specified, and project will be extracted from image. Because almasimmos does not necessarily use the same modelimage as specified in its parameters when ignorecoords is True, the modelimage MUST be project.input_model! mod_w_complist is a input model image with the input component list added to it. It will be used if specified, and otherwise generated if necessary.
fidel_im(convmod, diff, imroot, ia = None)
Calculates and returns the filename of the image fidelity for convmod and diff as in http://www.alma.nrao.edu/memos/html-memos/alma398/memo398.pdf One difference is that the median |value - median| is used instead of the rms to prevent division by 0. The median |value - median| is close to the 0.675 * the rms, but is less sensitive to outliers (i.e. catastrophic errors confined to a small region of the image).
fidel_uv(convmod, diff, project, imroot = None, longestbllinl = None)
Calculates and returns the filename of the uv fidelity for convmod and diff as in http://www.alma.nrao.edu/memos/html-memos/alma398/memo398.pdf The image will be chopped down to 2*longestbll on a side, where longestbll is returned as the longest baseline length. If longestbllinl, the longest baseline length in wavelengths, is not supplied, it will be looked for in project.almasimmos.
uvamp(img, longestbll, outname = None)
FFTs the image with directory name img and returns the directory name of the resulting amplitudes. That directory name will be outname if supplied, and img + '_amp' otherwise. Each axis of the amplitude image will go from -longestbll to longestbll (which should be in world coordinates).
im_plus_complist(im, complist, im_w_complist = None, ia = None)
Returns an image equal to im + complist. The name will be im_w_complist if specified, and im + '_w_complist' otherwise.
3.2kb, last modified Mon Dec 7 15:02:10 2009
list_autocorr(mspat="*[-_.][Mm][Ss]")
List MSes that include autocorrelations, and the flagging status of those autocorrelations. Status codes: N: The MS has unflagged autocorrelations. R: The MS has autocorrelations, but FLAG_ROW is True for all of them. F: The MS has non-rowflagged autocorrelations, but they are still flagged.
taql(query, tbinst=None, cols=None)
This generator returns a table tool resulting from a TaQL query on tbinst, which should already have an open table. It is intended to be used as a wrapper as in "with taql('!FLAG_ROW', t1, cols="FLAG") as t2:", so it can take care of the details of opening and closing the result as necessary.
find_autocorr(mses)
Check the list of MSes in mses for ones that include autocorrelations, and return the flagging status of those autocorrelations in a dictionary keyed by MS name. Status codes: N: The MS has unflagged autocorrelations. R: The MS has autocorrelations, but FLAG_ROW is True for all of them. F: The MS has non-rowflagged autocorrelations, but they are still flagged.
2.3kb, last modified Tue Apr 7 14:16:20 2009
find_file_among_alternatives(likely_locations, testfunc=os.path.isfile)
Given a set of likely_locations, returns the first member for which testfunc(member) is True. If none of them qualify, the set of potential locations is expanded using locate on the last part of each alternative. Raises a ValueError if it still can't find anything. Examples: >>> from find_file_among_alternatives import find_file_among_alternatives >>> likely_locs = ['/usr/lib/X11/rgb.txt', '/etc/X11/rgb.txt', '/usr/share/X11/rgb.txt'] >>> found_rgb = find_file_among_alternatives(likely_locs) >>> print found_rgb /usr/share/X11/rgb.txt >>> less_likely_locs = ['/nonexistant_path/rgb.txt', '/nonexistant_path/rgb.text', 'local_nonexistant_path/rgb.txt', 'rgb.txt', '/nonexistant_path/groups', 'groups'] >>> found_rgb = find_file_among_alternatives(less_likely_locs) >>> print found_rgb /usr/share/X11/rgb.txt
1.0kb, last modified Wed Jan 7 17:06:12 2009
idlfitstocasaim(imname, reffreq, freqincrement)
One of IDL's many crimes is claiming to write FITS files when it doesn't. This function (based on what Kumar Golap suggested) tries to get an IDL 'fits' file into casa. imname - this function copies imname.fits in the current directory to imname.im reffreq - Reference frequency in Hz. freqincrement - Frequency increment in Hz.
26.3kb, last modified Tue Apr 7 14:12:49 2009
Should be runnable either from a UNIX shell or as a python function within casapy.
class ConversionError(Warning)
class RubberLineError(ConversionError)
class UnsupportedItem(ConversionError)
class UnrecognizedCoordType(ConversionError)
ds9color(color, Xrgbdb, default_color='red', strict=False, ds9colordb=None)
Given color as a string (including '#09abcd'), translate it into something that ds9 will recognize. If strict is True (necessary for ds9 versions <= 4.00), the returned color will be quantized to the nearest color in ds9colordb.
ds9line(comment, item)
ang_match(ang1, ang2, period, tol)
Returns True if |ang1 - ang2| <= tol (after wrapping around period), False otherwise.
get_Xrgbdb_or_croak()
Returns a standard X ColorDB or raises an exception.
class KVH
KVis Handler whose member functions accept kvis input and spit out ds9 region lingo.
anno2ds9(infn, outfn, strict=False, input_format='kvis', default_color="red", wcs="ICRS", dotshape='circle')
Convert a kvis/kview/karma annotation file into ds9 format (with optional levels of strictness). infn: Input filename outfn: Output filename strict: Approximate colors, etc. as necessary to make the output usable by ds9 itself. The default is to use casaviewer's superset of ds9's format. input_format: The format of infn. 'kvis' (default), 'AIPS', or 'casaviewer'. Use "casaviewer" with strict=True to convert a "casaviewer" format annotation file to one usable by ds9. wcs: The world coordinate system of the kvis annotation file. dotshape: In kvis a dot is a single pixel, but ds9 lets you select from 'circle', 'box', 'diamond', 'cross', 'x', 'arrow', or 'boxcircle' "points". Not everything can be converted. It does its best, and tries to warn you when it encounters problems, but be prepared to check and edit the result.
ds9_to_boxfile(infn, outfn)
Convert a ds9 format annotation file into an AIPS boxfile (with special comments recognized by CASA) infn: Input filename outfn: Output filename
0.9kb, last modified Wed Jan 7 17:06:12 2009
Makes fidelity images for each configuration.
2.7kb, last modified Wed Jan 7 17:06:12 2009
Runs almasimmos for each configuration, putting the results for each config in its own directory.
0.4kb, last modified Tue Apr 7 14:17:38 2009
minarg(set, cmp=cmp)
Return the index of the minimum (acc. to cmp) entry in set.
1.0kb, last modified Tue Apr 7 14:18:06 2009
padimage(img, padfac=2.0, outputname=None, axes=range(2))
Pads img by a factor of padfac along axes. i.e. if img is 256x512 and padfac is 3, img will be placed in the center of a 768x1536 image. If outputname is unset it will default to img + '.padded'.
0.2kb, last modified Wed Jan 7 17:06:13 2009
pbsize(freq, d=12.0)
Returns the primary beam size in arcseconds for a dish with diameter d (default 12) m at frequency freq GHz.
6.2kb, last modified Wed Jan 7 17:06:13 2009
cfgfile_to_dict(cfgfile)
Reads cfgfile (in almasimmos format with optional pad numbers as comments) and returns a dictionary with 'x', 'y', 'z', and 'pad' columns.
uniquify_strlist(duplist)
Goes through the list of strings duplist, and appends a count number to any duplicates. i.e. given ['a', 'b', 'c', 'a', 'c', 'd', 'a', 'e'], it returns ['a_0', 'b', 'c_0', 'a_1', 'c_1', 'd', 'a_2', 'e']. Note that ['a', 'a', 'a_0'] would go to ['a_0', 'a_1', 'a_0']. If you have a list like that, you could run uniquify_strlist on the result.
filetotable(fn, overwrite=False)
Returns a CASA table (tb) tool as read from the comma separated value (CSV) file fn. Built around the fromascii line by Debra Shepherd. The first row in the CSV is assumed to be, and used as, column names, not as data values. If you want to use the tb for plotting, all other rows should be numbers. I usually produce my tables with whitespace separation for readability, but they can be easily converted to CSV format with this bash alias: # Use: csvize < table.readable > table.csv alias csvize='perl -wp -e "s/[ \t]+/,/g"' csvize will silently FAIL if there are any commas in table.readable!
timeaxis(datatb)
Attempts to return a reasonable time axis and label for it from datatb.
tablename(datatb)
Returns a slightly cleaned up name for datatb.
simpleplot(datatb, ycolnames=[], xcolname='', colnames=[], plotfunc=pl.plot)
Graph datatb[ycolname] vs. datatb[xcolname] for each ycolname in ycolnames, on the same plot. xcolname defaults to the first column in colnames or datatb.colnames(). ycolnames defaults to all but xcolname in colnames or datatb.colnames().
7.2kb, last modified Tue Apr 7 14:19:31 2009
class PlotIms(object)
Makes a figure out of ims.
6.4kb, last modified Fri Dec 18 11:59:51 2009
  • plotims/
  • plotims/taskutil.py
  • plotims/skyimg2plarr.py
  • plotims/plotcfgs.py
  • plotims/plotims.py
  • plotims/plotpsf.py
2.8kb, last modified Tue Apr 7 14:20:14 2009
class PlotImWithInset(PlotIms)
Plots littleim in a corner of bigim.
class PSFPlotter(PlotImWithInset)
Makes a figure with plots of imname for each config in cfgs.
0.6kb, last modified Tue Jul 13 16:29:40 2010
prefix_ants(mspath, prefix)
Prepends prefix to all of the antenna names in MS mspath. It is useful if the antenna names are numbers (esp. if not the same as the antenna numbers). Inspired by C. Brogan's http://casaguides.nrao.edu/index.php?title=CARMA_spectral_line_mosaic_M99
0.7kb, last modified Wed Jan 7 17:07:12 2009
0.8kb, last modified Wed Jan 7 17:07:12 2009
3.3kb, last modified Wed Jan 7 17:06:13 2009
function to print inputs with coloring colorparam 'blue'=> non-default, colorcomment 'green'=> can have sub params 'blue' => is a sub-parameter blue = \x1B[94m bold = \x1B[1m red = \x1B[91m cyan = \x1B[96m green= \x1B[92m normal = \x1B[0m underline= \x1B[04m reverse = \x1B[7m highlight with black = \x1B[40s
print_params_col(param=None, value=None, comment='', colorparam=None, colorcomment=None, noerrorval=True)
0.5kb, last modified Wed Jan 7 17:06:13 2009
psfsize(cfgfile, freq)
Returns the PSF FWHM of cfgfile in arcsec. Only really works for snapshots at zenith.
11.5kb, last modified Wed Jan 7 17:06:13 2009
A module for plotting ALMA ATF PSI archive data using CASA. Use: From casapy, execfile 'psi_archive_plotter.py' example: # Set vadtxtb to be a tb tool filled with the contents of # ./VA--1-DTX----0x050-2007-09-26-test02.csv. The contents will be # fetched from ./VA--1-DTX----0x050-2007-09-26-test02.tb if it already # exists, and ./VA--1-DTX----0x050-2007-09-26-test02.csv otherwise. vadtxtb = filetotable('VA--1-DTX----0x050-2007-09-26-test02.csv') vadtxtb.colnames() # Plot V____DG_VOLTAGE_3.1_-_3.5V vs. time. simpleplot(vadtxtb, 'V____DG_VOLTAGE_3.1_-_3.5V') # Plot a list of voltages vs. time. simpleplot(vadtxtb, ['V____DG_VOLTAGE_3.1_-_3.5V', 'V____DG_VOLTAGE_4.8_-_5.2V']) # Plot two arbitrary variables vs. time. two_y_axes(vadtxtb, 'V____DG_VOLTAGE_4.8_-_5.2V', 'V____DG_VOLTAGE_3.1_-_3.5V') # Create a dictionary containing a tb for each .csv file in the # current directory (slow if there are a lot of new ones): pap = PSI_archive_plotter() # timeaxis() is just a helper function now, but Gene DuVall might # extend it to use minutes, hours, etc., and/or to supply a time axis # for customized plots. # tablename() returns the table's filename without any directory or # .csv. Sample directory: /groups/psi/Public_PSI/Data/Daily/2007/2007-10-05-ACU_02
truer_glob(patlist = '*')
Unfortunately glob.glob('a b.*') doesn't work. This function returns a list of filenames matching the string patlist like it would in a shell (i.e. like perl's <a b.*>).
uniquify_strlist(duplist)
Goes through the list of strings duplist, and appends a count number to any duplicates. i.e. given ['a', 'b', 'c', 'a', 'c', 'd', 'a', 'e'], it returns ['a_0', 'b', 'c_0', 'a_1', 'c_1', 'd', 'a_2', 'e']. Note that ['a', 'a', 'a_0'] would go to ['a_0', 'a_1', 'a_0']. If you have a list like that, you could run uniquify_strlist on the result.
filetotable(fn, overwrite=false)
Returns a CASA table as read from the comma separated value file fn. Borrows heavily from an example by Debra Shepherd.
timeaxis(datatb)
Attempts to return a reasonable time axis and label for it from datatb.
tablename(datatb)
Returns a slightly cleaned up name for datatb.
simpleplot(datatb, colnames)
Graph datatb[colname] vs. datatb['time'] for each colname in colnames, on the same plot.
two_y_axes(datatb, lcol, rcol)
Graph datatb[lcol] and datatb[rcol] vs. datatb['time'] with lcol's y axis on the left, and rcol's y axis on the right, on the same plot. Unfortunately lcol and rcol cannot be lists like in simpleplot, because the second y axis essentially starts a new plot and resets the color cycler.
class PSI_archive_plotter(object)
Reads all directory/files and stores the data in a dictionary of dictionaries of dictionaries for each column: self.tables[tkey][colname][dtype], where tkey = filename with directory/ and .csv stripped off, colname = column name There is always a key 'colnames' with a list of column names in tkey as its value. dtype = data type
1.5kb, last modified Wed Jan 7 17:06:13 2009
ptgs2ann(ptgs, diam, ann, color = 'green')
Given a list of pointings ptgs, make a kvis annotation file ann with a cross and circle of diameter diam (an angle qa) at each pointing.
direction_splitter(direction)
Given a direction, return its epoch, x, and y parts. Epoch will be '' if absent, or '%s ' % epoch if present. x and y will be angle qa's in degrees.
10.2kb, last modified Wed Jan 7 17:06:13 2009
radplot(img=None, wc=None, maxrad=None, rs=None, azav=None, runit=None, title=None, rlab=None, azavlab=None)
Plots the azimuthal average of an image about a point. For now it assumes you are only interested in the first plane of img, and that it has square pixels. Keyword arguments: img -- Name of image to made a radial plot of. wc -- World coordinate to use as center. rs -- An optional list or array of radii to use instead of calculating. azav -- An optional list or array of azimuthal averages to use instead of calculating. blunit -- Unit of the radii. Derived from img if necessary. title -- Title for the plot. Defaults to 'Azimuthal average of %s about %s' % (img, wc). rlab -- Label for the radial axis. Defaults to 'Radius (runit)'. azavlab -- Label for the azimuthal average axis. Defaults to 'Azimuthal average (azavunit)'
radplot_defaults(param = None)
radplot_description(key='radplot', subkey = None)
radplot_check_params(param=None, value=None)
radav(img, wc, maxrad=None)
Returns the azimuthal average of image with name img about the world coordinate wc, and the weights and baseline unit used to calculate that average. The baseline unit is taken from maxrad, or from img's axisunits if maxrad is not specified. For now it assumes you are only interested in the first plane of img, and that it has square pixels.
5.0kb, last modified Wed Jan 7 17:06:13 2009
1/23/2008: Fixed typo preventing regridding when no axis rearrangment was needed.
thorough_regrid(inim, template, outim, keep_inim_Stokes=False)
CASA uses a different order for the frequency and Stokes axes from the rest of the world. This function swaps the freq and Stokes axes of a newly loaded FITS file (inim) into CASA's convention (template), makes the RA nonnegative, and puts the result in outim. The output image header will have the same Stokes parameter as the template image, unless keep_inim_Stokes is True. No actual Stokes conversion is done (i.e. RR can get called I without being averaged with LL). Even if keep_inim_Stokes is True, the output image will only have a Stokes axis if the template does. If keep_inim_Stokes is True and template has a Stokes axis, but inim does not, outim will default with a warning to I.
index_or_minus1(lis, item)
Returns the index of item in list lis, or -1 if it is not found.
3.1kb, last modified Tue Apr 7 14:13:13 2009
Functions returning colormaps defined by Rob Reid. Example:: img = pl.outerproduct([0.125 * i for i in range(-8, 8)], pl.cos(range(-8, 8))) import rr_cmaps sunbow = rr_cmaps.make_sunbow() pl.ion() pl.clf() pl.imshow(img, cmap=sunbow) pl.colorbar()
make_sunbow(ncolors=256)
Returns sunbow as it is found in karma's kvis. It works well as a colormap for images where you would like 0 to be innocuous, (white here, to save printer ink), positive values to be warm, and negative ones to be cool:: |d(r, g, b)| { 2, 0.25 < I < 0.75 |----------| = { | dI | { 6, otherwise. @param ncolors: Number of entries in the resulting lookup table. Defaults to 256. @type ncolors: int
make_sunbow2(ncolors=256)
A revised, less pastel, version of sunbow. |d(rgb)/dI| = 4 everywhere, but the colorbar looks like it has flat blue, cyan, white, yellow, and red steps, with sharp transitions in between.
make_parabolic_sunbow(ncolors=256)
A parabolic, less pastel, version of sunbow that gets a bit darker at the ends. |d(rgb)/dI| >= 4 everywhere. This is the recommended version unless you need to emulate kvis.
4.9kb, last modified Wed Jan 7 17:06:13 2009
run_task_with_dict(tname, pdict, saveinput_file=None)
A wrapper function for running tname with the parameters in pdict. If tname has defaults, they will be used as necessary. This is NOT the same as calling default(tname), since variables at the calling level are only altered if tname does it. If saveinput_file is a string, the parameter values (including defaulted ones) are saved in it. If it is just True, then tname.saved is used. Returns the return value of tname. Example: imh_pset = {'imagename': '../ImLib/m31/m31_inpmod.im', 'mode': 'list'} run_task('imhead', imh_pset, 1)
dict_from_savefile(savefile)
Read a saveinputs-style file savefile, and return a dictionary of the values keyed by parameter name.
dict_to_savefile(pdict, savefile, tname=None)
Writes a parameter set pdict to savefile in saveinputs(tname) style.
2.4kb, last modified Tue Apr 7 14:22:07 2009
show_structure(root, level=0, linelength=80, tabwidth=4, bracketize=False)
Prints a root's type, or a deep list of its keys, grouped by common sets of subkeys. Lines are truncated to a maximum length of linelength. If bracketize is True, each key will be surrounded by [''] for more convenient selection and pasting, at the expense of space.
0.5kb, last modified Wed Jan 7 17:06:13 2009
skyimg2plarr(img)
Returns CASA image with directory name img as a matplotlib array suitable for plotting, followed by the maximum and minimum pixel values.
2.1kb, last modified Wed Jan 7 17:06:13 2009
suggestalmaconfig(res, frequency, declination)
Returns a suggested ALMA configuration for a desired resolution and frequency. It assumes a 4h observation, but the observation length should not matter. @param res: desired FWHM naturally weighted dirty beam major axis in \". @type res: float or int @param frequency: Center frequency to use in GHz. @type frequency: float or int @param declination: declination to use in degrees. @type declination: float or int
beamsizes(declin)
Reads almabeams<declin>.summary and returns an array of beam sizes in arcseconds, going from out01 to out28 (= Y8). The beam size is the FWHM square root of the minor axis x the major axis. @param declin: declination to use in degrees. @type declin: int
6.0kb, last modified Wed Jan 7 17:06:13 2009
summarize(imlist, collist = 'bunit, bmaj, bmin, bpa')
For each image in imlist, prints the values of collist, and returns the output of ia.summary() for each image as a dictionary keyed by the image names. Except for the special values listed in the default of collist, its columns should be keys of ia.summary()'s output. imlist and collist can both be either single valued strings, comma separated strings, or lists of strings, i.e. summarize('robust0_nonoise.image', ['bmaj', 'bmin']); summarize(['robust0_nonoise.image', 'robust0_nonoise.residual'], ['bunit']); and summarize('robust0_nonoise.im*, robust0_nonoise.residual', 'bmaj, bmin'); are all valid. N.B. 1. The above lines all end in ; to *skip the return value* in ipython. 2. The items in imlist can have wildcards. Sample output: Image bunit bmaj (mas) bmin (mas) bpa (deg) input672GHz_50pc.image Jy/pixel robust0_nonoise.image Jy/beam 28.8220365 25.5090762 97.6345 casa_robust0intclean.image 15.7047883 14.4392923 101.9130
str_or_list_to_list(strorlist)
Returns a list made from splitting strorlist at commas and/or whitespace
1.7kb, last modified Tue Apr 7 14:22:07 2009
make_sunbow(ncolors=256)
Returns "The Fantastically Advanced Glorious Sunbow Colormap For Making Greater Understanding of Perhaps Equally Positive and Negative Imagings And Expressing The Aesthetic Genius Of Its Magnaminous Creator Rob Reid", or sunbow, as it's known in karma's kvis. It's very nice, at least as a colormap for images where you would like 0 to be innocuous, (white here, to save printer ink), positive values to be warm, and negative ones to be cool. @param ncolors: Number of entries in the resulting lookup table. Defaults to 256. @type ncolors: int
make_sunbow2(ncolors=256)
7.0kb, last modified Wed Jan 7 17:06:13 2009
A module for plotting ASCII or AIPS++/CASA tables using CASA. News: 1/22/2008: simpleplot()'s output is much more customizable now. It passes its keyword arguments to plotfunc, and takes a list of symbols for plotting each y column. Column labels are now filtered in case you are using LaTeX. Use: From casapy, # Preferred execfile 'tabplotter.py' example: # Set btb to be a tb tool filled with the contents of # ./cfgres_10to20.csv. The contents will be # fetched from ./cfgres_10to20.tb if it already # exists, and ./cfgres_10to20.csv otherwise. btb = filetotable('cfgres_10to20.csv') # Normal tb commands work. btb.browse() # You may need btb.clearlocks() btb.colnames() # As does help. help simpleplot # Plot everything in btb except the first column vs. the first column, # with a logarithmic y axis. simpleplot(btb, plotfunc=pl.semilogy) # Plot Nom.rms.res vs. Actual_res. simpleplot(btb, 'Nom.rms.res', 'Actual_res') # Plot Nom.rms.res and Actual_res vs. Nom.avg.res simpleplot(btb, ['Nom.rms.res', 'Actual_res'], 'Nom.avg.res') # timeaxis() is just a helper function now, but Gene DuVall might # extend it to use minutes, hours, etc., and/or to supply a time axis # for customized plots. # tablename() returns the table's filename without any directory or # .csv.
uniquify_strlist(duplist)
Goes through the list of strings duplist, and appends a count number to any duplicates. i.e. given ['a', 'b', 'c', 'a', 'c', 'd', 'a', 'e'], it returns ['a_0', 'b', 'c_0', 'a_1', 'c_1', 'd', 'a_2', 'e']. Note that ['a', 'a', 'a_0'] would go to ['a_0', 'a_1', 'a_0']. If you have a list like that, you could run uniquify_strlist on the result.
filetotable(fn, overwrite=False)
Returns a CASA table (tb) tool as read from the comma separated value (CSV) file fn. Built around the fromascii line by Debra Shepherd. The first row in the CSV is assumed to be, and used as, column names, not as data values. If you want to use the tb for plotting, all other rows should be numbers. I usually produce my tables with whitespace separation for readability, but they can be easily converted to CSV format with this bash alias: # Use: csvize < table.readable > table.csv alias csvize='perl -wp -e "s/[ \t]+/,/g"' csvize will silently FAIL if there are any commas in table.readable!
timeaxis(datatb)
Attempts to return a reasonable time axis and label for it from datatb.
tablename(datatb)
Returns a slightly cleaned up name for datatb.
simpleplot(datatb, ycolnames=[], xcolname='', colnames=[], plotfunc=pl.plot, symblist=['b-'], **kwargs)
Graph datatb[ycolname] vs. datatb[xcolname] for each ycolname in ycolnames, on the same plot. xcolname defaults to the first column in colnames or datatb.colnames(). ycolnames defaults to all but xcolname in colnames or datatb.colnames(). symblist is a list of symbols to plot each y column with, in plotfunc's format. **kwargs is passed on to plotfunc.
raw_to_latex(a)
Returns a copy of s that has been converted from plain text to valid LaTeX input. Do not run on strings that already have LaTeX markup!
1.8kb, last modified Wed Jan 7 17:06:13 2009
radplot(img, wc, maxrad, rs, azav, runit, title, rlab, azavlab)
Plots the azimuthal average of an image about a point. For now it assumes you are only interested in the first plane of img, and that it has square pixels. Keyword arguments: img -- Name of image to made a radial plot of. wc -- World coordinate to use as center. rs -- An optional list or array of radii to use instead of calculating. azav -- An optional list or array of azimuthal averages to use instead of calculating. blunit -- Unit of the radii. Derived from img if necessary. title -- Title for the plot. Defaults to 'Azimuthal average of %s about %s' % (img, wc). rlab -- Label for the radial axis. Defaults to 'Radius (runit)'. azavlab -- Label for the azimuthal average axis. Defaults to 'Azimuthal average (azavunit)'
2.5kb, last modified Wed Jan 7 17:06:13 2009
Functions used in converting other functions into tasks. Use: import taskutil
get_global_namespace(ns_label='ipython console')
Returns a dictionary of the globals in the lowest stacklevel containing ns_label in its label.
update_myf(myf)
Fills unfilled parameters with defaults, and handles globals or user override of arguments.
check_param_types(taskname, arg_desc)
Checks the values of taskname's arguments against their allowed types. Suitable for tasks without any menu parameters. Returns None if everything seems OK, and the exception otherwise (after printing an error message).
startlog(casalog, taskname)
Starts an entry in casalogger for taskname.
endlog(casalog, taskname)
Finishes an entry in casalogger for taskname.
39.0kb, last modified Wed Jan 7 17:06:02 2009
  • telesims/
  • telesims/airydisk.py
  • telesims/almasimmos_helpers.py
  • telesims/annular_mask.py
  • telesims/beam_nongaussianity.py
  • telesims/cfgsummary.py
  • telesims/cleansim.py
  • telesims/coherence.py
  • telesims/fidelity.py
  • telesims/idlfitstocasaim.py
  • telesims/makefids.py
  • telesims/makemses.py
  • telesims/pbsize.py
  • telesims/plotcfgs.py
  • telesims/psfsize.py
  • telesims/psi_archive_plotter_wrcas.py
  • telesims/ptgs_to_ann.py
  • telesims/radplot.py
  • telesims/regrid4d.py
  • telesims/skyimg2plarr.py
  • telesims/suggestalmaconfig.py
  • telesims/summarize.py
  • telesims/tabplotter.py
  • telesims/task_radplot.py
  • telesims/taskutil.py
  • telesims/testconfigs.py
  • telesims/uvsamp_from_psf.py
  • telesims/writebeams.py
  • telesims/avgsep
  • telesims/COPYING
1.9kb, last modified Wed Jan 7 17:06:13 2009
testconfigs(avgsepsf="configs.avgsep")
Test ALMA configurations.
0.0kb, last modified Wed Jan 7 17:06:13 2009
uvsamp_from_psf(psf, longestbll)
5.0kb, last modified Wed Jan 7 17:06:13 2009
summary_start(weighting, dec)
write_beam_stats(bim, ofile, relsens, beam, confnum)
do_other_weightings(dec, avgsepsf="../configs.avgsep")
Make robust and uniform weighted dirty beams for measurement sets have already been made at declination dec.
writebeams()
Export beam images to FITS.
summarize_beams(outfileroot='almabeams_briggs')
Write a summary of the ALMA beams into outfileroot_dec.summary.


Page generated by s2dh, based on DirToHtml, a GNU generator of html directory listings.