Go to the documentation of this file.00001 import os
00002 import time
00003 import regression_utility as regutl
00004
00005 REGNAME = "pointing";
00006
00007 MS = "pointingtest.ms";
00008 MODELIMAGE = "pointingmodel50m.im";
00009 EPJTABLE = "epjones2.tab";
00010 EPJCACHE = "pointing.cf";
00011 PASTEP = 360.0;
00012 INTEG = '30.0s';
00013 THISHOME = "./pointing_regression_data/";
00014
00015 TOTALTIME = '*+1:0:0';
00016 EPS = 1E-4;
00017
00018 TEMPLATEEPJ='template2.epj';
00019
00020
00021 REPOSNAME = os.environ.get('CASAPATH').split()[0]+"/data/regression/"+REGNAME+'/';
00022
00023 REUSELOCALREPOS = False;
00024
00025
00026
00027 MYMS = THISHOME + MS;
00028 MYIMAGE = THISHOME + MODELIMAGE;
00029 MYTEMPLATEEPJ = THISHOME + TEMPLATEEPJ;
00030 def pointing_reg():
00031 if (REUSELOCALREPOS):
00032 os.system("rm -rf " + THISHOME+EPJTABLE);
00033 else:
00034 os.system("rm -rf "+THISHOME);
00035 os.mkdir(THISHOME);
00036 os.system("cp -r " + REPOSNAME+MS + " " + MYMS);
00037 os.system("cp -r " + REPOSNAME+MODELIMAGE + " " + MYIMAGE);
00038 os.system("cp -r " + REPOSNAME+TEMPLATEEPJ + " " + MYTEMPLATEEPJ);
00039
00040 cb.open(MYMS);
00041
00042 cb.selectvis(time=TOTALTIME);
00043 cb.setsolve(type = "EP",
00044 t = INTEG,
00045 table = THISHOME+EPJTABLE,
00046 preavg = -1,
00047 phaseonly = false,
00048 append = false,
00049 cfcache = THISHOME + EPJCACHE,
00050 painc = PASTEP);
00051 cb.setmodel(modelimage=MYIMAGE);
00052 cb.solve();
00053
00054
00055
00056 try:
00057 startTime = time.time();
00058 startProc = time.clock();
00059 regstate = False;
00060
00061
00062
00063 pointing_reg();
00064
00065
00066
00067
00068 tb.open(MYTEMPLATEEPJ);
00069 tmp_sol=tb.getcol('GAIN');
00070 tb.close();
00071 endTime = time.time();
00072 endProc = time.clock();
00073
00074
00075
00076
00077 tb.open(THISHOME+EPJTABLE);
00078 this_sol=tb.getcol('GAIN');
00079 tb.close();
00080
00081
00082
00083
00084 nt=this_sol.shape[2];
00085
00086 dsol=tmp_sol[[0,2],0,0:nt]-this_sol[[0,2],0,0:nt];
00087 dMax=dsol.max();
00088 dMin=dsol.min();
00089 dVar=dsol.var();
00090 dMean=dsol.mean();
00091
00092 import datetime
00093 datestring=datetime.datetime.isoformat(datetime.datetime.today())
00094 outfile=REGNAME+'-'+datestring+'.log'
00095 logfile=open(outfile,'w')
00096
00097 print >>logfile, "Pointing solution statistics:";
00098 print >>logfile, "-------------------------------------------------";
00099 print >>logfile, "Res. Max = ",dMax, " Res. Var = ",dVar, " Res. Min = ",dMin, " Res. Mean = ",dMean;
00100 print >>logfile, "";
00101
00102 if ((abs(dMax) < EPS) &
00103 (abs(dVar) < EPS) &
00104 (abs(dMin) < EPS)):
00105 regstate=True;
00106 print >>logfile,REGNAME+" Regression passed.";
00107 print ''
00108 print 'Regression PASSED'
00109 print ''
00110 else:
00111 regstate=False;
00112 print >>logfile,REGNAME+" Regression failed.";
00113 print ''
00114 print 'Regression FAILED'
00115 print ''
00116
00117 print >>logfile,''
00118 print >>logfile,''
00119 print >>logfile,'********* Benchmarking *****************'
00120 print >>logfile,'* *'
00121 print >>logfile,'Total wall clock time was: ', endTime - startTime
00122 print >>logfile,'Total CPU time was: ', endProc - startProc
00123
00124
00125 logfile.close();
00126
00127 except Exception, instance:
00128 print "###Error in pointing regression: ", instance;