Utility Functions

This module contains utility functions used throughout the ADMIT codebase

admit.util.util.add_new_at()

Method to add a new BDP ot AT to the ADMIT infrastructure

Parameters:None
Returns:None
admit.util.util.add_new_bdp()

Method to add a new BDP ot AT to the ADMIT infrastructure

Parameters:None
Returns:None
admit.util.util.casa2fits(args)
admit.util.util.find_files(directory, pattern)
admit.util.util.freqtovel(freq, delta)
admit.util.util.getClass(typ, name)

Get an instance of an AT or BDP class

Parameters:

typ : str

Type of class: at or bdp

name : str

The name of the class to retrieve

Returns:

An instance of the requested class

admit.util.util.getinputs(obj, getargs=False)

inspect a CASA task

( can it do tools too? No it cannot as the tools’ arguments are specified as *args and **kargs, and thus cannot be properly retrieved.) return a dictionary of {‘key’:default_val} if getargs=True, also return a list of all the [‘key’]

Examples

>>> (dict,list) = getinputs(casa_task,True)
>>> dict        = getinputs(casa_task,False)
admit.util.util.getmass(formula)
admit.util.util.iscloseinE(v1, v2)
admit.util.util.makehisto(data, filename, bins=40, xlabel='', ylabel='', title='', interactive=True)
admit.util.util.makespec(x, y, filename, title='', lines=[], interactive=False)
admit.util.util.on_error_retry(exception, callback, timeout=2, timedelta=0.1)

A generic method for doing retries with timeout.

Parameters:

exception : Exception

An Exception class to handle exceptions from the callback.

callback : function

The callback method to invoke

timeout : float

timeout in seconds before giving up. default: 2

timedelta : float

number of seconds to sleep before retries. default: 0.1

Examples

>>> for retry in on_error_retry(SomeSpecificException, do_stuff):
        retry()

stolen from stackoverflow.

admit.util.util.remove(item)

Remove a file or directory.

The method determines if it is a file or directory and removes it appropriately.

Parameters:

item : str

Item to be deleted

Returns:

None

admit.util.util.rm(file)

Remove a file

Parameters:

file : str

File to be deleted

Returns:

None

admit.util.util.rmdir(dir)

Remove a directory

Parameters:

dir : str

Directory to be deleted

Returns:

None

admit.util.util.rreplace(s, old, new, occurrence)
admit.util.util.run(task, args)
admit.util.util.veltofreq(vel, freq)

Next topic

ADMIT Design Overview

This Page