casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FlagAgentShadow.h
Go to the documentation of this file.
00001 //# FlagAgentShadow.h: This file contains the interface definition of the FlagAgentShadow class.
00002 //#
00003 //#  CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
00004 //#  Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
00005 //#  Copyright (C) European Southern Observatory, 2011, All rights reserved.
00006 //#
00007 //#  This library is free software; you can redistribute it and/or
00008 //#  modify it under the terms of the GNU Lesser General Public
00009 //#  License as published by the Free software Foundation; either
00010 //#  version 2.1 of the License, or (at your option) any later version.
00011 //#
00012 //#  This library is distributed in the hope that it will be useful,
00013 //#  but WITHOUT ANY WARRANTY, without even the implied warranty of
00014 //#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 //#  Lesser General Public License for more details.
00016 //#
00017 //#  You should have received a copy of the GNU Lesser General Public
00018 //#  License along with this library; if not, write to the Free Software
00019 //#  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00020 //#  MA 02111-1307  USA
00021 //# $Id: $
00022 
00023 #ifndef FlagAgentShadow_H_
00024 #define FlagAgentShadow_H_
00025 
00026 #include <flagging/Flagging/FlagAgentBase.h>
00027 
00028 #include <measures/Measures/MeasFrame.h>
00029 //#include <casa/Quanta/MVAngle.h>
00030 //#include <casa/Quanta/MVTime.h>
00031 //#include <measures/Measures/MeasTable.h>
00032 #include <measures/Measures/MBaseline.h>
00033 #include <measures/Measures/MCBaseline.h>
00034 #include <measures/Measures/Muvw.h>
00035 #include <measures/Measures/MCuvw.h>
00036 #include <casa/Quanta/MVuvw.h>
00037 #include <measures/Measures/MEpoch.h>
00038 #include <measures/Measures/MPosition.h>
00039 #include <measures/Measures/MCPosition.h>
00040 #include <measures/Measures/MDirection.h>
00041 #include <casa/Quanta/MVDirection.h>
00042 #include <measures/Measures.h>
00043 #include <casa/Utilities/DataType.h>
00044 
00045 #include <casa/Containers/Record.h>
00046 
00047 
00048 namespace casa { //# NAMESPACE CASA - BEGIN
00049 
00050 class FlagAgentShadow : public FlagAgentBase {
00051 
00052 public:
00053 
00054         FlagAgentShadow(FlagDataHandler *dh, Record config, Bool writePrivateFlagCube = false, Bool flag = true);
00055         ~FlagAgentShadow();
00056 
00057 protected:
00058 
00059         // Common functionality for each visBuffer (don't repeat at the row level)
00060         void preProcessBuffer(const vi::VisBuffer2 &visBuffer);
00061 
00062         // Common preProcessing code for the single/multiple agent cases
00063         void preProcessBufferCore(const vi::VisBuffer2 &visBuffer);
00064 
00065         // Compute flags afor a given mapped visibility point
00066         bool computeRowFlags(const vi::VisBuffer2 &visBuffer, FlagMapper &flags, uInt row);
00067 
00068         // Parse configuration parameters
00069         void setAgentParameters(Record config);
00070 
00071 private:
00072 
00073         // Function to compute antenna UVW values for the current timestep
00074         Bool computeAntUVW(const vi::VisBuffer2 &vb, Int rownr);
00075         // Function to compute shadowed antennas, given a list of antenna UVWs.
00076         void calculateShadowedAntennas(const vi::VisBuffer2 &visBuffer, Int rownr);
00077         // Function to decide if the 'behind' antenna is shadowed or not, for one baseline
00078         void decideBaselineShadow(Double uvDistance, Double w, Int antenna1, Int antenna2);
00079         // Function to return baseline index.
00080         uInt baselineIndex(uInt nAnt, uInt a1, uInt a2);
00081  
00083         Double shadowTolerance_p;
00084         Record additionalAntennas_p;
00085 
00086         // Copies of antenna-information lists, containing extra antennas if specified.
00088         Vector<Double> shadowAntennaDiameters_p;
00089         Vector<MPosition> shadowAntennaPositions_p;
00090 
00091         // Declaration of static members for common pre-processing
00092         uShort agentNumber_p;
00093         static vector<Int> shadowedAntennas_p;
00094         static casa::async::Mutex staticMembersMutex_p;
00095         static vector<bool> startedProcessing_p;
00096         static bool preProcessingDone_p;
00097         static uShort nAgents_p;
00098         
00099         // Private variables that change with each timestep
00100         Matrix<Double> uvwAnt_p;
00101         Double currTime_p;
00102 
00103         Bool firststep_p; // helper variable to control a debug print statement
00104     
00105 };
00106 
00107 } //# NAMESPACE CASA - END
00108 
00109 #endif /* FlagAgentShadow_H_ */
00110