Commit 2fb274d7 authored by Andrea Orlat's avatar Andrea Orlat
Browse files

implemented the noData fits file

parent f6b1600a
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ module Backends {
	ACS_ENUM(TPolarization);

	/**
	 * This stucture reports the information that composes the section header of the data flux. Each section can have one or two inputs. Generally the number of inputs depends on the
	 * This structure reports the information that composes the section header of the data flux. Each section can have one or two inputs. Generally the number of inputs depends on the
	 * the polarization type of the section, if simple LEFT or RIGHT the input is one, if FULL_STOKES the inputs are two. The two positions fields <i>attenuation</i> and <i>IF</i> reports
	 * on the levels of attenuation and on the intermediate frequency chain number of the receiver of each input. If you want to know which the polarization of the second input of a given
	 * section you have to read the value of Receivers::polarization[IF[1]]. The attenuation level in db of the first input of a given section is attenuation[0]. 
@@ -64,7 +64,7 @@ module Backends {
	};
	
	/**
	 * This stucture exports all the information that composes the main header of the data flux
	 * This structure exports all the information that composes the main header of the data flux
	*/   
	struct TMainHeader {
		long sections;           /*!< number of sections that will be transfered by the backend, this record will be followed by "sections"
@@ -72,19 +72,23 @@ module Backends {
		long beams;               /*!< number of beams of the telescope */
		long integration;       /*<! integration time in milli seconds, it applies to all sections */
		long sampleSize;       /*<! number of bytes that a single sample is */
		boolean noData;  /*<! this flag indicates that the dump is virtual or in other words no raw data will be appended to the dump.
			//                         If true it will cause the file creator to create a file with just meta-data. */
	};
	
	/**
	 * This structure is the dump header, a dump is the ammount of data collected during the integration time for all the channels.
	 * Inside the dump the channels will be transfrered in the order they appear in the <i>TChannelHeader</i> sequence. First of all 
	 * the tsys information is transferred for each channel. Then for each channel and polarization an array of <i>bins</i> sample is trasmitted;
	 * in case of a full stokes 4 arrays are transfered (left first then right, then stokes Q and U respectively).
	 * This structure is the dump header, a dump is the all the data collected during the integration time for all the sections.
	 * Inside the dump the sections will be transferred in the order they appear in the <i>TChannelHeader</i> sequence. First of all
	 * the total intensity information(counts or Kelvin) is transferred for each inputs (the inputs appear in the same order of the sections).
	 * Then for each channel and polarization an array of <i>bins</i> sample is transmitted;
	 * in case of a full stokes, 4 arrays are transfered (left first then right, then stokes Q and U respectively).
	*/ 
	struct TDumpHeader {
		ACS::Time time;  /*!<! timestamp that marks the dump in time, this have to mark the exact start time of the acquisition. The duration is determined by the <i>TMainHeader::integration</i> */
		long dumpSize;  /*!<! size of the dump in bytes, it must be a multiple of the <i>sampleSize</i> parameter reported by the 
											<i>TMainHeader</i>.  */
		boolean calOn;			/*<! if true the calibration diode is on, false otherwise*/
		//ACS::Time tsysTime; /*<! if non-zero, the last measure of the system temperature is also appended. */
	};
	
};
+7 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
/* Andrea Orlati(aorlati@ira.inaf.it)  04/09/2012	   added function makeDirectory() and directoryExists() */
/* Andrea Orlati(aorlati@ira.inaf.it)  12/06/2014	  Function to handle conversions from Reference frame and definition for radial velocity */
/* Marco Bartolini (bartolini@ira.inaf.it)  18/06/2014	   added function ACS::Time getACSTime() */

/* Andrea Orlati(aorlati@ira.inaf.it)  12/08/2015	  Function to check if a file exists or not */

#include <time.h>
#include <sys/time.h>
@@ -652,6 +652,12 @@ public:
	  */
	 static bool directoryExists(const IRA::CString& path);

	 /**
	  * Check if a file exists on the local file system
	  * @return true if the file exists, false otherwise
	  */
	 static bool fileExists(const IRA::CString& file);

	 /**
	  * Round a double value to the nearest number with decimals precision
	  * @param val number to be rounded
+7 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#include <slalib.h>
#include <sys/stat.h>
#include <dirent.h>
#include <sys/stat.h>

using namespace IRA;

@@ -1091,6 +1092,12 @@ bool CIRATools::directoryExists(const IRA::CString& path)
    return exists;
}

bool CIRATools::fileExists(const IRA::CString& file)
{
	struct stat buffer;
	return (stat((const char *)file,&buffer)==0);
}

double CIRATools::roundNearest(const double& val,const long& decimals)
{
	long precision=(long)pow(10,decimals);
+33 −0
Original line number Diff line number Diff line
@@ -40,23 +40,56 @@ public:
		}
	}

	::testing::AssertionResult fileExists_checkExistance() {
		IRA::CString file;
		::testing::Test::RecordProperty("description","check if an existing file is detected");
		file=basePath+fileName;
		if (IRA::CIRATools::fileExists(file)) {
			return ::testing::AssertionSuccess();
		}
		else {
			return ::testing::AssertionFailure() << (const char *) file << " should be present but (fileExists) fails to detect it";
		}
	}

	::testing::AssertionResult fileExists_checkNoExistance() {
		IRA::CString file;
		::testing::Test::RecordProperty("description","check if a not existing file is correctly not detected");
		file="fooAnddymmyFile.test";
		if (IRA::CIRATools::fileExists(file)) {
			return ::testing::AssertionFailure() << (const char *) file << " should not be present but (fileExists) detects it";
		}
		else {
			return ::testing::AssertionSuccess();
		}
	}


protected:
	static IRA::CString simpleDirPath;
	static IRA::CString complexDirPath;
	static IRA::CString fileName;
	IRA::CString basePath;
	virtual void SetUp() {
		IRA::CString command;
		int i;
		char buff[256];
		getcwd(buff,256);
		basePath=buff;
		command="touch "+basePath+fileName;
		i=system((const char *)command);
	}
	virtual void TearDown() {
		IRA::CString cleanCommand;
		int i;
		cleanCommand="rm -rf "+basePath+simpleDirPath;
		i=system((const char *)cleanCommand);
		cleanCommand="rm "+basePath+fileName;
		i=system((const char *)cleanCommand);
	}
};

IRA::CString IRALibrary_IRATools::simpleDirPath = IRA::CString("/firstLevelDirectory");
IRA::CString IRALibrary_IRATools::complexDirPath = simpleDirPath+IRA::CString("/secondLevelDirectory");
IRA::CString IRALibrary_IRATools::fileName = IRA::CString("/dummyFile.tst");
}
+12 −1
Original line number Diff line number Diff line
@@ -5,7 +5,18 @@

using namespace IRALibraryTest;

TEST_F(IRALibrary_IRATools, MakeDirectory){
TEST_F(IRALibrary_IRATools, makeDirectory_createSimpleDirectory){
	EXPECT_TRUE(makeDirectory_createSimpleDirectory());
}

TEST_F(IRALibrary_IRATools, makeDirectory_createComplexDirectory){
	EXPECT_TRUE(makeDirectory_createComplexDirectory());
}

TEST_F(IRALibrary_IRATools, fileExists_checkExistance){
	EXPECT_TRUE(fileExists_checkExistance());
}

TEST_F(IRALibrary_IRATools, fileExists_checkNoExistance){
	EXPECT_TRUE(fileExists_checkNoExistance());
}
Loading