diff --git a/Code/Mantid/Framework/MDAlgorithms/test/CPRebinKeepPixTest.h b/Code/Mantid/Framework/MDAlgorithms/test/CPRebinKeepPixTest.h index 0fb3d9fc4ed5eb57f06db7986585c5b5452e587c..1a0277b4ac960b18f6f3d9746817fc252612fd40 100644 --- a/Code/Mantid/Framework/MDAlgorithms/test/CPRebinKeepPixTest.h +++ b/Code/Mantid/Framework/MDAlgorithms/test/CPRebinKeepPixTest.h @@ -46,8 +46,8 @@ MDWorkspace_sptr load_fake_workspace(std::string &wsName){ IMD_FileFormat *pf = inputWS->get_pFileReader(); pf->read_MDImg_data(*inputWS->get_spMDImage()); - //TODO: should be moved into datapoints; - inputWS->get_spMDImage()->identify_SP_points_locations(); + + inputWS->get_spMDDPoints()->init_pix_locations(); return inputWS; diff --git a/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MD_FileHoraceReader.h b/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MD_FileHoraceReader.h index 75dadcbf35df8bd0be836fd32ed8e795171865ba..75cbec66e6cb0325dda761d8182e4834fc8ad2e3 100644 --- a/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MD_FileHoraceReader.h +++ b/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MD_FileHoraceReader.h @@ -127,6 +127,8 @@ private: void compact_hor_data(char *buffer,size_t &buf_size); // the size of data block for Horace reader; static const unsigned int hbs=9*4; + // the array specifying the locations of MD points wrt MD cells; + std::vector<uint64_t> hor_points_locations; // Function performing work previously in GOTO statement. void inline validateFileStreamHolder(std::ifstream& fileStreamHolder); diff --git a/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MD_File_hdfMatlab.h b/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MD_File_hdfMatlab.h index 2346cf7462b04e08753c1b9be12b78eb8f428005..399bde6e09d25bff5035d958c38eff10545310f0 100644 --- a/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MD_File_hdfMatlab.h +++ b/Code/Mantid/Framework/MDDataObjects/inc/MDDataObjects/MD_File_hdfMatlab.h @@ -134,7 +134,12 @@ protected: // function checks if pixel dataset is opened and if not opens it. true if it was already opened, false if did nothing bool check_or_open_pix_dataset(void); - + // the array specifying the locations of MD points wrt MD cells; + std::vector<uint64_t> mp_points_locations; +private: + + + }; // function used to understand Horace written Matlab dataset. diff --git a/Code/Mantid/Framework/MDDataObjects/src/MDDataPoints.cpp b/Code/Mantid/Framework/MDDataObjects/src/MDDataPoints.cpp index 54c35806b57e4b23391380c89de6642886635597..e95db38850a772d430d3683b47099d9c91771bc7 100644 --- a/Code/Mantid/Framework/MDDataObjects/src/MDDataPoints.cpp +++ b/Code/Mantid/Framework/MDDataObjects/src/MDDataPoints.cpp @@ -20,7 +20,7 @@ void MDDataPoints::init_pix_locations() { // and calculate cells location for pixels; - const MD_image_point const* pData = this->spMDImage->get_const_pData(); + MD_image_point const * const pData = this->spMDImage->get_const_pData(); size_t nCells = this->spMDImage->getDataSize(); if(this->pix_location.size()!=nCells){ this->pix_location.resize(nCells); @@ -80,7 +80,11 @@ MDDataPoints::initialize(boost::shared_ptr<const MDImage> spImage,boost::shared_ } } //this->alloc_pix_array(); - this->n_data_points = this->spFileReader->getNPix(); + this->n_data_points = this->spFileReader->getNPix(); + + unsigned int nDims= this->spMDImage->getGeometry()->getNumDims(); + this->box_min.assign(nDims,FLT_MAX); + this->box_max.assign(nDims,-FLT_MAX); } // boost::shared_ptr<IMD_FileFormat> @@ -91,6 +95,10 @@ MDDataPoints::initialize(boost::shared_ptr<const MDImage> pImageData) } this->n_data_points =0; //this->alloc_pix_array(); + unsigned int nDims= this->spMDImage->getGeometry()->getNumDims(); + + this->box_min.assign(nDims,FLT_MAX); + this->box_max.assign(nDims,-FLT_MAX); return this->spFileReader; } @@ -127,8 +135,6 @@ MDDataPoints::alloc_pix_array(size_t buf_size) } unsigned int nDims = this->spMDImage->getGeometry()->getNumDims(); - this->box_min.assign(nDims,FLT_MAX); - this->box_max.assign(nDims,-FLT_MAX); // identify maximal number of pixels, possible to fit into buffer for current architecture; size_t nMemPix(0); diff --git a/Code/Mantid/Framework/MDDataObjects/src/MDImage.cpp b/Code/Mantid/Framework/MDDataObjects/src/MDImage.cpp index b2d19732730eab78f2cfc8086dda092af5dd7242..7edfa8bc678126cdcabdd4d7574addb98a0fe3c4 100644 --- a/Code/Mantid/Framework/MDDataObjects/src/MDImage.cpp +++ b/Code/Mantid/Framework/MDDataObjects/src/MDImage.cpp @@ -278,11 +278,6 @@ MDImage::~MDImage() this->clear_class(); } // -void -MDImage::identify_SP_points_locations() -{ - -} //*************************************************************************************** void diff --git a/Code/Mantid/Framework/MDDataObjects/src/MD_FileHoraceReader.cpp b/Code/Mantid/Framework/MDDataObjects/src/MD_FileHoraceReader.cpp index 715ac54cd56b8b450bfe279b1ea6bd7c73bde8db..e2f16acfd64ccecaf680a2fc79027291c44d4bbf 100644 --- a/Code/Mantid/Framework/MDDataObjects/src/MD_FileHoraceReader.cpp +++ b/Code/Mantid/Framework/MDDataObjects/src/MD_FileHoraceReader.cpp @@ -243,16 +243,22 @@ MD_FileHoraceReader::read_MDImg_data(MDImage & mdd) this->fileStreamHolder.seekg(this->positions.s_start,std::ios::beg); this->fileStreamHolder.read(&buff[0],nCells*8); + for(i=0;i<nCells;i++){ pImg_data[i].s = (double)*((float32*)(&buff[i*4])); pImg_data[i].err = (double)*((float32*)(&buff[(i+nCells)*4])); + } // read npixels this->fileStreamHolder.seekg(this->positions.n_cell_pix_start,std::ios::beg); this->fileStreamHolder.read(&buff[0],buff.size()); - for(i=0;i<nCells;i++){ - pImg_data[i].npix = (size_t)*((uint64_t*)(&buff[i*8])); + hor_points_locations.resize(nCells); + pImg_data[0].npix = (size_t)*((uint64_t*)(&buff[0*8])); + hor_points_locations[0] = 0; + for(i=1;i<nCells;i++){ + pImg_data[i].npix = (size_t)*((uint64_t*)(&buff[i*8])); + hor_points_locations[i] = hor_points_locations[i-1]+pImg_data[i-1].npix; } @@ -327,15 +333,15 @@ MD_FileHoraceReader::read_pix_subset(const MDImage &dnd,const std::vector<size_t while(true){ cell_index = selected_cells[ic]; - pixels_start = this->positions.pix_start+hbs*pImgData[cell_index].chunk_location; + pixels_start = this->positions.pix_start+hbs*hor_points_locations[cell_index]; // optimisaion possible when cells are adjacent block_size = hbs*pImgData[cell_index].npix; // if the next cell follows the current on HDD, we should read them together aggregating adjacent cells; - size_t next_block = pImgData[cell_index].chunk_location+pImgData[cell_index].npix; + uint64_t next_block = hor_points_locations[cell_index]+pImgData[cell_index].npix; size_t next_index = selected_cells[ic_next]; - while(pImgData[next_index].chunk_location==next_block){ + while(hor_points_locations[next_index]==next_block){ // block size grows and all other is auxiliary block_size += hbs*pImgData[next_index].npix; ic = ic_next; @@ -343,7 +349,7 @@ MD_FileHoraceReader::read_pix_subset(const MDImage &dnd,const std::vector<size_t if(ic_next > iCellRead)break; cell_index = selected_cells[ic]; - next_block = pImgData[cell_index].chunk_location+pImgData[cell_index].npix; + next_block = hor_points_locations[cell_index]+pImgData[cell_index].npix; next_index = selected_cells[ic_next]; } diff --git a/Code/Mantid/Framework/MDDataObjects/src/MD_File_hdfMatlab.cpp b/Code/Mantid/Framework/MDDataObjects/src/MD_File_hdfMatlab.cpp index ed821b601b92b15e14e01ecbdc70a9975002c381..14092c5d7ba79d1ec16028c7f686844747429cf0 100644 --- a/Code/Mantid/Framework/MDDataObjects/src/MD_File_hdfMatlab.cpp +++ b/Code/Mantid/Framework/MDDataObjects/src/MD_File_hdfMatlab.cpp @@ -266,10 +266,16 @@ MD_File_hdfMatlab::read_MDImg_data(MDImage & dnd) } MD_image_point *pData = pMD_struct->data; // transform the data into the format specified -for(unsigned long i=0;i<pMD_struct->data_size;i++){ +mp_points_locations.resize(pMD_struct->data_size); +pData[0].s =buf[0]; +pData[0].err =buf[1]; +pData[0].npix=(size_t)buf[2]; +mp_points_locations[0] = 0; +for(unsigned long i=1;i<pMD_struct->data_size;i++){ pData[i].s =buf[i*3+0]; pData[i].err =buf[i*3+1]; pData[i].npix=(size_t)buf[i*3+2]; + mp_points_locations[i]=mp_points_locations[i-1]+pData[i-1].npix; } delete [] buf; H5Tclose(memtype); @@ -521,10 +527,10 @@ MD_File_hdfMatlab::read_pix_subset(const MDImage &DND,const std::vector<size_t> cells_preselection_buf.resize(max_npix_selected); size_t ic(0); uint64_t max_npix_indataset = this->getNPix(); - size_t pixel_num,block_location; + uint64_t pixel_num,block_location; for(i=starting_cell;i<=n_selected_cells;i++){ npix_tt =pData[selected_cells[i]].npix; - block_location =pData[selected_cells[i]].chunk_location; + block_location =mp_points_locations[selected_cells[i]]; for(j=0;j<npix_tt;j++){ pixel_num=block_location+j; // this to go around the bug in hdf dataset creation. diff --git a/Code/Mantid/Framework/MDDataObjects/src/MD_File_hdfMatlab4D.cpp b/Code/Mantid/Framework/MDDataObjects/src/MD_File_hdfMatlab4D.cpp index b4f7563b6d04086097c5425c0fb4a91773649cd7..d0cb4692eb670629d4b02d9e9dfb0422e5b1de29 100644 --- a/Code/Mantid/Framework/MDDataObjects/src/MD_File_hdfMatlab4D.cpp +++ b/Code/Mantid/Framework/MDDataObjects/src/MD_File_hdfMatlab4D.cpp @@ -231,10 +231,10 @@ MD_File_hdfMatlab4D::read_pix_subset(const MDImage &SQW,const std::vector<size_t cells_preselection_buf.resize(max_npix_selected); size_t ic(0); hsize_t max_npix_indataset = this->getNPix(); - size_t pixel_num,block_location; + uint64_t pixel_num,block_location; for(i=starting_cell;i<=n_selected_cells;i++){ npix_tt =pData[selected_cells[i]].npix; - block_location =pData[selected_cells[i]].chunk_location; + block_location =mp_points_locations[selected_cells[i]]; for(j=0;j<npix_tt;j++){ pixel_num=block_location+j; // this to go around the bug in hdf dataset creation. diff --git a/Code/Mantid/Framework/MDDataObjects/test/HoraceReaderTest.h b/Code/Mantid/Framework/MDDataObjects/test/HoraceReaderTest.h index 9a4261924da714334010bb53bc0a410f2246e026..70279009a2788822089d9f41ca6f380077bd5b38 100644 --- a/Code/Mantid/Framework/MDDataObjects/test/HoraceReaderTest.h +++ b/Code/Mantid/Framework/MDDataObjects/test/HoraceReaderTest.h @@ -108,9 +108,8 @@ public: TSM_ASSERT_THROWS_NOTHING("MD image reader should not normaly throw", this->pReader->read_MDImg_data(*pImg)); - // temporary here and should move to constructor for MDDataPoints; - pImg->identify_SP_points_locations(); - // check what has been read; + + // check what has been read; } void testReadAllPixels(){ MDPointDescription defaultDescr; diff --git a/Code/Mantid/Framework/MDDataObjects/test/MDImageTest.h b/Code/Mantid/Framework/MDDataObjects/test/MDImageTest.h index c8a41e9f36976ccd4f93ba577903e70492af911e..f1d4be5a45016324e5dd0f0caf580fda35c732c0 100644 --- a/Code/Mantid/Framework/MDDataObjects/test/MDImageTest.h +++ b/Code/Mantid/Framework/MDDataObjects/test/MDImageTest.h @@ -59,10 +59,10 @@ private: static std::auto_ptr<MDGeometry> getMDGeometry() { std::set<MDBasisDimension> basisDimensions; - basisDimensions.insert(MDBasisDimension("q1", true, 1)); - basisDimensions.insert(MDBasisDimension("q2", true, 2)); - basisDimensions.insert(MDBasisDimension("q3", true, 3)); - basisDimensions.insert(MDBasisDimension("u1", false, 5)); + basisDimensions.insert(MDBasisDimension("q1", true, 0)); + basisDimensions.insert(MDBasisDimension("q2", true, 1)); + basisDimensions.insert(MDBasisDimension("q3", true, 2)); + basisDimensions.insert(MDBasisDimension("u1", false, 3)); UnitCell cell; return std::auto_ptr<MDGeometry>(new MDGeometry(MDGeometryBasis(basisDimensions, cell))); diff --git a/Code/Mantid/Framework/MDDataObjects/test/MDWorkspaceTest.h b/Code/Mantid/Framework/MDDataObjects/test/MDWorkspaceTest.h index fb26ad2ed5ddfcca7bb0c5e31aec0f408140eaa1..e7336e6f01c219960ce5bc46c2a77a2b554d85f2 100644 --- a/Code/Mantid/Framework/MDDataObjects/test/MDWorkspaceTest.h +++ b/Code/Mantid/Framework/MDDataObjects/test/MDWorkspaceTest.h @@ -48,10 +48,10 @@ private: { using namespace Mantid::Geometry; std::set<MDBasisDimension> basisDimensions; - basisDimensions.insert(MDBasisDimension("q1", true, 1)); - basisDimensions.insert(MDBasisDimension("q2", true, 2)); - basisDimensions.insert(MDBasisDimension("q3", true, 3)); - basisDimensions.insert(MDBasisDimension("u1", false, 4)); + basisDimensions.insert(MDBasisDimension("q1", true, 0)); + basisDimensions.insert(MDBasisDimension("q2", true, 1)); + basisDimensions.insert(MDBasisDimension("q3", true, 2)); + basisDimensions.insert(MDBasisDimension("u1", false, 3)); UnitCell cell; return new MDGeometry(MDGeometryBasis(basisDimensions, cell));