def reportresults(redi):
    """
    Helper function to pretty print the results in redi and report whether
    they all passed.  redi is a dict with format
    {test_name1: (pass/fail,
                  (Optional) note,
                  (Even more optional) quantitative difference),
     test_name2: (pass/fail,
                  (Optional) note,
                  (Even more optional) quantitative difference)}
    """
    passfail = {True: '* Passed', False: '* FAILED'}
    normalsevere = {True: 'NORMAL', False: 'SEVERE'}
    ok = True

    for t in redi:
        tup = redi[t]
        msg = passfail[tup[0]] + ' ' + t + ' test'
        print >> n5921reglog, msg
        tstutl.note(msg, normalsevere[tup[0]])
        if len(tup) > 1:
            print >> n5921reglog, tup[1]
        #tstutl.note("\"tup[0]\": \"%s\"" % tup[0], "WARN")
        if not tup[0]:
            ok = False
            if len(tup) > 2:
                tstutl.note('  ' + t + " difference: " + str(tup[2]),
                            normalsevere[tup[0]])
    return ok
Exemple #2
0
def reportresults(redi):
    """
    Helper function to pretty print the results in redi and report whether
    they all passed.  redi is a dict with format
    {test_name1: (pass/fail,
                  (Optional) note,
                  (Even more optional) quantitative difference),
     test_name2: (pass/fail,
                  (Optional) note,
                  (Even more optional) quantitative difference)}
    """
    passfail = {True: '* Passed', False: '* FAILED'}
    normalsevere = {True: 'NORMAL', False: 'SEVERE'}
    ok = True
    
    for t in redi:
        tup = redi[t]
        msg = passfail[tup[0]] + ' ' + t + ' test'
        print >>n5921reglog, msg
        tstutl.note(msg, normalsevere[tup[0]])
        if len(tup) > 1:
            print >>n5921reglog, tup[1]
        #tstutl.note("\"tup[0]\": \"%s\"" % tup[0], "WARN")
        if not tup[0]:
            ok = False
            if len(tup) > 2:
                tstutl.note('  ' + t + " difference: " + str(tup[2]),
                            normalsevere[tup[0]])
    return ok
Exemple #3
0
def listfailures(redi):
    """
    Helper function to summarize any failures in redi at the end.
    redi has the same format as in reportresults.
    """
    for t in redi:
        tup = redi[t]
        if not tup[0]:
            msg = t + "  FAILED"
            if len(tup) > 2:
                msg += ":\n  " + str(tup[1]) + "\n    difference: " + str(tup[2])
            tstutl.note(msg, "SEVERE")
 def test2():
     info('')
     info('')
     info('')
     info('Test 2 - stokesi, stokesq, stokesu, stokesv, stokes')
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test1():
     info('')
     info('')
     info('')
     info('Test 1 - open, done, and summary')
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test1():
     info('')
     info('')
     info('')
     info('Test 1 - open, done, and summary')
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test2():
     info('')
     info('')
     info('')
     info('Test 2 - stokesi, stokesq, stokesu, stokesv, stokes')
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
def listfailures(redi):
    """
    Helper function to summarize any failures in redi at the end.
    redi has the same format as in reportresults.
    """
    for t in redi:
        tup = redi[t]
        if not tup[0]:
            msg = t + "  FAILED"
            if len(tup) > 2:
                msg += ":\n  " + str(tup[1]) + "\n    difference: " + str(
                    tup[2])
            tstutl.note(msg, "SEVERE")
 def test8():
     info('')
     info('')
     info('')
     info('Test 8 - sigmafraclinpol, sigmafractotpol')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test10():
     info('')
     info('')
     info('')
     info('Test 10 - fourierrotationmeasure')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test3():
     info('')
     info('')
     info('')
     info('Test 3 - linpolint, linpolposang, totpolint')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test3():
     info('')
     info('')
     info('')
     info('Test 3 - linpolint, linpolposang, totpolint')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test10():
     info('')
     info('')
     info('')
     info('Test 10 - fourierrotationmeasure')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test12():
     info('')
     info('')
     info('')
     info('Test 12 - depolratio, sigmadepolratio')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test8():
     info('')
     info('')
     info('')
     info('Test 8 - sigmafraclinpol, sigmafractotpol')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test11():
     info('')
     info('')
     info('')
     info('Test 11 - complexlinpol, complexfraclinpol, makecomplex')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test11():
     info('')
     info('')
     info('')
     info('Test 11 - complexlinpol, complexfraclinpol, makecomplex')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
 def test12():
     info('')
     info('')
     info('')
     info('Test 12 - depolratio, sigmadepolratio')
     #
     testdir = 'imagepoltest_temp'
     if not cleanup(testdir): return False
     # Make the directory
     try:
         os.mkdir(testdir)
     except IOError, e:
         note(e, "SEVERE")
         raise RuntimeError, "mkdir " + testdir + " fails!"
