Commit 7d5239f55c3c22aa91b9ae2931d7ed023e8e5060
1 parent
02ca5322
Exists in
master
and in
96 other branches
Fix instant plot (#6275)
Showing
2 changed files
with
85 additions
and
128 deletions
Show diff stats
src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc
... | ... | @@ -974,21 +974,34 @@ void InstantPlot::drawSpectro(double startDate, double stopDate, std::string pPa |
974 | 974 | |
975 | 975 | ParameterData& data = (*_pParameterValues)[pParamId]; |
976 | 976 | |
977 | - boost::shared_ptr<AMDA::Info::ParamTable> tableXSPtr; | |
978 | - boost::shared_ptr<AMDA::Info::ParamTable> tableYSPtr; | |
977 | + boost::shared_ptr<AMDA::Info::ParamTable> tableOnXSPtr; | |
978 | + boost::shared_ptr<AMDA::Info::ParamTable> tableOnYSPtr; | |
979 | + int dimOnXSize = 0.; | |
980 | + int dimOnYSize = 0.; | |
981 | + std::map<std::string, std::string> paramsOnX; | |
982 | + std::map<std::string, std::string> paramsOnY; | |
979 | 983 | AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId()); |
980 | - if (paramInfo != nullptr) | |
984 | + if (_iSpectroProperties->getDimOnXAxis() == 0) | |
981 | 985 | { |
982 | - if (_iSpectroProperties->getDimOnXAxis() == 0) | |
983 | - { | |
984 | - tableXSPtr = paramInfo->getTable(0); | |
985 | - tableYSPtr = paramInfo->getTable(1); | |
986 | + if (paramInfo != nullptr) { | |
987 | + tableOnXSPtr = paramInfo->getTable(0); | |
988 | + tableOnYSPtr = paramInfo->getTable(1); | |
986 | 989 | } |
987 | - else | |
988 | - { | |
989 | - tableXSPtr = paramInfo->getTable(1); | |
990 | - tableYSPtr = paramInfo->getTable(0); | |
990 | + dimOnXSize = data.getDim1Size(); | |
991 | + dimOnYSize = data.getDim2Size(); | |
992 | + paramsOnX = _iSpectroProperties->getTable0Params(); | |
993 | + paramsOnY = _iSpectroProperties->getTable1Params(); | |
994 | + } | |
995 | + else | |
996 | + { | |
997 | + if (paramInfo != nullptr) { | |
998 | + tableOnXSPtr = paramInfo->getTable(1); | |
999 | + tableOnYSPtr = paramInfo->getTable(0); | |
991 | 1000 | } |
1001 | + dimOnXSize = data.getDim2Size(); | |
1002 | + dimOnYSize = data.getDim1Size(); | |
1003 | + paramsOnX = _iSpectroProperties->getTable1Params(); | |
1004 | + paramsOnY = _iSpectroProperties->getTable0Params(); | |
992 | 1005 | } |
993 | 1006 | |
994 | 1007 | //get axis |
... | ... | @@ -997,172 +1010,116 @@ void InstantPlot::drawSpectro(double startDate, double stopDate, std::string pPa |
997 | 1010 | boost::shared_ptr<ColorAxis> lZAxis = _panel->getColorAxis(); |
998 | 1011 | |
999 | 1012 | //Check dimensions |
1000 | - if ((data.getDim1Size() + 1 <= 0) || (data.getDim2Size() + 1 <= 0)) | |
1013 | + if ((dimOnXSize <= 0) || (dimOnYSize <= 0)) | |
1001 | 1014 | { |
1002 | 1015 | LOG4CXX_INFO(gLogger, "InstantPlot::drawSpectro - No data to plot"); |
1003 | 1016 | return; |
1004 | 1017 | } |
1005 | 1018 | |
1006 | 1019 | MatrixGrid matrixGrid; |
1007 | - for (int i = 0; i < data.getDim1Size(); ++i) | |
1020 | + for (int i = 0; i < dimOnXSize; ++i) | |
1008 | 1021 | { |
1009 | 1022 | GridPart part; |
1010 | - if (_iSpectroProperties->getDimOnXAxis() == 0) | |
1023 | + if (tableOnXSPtr == nullptr) | |
1024 | + { | |
1025 | + //no table defined => use index | |
1026 | + part.x[0] = i; | |
1027 | + part.x[1] = i+1; | |
1028 | + } | |
1029 | + else | |
1011 | 1030 | { |
1012 | - if (tableXSPtr == nullptr) | |
1031 | + if (!tableOnXSPtr->isVariable(&_parameterManager)) | |
1013 | 1032 | { |
1014 | - //no table defined => use index | |
1015 | - part.x[0] = i; | |
1016 | - part.x[1] = i+1; | |
1033 | + part.x[0] = tableOnXSPtr->getBound(&_parameterManager, i).min; | |
1034 | + part.x[1] = tableOnXSPtr->getBound(&_parameterManager, i).max; | |
1017 | 1035 | } |
1018 | 1036 | else |
1019 | 1037 | { |
1020 | - if (!tableXSPtr->isVariable(&_parameterManager)) | |
1021 | - { | |
1022 | - part.x[0] = tableXSPtr->getBound(&_parameterManager, i).min; | |
1023 | - part.x[1] = tableXSPtr->getBound(&_parameterManager, i).max; | |
1024 | - } | |
1025 | - else | |
1038 | + std::map<std::string, std::vector<double>> paramsTableData; | |
1039 | + for (std::map<std::string, std::string>::iterator it = paramsOnX.begin(); it != paramsOnX.end(); ++it) | |
1026 | 1040 | { |
1027 | - std::map<std::string, std::vector<double>> paramsTableData; | |
1028 | - for (std::map<std::string, std::string>::iterator it = _iSpectroProperties->getTable0Params().begin(); it != _iSpectroProperties->getTable0Params().end(); ++it) | |
1041 | + ParameterData& data = (*_pParameterValues)[it->second]; | |
1042 | + double valIdx = data.indexOf(_time); | |
1043 | + std::vector<double> paramTableValues; | |
1044 | + for (int k = 0; k < data.getDim1Size(); ++k) | |
1029 | 1045 | { |
1030 | - ParameterData& data = (*_pParameterValues)[it->second]; | |
1031 | - double valIdx = data.indexOf(_time); | |
1032 | - std::vector<double> paramTableValues; | |
1033 | - for (int j = 0; j < data.getDim1Size(); ++j) | |
1034 | - { | |
1035 | - double* values = data.getValues(AMDA::Common::ParameterIndexComponent(j), valIdx); | |
1036 | - paramTableValues.push_back((*values)); | |
1037 | - } | |
1038 | - paramsTableData[it->first] = paramTableValues; | |
1046 | + double* values = data.getValues(AMDA::Common::ParameterIndexComponent(k), valIdx); | |
1047 | + paramTableValues.push_back((*values)); | |
1039 | 1048 | } |
1040 | - part.x[0] = tableXSPtr->getBound(&_parameterManager, i, ¶msTableData).min; | |
1041 | - part.x[1] = tableXSPtr->getBound(&_parameterManager, i, ¶msTableData).max; | |
1049 | + paramsTableData[it->first] = paramTableValues; | |
1042 | 1050 | } |
1051 | + part.x[0] = tableOnXSPtr->getBound(&_parameterManager, i, ¶msTableData).min; | |
1052 | + part.x[1] = tableOnXSPtr->getBound(&_parameterManager, i, ¶msTableData).max; | |
1043 | 1053 | } |
1044 | 1054 | } |
1045 | - else | |
1055 | + | |
1056 | + if (std::isnan(part.x[0]) || std::isnan(part.x[1])) { | |
1057 | + continue; | |
1058 | + } | |
1059 | + | |
1060 | + if (lXAxis->_scale == Axis::Scale::LOGARITHMIC) { | |
1061 | + if ((part.x[0] <= 0) || (part.x[1] <= 0)) { | |
1062 | + continue; | |
1063 | + } | |
1064 | + part.x[0] = log10(part.x[0]); | |
1065 | + part.x[1] = log10(part.x[1]); | |
1066 | + } | |
1067 | + | |
1068 | + for (int j = 0; j < dimOnYSize; ++j) | |
1046 | 1069 | { |
1047 | - if (tableYSPtr == nullptr) | |
1070 | + if (tableOnYSPtr == nullptr) | |
1048 | 1071 | { |
1049 | 1072 | //no table defined => use index |
1050 | - part.y[0] = i; | |
1051 | - part.y[1] = i+1; | |
1073 | + part.y[0] = j; | |
1074 | + part.y[1] = j+1; | |
1052 | 1075 | } |
1053 | 1076 | else |
1054 | 1077 | { |
1055 | - if (!tableYSPtr->isVariable(&_parameterManager)) | |
1078 | + if (!tableOnYSPtr->isVariable(&_parameterManager)) | |
1056 | 1079 | { |
1057 | - part.y[0] = tableYSPtr->getBound(&_parameterManager, i).min; | |
1058 | - part.y[1] = tableYSPtr->getBound(&_parameterManager, i).max; | |
1080 | + part.y[0] = tableOnYSPtr->getBound(&_parameterManager, j).min; | |
1081 | + part.y[1] = tableOnYSPtr->getBound(&_parameterManager, j).max; | |
1059 | 1082 | } |
1060 | 1083 | else |
1061 | 1084 | { |
1062 | 1085 | std::map<std::string, std::vector<double>> paramsTableData; |
1063 | - for (std::map<std::string, std::string>::iterator it = _iSpectroProperties->getTable0Params().begin(); it != _iSpectroProperties->getTable0Params().end(); ++it) | |
1086 | + for (std::map<std::string, std::string>::iterator it = paramsOnY.begin(); it != paramsOnY.end(); ++it) | |
1064 | 1087 | { |
1065 | 1088 | ParameterData& data = (*_pParameterValues)[it->second]; |
1066 | 1089 | double valIdx = data.indexOf(_time); |
1067 | 1090 | std::vector<double> paramTableValues; |
1068 | - for (int j = 0; j < data.getDim1Size(); ++j) | |
1091 | + for (int k = 0; k < data.getDim1Size(); ++k) | |
1069 | 1092 | { |
1070 | - double* values = data.getValues(AMDA::Common::ParameterIndexComponent(j), valIdx); | |
1093 | + double* values = data.getValues(AMDA::Common::ParameterIndexComponent(k), valIdx); | |
1071 | 1094 | paramTableValues.push_back((*values)); |
1072 | 1095 | } |
1073 | 1096 | paramsTableData[it->first] = paramTableValues; |
1074 | 1097 | } |
1075 | - part.y[0] = tableXSPtr->getBound(&_parameterManager, i, ¶msTableData).min; | |
1076 | - part.y[1] = tableXSPtr->getBound(&_parameterManager, i, ¶msTableData).max; | |
1098 | + part.y[0] = tableOnYSPtr->getBound(&_parameterManager, j, ¶msTableData).min; | |
1099 | + part.y[1] = tableOnYSPtr->getBound(&_parameterManager, j, ¶msTableData).max; | |
1077 | 1100 | } |
1078 | 1101 | } |
1079 | - } | |
1080 | 1102 | |
1081 | - for (int j = 0; j < data.getDim2Size(); ++j) | |
1082 | - { | |
1083 | - if (_iSpectroProperties->getDimOnXAxis() == 0) | |
1084 | - { | |
1085 | - if (tableYSPtr == nullptr) | |
1086 | - { | |
1087 | - //no table defined => use index | |
1088 | - part.y[0] = j; | |
1089 | - part.y[1] = j+1; | |
1090 | - } | |
1091 | - else | |
1092 | - { | |
1093 | - if (!tableYSPtr->isVariable(&_parameterManager)) | |
1094 | - { | |
1095 | - part.y[0] = tableYSPtr->getBound(&_parameterManager, j).min; | |
1096 | - part.y[1] = tableYSPtr->getBound(&_parameterManager, j).max; | |
1097 | - } | |
1098 | - else | |
1099 | - { | |
1100 | - std::map<std::string, std::vector<double>> paramsTableData; | |
1101 | - for (std::map<std::string, std::string>::iterator it = _iSpectroProperties->getTable1Params().begin(); it != _iSpectroProperties->getTable1Params().end(); ++it) | |
1102 | - { | |
1103 | - ParameterData& data = (*_pParameterValues)[it->second]; | |
1104 | - double valIdx = data.indexOf(_time); | |
1105 | - std::vector<double> paramTableValues; | |
1106 | - for (int i = 0; i < data.getDim1Size(); ++i) | |
1107 | - { | |
1108 | - double* values = data.getValues(AMDA::Common::ParameterIndexComponent(i), valIdx); | |
1109 | - paramTableValues.push_back((*values)); | |
1110 | - } | |
1111 | - paramsTableData[it->first] = paramTableValues; | |
1112 | - } | |
1113 | - part.y[0] = tableYSPtr->getBound(&_parameterManager, j, ¶msTableData).min; | |
1114 | - part.y[1] = tableYSPtr->getBound(&_parameterManager, j, ¶msTableData).max; | |
1115 | - } | |
1116 | - } | |
1103 | + if (std::isnan(part.y[0]) || std::isnan(part.y[1])) { | |
1104 | + continue; | |
1117 | 1105 | } |
1118 | - else | |
1106 | + | |
1107 | + if (lYAxis->_scale == Axis::Scale::LOGARITHMIC) | |
1119 | 1108 | { |
1120 | - if (tableXSPtr == nullptr) | |
1121 | - { | |
1122 | - part.x[0] = j; | |
1123 | - part.x[1] = j+1; | |
1124 | - } | |
1125 | - else | |
1126 | - { | |
1127 | - if (!tableYSPtr->isVariable(&_parameterManager)) | |
1128 | - { | |
1129 | - part.x[0] = tableXSPtr->getBound(&_parameterManager, j).min; | |
1130 | - part.x[1] = tableXSPtr->getBound(&_parameterManager, j).max; | |
1131 | - } | |
1132 | - else | |
1133 | - { | |
1134 | - std::map<std::string, std::vector<double>> paramsTableData; | |
1135 | - for (std::map<std::string, std::string>::iterator it = _iSpectroProperties->getTable1Params().begin(); it != _iSpectroProperties->getTable1Params().end(); ++it) | |
1136 | - { | |
1137 | - ParameterData& data = (*_pParameterValues)[it->second]; | |
1138 | - double valIdx = data.indexOf(_time); | |
1139 | - std::vector<double> paramTableValues; | |
1140 | - for (int i = 0; i < data.getDim1Size(); ++i) | |
1141 | - { | |
1142 | - double* values = data.getValues(AMDA::Common::ParameterIndexComponent(i), valIdx); | |
1143 | - paramTableValues.push_back((*values)); | |
1144 | - } | |
1145 | - paramsTableData[it->first] = paramTableValues; | |
1146 | - } | |
1147 | - part.x[0] = tableYSPtr->getBound(&_parameterManager, j, ¶msTableData).min; | |
1148 | - part.x[1] = tableYSPtr->getBound(&_parameterManager, j, ¶msTableData).max; | |
1149 | - } | |
1109 | + if ((part.y[0] <= 0) || (part.y[1] <= 0)) { | |
1110 | + continue; | |
1150 | 1111 | } |
1112 | + part.y[0] = log10(part.y[0]); | |
1113 | + part.y[1] = log10(part.y[1]); | |
1151 | 1114 | } |
1152 | 1115 | |
1153 | - if (lXAxis->_scale == Axis::Scale::LOGARITHMIC) | |
1154 | - { | |
1155 | - part.x[0] = ((part.x[0] > 0) ? log10(part.x[0]) : 10e-3); | |
1156 | - part.x[1] = ((part.x[1] > 0) ? log10(part.x[1]) : 10e-3); | |
1116 | + if (_iSpectroProperties->getDimOnXAxis() == 0) { | |
1117 | + part.value = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i,j)); | |
1157 | 1118 | } |
1158 | - | |
1159 | - if (lYAxis->_scale == Axis::Scale::LOGARITHMIC) | |
1160 | - { | |
1161 | - part.y[0] = ((part.y[0] > 0) ? log10(part.y[0]) : 10e-3); | |
1162 | - part.y[1] = ((part.y[1] > 0) ? log10(part.y[1]) : 10e-3); | |
1119 | + else { | |
1120 | + part.value = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(j,i)); | |
1163 | 1121 | } |
1164 | - | |
1165 | - part.value = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i,j)); | |
1122 | +std::cout << "BRE - " << part.value << std::endl; | |
1166 | 1123 | if (!isNAN(part.value)) |
1167 | 1124 | noData = false; |
1168 | 1125 | matrixGrid.push_back(part); | ... | ... |
test/FitNesseRoot/ReleaseS/ThirdPart/ReLease3/SprinT3/UserStory29/plot_29_01_REF.png