<commit_before>//#include <boost/python.hpp>
#include <iostream>
#include "io.h"
#include "particle.h"
#include "detector.h"
#include "beam.h"
#include "diffraction.h"

//#ifdef COMPILE_WITH_CUDA
#include "diffraction.cuh"
//#endif

#include "toolbox.h"

#include <hdf5.h>
//#include "H5Cpp.h"

#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <armadillo>

using namespace std;
using namespace arma;
using namespace particle;
using namespace detector;
using namespace beam;
using namespace diffraction;
using namespace toolbox;

#ifdef OLD_HEADER_FILENAME
#include <iostream.h>
#else
#include <iostream>
#endif
#include <string>

#ifndef H5_NO_NAMESPACE
#ifndef H5_NO_STD
    using std::cout;
    using std::endl;
#endif  // H5_NO_STD
#endif

#include "H5Cpp.h"

#ifndef H5_NO_NAMESPACE
    using namespace H5;
#endif

void hdf5write(std::string filename, std::string datasetname, arma::fmat image){
	const H5std_string FILE_NAME( filename );
	const H5std_string DATASET_NAME( datasetname );
	//const int    NX = 1456;		// output buffer dimensions
	//const int    NY = 1456;
	
}

arma::fmat hdf5read(std::string filename, std::string datasetname){
	const H5std_string FILE_NAME( filename );
	const H5std_string DATASET_NAME( datasetname );
	//const int    NX_SUB = 3;	// hyperslab dimensions
	//const int    NY_SUB = 4;
	//const int    NX = 1456;		// output buffer dimensions
	//const int    NY = 1456;
	int NX, NY;
	const int    RANK_OUT = 2;
   
    fmat myDP;
   /*
    * Try block to detect exceptions raised by any of the calls inside it
    */
   try
   {
      /*
       * Turn off the auto-printing when failure occurs so that we can
       * handle the errors appropriately
       */
		Exception::dontPrint();
	
	  /*
       * Open the specified file and the specified dataset in the file.
       */
      	H5File file( FILE_NAME, H5F_ACC_RDONLY );
      	DataSet dataset = file.openDataSet( DATASET_NAME );

      /*
       * Get the class of the datatype that is used by the dataset.
       */
      	H5T_class_t type_class = dataset.getTypeClass();

      /*
       * Get class of datatype and print message if it's an integer.
       */
      if( type_class == H5T_FLOAT )
      {
	 	//cout << "Data set has FLOAT type" << endl;

         /*
	  	  * Get the integer datatype
          */
	 	 IntType intype = dataset.getIntType();

         /*
          * Get order of datatype and print message if it's a little endian.
          */
	 	 H5std_string order_string;
         H5T_order_t order = intype.getOrder( order_string );
	 	 cout << "Endian:" << order << endl;

         /*
          * Get size of the data element stored in file and print it.
          */
         size_t size = intype.getSize();
         cout << "Data size is " << size << endl;
      }

      /*
       * Get dataspace of the dataset.
       */
      DataSpace dataspace = dataset.getSpace();

      /*
       * Get the number of dimensions in the dataspace.
       */
      int rank = dataspace.getSimpleExtentNdims();

      /*
       * Get the dimension size of each dimension in the dataspace and
       * display them.
       */
      hsize_t dims_out[2];
      int ndims = dataspace.getSimpleExtentDims( dims_out, NULL);
      cout << "rank " << rank << ", dimensions " <<
	      (unsigned long)(dims_out[0]) << " x " <<
	      (unsigned long)(dims_out[1]) << endl;
	  
	  NX = (unsigned long)(dims_out[0]);
	  NY = (unsigned long)(dims_out[1]);
	  	  
      /*
       * Define hyperslab in the dataset; implicitly giving strike and
       * block NULL.
       */
      hsize_t      offset[2];	// hyperslab offset in the file
      hsize_t      count[2];	// size of the hyperslab in the file
      offset[0] = 0;
      offset[1] = 0;
      count[0]  = NX;//NX_SUB;
      count[1]  = NY;//NY_SUB;
      dataspace.selectHyperslab( H5S_SELECT_SET, count, offset );

      /*
       * Define the memory dataspace.
       */
      hsize_t     dimsm[2];              /* memory space dimensions */
      dimsm[0] = NX;
      dimsm[1] = NY;
      //dimsm[2] = 1 ;
      DataSpace memspace( RANK_OUT, dimsm );
	  
      /*
       * Define memory hyperslab.
       */
      hsize_t      offset_out[2];	// hyperslab offset in memory
      hsize_t      count_out[2];	// size of the hyperslab in memory
      offset_out[0] = 0;
      offset_out[1] = 0;
      //offset_out[2] = 0;
      count_out[0]  = NX;
      count_out[1]  = NY;
      //count_out[2]  = 1;
      memspace.selectHyperslab( H5S_SELECT_SET, count_out, offset_out );
	  
      /*
       * Read data from hyperslab in the file into the hyperslab in
       * memory and display the data.
       */
      float data_out[NX][NY]; /* output buffer */	
      dataset.read( data_out, PredType::NATIVE_FLOAT, memspace, dataspace );

	  myDP.zeros(NY,NX); 
	  for (int j = 0; j < NY; j++)
   	  {
      	for (int i = 0; i < NX; i++)
      	{
	    	myDP(j,i) = data_out[j][i];
      	}
      }
      cout << "myDP(66): " << myDP(66) << endl; // 3000
      cout << "myDP(76): " << myDP(76) << endl; // 45000

   }  // end of try block

   // catch failure caused by the H5File operations
   catch( FileIException error )
   {
      error.printError();
      //return -1;
   }

   // catch failure caused by the DataSet operations
   catch( DataSetIException error )
   {
      error.printError();
      //return -1;
   }

   // catch failure caused by the DataSpace operations
   catch( DataSpaceIException error )
   {
      error.printError();
      //return -1;
   }

   // catch failure caused by the DataSpace operations
   catch( DataTypeIException error )
   {<commit_msg>remove debug<commit_after>//#include <boost/python.hpp>
#include <iostream>
#include "io.h"
#include "particle.h"
#include "detector.h"
#include "beam.h"
#include "diffraction.h"

//#ifdef COMPILE_WITH_CUDA
#include "diffraction.cuh"
//#endif

#include "toolbox.h"

#include <hdf5.h>
//#include "H5Cpp.h"

#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <armadillo>

using namespace std;
using namespace arma;
using namespace particle;
using namespace detector;
using namespace beam;
using namespace diffraction;
using namespace toolbox;

#ifdef OLD_HEADER_FILENAME
#include <iostream.h>
#else
#include <iostream>
#endif
#include <string>

#ifndef H5_NO_NAMESPACE
#ifndef H5_NO_STD
    using std::cout;
    using std::endl;
#endif  // H5_NO_STD
#endif

#include "H5Cpp.h"

#ifndef H5_NO_NAMESPACE
    using namespace H5;
#endif

void hdf5write(std::string filename, std::string datasetname, arma::fmat image){
	const H5std_string FILE_NAME( filename );
	const H5std_string DATASET_NAME( datasetname );
	//const int    NX = 1456;		// output buffer dimensions
	//const int    NY = 1456;
	
}

arma::fmat hdf5read(std::string filename, std::string datasetname){
	const H5std_string FILE_NAME( filename );
	const H5std_string DATASET_NAME( datasetname );
	//const int    NX_SUB = 3;	// hyperslab dimensions
	//const int    NY_SUB = 4;
	//const int    NX = 1456;		// output buffer dimensions
	//const int    NY = 1456;
	int NX, NY;
	const int    RANK_OUT = 2;
   
    fmat myDP;
   /*
    * Try block to detect exceptions raised by any of the calls inside it
    */
   try
   {
      /*
       * Turn off the auto-printing when failure occurs so that we can
       * handle the errors appropriately
       */
		Exception::dontPrint();
	
	  /*
       * Open the specified file and the specified dataset in the file.
       */
      	H5File file( FILE_NAME, H5F_ACC_RDONLY );
      	DataSet dataset = file.openDataSet( DATASET_NAME );

      /*
       * Get the class of the datatype that is used by the dataset.
       */
      	H5T_class_t type_class = dataset.getTypeClass();

      /*
       * Get class of datatype and print message if it's an integer.
       */
      if( type_class == H5T_FLOAT )
      {
	 	//cout << "Data set has FLOAT type" << endl;

         /*
	  	  * Get the integer datatype
          */
	 	 IntType intype = dataset.getIntType();

         /*
          * Get order of datatype and print message if it's a little endian.
          */
	 	 H5std_string order_string;
         H5T_order_t order = intype.getOrder( order_string );
	 	 cout << "Endian:" << order << endl;

         /*
          * Get size of the data element stored in file and print it.
          */
         size_t size = intype.getSize();
         cout << "Data size is " << size << endl;
      }

      /*
       * Get dataspace of the dataset.
       */
      DataSpace dataspace = dataset.getSpace();

      /*
       * Get the number of dimensions in the dataspace.
       */
      int rank = dataspace.getSimpleExtentNdims();

      /*
       * Get the dimension size of each dimension in the dataspace and
       * display them.
       */
      hsize_t dims_out[2];
      int ndims = dataspace.getSimpleExtentDims( dims_out, NULL);
      cout << "rank " << rank << ", dimensions " <<
	      (unsigned long)(dims_out[0]) << " x " <<
	      (unsigned long)(dims_out[1]) << endl;
	  
	  NX = (unsigned long)(dims_out[0]);
	  NY = (unsigned long)(dims_out[1]);
	  	  
      /*
       * Define hyperslab in the dataset; implicitly giving strike and
       * block NULL.
       */
      hsize_t      offset[2];	// hyperslab offset in the file
      hsize_t      count[2];	// size of the hyperslab in the file
      offset[0] = 0;
      offset[1] = 0;
      count[0]  = NX;//NX_SUB;
      count[1]  = NY;//NY_SUB;
      dataspace.selectHyperslab( H5S_SELECT_SET, count, offset );

      /*
       * Define the memory dataspace.
       */
      hsize_t     dimsm[2];              /* memory space dimensions */
      dimsm[0] = NX;
      dimsm[1] = NY;
      //dimsm[2] = 1 ;
      DataSpace memspace( RANK_OUT, dimsm );
	  
      /*
       * Define memory hyperslab.
       */
      hsize_t      offset_out[2];	// hyperslab offset in memory
      hsize_t      count_out[2];	// size of the hyperslab in memory
      offset_out[0] = 0;
      offset_out[1] = 0;
      //offset_out[2] = 0;
      count_out[0]  = NX;
      count_out[1]  = NY;
      //count_out[2]  = 1;
      memspace.selectHyperslab( H5S_SELECT_SET, count_out, offset_out );
	  
      /*
       * Read data from hyperslab in the file into the hyperslab in
       * memory and display the data.
       */
      float data_out[NX][NY]; /* output buffer */	
      dataset.read( data_out, PredType::NATIVE_FLOAT, memspace, dataspace );

	  myDP.zeros(NY,NX); 
	  for (int j = 0; j < NY; j++)
   	  {
      	for (int i = 0; i < NX; i++)
      	{
	    	myDP(j,i) = data_out[j][i];
      	}
      }

   }  // end of try block

   // catch failure caused by the H5File operations
   catch( FileIException error )
   {
      error.printError();
      //return -1;
   }

   // catch failure caused by the DataSet operations
   catch( DataSetIException error )
   {
      error.printError();
      //return -1;
   }

   // catch failure caused by the DataSpace operations
   catch( DataSpaceIException error )
   {
      error.printError();
      //return -1;
   }

   // catch failure caused by the DataSpace operations
   catch( DataTypeIException error )
   {
{'fraction_non_alphanumeric': 0.11443946188340808, 'fraction_numerical': 0.015336322869955158, 'mean_word_length': 2.2024698449167146, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4373913', 'n_tokens_mistral': 3865, 'n_tokens_neox': 3692, 'n_words': 1067}