Exemple #19
0
#   sys.stderr=logfile

   #Turn off logviewer - no, leave it on, system regression need it
   #for pid in logpid:
   #   #print 'pid: ',pid
   #   os.kill(pid,9)

   #Turn off debug log
   #casalog.filter('DEBUG2') 

def plotfile(testName=""):
    return testplot+"/"+prefix+testName+'.png'

#print out usage
usage="plotxy_regression.py interactive=%s benchmarking=%s currentaffair=%s setnewbase=%s" % (manual, bench, current, savebase)
tstutl.note(usage, "INFO", this)

tstutl.note('*****************************************',"INFO",this)
tstutl.note('******plotxy regression test start ******',"INFO",this)

# Start bench clock
if bench:
    startTime=time.time()
    startProc=time.clock()

##############################################################################
# -1. preparing testing dataset                                              #
##############################################################################

tstutl.note('########## Preparing test data... ##########',"INFO",this)
msList=['NGC5921'
 def errFunc(raiser, problemPath, excInfo):
     note(raiser.__name__ + 'failed on' + problemPath, "SEVERE")
     raise RuntimeError, "Cleanup of " + dir + " fails!"
 def stop(message):
     note(message, priority="SEVERE", origin="imagepoltest")
     raise RuntimeError, message
#test working directory
testdir = '3c391polim_regression'

# clean up previous run
tstutl.cleanup(testdir)

# copying the data to testdir
tstutl.maketestdir(testdir)
print "Test working directory: ", testdir
try:
    print "copying data from " + datapath
    shutil.copytree(datapath, testdir + '/' + msdata)
    print "copying mask image from " + maskpath
    shutil.copyfile(maskpath, testdir + '/' + msk)
except Exception, e:
    tstutl.note("Failed with:" + str(e))
    raise e

##################
# reference data #
##################
refstats = {}
#
# Q image
#*.image
# on rishi (casapy-test 3.1.0 r13281)
refstats['qim'] = {
    'blc': array([0, 0, 0, 0], dtype=int32),
    'blcf': '18:50:12.253, -01.07.40.561, Q, 4.599e+09Hz',
    'flux': array([-0.02223448]),
    'max': array([0.00106219]),
def imagepoltest(which=None):
    #
    dowait = true
    #
    def info(message):
        note(message, origin="imagepoltest")
    def stop(message):
        note(message, priority="SEVERE", origin="imagepoltest")
        raise RuntimeError, message
    def fail(message=""):
        stop(message)
    def cleanup(dir):
        if (os.path.isdir(dir)):
            info("Cleaning up directory "+dir)
            def errFunc(raiser, problemPath, excInfo):
                note(raiser.__name__+'failed on'+problemPath,"SEVERE")
                raise RuntimeError, "Cleanup of " + dir + " fails!"
            shutil.rmtree(dir,0,errFunc)
        return True

    def addnoise(data, sigma):
        if len(data.shape)==3:
            for i in range(data.shape[0]):
                for j in range(data.shape[1]):
                    for k in range(data.shape[2]):
                        data[i][j][k] += random.normalvariate(0.0, sigma)
        else:
            stop('unhandled array shape '+str(data.shape)+' in addnoise')
        return True

    # 3D only
    def make_data(imshape, stokes):
        if imshape[2]>4: fail()
        if imshape[2]!=len(stokes): fail()
        data = ia.makearray(0, [imshape[0], imshape[1], imshape[2]])
        for k in range(imshape[2]):
            for i in range(imshape[0]):
                for j in range(imshape[1]):
                    data[i][j][k] = stokes[k]
        return data

    def alleqnum(x,num,tolerance=0):
        if len(x.shape)==3:
            for i in range(x.shape[0]):
                for j in range(x.shape[1]):
                    for k in range(x.shape[2]):
                        if not (abs(x[i][j][k]-num) < tolerance):
                            print "x[",i,"][",j,"][",k,"]=", x[i][j][k]
                            return false
        else:
            stop('unhandled array shape in alleqnum')
        return true
        
    def mean(x):
        result=0
        if len(x.shape)==2:
            for i in range(x.shape[0]):
                for j in range(x.shape[1]):
                    result += x[i][j]
            result = result/float(x.shape[0]*x.shape[1])
        else:
            if len(x.shape)==3:
                for i in range(x.shape[0]):
                    for j in range(x.shape[1]):
                        for k in range(x.shape[2]):
                            result += x[i][j][k]
                result = result /float(x.shape[0]*x.shape[1]*x.shape[2])
            else:
                stop('unhandled array shape '+str(x.shape)+' in mean')
        return result

    def max_with_location(x):
        max=-1e16
        loc=[-1,-1,-1,-1]
        if len(x.shape)==4:
            for i in range(x.shape[0]):
                for j in range(x.shape[1]):
                    for k in range(x.shape[2]):
                        for l in range(x.shape[3]):
                            if x[i][j][k][l] > max:
                                max = x[i][j][k][l]
                                loc = [i,j,k,l]
        else:
            stop('unhandled array shape '+str(x.shape)+' in max_with_location')
        return max, loc
    
    def test1():
        info('')
        info('')
        info('')
        info('Test 1 - open, done, and summary')
        testdir = 'imagepoltest_temp'
        if not cleanup(testdir): return False
        # Make the directory
        try:
            os.mkdir(testdir)
        except IOError, e:
            note(e, "SEVERE")
            raise RuntimeError, "mkdir " + testdir + " fails!"
        #
        # Make RA/DEC only
        #
        imname = testdir+'/imagefromshape.image'
        myim = ia.newimagefromshape(imname, [10,10])
        if not myim: fail()
        try:
            note("Expect SEVERE error and failure here")
            po.open(imname)
            isfail = False
        except Exception, e:
            note("Caught expected Exception")
            isfail = True
# Record processing completion time
if benchmarking:
    endProc = time.clock()
    endTime = time.time()

#
#=====================================================================
# Export tests
#
print ''
print ' --Export Tests--'
print ''
#
# First the UVFITS
#
tstutl.note("Opening UVFITS file " + srcuvfits + " to verify its existence")

if export_asynchronously:
    while True:
        try:
            if tm.retrieve(async_exportuvfits_id):
                break
            else:
                time.sleep(1)
        except Exception, e:
            tstutl.note("Error checking whether exportuvfits finished.",
                        "SEVERE")
            tstutl.note(
                "async_exportuvfits_id was " + str(async_exportuvfits_id),
                "SEVERE")
            raise e
    else:
        if doimage:
            for x in [sys.stdout, logfile]: print >> x ,'* Failed image rms test                *'
            regstate = False
        else:
            for x in [sys.stdout, logfile]: print >> x ,'* Did not do image rms test'
    for x in [sys.stdout, logfile]: print >> x ,'*   Image rms '+str(thistest_imrms)+' ('+str(imrms)+')'
    #if ((diff_cal1_2may<0.05) & (diff_cal2_2may<0.05) &
    #    (diff_cal1_8may<0.05) & (diff_cal2_8may<0.05) &
    #    (diff_src_2may<0.05) & (diff_src_8may<0.05) &
    #    (diff_immax<0.05) & (diff_imrms<0.05)): 
    if regstate:
        for x in [sys.stdout, logfile]: print >> x ,'---'
	for x in [sys.stdout, logfile]: print >> x ,'Passed Regression test for NGC1333'
	for x in [sys.stdout, logfile]: print >> x ,'---'
        tstutl.note("Passed Regression test for NGC1333","NORMAL")
    else: 
	for x in [sys.stdout, logfile]: print >> x ,'----FAILED Regression test for NGC1333'
        tstutl.note("FAILED Regression test for NGC1333","SEVERE")
    for x in [sys.stdout, logfile]: print >> x ,'*********************************'
    for x in [sys.stdout, logfile]: print >> x ,''
    for x in [sys.stdout, logfile]: print >> x ,''
    for x in [sys.stdout, logfile]: print >> x ,'********* Benchmarking *****************'
    for x in [sys.stdout, logfile]: print >> x ,'*                                      *'
    for x in [sys.stdout, logfile]: print >> x ,'Total wall clock time was: '+str(endTime - startTime)
    for x in [sys.stdout, logfile]: print >> x ,'Total CPU        time was: '+str(endProc - startProc)
    for x in [sys.stdout, logfile]: print >> x ,'Processing rate MB/s  was: '+str(240.3/(endTime - startTime))
    for x in [sys.stdout, logfile]: print >> x ,'* Breakdown:                           *'
    for x in [sys.stdout, logfile]: print >> x ,'*   import       time was: '+str(importtime-startTime)
    for x in [sys.stdout, logfile]: print >> x ,'*   listobs      time was: '+str(listtime-importtime)
    for x in [sys.stdout, logfile]: print >> x ,'*   flagdata     time was: '+str(flagtime-listtime)
     note("Expect SEVERE error and failure here")
     po.open(imname)
     isfail = False
 except Exception, e:
     note("Caught expected Exception")
     isfail = True
 if not isfail:
     stop('open 1 unexpectedly did not fail')
 if not myim.remove(True): fail()
 #
 # RA/DEC/I
 #
 myim = ia.newimagefromshape(imname, [10, 10, 1])
 if not myim: fail()
 try:
     note("Expect SEVERE error and failure here")
     po.open(imname)
     isfail = False
 except Exception, e:
     note("Caught expected Exception")
     isfail = True
 if not isfail:
     stop('open 2 unexpectedly did not fail')
 if not myim.remove(True): fail()
 #
 # RA/DEC/IQ
 #
 myim = ia.newimagefromshape(imname, [10, 10, 2])
 if not myim: fail()
 try:
     note("Expect SEVERE error and failure here")
#for pid in logpid:
#   #print 'pid: ',pid
#   os.kill(pid,9)

#Turn off debug log
#casalog.filter('DEBUG2')


def plotfile(testName=""):
    return testplot + "/" + prefix + testName + '.png'


#print out usage
usage = "plotxy_regression.py interactive=%s benchmarking=%s currentaffair=%s setnewbase=%s" % (
    manual, bench, current, savebase)
tstutl.note(usage, "INFO", this)

tstutl.note('*****************************************', "INFO", this)
tstutl.note('******plotxy regression test start ******', "INFO", this)

# Start bench clock
if bench:
    startTime = time.time()
    startProc = time.clock()

##############################################################################
# -1. preparing testing dataset                                              #
##############################################################################

tstutl.note('########## Preparing test data... ##########', "INFO", this)
msList = [
Exemple #28
0
# Record processing completion time
if benchmarking:
    endProc = time.clock()
    endTime = time.time()

#
#=====================================================================
# Export tests
#
print ''
print ' --Export Tests--'
print ''
#
# First the UVFITS
#
tstutl.note("Opening UVFITS file " + srcuvfits +
                " to verify its existence")

if export_asynchronously:
    while True:
        try:
            if tm.retrieve(async_exportuvfits_id):
                break
            else:
                time.sleep(1)
        except Exception, e:
            tstutl.note("Error checking whether exportuvfits finished.",
                        "SEVERE")
            tstutl.note("async_exportuvfits_id was " + str(async_exportuvfits_id), "SEVERE")
            raise e

uvfitsexists=False
 def errFunc(raiser, problemPath, excInfo):
     note(raiser.__name__+'failed on'+problemPath,"SEVERE")
     raise RuntimeError, "Cleanup of " + dir + " fails!"
 def stop(message):
     note(message, priority="SEVERE", origin="imagepoltest")
     raise RuntimeError, message
Exemple #31
0
import shutil
import random
import string

import regression_utility as tstutl

this = "maclog_regression"

#print out usage

nrows = 100000000
nrows = 1000

tstutl.note('*****************************************', "INFO", this)
tstutl.note('******maclog regression test start ******', "INFO", this)
for i in range(nrows):
    usage = "i=%s random=%s" % (i, random.random())
    tstutl.note(usage, "INFO", this)
tstutl.note('******maclog regression test finish******', 'INFO', this)
tstutl.note('*****************************************', 'INFO', this)
tstutl.note('casalogger, in a test done on 2009-10-29  ', 'INFO', this)
tstutl.note('with nrows=100000000 on a mac machine     ', 'INFO', this)
tstutl.note('followed the logging to near 7,000,000 rows', 'INFO', this)
tstutl.note('and quit when used 1.22G real memory and', 'INFO', this)
tstutl.note('4G of virtual memory. It quit when it ', 'INFO', this)
tstutl.note('could not allocate more memory. ', 'INFO', this)
tstutl.note('While is possible to follow big logging,', 'INFO', this)
tstutl.note('the maximum log casalogger can load statically', 'INFO', this)
tstutl.note('is set to 500000 rows.', 'INFO', this)
tstutl.note('*****************************************', 'INFO', this)
def imagepoltest(which=None):
    #
    dowait = True

    #
    def info(message):
        note(message, origin="imagepoltest")

    def stop(message):
        note(message, priority="SEVERE", origin="imagepoltest")
        raise RuntimeError, message

    def fail(message=""):
        stop(message)

    def cleanup(dir):
        if (os.path.isdir(dir)):
            info("Cleaning up directory " + dir)

            def errFunc(raiser, problemPath, excInfo):
                note(raiser.__name__ + 'failed on' + problemPath, "SEVERE")
                raise RuntimeError, "Cleanup of " + dir + " fails!"

            shutil.rmtree(dir, 0, errFunc)
        return True

    def addnoise(data, sigma):
        if len(data.shape) == 3:
            for i in range(data.shape[0]):
                for j in range(data.shape[1]):
                    for k in range(data.shape[2]):
                        data[i][j][k] += random.normalvariate(0.0, sigma)
        else:
            stop('unhandled array shape ' + str(data.shape) + ' in addnoise')
        return True

    # 3D only
    def make_data(imshape, stokes):
        if imshape[2] > 4: fail()
        if imshape[2] != len(stokes): fail()
        data = ia.makearray(0, [imshape[0], imshape[1], imshape[2]])
        for k in range(imshape[2]):
            for i in range(imshape[0]):
                for j in range(imshape[1]):
                    data[i][j][k] = stokes[k]
        return data

    def alleqnum(x, num, tolerance=0):
        if len(x.shape) == 3:
            for i in range(x.shape[0]):
                for j in range(x.shape[1]):
                    for k in range(x.shape[2]):
                        if not (abs(x[i][j][k] - num) < tolerance):
                            print "x[", i, "][", j, "][", k, "]=", x[i][j][k]
                            return False
        else:
            stop('unhandled array shape in alleqnum')
        return True

    def mean(x):
        result = 0
        if len(x.shape) == 2:
            for i in range(x.shape[0]):
                for j in range(x.shape[1]):
                    result += x[i][j]
            result = result / float(x.shape[0] * x.shape[1])
        else:
            if len(x.shape) == 3:
                for i in range(x.shape[0]):
                    for j in range(x.shape[1]):
                        for k in range(x.shape[2]):
                            result += x[i][j][k]
                result = result / float(x.shape[0] * x.shape[1] * x.shape[2])
            else:
                stop('unhandled array shape ' + str(x.shape) + ' in mean')
        return result

    def max_with_location(x):
        max = -1e16
        loc = [-1, -1, -1, -1]
        if len(x.shape) == 4:
            for i in range(x.shape[0]):
                for j in range(x.shape[1]):
                    for k in range(x.shape[2]):
                        for l in range(x.shape[3]):
                            if x[i][j][k][l] > max:
                                max = x[i][j][k][l]
                                loc = [i, j, k, l]
        else:
            stop('unhandled array shape ' + str(x.shape) +
                 ' in max_with_location')
        return max, loc

    def test1():
        info('')
        info('')
        info('')
        info('Test 1 - open, done, and summary')
        testdir = 'imagepoltest_temp'
        if not cleanup(testdir): return False
        # Make the directory
        try:
            os.mkdir(testdir)
        except IOError, e:
            note(e, "SEVERE")
            raise RuntimeError, "mkdir " + testdir + " fails!"
        #
        # Make RA/DEC only
        #
        imname = testdir + '/imagefromshape.image'
        myim = ia.newimagefromshape(imname, [10, 10])
        if not myim: fail()
        try:
            note("Expect SEVERE error and failure here")
            po.open(imname)
            isfail = False
        except Exception, e:
            note("Caught expected Exception")
            isfail = True
 def info(message):
     note(message, origin="imagepoltest")
#test working directory
testdir = '3c391polim_regression'

# clean up previous run
tstutl.cleanup(testdir)

# copying the data to testdir
tstutl.maketestdir(testdir)
print "Test working directory: ", testdir
try:
  print "copying data from "+datapath
  shutil.copytree(datapath,testdir+'/'+msdata)
  print "copying mask image from "+maskpath
  shutil.copyfile(maskpath,testdir+'/'+msk)
except Exception,e:
  tstutl.note("Failed with:"+str(e))
  raise e

##################
# reference data #
##################
refstats={}
#
# Q image 
#*.image
# on rishi (casapy-test 3.1.0 r13281)
refstats['qim'] = {'blc': array([0, 0, 0, 0], dtype=int32),
         'blcf': '18:50:12.253, -01.07.40.561, Q, 4.599e+09Hz',
         'flux': array([-0.02223448]),
         'max': array([ 0.00106219]),
         'maxpos': array([339, 268,   0,   0], dtype=int32),
 def info(message):
     note(message, origin="imagepoltest")
import shutil
import random
import string

import regression_utility as tstutl

this="maclog_regression"

#print out usage

nrows=100000000
nrows=1000

tstutl.note('*****************************************',"INFO",this)
tstutl.note('******maclog regression test start ******',"INFO",this)
for i in range(nrows):
    usage="i=%s random=%s" % (i, random.random())
    tstutl.note(usage, "INFO", this)
tstutl.note('******maclog regression test finish******','INFO',this)
tstutl.note('*****************************************','INFO',this)
tstutl.note('casalogger, in a test done on 2009-10-29  ','INFO',this) 
tstutl.note('with nrows=100000000 on a mac machine     ','INFO',this)
tstutl.note('followed the logging to near 7,000,000 rows','INFO',this)
tstutl.note('and quit when used 1.22G real memory and','INFO',this)
tstutl.note('4G of virtual memory. It quit when it ','INFO',this)
tstutl.note('could not allocate more memory. ','INFO',this)
tstutl.note('While is possible to follow big logging,','INFO',this)
tstutl.note('the maximum log casalogger can load statically','INFO',this)
tstutl.note('is set to 500000 rows.','INFO',this)
tstutl.note('*****************************************','INFO',this)
     note("Expect SEVERE error and failure here")
     po.open(imname)
     isfail = False
 except Exception, e:
     note("Caught expected Exception")
     isfail = True
 if not isfail:
     stop('open 1 unexpectedly did not fail')
 if not myim.remove(True): fail()
 #
 # RA/DEC/I
 #
 myim = ia.newimagefromshape(imname, [10,10,1])
 if not myim: fail()
 try:
     note("Expect SEVERE error and failure here")
     po.open(imname)
     isfail = False
 except Exception, e:
     note("Caught expected Exception")
     isfail = True
 if not isfail:
     stop('open 2 unexpectedly did not fail')
 if not myim.remove(True): fail()
 #
 # RA/DEC/IQ
 #
 myim = ia.newimagefromshape(imname, [10,10,2])
 if not myim: fail()
 try:
     note("Expect SEVERE error and failure here")