Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 import os;
00026 import shutil;
00027 from casac import *;
00028
00029 def setToCasaOrder(inputMS='',outputMS=''):
00030 """
00031 This script will re-sort the input MS into the following sort order
00032 ARRAY, FIELD, SPW (or data_desc_id), TIME, ANTENNA1, ANTENNA2
00033
00034 For I/O operations, data are by-default partitioned on array, field and spw.
00035 CASA prefers data in which ANTENNA1,ANTENNA2 are the fastest-varying axes.
00036
00037 To check if your MS is in the correct order (and if you need this or not),
00038 open the MS using 'casabrowser' or 'browsetable()', and look at the
00039 ANTENNA1, ANTENNA2, DATA_DESC_ID, FIELD_ID, ARRAY_ID, and TIME columns.
00040 The sort order in the MS should be apparant from the indices in these columns.
00041
00042 Re-sorting makes the most difference in some cases when UVFITS files
00043 written out of AIPS are read into CASA via importuvfits. Often, SPW (data_desc_id)
00044 is the fastest-varying index, and this is the worst-possible case for the CASA
00045 data-access pattern.
00046 Note : This is due to a difference in the choice of default sort order
00047 in AIPS and CASA, which the importuvfits task currently ignores.
00048
00049 This script will create a temporary reference-MS (a list of row indices containing the
00050 mapping from the input to output MSs) called 'tmpreftable.tab' in the current
00051 working directory. Therefore, please do not run two instances of this script in
00052 the same directory.
00053
00054 """
00055
00056 tb = casac.table()
00057
00058
00059 if(not os.path.exists(inputMS)):
00060 print "Original MS ", inputMS, " not found ";
00061 return False;
00062
00063 if(os.path.exists(outputMS)):
00064 print "An MS named ", outputMS, " already exists. Please delete it first, or choose another output MS name";
00065 return False;
00066
00067
00068
00069
00070 print "Making reference table.";
00071 tb.open(inputMS);
00072 tmptb = tb.query(name='tmpreftable.tab', query='DATA_DESC_ID>-1',sortlist='ARRAY_ID,FIELD_ID,DATA_DESC_ID,TIME,ANTENNA1,ANTENNA2');
00073 tmptb.close()
00074 tb.close();
00075
00076
00077
00078
00079 print "Making deep-copy of ref-table";
00080 tb.open('tmpreftable.tab');
00081 tmptb = tb.copy(outputMS,deep=True);
00082 tmptb.close()
00083 tb.close();
00084
00085
00086 print "Removing ref-table";
00087 if(os.path.exists('tmpreftable.tab')):
00088 shutil.rmtree('tmpreftable.tab');
00089
00090