From f5d38ffd1de80d4ef0b9c2e1c5b090f2e3c10ff3 Mon Sep 17 00:00:00 2001 From: Wiarda <wiardada@ornl.gov> Date: Tue, 2 Jun 2020 11:53:28 -0400 Subject: [PATCH] Address review comments. --- sammy/src/salmon/GridData.h | 35 ++++++++++++--- sammy/src/salmon/SammyGridAccess.h | 57 +++++++++++++++++++++++++ sammy/src/salmon/tests/GridDataTest.cpp | 6 +-- 3 files changed, 87 insertions(+), 11 deletions(-) diff --git a/sammy/src/salmon/GridData.h b/sammy/src/salmon/GridData.h index 485bda0d1..9fd75f36c 100644 --- a/sammy/src/salmon/GridData.h +++ b/sammy/src/salmon/GridData.h @@ -10,12 +10,21 @@ namespace sammy{ /** * @brief The GridData class contains energy data and potentially data points * - * The grid can be energy or angle (energy in pos 0 and angle in pos 1) or anything that - * The row offset is stored for use by calling programs (for example to indicate that - * we want position i in energy the first energy. But because there can be more than - * one equal energy in position 0, the use of this parameter is left to the calling program + * Ideally, there is going to be one grid with experiental data points for each data set to be + * fitted. There may be corresponding auxiallary grid for each data set with additional points + * needed for calculation (for exampe extra energy points for doppler broadening) * - * The start of the data is indicated by the function getDataIndex + * Since SAMMY uses one grid and one auxillary grid only, we allowed to have + * more than one column to allow to experimental data (for example energy in column 0, angle in column 1) + * In this case energy points for each angle are repeated (as SAMMY requires all angle data to be on the + * same energy grid). But we want to relax that going forward. + * + * To indicate where the data start, the grid has a function (getDataIndex) to indicate the data column + * + * Sometimes we may want to store more energy data then are used for the calculation, for example extra data points being read + * in or points of the auxillary grid not used, therefore we allow for an offset, that indicates from where counting of + * data points start (getRowOffset/setRowOffset()). This does not affect the indexing used by getData to retrieve data from the + * grid. * */ class GridData { @@ -140,7 +149,13 @@ namespace sammy{ /** * Get the index of the auxillary grid, if using. - * By default this is the second grid if present and the first grid otherwise + * By default this is the second grid if present and the first grid otherwise. + * + * Note: In principle this should be in the GridAccess class. However, + * only the GridDataList is currently globally available in SAMMY. + * Thus, until a correct object of GridAccess can be passed arround, + * we opted to have the information in this class. + * * @brief getAuxGridIndex index of the auxillary grid, if using. * @return index of the auxillary grid, if using. */ @@ -148,7 +163,13 @@ namespace sammy{ /** * Get the index of the experimental grid, if using. - * By default this is the first grid + * By default this is the first grid. + * + * Note: In principle this should be in the GridAccess class. However, + * only the GridDataList is currently globally available in SAMMY. + * Thus, until a correct object of GridAccess can be passed arround, + * we opted to have the information in this class. + * * @brief getExpGridIndex index of the experimental grid, if using. * @return index of the experimental grid, if using. */ diff --git a/sammy/src/salmon/SammyGridAccess.h b/sammy/src/salmon/SammyGridAccess.h index 0341a4982..574b7e5b6 100644 --- a/sammy/src/salmon/SammyGridAccess.h +++ b/sammy/src/salmon/SammyGridAccess.h @@ -4,22 +4,79 @@ #include "GridData.h" namespace sammy{ + /** + * @brief The SammyGridAccess class enables easier use of the new GridData in SAMMY + * + * Going forward, we would like to store experimental, theoretical and derivative data in + * the new GridData. This class attempts to make the transition within SAMMY easier. + * + * Currently, SAMMY has two grids: experimental grid and auxiallary grid. If angle data + * are given, the angle grid (of length numcro) needs to be the same for each energy at + * which angles are given. In addition energies sometimes are used with an additional calibration + * applied (ktzero != 0). + * + * In order to allow for the least amount of changes in SAMMY, this class gives functions to access the + * energy just as SAMMY would access its current energy grid, with the function getEnergy. If a + * If the underlying GridData has a row offset applied it is taken into acount in the index passed to getEnergy. + * Depending on the value of ktzero, the orignal or the calibrated energy is returned (getOrigEnergy) will always + * give the user energy. + * + * The grid access can be either to the experimental grid or the auxillary grid. + */ class SammyGridAccess { public: SammyGridAccess():numcro(1),ktzero(0),gridIndex(0){} virtual ~SammyGridAccess(){} + /** + * Set the values for numcro and ktzero. + * See class description for more info. + * + * @param numcro number of angles on the angle grid for each energy + * @param ktzero do we have an energy calibration applied + */ void setParameters(int numcro, int ktzero); + /** + * Indicate that this access is for the experimental grid + * @param list the container for the underlying grids + */ void setExpGrid(const GridDataList & list); + /** + * Indicate that this access is for the auxillary grid + * @param list the container for the underlying grids + */ void setAuxGrid(const GridDataList & list); + /** + * Get the energy at the desired index. + * If a row offset is set on the underlying grid, the index is corrected for the offset before + * retrieving the data + * @param index the index for the desired energy + * @param list the underlying list info + * @return the energy at the indicated index + */ double getEnergy(int index, const GridDataList & list) const; + /** + * Get the original energy at the desired index. Unless ktzero != 0, this is the same as getEnergy. + * + * If a row offset is set on the underlying grid, the index is corrected for the offset before + * retrieving the data + * @param index the index for the desired energy + * @param list the underlying list info + * @return the energy at the indicated index + */ double getOrigEnergy(int index, const GridDataList & list) const; + /** + * Get the number of energy points on the desired grid. + * If a row offset is set on the underlying grid, the number is adjusted accordingly. + * @param list the underlying list info + * @return number of energy points on the desired grid. + */ int getNumEnergies(const GridDataList & list) const; private: diff --git a/sammy/src/salmon/tests/GridDataTest.cpp b/sammy/src/salmon/tests/GridDataTest.cpp index fd3cb0511..ffdbbd9d9 100644 --- a/sammy/src/salmon/tests/GridDataTest.cpp +++ b/sammy/src/salmon/tests/GridDataTest.cpp @@ -78,8 +78,8 @@ TEST(DataInfo,gridData){ // copy constructor sammy::GridData gridCopy(grid); - gridCopy.setDataIndex(6); - gridCopy.setRowOffset(9); + ASSERT_EQ(6, gridCopy.getDataIndex()); + ASSERT_EQ(9, gridCopy.getRowOffset()); xx = 1.0; for (int i = 0; i < 5; i++){ for( int j = 0; j < 3; j++){ @@ -118,7 +118,6 @@ TEST(GridList, gridDataList){ for( int j = 0; j < 2; j++){ ASSERT_NEAR(i+1, grid->getData(j,1), 1e-3); - \ ASSERT_NEAR( i+5, list.getExperimentalCov(i*3, j), 1e-3); } } @@ -134,7 +133,6 @@ TEST(GridList, gridDataList){ for( int j = 0; j < 2; j++){ ASSERT_NEAR(i+1, grid->getData(j,1), 1e-3); - \ ASSERT_NEAR( i+5, listCopy.getExperimentalCov(i*3, j), 1e-3); } } -- GitLab