casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
Public Member Functions
tests.test_imcontsub.imcontsub_test Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_bad_imagename
 Incorrect inputs to parameters.
def test_bad_linefile
def test_bad_contfile
def test_bad_fitorder
def test_bad_region
def test_bad_chans
def test_bad_box
def test_bad_stokes
def test_fitorder
 

Continuum subtraction correctness test.


def cmp_images
def test_box_and_chans

Detailed Description

Definition at line 129 of file test_imcontsub.py.


Member Function Documentation

def tests.test_imcontsub.imcontsub_test.cmp_images (   self,
  newimg,
  oldimg,
  errmsg,
  retval,
  tol = 1.0e-8 
)
Check that newimg matches oldimg to within tol.
errmsg is a descriptive label in case there is an error.
retval is updated with the results and returned.

Definition at line 454 of file test_imcontsub.py.

References irc_cs_task_regression.max.

Referenced by tests.test_imcontsub.imcontsub_test.test_box_and_chans(), and tests.test_imcontsub.imcontsub_test.test_fitorder().

Definition at line 131 of file test_imcontsub.py.

Definition at line 141 of file test_imcontsub.py.

Test bad box parameter causes failure

Definition at line 245 of file test_imcontsub.py.

Test bad chans parameter causes failure

Definition at line 226 of file test_imcontsub.py.

Test bad continuum file name fails

Definition at line 188 of file test_imcontsub.py.

Test bad fitorder fails

Definition at line 199 of file test_imcontsub.py.

Incorrect inputs to parameters.

The parameters are: imagename linefile contfile fitorder region box chans stokes

Returns True if successful, and False if it has failed.

Test bad image name throws exception

Definition at line 166 of file test_imcontsub.py.

Test bad line file name fails

Definition at line 177 of file test_imcontsub.py.

Test bad region parameter fails

Definition at line 208 of file test_imcontsub.py.

Test bad stokes parameter causes failure

Definition at line 272 of file test_imcontsub.py.

Imcontsub: Testing box and chans

Definition at line 479 of file test_imcontsub.py.

References tests.test_imcontsub.imcontsub_test.cmp_images().

Continuum subtraction correctness test.

This test subtacts the continuum from the g192 data file

and compares the results (both continuum and spectral line

with subtracted continuum files) with pervious results.

Random values are selected in the files and compared.

FIXME compare the entire arrays, not bloody random values

FIXED - replacing it with the equivalent but better test_fitorder(0)

sped the suite up from 1847s to 1194s on faraday.cv.nrao.edu.

Returns True if successful, and False if it has failed.

def test_continuum(self): '''Imcontsub: Testing continuum sub correctness''' retValue = {'success': True, 'msgs': "", 'error_msgs': '' } casalog.post( "Starting imcontsub CONTINUUM SUB CORRECTNESS tests.", 'NORMAL2' ) try: results=imcontsub( 'g192_a2.image', fitorder=0, contfile='cont_test_cont1', linefile='cont_test_line1' ) except Exception, err: retValue['success']=False retValue['error_msgs']=retValue['error_msgs']\ +"\nError: Unable to subtract continuum with a fit order of 0 "\ +"\n\t REULTS: "+str(results) else: if ( not os.path.exists( 'cont_test_cont1' ) or not os.path.exists( 'cont_test_line1' ) or not results ): retValue['success']=False retValue['error_msgs']=retValue['error_msgs']\ +"\nError: continuum 3 output files were NOT created." else:

Now that we know something has been done lets check some values

with previously created files to see if the values are the same.

We randomly pick 50 points (almost 10%)

FIXME lovely, yes let's pick random values to make sure any failures

cannot easily be reproduced, ugh

for count in range(0,50): x = random.randint(0,511) y = random.randint(0,511) box=str(x)+','+str(y)+','+str(x)+','+str(y) chan = str(random.randint(0,39)) line_prev_value={} line_cur_value={'empty':''} try: line_prev_value = imval( 'g192_a2.contfree', box=box, chans=chan, stokes='I' ) line_cur_value = imval( 'cont_test_line1', box=box, chans=chan, stokes='I' ) except: retValue['success']=False retValue['error_msgs']=retValue['error_msgs']\ +"\nError: Unable to compare spectral line files." else:

print "Spec line prev value: ", line_prev_value

print "spec line current value: ", line_cur_value

casalog.post( "*** line_prev_value " + str(line_prev_value), 'WARN') casalog.post( "*** line_cur_value " + str(line_cur_value), 'WARN') if ( (line_prev_value['data'] != line_cur_value['data']).any() ): retValue['success'] = False retValue['error_msgs'] = ': spectral line value differs with '\

  • "previously calculated value at: "\
  • "\t["+str(x)+','+str(y)+','+chan+',I].'\
  • "\tvalues are "+str(line_prev_value)+" and "+str(line_cur_value) try: cont_prev_value = imval( 'g192_a2.cont', box=box, chans=chan, stokes='I' ) cont_cur_value = imval( 'cont_test_cont1', box=box, chans=chan, stokes='I' ) except: retValue['success']=False retValue['error_msgs']=retValue['error_msgs']\ +"\nError: Unable to compare continuum files." else:

    print "Continuum prev value: ", cont_prev_value

print "Continuum current value: ", cont_cur_value

if ( (cont_prev_value['data'] != cont_cur_value['data']).any() ): retValue['success'] = False retValue['error_msgs'] = ': continuum value differs with '\

  • "previously calculated value at: "\
  • "\t["+str(x)+','+str(y)+','+chan+',I].'

    + "\tvalues are "+str(cont_prev_value)+" and "+str(cont_cur_value)

self.assertTrue(retValue['success'],retValue['error_msgs']) Region selection correction test.

This test selects a region for continuum subtraction. Checks are done to make sure only the data in the selected region changes.

Returns True if successful, and False if it has failed. Fitorder tests correctness test.

This test subtacts the continuum from the g192 data file for fitorder =1 and fitorder=2, note that fitorder=0 is tested in the continuum test and valid/invalid inputs to the fitorder paramter are tested in the input test.

The results, image file contents, are compared with previously created image files.

Returns True if successful, and False if it has failed.

Imcontsub: testing fitorder correctness

Definition at line 405 of file test_imcontsub.py.

References tests.test_imcontsub.imcontsub_test.cmp_images().


The documentation for this class was generated from the following file: