casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSTileLayout.h
Go to the documentation of this file.
00001 //# MSTileLayout.h: Determine appropriate tiling for a MeasurementSet
00002 //# Copyright (C) 2002
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: MSTileLayout.h 20299 2008-04-03 05:56:44Z gervandiepen $
00027 
00028 #ifndef MS_MSTILELAYOUT_H
00029 #define MS_MSTILELAYOUT_H
00030 
00031 #include <casa/aips.h>
00032 
00033 namespace casa { //# NAMESPACE CASA - BEGIN
00034 
00035 //# forward decl
00036 class IPosition;
00037 class String;
00038 
00039 // <summary> 
00040 // An helper class for deciding on tile shapes in MeasurementSets
00041 // </summary>
00042  
00043 // <use visibility=export>
00044  
00045 // <prerequisite>
00046 //   <li> <linkto class="MeasurementSet:description">MeasurementSet</linkto> 
00047 //   <li> <linkto class="TiledStMan:description">TiledStMan</linkto> 
00048 // </prerequisite>
00049 //
00050 // <etymology>
00051 // MSTileLayout stands for the MeasurementSet tile layout chooser
00052 // </etymology>
00053 //
00054 // <synopsis> 
00055 // MSTileLayout is a class to determine an appropriate tile shape choice
00056 // for the MeasurementSet DATA columns, based on the shape of the DATA,
00057 // the observing mode and the number of interferometers
00058 // </synopsis> 
00059 //
00060 // <example>
00061 // <srcblock>
00062 // // The following code returns the tile shape given the DATA shape,
00063 // // the observing type and the array name.
00064 // IPosition dataShape(2,4,1024); // 4 polarizations, 1024 channels
00065 // IPosition tileShape = MSTileLayout::tileShape(dataShape,
00066 //                                               MSTileLayout::FastMosaic,
00067 //                                               "ATCA");
00068 // cout << "tileShape = "<< tileShape << endl;
00069 // // Output is: 
00070 // tileShape = (4,11,15)
00071 // </srcblock>
00072 // </example>
00073 
00074 // <motivation>
00075 // This class is intended to replace bits of code scattered throughout various
00076 // fillers and collect all tiling decisions in one place.
00077 // </motivation>
00078 //
00079 // <todo>
00080 // </todo>
00081 
00082 class MSTileLayout
00083 {
00084 public:
00085   enum ObsType {
00086     // Standard, optimizes i/o by using large tiles (128 kB)
00087     Standard=0,
00088     // Fast Mosaic, specify this if you have many (>30) fields and you 
00089     // spend only a few integrations per pointing before moving on.
00090     // Avoids useless i/o caching by using small tiles
00091     FastMosaic=1
00092   };
00093 
00094   // Suggest tile shape based on the data shape, the observing mode, 
00095   // the number of interferometers and the number of integrations per
00096   // pointing.
00097   //
00098   // First argument should be a 2-dimensional IPosition with the data matrix
00099   // shape.
00100   // The second argument is one of the enums above specifying the type of
00101   // observation. 
00102   // The third argument is an estimate of the number of interferometers
00103   // present throughout most of the data.
00104   // The last argument is an estimate of the number of integrations per
00105   // pointing. 
00106   //
00107   // The last three arguments only need to be specified if the observing mode 
00108   // is non Standard.
00109   // Basically the choice is between large tiles for efficient I/O and small
00110   // tiles when a common access pattern (field_id order) would result
00111   // in very inefficient caching. The latter occurs for large tiles if the 
00112   // field_id changes rapidly AND there are many fields AND the data 
00113   // matrix is small (e.g., continuum mosaic of a large area with only
00114   // one or two integrations per pointing). Note that accessing fast mosaic
00115   // data with large tiles in field_id order can be 10-100 times slower than
00116   // sequential access.
00117   static IPosition tileShape(const IPosition& dataShape,
00118                              Int observationType = Standard,
00119                              Int nIfr = 0, Int nInt = 1);
00120 
00121   // same as above, but pick standard nIfr (number of interferometers)
00122   // for named array and default nInt.
00123   static IPosition tileShape(const IPosition& dataShape,
00124                              Int observationType,
00125                              const String& array);
00126 };
00127 
00128 
00129 } //# NAMESPACE CASA - END
00130 
00131 #endif