bool Parameter::GetRadialParValue(const SC_DoubleArray& rVal, SC_DoubleArray& parVals, SC_SetupErr& errData) { // sanity if (!IsRadial()) GenAppInternalError("Parameter::GetRadialParValue"); parVals.AllocAndSetSize(rVal.Size()); if (IsPoints()) { if (rPointsCurve == 0) GenAppInternalError("Parameter::GetRadialParValue_1"); if (!rPointsCurve->CurveOK(errData)) return false; for (int i = 0; i < rVal.Size(); i++) parVals[i] = rPointsCurve->GetMetricPointCurveY(rVal[i]); } else { for (int i = 0; i < rVal.Size(); i++) parVals[i] = rFixedCurve.GetMetricFileCurveY(rVal[i]); } return true; }
void DataCaptureListing::CreateListing() { StdTitle("Simulation Results Setup"); for (int i = 0; i < dataCaptureData.Size(); i++) if (dataCaptureData.IsValid(i)) { dataCaptureData.GetRef(i).SetIDs(); ListDataCapture(dataCaptureData.GetRef(i)); } if (productionRestartTimes.Size() > 0) { SubTitle("Production Restart Times"); for (int i = 0; i < productionRestartTimes.Size(); i++) { char tempStr[40]; CopyString(tempStr, "Time#", 40); char intStr[40]; IntToString(i + 1, intStr, 40); ConcatString(tempStr, intStr, 40); UnitReal temp(productionRestartUnits, productionRestartTimes[i]); AddUnitReal(tempStr, temp); } } }
void XYGridControl::PasteFromClipboardXY(int nIndexFrom) { int nIndex = nIndexFrom; PS_Import import; if (!import.OpenClipboardImport()) { GenAppWarningMsg("XYGridControl", "Can't open clipboard"); return; } SC_DoubleArray xyRowData; while (import.GetLineDoubles(xyRowData)) { if (xyRowData.Size() > 1) { xyData.SetAtGrow(nIndex, XYItem(xyRowData[0], xyRowData[1])); nIndex++; } } import.CloseImport(); int nCount = nIndex - nIndexFrom; CString strInfo; strInfo.Format("Imported %d rows from clipboard", nCount); GenAppInfoMsg("XYGridControl", strInfo); }
bool DC_DataLimit::MapDataToRange(const SC_DoubleArray& inData, SC_IntArray& outMap, bool clipToRange) const { outMap.Alloc(inData.Size()); actMin = minLimit; actMax = maxLimit; if (clipToRange && logRange) { actMin = log10(actMin); actMax = log10(actMax); } bool oneOK = false; for (int i = 0; i < inData.Size(); i++) { double dataVal = inData[i]; if (!TransformValueForRange(dataVal, clipToRange)) { outMap[i] = -1; continue; } int nodeMap = 0; if (clipToRange && ((dataVal < actMin) || (dataVal > actMax))) nodeMap = -1; oneOK = oneOK || (nodeMap == 0); outMap[i] = nodeMap; } return oneOK; }
void RadiusPressureExtraction::SetExtraction(const SC_DoubleArray& nodeRadii, const double& capRadius) { doScale = false; // special cases first if (capRadius <= nodeRadii[0]) { radIndex = 0; weight = 1.0; return; } if (capRadius >= nodeRadii.LastIndex()) { radIndex = nodeRadii.Size() - 2; weight = 0.0; return; } for (int i = 1; i < nodeRadii.Size(); i++) if (capRadius < nodeRadii[i]) { radIndex = i - 1; weight = 1.0 - (capRadius - nodeRadii[i - 1]) / (nodeRadii[i] - nodeRadii[i - 1]); return; } // ??? ouch GenAppInternalError("RadiusPressureExtraction::SetExtraction"); }
void VariableVerticalPressureExtraction::SetExtraction(const SC_DoubleArray& nodeRadii, const SC_DoubleArray& fixedZ, const double& thickToPress, const double& capRadius, bool vertNormalized, const double& vertActualOffset, const double& vertNormalizedOffset) { RadiusPressureExtraction::SetExtraction(nodeRadii, capRadius); normalized = vertNormalized; if (normalized) offsetVal = vertNormalizedOffset; else offsetVal = vertActualOffset; fixedNodeZ = &fixedZ; thicknessToPressure = thickToPress; doFixedZ = true; if ((!normalized) && (offsetVal < fixedZ.LastIndex())) { CalcConstantVert(offsetVal); } else if (offsetVal < stdEps) { // all zeroes at bottom CalcConstantVert(0.0); } else doFixedZ = false; }
void OGL3DBase::TransformIncrements(bool axisIsLog, const SC_DoubleArray& inIncs, SC_DoubleArray& tranIncs) { tranIncs = inIncs; if (axisIsLog) for (int i = 0; i < tranIncs.Size(); i++) tranIncs[i] = log10(inIncs[i]); }
void SC_Statistics::CalcMode(const SC_DoubleArray& data) { if (nOK == 0) return; // min == max if (realResults[soVar] < stdEps) { realResults[soMode] = realResults[soMean]; return; } // Scott, 1979 algorithm for bin width // W = (3.49)(std.dev.)[(#samples)^(-1/3)] double width = 3.49 * realResults[soStdDev] * (pow(realResults[soN], -0.3333)); if (width < stdEps) { realResults[soMode] = realResults[soMean]; return; } double maxNBins = (realResults[soMax] - realResults[soMin]) / width; if (maxNBins > 10000.0) return; int nbins = int(ceil(maxNBins)); // note just linear bins width = (realResults[soMax] - realResults[soMin]) / double(nbins); SC_IntArray binCount(nbins, 0); for (int i = 0; i < data.Size(); i++) { double dVal = data[i]; if (RealIsNull(dVal) || (dVal < realResults[soMin])) // can happen if stats calc was log continue; int binIndex = int(floor((dVal - realResults[soMin]) / width)); // pathological case == maxVal if (binIndex == nbins) binIndex--; binCount[binIndex]++; } int maxBin = 0; int maxCount = binCount[0]; for (int i = 1; i < nbins; i++) if (binCount[i] > maxCount) { maxBin = i; maxCount = binCount[i]; } realResults[soMode] = realResults[soMin] + (double(maxBin) + 0.5) * width; }
void DataCaptureStaticSupport::SetToInitial() { dataCaptureData.DeAlloc(); dataCaptureData.Alloc(10); dataCaptureData.CreateIfNecessary(0); dataCaptureData.CreateIfNecessary(1); productionRestartTimes.DeAlloc(); productionRestartTimes.Alloc(10); // start with a default TZ pressure { DataCaptureSpec& currRef = dataCaptureData.GetRef(0); currRef.SetUserDesig("DAT"); } // and flows { DataCaptureSpec& currRef = dataCaptureData.GetRef(1); currRef.SetUserDesig("DAT"); currRef.captureType = DataCaptureSpec::ctFlow; currRef.flowCapType = DataCaptureSpec::fctWell; currRef.SetOutputUnits(); } dataCaptureData.SetSize(2); capturedDataXY.DeAlloc(); capturedDataXY.AllocAndSetSize(2); capturedDataXY[0].SetEmpty(); capturedDataXY[0].SetID("sPDAT"); capturedDataXY[1].SetEmpty(); capturedDataXY[1].SetID("sQDAT"); capturedData.DeAlloc(); capturedData.AllocAndSetSize(3); capturedData[0].SetResizable(); capturedData[1].SetResizable(); capturedData[2].SetResizable(); capturedDataFO.DoStatusChk(); dataCaptureData[0]->outputFO.DoStatusChk(); dataCaptureData[1]->outputFO.DoStatusChk(); }
void DataCaptureErrorListing::CreateListing() { StdTitle("Simulation Results Setup Errors"); SC_SetupErr dcErr; if (dataCaptureData.IsEmpty()) AddError("no output data specified"); for (int i = 0; i < dataCaptureData.Size(); i++) if (dataCaptureData.IsNotValid(i)) { AddError("Null capture spec found"); } else { if (!dataCaptureData.GetRef(i).SetupOK(dcErr)) { AddError(dcErr); } } if (productionRestartTimes.Size() > 0) { double prev = productionRestartTimes[0]; for (int i = 1; i < productionRestartTimes.Size(); i++) { double next = productionRestartTimes[i]; if (RealIsNull(prev) || RealIsNull(next)) { AddError("Null production restart time found"); break; } if (prev >= next) { AddError("Production restart times must be ascending"); break; } } } }
void DC_Normalize::DoNormalize(SC_DoubleArray& inData) { if (normalizeOp != noPower) { if (autoLimit) { inData.CalcMinMax(inputMinimum, inputMaximum); if (RealIsNull(inputMinimum)) return; } if (fabs(inputMaximum - inputMinimum) < stdEps) spanMult = 0.0; else spanMult = (outputMaximum - outputMinimum) / (inputMaximum - inputMinimum); } intPower = double(int(normPower)); for (int i = 0; i < inData.Size(); i++) inData[i] = Normalize(inData[i]); }
void FixedVerticalPressureExtraction::SetExtraction(const SC_DoubleArray& nodeRadii, const SC_DoubleArray& fixedZ, const double& capRadius, bool vertNormalized, const double& vertActualOffset, const double& vertNormalizedOffset) { RadiusPressureExtraction::SetExtraction(nodeRadii, capRadius); fixedNodeZ = &fixedZ; double capZ; if (vertNormalized) capZ = vertNormalizedOffset * fixedZ.LastIndex(); else capZ = vertActualOffset; CalcConstantVert(capZ); }
bool DC_XYData::SetNDX(SC_SetupErr& err, SC_DoubleArray& ndxData)const { int n = 0; for (int i = 0; i < Size(); i++) { double x = xData[i]; double y = yData[i]; if (RealIsNull(x) || RealIsNull(y)) { err.SetConstantError("all x and y must be non null"); return false; } if ((x < 0.5) || (x > 999)) { err.SetConstantError("all x values must be integers > 0 and < 1000"); return false; } if (y < 1.0E-5) { err.SetConstantError("all y values must be > 1E-5"); return false; } n += int(x); } if (n > 10000) { err.SetConstantError("total number of x/y ndx calculated nodes points be < 10000"); return false; } ndxData.Alloc(n); for (int i = 0; i < Size(); i++) { n = int(xData[i]); double y = yData[i]; for (int j = 0; j < n; j++) ndxData += y; } return true; }
void LayerStaticSupport::GetLayerDiscretization(SC_DoubleArray& layerNodeZ, SC_IntArray& layerWellBoreZoneIndex, SC_IntArray& layerGeologyIndex) { if (!layerSpec.SetThicknesses()) { layerNodeZ.Alloc(2); layerNodeZ[0] = 0.0; layerNodeZ[1] = 1.0; layerWellBoreZoneIndex.AllocAndFill(1, 0); layerGeologyIndex.AllocAndFill(1, 0); return; } SC_DoubleArray geoLayerZ(GetNGeoLayer() + 1), geoLayerDZ(GetNGeoLayer()); geoLayerZ[0] = bottomLayerElevation.GetMetricVal(); for (int i = 0; i < GetNGeoLayer(); i++) { GeologyLayer& currLayer = geologyLayers[i]; geoLayerZ[i + 1] = geoLayerZ[i] + currLayer.currThickness; geoLayerDZ[i] = currLayer.currThickness / double(currLayer.nintervalNodes); } double maxZ = geoLayerZ.LastIndex(); SC_DoubleArray wbzLayerZ(GetNWellboreZone() + 1); wbzLayerZ[0] = geoLayerZ[0]; for (int i = 0; i < GetNWellboreZone(); i++) { } }
void SC_Statistics::CalcMedian(SC_DoubleArray& data) { if (nOK == 0) return; if (nOK != data.Size()) { data.Cleanup(); nOK = data.Size(); } // mix before sort to help sort routine SC_Random mix; mix.RandomMix(data); if (!data.Sort(true)) { realResults[soMedian] = nullReal; } else { int midPt = data.Size() / 2; if ((data.Size() % 2) == 1) { // odd entries -- pick middle realResults[soMedian] = data[midPt]; } else { // average possibilities realResults[soMedian] = data[midPt]; realResults[soMedian] += data[midPt - 1]; realResults[soMedian] /= 2.0; } } }
DataCaptureStaticSupport::DataCaptureStaticSupport() { dataCaptureData.SetResizable(); productionRestartTimes.SetResizable(); }
void SimulatedAnnealingOptimizer::GetExtraOutput(SC_DoubleArray& extraData) const { extraData.Alloc(2); extraData += temperature; extraData += currSimplexSpan; }
namespace nsDataCapture { DataCaptureArray dataCaptureData; UnitIndex productionRestartUnits(uTime); SC_DoubleArray productionRestartTimes; SC_DoubleMatrix capturedData; DC_XYDataArray capturedDataXY; DataCaptureOutput capturedDataFO; bool dataCaptureUIChange = false; DataCaptureErrorListing dataCaptureErrorListing; DataCaptureStaticSupport dataCapture; CaptureOutputFO::CaptureOutputFO() : FuncObjC("f(t)Output") { DataCaptureStaticSupport::capturedObj.AddTo(this); dcIndex = 0; AddOutPort(xyDataDO); AddInPort(xyArrayObjRef, typeid(DO_XYDataArray)); xyArrayObjRef = FuncObjRef(capturedDataFO); } CaptureOutputFO::~CaptureOutputFO() { DataCaptureStaticSupport::capturedObj.DeleteFrom(this); } void CaptureOutputFO::DoStatusChk() { xyDataDO.xyData = 0; FuncObjC::DoStatusChk(); if (!CheckInputFO(xyArrayObjRef, "Input array")) return; DO_XYDataArray* dataDO = static_cast<DO_XYDataArray*>(GetInPortData(xyArrayObjRef)); if (dataDO->xyDataArray->IsEmpty()) { SetObjErrMsg("no entries in input array ??"); return; } if (dcIndex > dataDO->xyDataArray->UpperBound()) dcIndex = 0; xyDataDO.xyData = &(*dataDO->xyDataArray)[dcIndex]; } void CaptureOutputFO::CalcOutput(FOcalcType calcType) { DoStatusChk(); capturedDataFO.InitStaticPressure(); // FB376 fix } DataCaptureArray::~DataCaptureArray() { // causes memory leak on exit, but required to avoid crash caused // by capturedObj.DeleteFrom after capturedObj is gone.. tListData = 0; } DataCaptureOutput::DataCaptureOutput() : GlobalFunc("f(t)Table") { xyDataArrayDO.xyDataArray = &capturedDataXY; AddOutPort(xyDataArrayDO); AddOutPort(staticPressureDO); staticPressureDO.SetTypeLabel("Static pressure"); staticPressureDO.InitLabelAndValue(0.0); DoStatusChk(); } void DataCaptureOutput::DoStatusChk() { FuncObjC::DoStatusChk(); if (!xyDataArrayDO.DataOK()) SetObjErrMsg("No data in output table"); } void DataCaptureOutput::CalcOutput(FOcalcType calcType) { DoStatusChk(); if (!StatusOK()) return; for (int i = 0; i < capturedDataXY.Size(); i++) capturedDataXY[i].CreateFrom(capturedData[0], capturedData[i + 1]); } void DataCaptureOutput::InitStaticPressure() { double staticPressure = 0.0; if (control.IsConfined()) { Parameter& staticPar = *(allParam[pF_Pf]); SC_SetupErr dummy; if (staticPar.SetupOK(dummy)) { UnitIndex pConv(uPress); staticPressure = pConv.MetricToUser(staticPar.GetParValue()); } } capturedDataFO.staticPressureDO.InitLabelAndValue(staticPressure); // std::cout << "** Static P init " << staticPressure << std::endl; } DataCaptureListing::DataCaptureListing() :OSListObj("nPreDataCapture") { } void DataCaptureListing::ListSuperComponent(const SuperComponent& outSuper) { ClearEnumStrs(); AddEnumStr("+ Pressure", SuperComponent::soAddP); AddEnumStr("- Pressure", SuperComponent::soSubP); AddEnumStr("+ Delta P", SuperComponent::soAddDP); AddEnumStr("- Delta P", SuperComponent::soSubDP); char tempStr[80]; CopyString(tempStr, " ", 80); ConcatString(tempStr, outSuper.GetID(), 80); ConcatString(tempStr, " operation", 80); AddStdEnum(tempStr, outSuper.superOp); ClearEnumStrs(); AddEnumStr("Constant", SuperComponent::stConstant); AddEnumStr("Optimized", SuperComponent::stOptimized); AddEnumStr("Sampled", SuperComponent::stSampled); AddStdEnum(" Type", outSuper.superType); switch (outSuper.superType) { case SuperComponent::stConstant : { UnitReal temp(outSuper.superRadUnits, outSuper.constantRad); AddUnitReal(" Fixed radius", temp); break; } case SuperComponent::stOptimized : { AddOptVar(" Optimized radius", outSuper.optRadVal); break; } case SuperComponent::stSampled : { AddSampVar(" Sampled radius", outSuper.sampRadVal); break; } case SuperComponent::stVary : { AddVaryVar(" Varied radius", outSuper.varyRadVal); break; } } } void DataCaptureListing::ListDataCapture(const DataCaptureSpec& outDC) { AddConditionalBlank(); AddStdText("Output ID", outDC.dataDesig); ClearEnumStrs(); AddEnumStr("Pressure", DataCaptureSpec::ctPressure); AddEnumStr("Flow Rate", DataCaptureSpec::ctFlow); AddEnumStr("Cumulative Production", DataCaptureSpec::ctProduction); AddEnumStr("Test Zone Property", DataCaptureSpec::ctTestZone); AddEnumStr("Water Table", DataCaptureSpec::ctWaterTable); AddStdEnum(" Output type", outDC.captureType); ClearEnumStrs(); switch (outDC.captureType) { case DataCaptureSpec::ctPressure : { AddEnumStr("Test Zone", DataCaptureSpec::pctTestZone); AddEnumStr("Observation Well", DataCaptureSpec::pctRadius); AddEnumStr("Superposition", DataCaptureSpec::pctSuperposition); AddStdEnum(" Pressure capture type", outDC.pressureCapType); switch (outDC.pressureCapType) { case DataCaptureSpec::pctTestZone : { if (control.IsLayered()) { AddStdText("Wellbore zone", outDC.wellboreZoneID); } break; } case DataCaptureSpec::pctRadius : { if (control.IsHorizontalAnisotropic()) { AddUnitReal(" Observation well X location", outDC.obsXLocation); AddUnitReal(" Observation well Y location", outDC.obsYLocation); AddStdReal(" Observation well angle (degrees)", Degrees(outDC.GetObsAngle()), SC_DecFormat(3)); } AddUnitReal(" Observation well radius", outDC.radiusData); if (control.Is2DRadial()) { AddBoolText(" Vertical position", outDC.zvalueIsRatio, "Actual", "Ratio"); if (outDC.zvalueIsRatio) AddStdReal(" Vertical ratio", outDC.normalizedZ, SC_DecFormat(3)); else AddUnitReal(" Vertical offset", outDC.actualZ); } break; } case DataCaptureSpec::pctSuperposition : { for (int i = 0; i < outDC.superData.Size(); i++) if (outDC.superData.IsValid(i)) ListSuperComponent(outDC.superData.GetRef(i)); break; } } break; } case DataCaptureSpec::ctFlow : { AddEnumStr("Well", DataCaptureSpec::fctWell); AddEnumStr("Formation", DataCaptureSpec::fctFormation); AddEnumStr("Test Zone", DataCaptureSpec::fctTestZone); AddEnumStr("Wellbore Storage", DataCaptureSpec::fctWellboreStorage); AddStdEnum(" Flow rate output type", outDC.flowCapType); break; } case DataCaptureSpec::ctProduction : { AddEnumStr("Well", DataCaptureSpec::prctWell); AddEnumStr("Formation", DataCaptureSpec::prctFormation); AddEnumStr("Test Zone", DataCaptureSpec::prctTestZone); AddStdEnum(" Production output type", outDC.flowCapType); break; } case DataCaptureSpec::ctTestZone : { AddEnumStr("Temperature", DataCaptureSpec::tzctTemperature); AddEnumStr("Compressibility", DataCaptureSpec::tzctCompressibility); AddEnumStr("Volume", DataCaptureSpec::tzctVolume); AddStdEnum(" Test zone property output type", outDC.flowCapType); break; } case DataCaptureSpec::ctWaterTable : { AddUnitReal(" Water table radius", outDC.radiusData); break; } } AddUnitIndex(" Output units", outDC.outputUnits); } void DataCaptureListing::CreateListing() { StdTitle("Simulation Results Setup"); for (int i = 0; i < dataCaptureData.Size(); i++) if (dataCaptureData.IsValid(i)) { dataCaptureData.GetRef(i).SetIDs(); ListDataCapture(dataCaptureData.GetRef(i)); } if (productionRestartTimes.Size() > 0) { SubTitle("Production Restart Times"); for (int i = 0; i < productionRestartTimes.Size(); i++) { char tempStr[40]; CopyString(tempStr, "Time#", 40); char intStr[40]; IntToString(i + 1, intStr, 40); ConcatString(tempStr, intStr, 40); UnitReal temp(productionRestartUnits, productionRestartTimes[i]); AddUnitReal(tempStr, temp); } } } DataCaptureErrorListing::DataCaptureErrorListing() :ErrorListObjC("DataCapture") { } void DataCaptureErrorListing::CreateListing() { StdTitle("Simulation Results Setup Errors"); SC_SetupErr dcErr; if (dataCaptureData.IsEmpty()) AddError("no output data specified"); for (int i = 0; i < dataCaptureData.Size(); i++) if (dataCaptureData.IsNotValid(i)) { AddError("Null capture spec found"); } else { if (!dataCaptureData.GetRef(i).SetupOK(dcErr)) { AddError(dcErr); } } if (productionRestartTimes.Size() > 0) { double prev = productionRestartTimes[0]; for (int i = 1; i < productionRestartTimes.Size(); i++) { double next = productionRestartTimes[i]; if (RealIsNull(prev) || RealIsNull(next)) { AddError("Null production restart time found"); break; } if (prev >= next) { AddError("Production restart times must be ascending"); break; } } } } DataCaptureStaticSupport::DataCaptureStaticSupport() { dataCaptureData.SetResizable(); productionRestartTimes.SetResizable(); } void DataCaptureStaticSupport::SetToInitial() { dataCaptureData.DeAlloc(); dataCaptureData.Alloc(10); dataCaptureData.CreateIfNecessary(0); dataCaptureData.CreateIfNecessary(1); productionRestartTimes.DeAlloc(); productionRestartTimes.Alloc(10); // start with a default TZ pressure { DataCaptureSpec& currRef = dataCaptureData.GetRef(0); currRef.SetUserDesig("DAT"); } // and flows { DataCaptureSpec& currRef = dataCaptureData.GetRef(1); currRef.SetUserDesig("DAT"); currRef.captureType = DataCaptureSpec::ctFlow; currRef.flowCapType = DataCaptureSpec::fctWell; currRef.SetOutputUnits(); } dataCaptureData.SetSize(2); capturedDataXY.DeAlloc(); capturedDataXY.AllocAndSetSize(2); capturedDataXY[0].SetEmpty(); capturedDataXY[0].SetID("sPDAT"); capturedDataXY[1].SetEmpty(); capturedDataXY[1].SetID("sQDAT"); capturedData.DeAlloc(); capturedData.AllocAndSetSize(3); capturedData[0].SetResizable(); capturedData[1].SetResizable(); capturedData[2].SetResizable(); capturedDataFO.DoStatusChk(); dataCaptureData[0]->outputFO.DoStatusChk(); dataCaptureData[1]->outputFO.DoStatusChk(); } void DataCaptureStaticSupport::SetForFlags() { for (int i = 0; i < dataCaptureData.Size(); i++) if (dataCaptureData.IsValid(i)) dataCaptureData[i]->SetForFlags(); } bool DataCaptureStaticSupport::DataCaptureOK() { if (dataCaptureData.IsEmpty()) return false; if (!dataCaptureErrorListing.ErrorCheckOK()) return false; // check to see if alloc needs changing if (capturedDataXY.Size() != dataCaptureData.Size()) { capturedDataXY.AllocAndSetSize(dataCaptureData.Size()); // and the table capturedData.AllocAndSetSize(dataCaptureData.Size() + 1); for (int i = 0; i <= dataCaptureData.Size(); i++) capturedData[i].SetResizable(); } // reset the IDs, FOs, and clear for (int i = 0; i < dataCaptureData.Size(); i++) { DataCaptureSpecGlob& currSpec = *(dataCaptureData[i]); char foDesig[80]; CopyString(foDesig, "s", 80); if (currSpec.IsWell()) { if (currSpec.IsPressure()) ConcatString(foDesig, "P", 80); if (currSpec.IsFlow()) ConcatString(foDesig, "Q", 80); } // clear if already has correct designator if (strstr(currSpec.dataDesig, foDesig) == currSpec.dataDesig) SetToNull(foDesig); ConcatString(foDesig, currSpec.dataDesig, 80); capturedDataXY[i].SetID(foDesig); currSpec.outputFO.SetID(foDesig); currSpec.outputFO.dcIndex = i; currSpec.outputFO.DoStatusChk(); // capturedDataXY[i].SetEmpty(); } // check for alloc size int minTS = sequence.GetTotalNTimeStep(); bool reAlloc = false; for (int i = 0; i < dataCaptureData.Size(); i++) if (capturedData[i].AllocSize() < minTS) { reAlloc = true; break; } if (reAlloc) { for (int i = 0; i < dataCaptureData.Size(); i++) capturedData[i].Alloc(minTS); } capturedDataFO.InitStaticPressure(); capturedDataFO.PreCalcSetup(); return true; } void DataCaptureStaticSupport::DataCaptureCleanup() { dataCaptureData.Cleanup(); } bool DataCaptureStaticSupport::SetDataCaptureDesigs() { int nextP_TZ = 1; int nextP_OW = 1; int nextP_S = 1; int nextQ_W = 1; int nextQ_F = 1; int nextQ_TZ = 1; int nextQ_WS = 1; int nextPr_W = 1; int nextPr_F = 1; int nextPr_TZ = 1; int nextO_T = 1; int nextO_C = 1; int nextO_V = 1; int nextWT = 1; bool retVal = false; for (int i = 0; i < dataCaptureData.Size(); i++) if (dataCaptureData.IsValid(i)) { int nextVal; char nextStr[20]; DataCaptureSpec& currDC = dataCaptureData.GetRef(i); switch (currDC.captureType) { case DataCaptureSpec::ctPressure : { switch (currDC.pressureCapType) { case DataCaptureSpec::pctTestZone : { nextVal = nextP_TZ++; CopyString(nextStr, "P_TZ_", 20); break; } case DataCaptureSpec::pctRadius : { nextVal = nextP_OW++; CopyString(nextStr, "P_OW_", 20); break; } case DataCaptureSpec::pctSuperposition: { nextVal = nextP_S++; CopyString(nextStr, "P_S_", 20); break; } } break; } case DataCaptureSpec::ctFlow : { switch (currDC.flowCapType) { case DataCaptureSpec::fctWell: { nextVal = nextQ_W++; CopyString(nextStr, "Q_W_", 20); break; } case DataCaptureSpec::fctFormation : { nextVal = nextQ_F++; CopyString(nextStr, "Q_F_", 20); break; } case DataCaptureSpec::fctTestZone: { nextVal = nextQ_TZ++; CopyString(nextStr, "Q_TZ_", 20); break; } case DataCaptureSpec::fctWellboreStorage: { nextVal = nextQ_WS++; CopyString(nextStr, "Q_WS_", 20); break; } } break; } case DataCaptureSpec::ctProduction : { switch (currDC.productionCapType) { case DataCaptureSpec::prctWell: { nextVal = nextPr_W++; CopyString(nextStr, "Pr_W_", 20); break; } case DataCaptureSpec::prctFormation : { nextVal = nextPr_F++; CopyString(nextStr, "Pr_F_", 20); break; } case DataCaptureSpec::prctTestZone: { nextVal = nextPr_TZ++; CopyString(nextStr, "Pr_TZ_", 20); break; } } break; } case DataCaptureSpec::ctTestZone : { switch (currDC.testZoneCapType) { case DataCaptureSpec::tzctTemperature : { nextVal = nextO_T++; CopyString(nextStr, "O_T_", 20); break; } case DataCaptureSpec::tzctCompressibility : { nextVal = nextO_C++; CopyString(nextStr, "O_C_", 20); break; } case DataCaptureSpec::tzctVolume : { nextVal = nextO_V++; CopyString(nextStr, "O_V_", 20); break; } } break; } case DataCaptureSpec::ctWaterTable : { nextVal = nextWT++; CopyString(nextStr, "WT_OW_", 20); break; } } if (currDC.makeDefaultDataDesig) { char nextIStr[10]; IntToString(nextVal, nextIStr, 2, 10); char newDesig[40]; CopyString(newDesig, nextStr, 40); ConcatString(newDesig, nextIStr, 40); retVal = retVal || (strcmp(newDesig, currDC.dataDesig) != 0); CopyString(currDC.dataDesig, newDesig, 40); } } return retVal; } void DataCaptureStaticSupport::CheckAndAllocDataCapture(int dcIndex) { dataCaptureData.CreateIfNecessary(dcIndex); /* if (dataCaptureData.CreateIfNecessary(dcIndex)) { IntToString(dcIndex, dataCaptureData[dcIndex]->dataDesig, 20); } */ } bool DataCaptureStaticSupport::GetWellIDs(SC_StringArray& wellIDs) { wellIDs.SetStringLen(40); wellIDs.Alloc(dataCaptureData.Size()); for (int i = 0; i < dataCaptureData.Size(); i++) { DataCaptureSpecGlob& currSpec = *(dataCaptureData[i]); if (currSpec.IsWell() && currSpec.IsPressure()) wellIDs += currSpec.dataDesig; } return wellIDs.IsNotEmpty(); } FuncObjC* DataCaptureStaticSupport::GetWellPFO(const char* wellID) { for (int i = 0; i < dataCaptureData.Size(); i++) { DataCaptureSpecGlob& currSpec = *(dataCaptureData[i]); if (SameString(wellID, currSpec.dataDesig) && currSpec.IsWell() && currSpec.IsPressure()) return currSpec.GetObjRef(); } return 0; } FuncObjC* DataCaptureStaticSupport::GetWellQFO(const char* wellID) { for (int i = 0; i < dataCaptureData.Size(); i++) { DataCaptureSpecGlob& currSpec = *(dataCaptureData[i]); if (SameString(wellID, currSpec.dataDesig) && currSpec.IsWell() && currSpec.IsFlow()) return currSpec.GetObjRef(); } return 0; } bool DataCaptureStaticSupport::GetSuperpositionCapture(DataCapturePtrArray& superpositionCapture) { superpositionCapture.Alloc(dataCaptureData.Size()); for (int i = 0; i < dataCaptureData.Size(); i++) if (dataCaptureData.IsValid(i) && dataCaptureData.GetRef(i).IsSuperposition()) superpositionCapture += dataCaptureData[i]; return !superpositionCapture.IsEmpty(); } appFuncObjGlobals::AppFuncArray DataCaptureStaticSupport::capturedObj("f(t)Output"); void DataCaptureStaticSupport::InitAppGlobals() { capturedObj.AddTo(&capturedDataFO); capturedObj.AddTo(&optRangeOutputFO); appFuncObjGlobals::appFuncData += &capturedObj; } const char* DataCaptureStaticSupport::groupHeader = "DataCapture"; //const int DataCaptureStaticSupport::majorVersion = 0; //const int DataCaptureStaticSupport::majorVersion = 1; // added vary par //const int DataCaptureStaticSupport::majorVersion = 2; // added global objects //const int DataCaptureStaticSupport::majorVersion = 3; // added unconfined support //const int DataCaptureStaticSupport::majorVersion = 4; // added horizontal anisotropy const int DataCaptureStaticSupport::majorVersion = 5; // added layered support const int DataCaptureStaticSupport::minorVersion = 0; void DataCaptureStaticSupport::WriteSuperComponent(SuperComponent& outSuper) { WriteInt(outSuper.superOp); WriteInt(outSuper.superType); WriteDouble(outSuper.constantRad); WriteSampVar(outSuper.sampRadVal); WriteOptVar(outSuper.optRadVal); WriteVaryVar(outSuper.varyRadVal); } void DataCaptureStaticSupport::WriteDataCapture(DataCaptureSpecGlob& outDC) { WriteText(outDC.dataDesig); WriteBool(outDC.makeDefaultDataDesig); WriteInt(outDC.captureType); WriteInt(outDC.pressureCapType); WriteInt(outDC.flowCapType); WriteInt(outDC.productionCapType); WriteInt(outDC.testZoneCapType); WriteUnitReal(outDC.radiusData); WriteBool(outDC.zvalueIsRatio); // added v3 WriteUnitReal(outDC.actualZ); // added v3 WriteDouble(outDC.normalizedZ); // added v3 WriteUnitReal(outDC.obsXLocation); // addec v4 WriteUnitReal(outDC.obsYLocation); // addec v4 WriteLine(); // added v5 WriteText(outDC.wellboreZoneID); // added v5 WriteUnitIndex(outDC.outputUnits); WriteGlobalFunc(outDC.outputFO); WriteLine(); WriteInt(outDC.superData.ValidSize()); WriteLine(); for (int i = 0; i < outDC.superData.Size(); i++) if (outDC.superData.IsValid(i)) WriteSuperComponent(outDC.superData.GetRef(i)); } void DataCaptureStaticSupport::ReadSuperComponent(SuperComponent& inSuper) { inSuper.superOp = SuperComponent::SuperOp(ReadInt()); inSuper.superType = SuperComponent::SuperType(ReadInt()); inSuper.constantRad = ReadDouble(); ReadSampVar(inSuper.sampRadVal); ReadOptVar(inSuper.optRadVal); if (currentObjReadMajorVersion > 0) ReadVaryVar(inSuper.varyRadVal); inSuper.isOpt = (inSuper.superType == SuperComponent::stOptimized); inSuper.isSampled = (inSuper.superType == SuperComponent::stSampled); inSuper.isVary = (inSuper.superType == SuperComponent::stVary); } void DataCaptureStaticSupport::ReadDataCapture(DataCaptureSpecGlob& inDC) { ReadText(inDC.dataDesig, DataCaptureSpec::dataDesigLen); inDC.makeDefaultDataDesig = ReadBool(); inDC.captureType = DataCaptureSpec::CaptureType(ReadInt()); inDC.pressureCapType = DataCaptureSpec::PressureCapType(ReadInt()); inDC.flowCapType = DataCaptureSpec::FlowCapType(ReadInt()); inDC.productionCapType = DataCaptureSpec::ProductionCapType(ReadInt()); inDC.testZoneCapType = DataCaptureSpec::TestZoneCapType(ReadInt()); ReadUnitReal(inDC.radiusData); if (currentObjReadMajorVersion > 2) { inDC.zvalueIsRatio = ReadBool(); // added v3 ReadUnitReal(inDC.actualZ); // added v3 inDC.normalizedZ = ReadDouble(); // added v3 } if (currentObjReadMajorVersion > 3) { ReadUnitReal(inDC.obsXLocation); // added v4 ReadUnitReal(inDC.obsYLocation); // added v4 } if (currentObjReadMajorVersion > 4) ReadText(inDC.wellboreZoneID, IntervalBase::intervalIDLen); ReadUnitIndex(inDC.outputUnits); if (currentObjReadMajorVersion > 1) ReadGlobalFunc(inDC.outputFO); inDC.superData.AllocAndCreate(ReadInt()); for (int i = 0; i < inDC.superData.Size(); i++) ReadSuperComponent(inDC.superData.GetRef(i)); inDC.SetIDs(); } void DataCaptureStaticSupport::WriteToFile() { WriteGroupHeader(groupHeader, majorVersion, minorVersion); // global objects WriteGlobalFunc(capturedDataFO); WriteGlobalFunc(optRangeOutputFO); WriteInt(dataCaptureData.ValidSize()); WriteLine(); for (int i = 0; i < dataCaptureData.Size(); i++) if (dataCaptureData.IsValid(i)) WriteDataCapture(dataCaptureData.GetRef(i)); WriteUnitIndex(productionRestartUnits); WriteDoubleArray(productionRestartTimes, true); WriteLine(); } bool DataCaptureStaticSupport::ReadFromFile() { ReadGroupHeader(groupHeader, majorVersion); if (currentObjReadMajorVersion > 1) { ReadGlobalFunc(capturedDataFO); ReadGlobalFunc(optRangeOutputFO); } dataCaptureData.AllocAndCreate(ReadInt()); for (int i = 0; i < dataCaptureData.Size(); i++) ReadDataCapture(dataCaptureData.GetRef(i)); ReadUnitIndex(productionRestartUnits); ReadDoubleArray(productionRestartTimes, true); return true; } }; // end namespace
void OGL3DBase::DrawOneAxes( const double& axMin, const double& axMax, const SC_DoubleArray& majorIncs, const SC_DoubleArray& minorIncs, const PC_AxesFormat& format, Point2D& stPoint, Point2D& majTicEndPoint, Point2D& minTicEndPoint, Point2D& gridEndPoint, Point2D& offsetEndPoint, double& stComponent, double& majTicComponent, double& minTicComponent, double& gridComponent, double& offsetComponent, const double& zValue, Plane3D axPlane, bool axisIsLog) { Point2D* endPoint; double* endComponent; PC_3DAxesFormat& axesFormat = plot3Dbase.axesFormat; DC_PenSet& penSet = *plot3Dbase.defaultPenSet; // default PenSet used for plot if (format.axesLinePos == PC_AxesFormat::alpBoth) { SetDrawColor(penSet.GetColor(axesFormat.axesLinePen)); SetLine(axesFormat.axesLineWidth); SetLineSolid(); HardCopyBlockStart(6); stComponent = axMin; Point2D axSt = stPoint; stComponent = axMax; Point2D axEnd = stPoint; DrawLine(axSt, axEnd, zValue, axPlane); // needed at axes end to make offsets look clean endPoint = &offsetEndPoint; endComponent = &offsetComponent; stComponent = axMin; *endComponent = stComponent; DrawLine(stPoint, *endPoint, zValue, axPlane); stComponent = axMax; *endComponent = stComponent; DrawLine(stPoint, *endPoint, zValue, axPlane); HardCopyBlockEnd(); } if ((format.axesMajorInc == PC_Axes::aitGrid) || ((format.axesMajorInc == PC_Axes::aitTic) && (format.axesTicPos == PC_AxesFormat::atpBoth))) { SetDrawColor(penSet.GetColor(axesFormat.majorPen)); if (format.axesMajorInc == PC_Axes::aitTic) { SetLine(axesFormat.majorTicWidth); endPoint = &majTicEndPoint; endComponent = &majTicComponent; } else { SetLine(axesFormat.majorGridWidth); SetLineType(axesFormat.majorGridLineType); endPoint = &gridEndPoint; endComponent = &gridComponent; } HardCopyBlockStart(majorIncs.Size() * 2); for (int i = 0; i < majorIncs.Size(); i++) { stComponent = majorIncs[i]; if (Limit::WithinOneLimit(axMin, axMax, stComponent)) { *endComponent = stComponent; DrawLine(stPoint, *endPoint, zValue, axPlane); } } HardCopyBlockEnd(); } if ((format.axesMinorInc == PC_Axes::aitGrid) || ((format.axesMinorInc == PC_Axes::aitTic) && (format.axesTicPos == PC_AxesFormat::atpBoth))) { SetDrawColor(penSet.GetColor(axesFormat.minorPen)); if (format.axesMinorInc == PC_Axes::aitTic) { SetLine(axesFormat.minorTicWidth); endPoint = &minTicEndPoint; endComponent = &minTicComponent; } else { SetLine(axesFormat.minorGridWidth); SetLineType(axesFormat.minorGridLineType); endPoint = &gridEndPoint; endComponent = &gridComponent; } HardCopyBlockStart((majorIncs.Size() + 1) * minorIncs.Size() * 2); if (!axisIsLog) { double multVal = 1.0; if (axMin > axMax ) multVal = -1.0; for (int i = -1; i < majorIncs.Size(); i++) for (int j = 0; j < minorIncs.Size(); j++) { if (i < 0) stComponent = majorIncs[0] - (minorIncs[j] * multVal); else stComponent = majorIncs[i] + (minorIncs[j] * multVal); if (Limit::WithinOneLimit(axMin, axMax, stComponent)) { *endComponent = stComponent; DrawLine(stPoint, *endPoint, zValue, axPlane); } } } else { // static const double logIncVals[] = {0.30103, 0.47712, 0.60206, 0.69897, 0.77815, 0.84510, 0.90309, 0.95424}; if (axMin < axMax) { for (int i = -1; i < majorIncs.Size(); i++) for (int j = 0; j < 8; j++) { if (i < 0) stComponent = majorIncs[0] - 1.0 + logIncVals[j]; else stComponent = majorIncs[i] + logIncVals[j]; if (Limit::WithinOneLimit(axMin, axMax, stComponent)) { *endComponent = stComponent; DrawLine(stPoint, *endPoint, zValue, axPlane); } } } else { for (int i = -1; i < majorIncs.Size(); i++) for (int j = 0; j < 8; j++) { if (i < 0) stComponent = majorIncs[0] + logIncVals[j]; else stComponent = majorIncs[i] - 1.0 + logIncVals[j]; if (Limit::WithinOneLimit(axMin, axMax, stComponent)) { *endComponent = stComponent; DrawLine(stPoint, *endPoint, zValue, axPlane); } } } } HardCopyBlockEnd(); } }
void OGL3DBase::DrawAxesLabels(const SC_DoubleArray& xMajorIncs, const SC_DoubleArray& xtranMajorIncs, const SC_DoubleArray& yMajorIncs, const SC_DoubleArray& ytranMajorIncs, const SC_DoubleArray& zMajorIncs, const SC_DoubleArray& ztranMajorIncs, const SC_RealFormat& xFormat, const SC_RealFormat& yFormat, const SC_RealFormat& zFormat) { PC_3DAxesLabel& axesLabel = plot3Dbase.axesLabel; if (!(axesLabel.plotIncrementLabel || axesLabel.plotAxesLabel)) return; PC_3DAxesFormat& axesFormat = plot3Dbase.axesFormat; if (axesLabel.autoPositionLabels) { axesLabel.xyLabIsVert = (fabs(currView.elevation) < 45.0); axesLabel.xLabYPosIsMax = (fabs(currView.azimuth) >= 90.0); axesLabel.yLabXPosIsMax = (currView.azimuth < 0.0); axesLabel.zLabYPosIsMax = !axesLabel.yLabXPosIsMax; axesLabel.zLabXPosIsMax = axesLabel.xLabYPosIsMax; if (fabs(currView.azimuth) >= 135.0) axesLabel.zLabOrientation = PC_3DAxesLabel::zloXZr; else if (currView.azimuth < -45.0) axesLabel.zLabOrientation = PC_3DAxesLabel::zloYZn; else if (currView.azimuth < 45.0) axesLabel.zLabOrientation = PC_3DAxesLabel::zloXZn; else axesLabel.zLabOrientation = PC_3DAxesLabel::zloYZr; } SetDrawColor(plot3Dbase.defaultPenSet->GetColor(axesFormat.majorPen)); double fontRatio = double(axesLabel.incrementFont.fontSize) / double(axesLabel.labelFont.fontSize); char labStr[80]; Coord3D labLoc; int i; bool adjSt, adjEnd; Coord3D minLim, maxLim; GetTransformedLimits(minLim, maxLim); Coord3D offComp = GetPixelComponents(axesFormat.axesOffset); // x axis first SetAlignmentAdjust(xtranMajorIncs, minLim.cX, maxLim.cX, adjSt, adjEnd); labLoc = Coord3D(0.0, minLim.cY - offComp.cY, minLim.cZ - offComp.cZ); if (axesLabel.xLabYPosIsMax) labLoc.cY = maxLim.cY + offComp.cY; double rotVal = 0.0; if ((!axesLabel.xyLabIsVert) && axesLabel.xLabYPosIsMax) rotVal = 180.0; bool mirror = (axesLabel.xyLabIsVert) && axesLabel.xLabYPosIsMax; Plane3D txtPlane = p3D_XY; if (axesLabel.xyLabIsVert) txtPlane = p3D_XZ; HorizontalTextAlignment halign = hta_Center; if (adjSt) if (axesLabel.xLabYPosIsMax) halign = hta_Right; else halign = hta_Left; bool xyExponents = (xFormat.format > ncf_Scientific) || (yFormat.format > ncf_Scientific); double xyIncOffset = -0.25; if (xyExponents) xyIncOffset = -0.40; if (axesLabel.plotIncrementLabel) { for (i = 0; i < xMajorIncs.Size(); i++) { labLoc.cX = xtranMajorIncs[i]; if (Limit::WithinOneLimit(minLim.cX, maxLim.cX, labLoc.cX)) { xFormat.RealToString(xMajorIncs[i], labStr, 80); if (adjEnd && (i == (xMajorIncs.Size() - 1))) if (axesLabel.xLabYPosIsMax) halign = hta_Left; else halign = hta_Right; Axes3DLabel(axesLabel.incrementFont, labLoc, 0.0, xyIncOffset, rotVal, halign, vta_Top, txtPlane, mirror, labStr); } halign = hta_Center; } } // need to check both X&Y here double xyAxOffset = xyIncOffset - 1.15; if (axesLabel.plotAxesLabel) { if (!axesLabel.plotIncrementLabel) xyAxOffset = -.25; xyAxOffset *= fontRatio; double labWidth, xoverTop, yoverTop; GetLabelSpecs(axesLabel.labelFont, axesLabel.xaxesLabel, xoverTop, labWidth); GetLabelSpecs(axesLabel.labelFont, axesLabel.yaxesLabel, yoverTop, labWidth); if (xoverTop > yoverTop) xyAxOffset -= xoverTop; else xyAxOffset -= yoverTop; } if (axesLabel.plotAxesLabel && (StringLength(axesLabel.xaxesLabel) > 0)) { labLoc.cX = (minLim.cX + maxLim.cX) / 2.0; Axes3DLabel(axesLabel.labelFont, labLoc, 0.0, xyAxOffset, rotVal, hta_Center, vta_Top, txtPlane, mirror, axesLabel.xaxesLabel); } // y axes SetAlignmentAdjust(ytranMajorIncs, minLim.cY, maxLim.cY, adjSt, adjEnd); labLoc = Coord3D(minLim.cX - offComp.cX, 0.0, minLim.cZ - offComp.cZ); if (axesLabel.yLabXPosIsMax) labLoc.cX = maxLim.cX + offComp.cX; rotVal = 0.0; if (axesLabel.xyLabIsVert) txtPlane = p3D_YZ; else if (axesLabel.yLabXPosIsMax) rotVal = 90.0; else rotVal = -90.0; mirror = (axesLabel.xyLabIsVert) && (!axesLabel.yLabXPosIsMax); halign = hta_Center; if (adjSt) if (axesLabel.yLabXPosIsMax) halign = hta_Left; else halign = hta_Right; if (axesLabel.plotIncrementLabel) { for (i = 0; i < yMajorIncs.Size(); i++) { labLoc.cY = ytranMajorIncs[i]; if (Limit::WithinOneLimit(minLim.cY, maxLim.cY, labLoc.cY)) { yFormat.RealToString(yMajorIncs[i], labStr, 80); if (adjEnd && (i == (yMajorIncs.Size() - 1))) if (axesLabel.yLabXPosIsMax) halign = hta_Right; else halign = hta_Left; Axes3DLabel(axesLabel.incrementFont, labLoc, 0.0, xyIncOffset, rotVal, halign, vta_Top, txtPlane, mirror, labStr); } halign = hta_Center; } } if (axesLabel.plotAxesLabel && (StringLength(axesLabel.yaxesLabel) > 0)) { labLoc.cY = (minLim.cY + maxLim.cY) / 2.0; double fontOffset = -1.50; if (!axesLabel.plotIncrementLabel) fontOffset = -.25; Axes3DLabel(axesLabel.labelFont, labLoc,0.0, xyAxOffset, rotVal, hta_Center, vta_Top, txtPlane, mirror, axesLabel.yaxesLabel); } // zaxes bool doLeft = false; switch (axesLabel.zLabOrientation) { case PC_3DAxesLabel::zloXZn : { txtPlane = p3D_XZ; mirror = false; doLeft = axesLabel.zLabXPosIsMax; break; } case PC_3DAxesLabel::zloXZr : { txtPlane = p3D_XZ; mirror = true; doLeft = !axesLabel.zLabXPosIsMax; break; } case PC_3DAxesLabel::zloYZn : { txtPlane = p3D_YZ; mirror = false; doLeft = axesLabel.zLabYPosIsMax; break; } case PC_3DAxesLabel::zloYZr : { txtPlane = p3D_YZ; mirror = true; doLeft = !axesLabel.zLabYPosIsMax; break; } } double offsetMult = 1.0; if (doLeft) halign = hta_Left; else { halign = hta_Right; offsetMult = -1.0; } if (axesLabel.zLabYPosIsMax) labLoc.cY = maxLim.cY + offComp.cY; else labLoc.cY = minLim.cY - offComp.cY; if (axesLabel.zLabXPosIsMax) labLoc.cX = maxLim.cX + offComp.cX; else labLoc.cX = minLim.cX - offComp.cX; double zAxOffset = 0.0; if (axesLabel.plotIncrementLabel) { for (i = 0; i < zMajorIncs.Size(); i++) { labLoc.cZ = ztranMajorIncs[i]; if (Limit::WithinOneLimit(minLim.cZ, maxLim.cZ, labLoc.cZ)) { zFormat.RealToString(zMajorIncs[i], labStr, 80); double labLen, overTop; GetLabelSpecs(axesLabel.incrementFont, labStr, overTop, labLen); if (labLen > zAxOffset) zAxOffset = labLen; Axes3DLabel(axesLabel.incrementFont, labLoc, 0.5 * offsetMult, 0.0, 0.0, halign, vta_Center, txtPlane, mirror, labStr); } } } if (axesLabel.plotAxesLabel && (StringLength(axesLabel.zaxesLabel) > 0)) { labLoc.cZ = (minLim.cZ + maxLim.cZ) / 2.0; double fontOffset = - (zAxOffset + 0.75) * fontRatio * offsetMult; VerticalTextAlignment valign = vta_Bottom; if (fontOffset < 0.0) valign = vta_Top; Axes3DLabel(axesLabel.labelFont, labLoc, 0.0, fontOffset, 90.0, hta_Center, valign, txtPlane, mirror, axesLabel.zaxesLabel); } }
void PFO_GridContour:: CalcOutput(FOcalcType calcType) { DoStatusChk(); if (StatusNotOK()) return; SC_DoubleArray contourData; gridData->GetData(contourData); if (contourSpec.doLogContours) contourData.Log10(); if (contourData.GetnDataOK() < 3) { SetObjErrMsg("less than 3 valid data"); return; } SC_Triangulation& currTri = gridData->GetTriangulation(); contourLines.Alloc(contourSpec.Size()); SC_IntArray orderedPoints; Line3D cLine; Coord3D nextPoint; for (int i = 0; i < contourSpec.Size(); i++) { double currVal = contourSpec[i].contourVal; if (contourSpec.doLogContours) currVal = log10(currVal); if (currTri.GetConnectedEdgeList(contourData, currVal, orderedPoints)) { contourLines[i].Alloc(orderedPoints.Size()); for (int j = 0; j < orderedPoints.Size(); j++) { int edgeIndex = orderedPoints[j]; if (edgeIndex < 0) { nextPoint = Coord3D(); } else { const SC_Triangulation::TriangleEdge& currEdge = currTri.GetEdge(edgeIndex); currTri.GetNodeCoord(currEdge.stNode, cLine.stPt); currTri.GetNodeCoord(currEdge.endNode, cLine.endPt); // slight kluge: if Z is same, honor log stuff if ((zvalueSource == zvs_Same) && contourSpec.doLogContours) { cLine.stPt.cZ = contourData[currEdge.stNode]; cLine.endPt.cZ = contourData[currEdge.endNode]; nextPoint = cLine.PointOnLine(currEdge.cPos); nextPoint.cZ = InvLgt(nextPoint.cZ); } else { cLine.stPt.cZ = GetZVal(currEdge.stNode, *gridData); cLine.endPt.cZ = GetZVal(currEdge.endNode, *gridData); nextPoint = cLine.PointOnLine(currEdge.cPos); } // just affects X & Y gridData->UnTransformCoord(nextPoint); MapCoords(nextPoint); } contourLines[i] += nextPoint; } } } contourLines.SetSize(contourSpec.Size()); }
void ColorMapGridControl::CopyFromClipboardTable(int startRow) { PS_Import import; if (!import.OpenClipboardImport()) { GenAppWarningMsg("ColorMapGridControl", "Can't open clipboard"); return; } // run through once to get size info SC_DoubleArray tableRowData; int maxCols = 0; int nRows = 0; while (import.GetLineDoubles(tableRowData)) { if (tableRowData.IsEmpty()) continue; if (tableRowData.Size() != 3) { GenAppWarningMsg("ColorMapGridControl", "Expecting RGB/HSV triplets"); import.CloseImport(); return; } nRows++; } import.CloseImport(); if (nRows == 0) { GenAppWarningMsg("ColorMapGridControl", "No numeric data in clipboard"); return; } if (nRows + startRow > DC_ColorMap::maxCMcolors) { GenAppWarningMsg("ColorMapGridControl", "Maximum 256 colors"); return; } if (!import.OpenClipboardImport()) { GenAppWarningMsg("ColorMapGridControl", "?? can't open clipboard again"); return; } int nReject = 0; while (import.GetLineDoubles(tableRowData)) { if (tableRowData.Size() == 3) { for (int i = 0; i < 3; i++) if ((tableRowData[i] < 0.0) || (tableRowData[i] > 1.0)) tableRowData[i] = 0.1; gColorMap.colorMapColors[startRow].RH = tableRowData[0]; gColorMap.colorMapColors[startRow].GS = tableRowData[1]; gColorMap.colorMapColors[startRow].BV = tableRowData[2]; startRow++; } else { nReject++; } } gColorMap.ncolorMap = startRow; import.CloseImport(); CString strInfo; strInfo.Format("Imported %d rows from clipboard(%d lines rejected)", nRows, nReject); GenAppInfoMsg("ColorMapGridControl", strInfo); UpdateAll(); UpdateColSize(); }
bool DC_DataLimit::MapDataToRange(const SC_DoubleArray& inData, SC_IntArray& outMap, bool clipToRange, int maxMap) const { outMap.AllocAndSetSize(inData.Size()); actMin = minLimit; actMax = maxLimit; if (logRange) { actMin = log10(actMin); actMax = log10(actMax); } bool zeroLimit = fabs(actMax - actMin) < stdEps; dAct = (actMax - actMin) / double(maxMap); bool oneOK = false; maxMap --; for (int i = 0; i < inData.Size(); i++) { int nodeMap = -1; double dataVal = inData[i]; if (!TransformValueForRange(dataVal, clipToRange)) { outMap[i] = -1; continue; } if (dataVal < actMin) { if (clipToRange) nodeMap = -1; else nodeMap = 0; } else if (dataVal > actMax) { if (clipToRange) nodeMap = -1; else nodeMap = maxMap; } else if (zeroLimit) // 0 range { nodeMap = maxMap / 2; oneOK = true; } else { double dnodeMap = (dataVal - actMin) / dAct; if (dnodeMap > double(maxMap)) nodeMap = maxMap; else nodeMap = int(dnodeMap); oneOK = true; } outMap[i] = nodeMap; } return oneOK; }
void DC_DataLimit::AddToLimit(const SC_DoubleArray& inData) { for ( int i = 0; i < inData.Size(); i++) AddToLimit(inData[i]); }
void SC_Statistics::CalcStatistics(const SC_DoubleArray& data, bool logData, bool baseTen) { Init(); if (data.IsEmpty()) return; int nData = data.Size(); double sum = 0.0; double geoSum = 0.0, harmSum = 0.0; //for geometric and harmonic means double minV, maxV, minAV; int minIndx, maxIndx, minAbsIndx; double minPV = nullReal; int minPosIndx = -1; nOK = 0; nPositive = 0; int nnegZero = 0; for (int i = 0; i < nData; i++) { double dVal = data[i]; if (dVal < 1.0E-99) nnegZero++; if (RealIsNull(dVal) || (logData && (dVal < 1.0E-99))) continue; // this used to be calculated after min/max // changed for SyView 1.2 - Mar 06 // minVal, maxVal, minAV, and minIndxs now based/reported on logged data if (logData) { if (baseTen) { dVal = log10(dVal); } else { dVal = log(dVal); } } double absVal = fabs(dVal); if (nOK == 0) { minV = dVal; maxV = dVal; minAV = absVal; minIndx = i; minAbsIndx = i; maxIndx = i; } if (dVal < minV) { minV = dVal; minIndx = i; } else if (dVal > maxV) { maxV = dVal; maxIndx = i; } if (absVal < minAV) { minAV = absVal; minAbsIndx = i; } if (dVal > 0.0) { if (minPosIndx < 0) { minPV = dVal; minPosIndx = i; } else if (dVal < minPV) { minPV = dVal; minPosIndx = i; } } sum += dVal; if(dVal > 0) { geoSum += log(dVal); harmSum += 1/dVal; nPositive++; } nOK++; } double dOK = double(nOK); double dPositive = double(nPositive); realResults[soN] = dOK; realResults[soNnull] = double(nData - nOK); realResults[soNnegZero] = double(nnegZero); intResults[soN] = nOK; intResults[soNnull] = nData - nOK; intResults[soNnegZero] = nnegZero; if (nData > 0) realResults[soPercentNonNull] = dOK / double(nData) * 100.0; if (nOK == 0) return; resultsOK = true; realResults[soSum] = sum; realResults[soMin] = minV; realResults[soMax] = maxV; realResults[soMinAbs] = minAV; realResults[soMinPos] = minPV; intResults[soMinIndx] = minIndx; intResults[soMaxIndx] = maxIndx; intResults[soMinAbsIndx] = minAbsIndx; intResults[soMinPosIndx] = minPosIndx; realResults[soMinIndx] = double(minIndx); realResults[soMaxIndx] = double(maxIndx); realResults[soMinAbsIndx] = double(minAbsIndx); realResults[soMinPosIndx] = double(minPosIndx); if (nOK > 0) { // pathological realResults[soRange] = maxV - minV; if (realResults[soRange] < stdEps) { realResults[soMean] = (minV + maxV) / 2.0; realResults[soMeanGeo] = (minV + maxV) / 2.0; realResults[soMeanHarm] = (minV + maxV) / 2.0; realResults[soVar] = 0.0; realResults[soStdDev] = 0.0; } else { realResults[soMean] = sum / dOK; realResults[soMeanGeo] = exp(geoSum / dPositive); realResults[soMeanHarm] = dPositive / harmSum; // variance and std dev if (nOK > 1) { double var = 0.0; double mean = realResults[soMean]; for (int i = 0; i < data.Size(); i++) { double dVal = data[i]; if (RealIsNull(dVal) || (logData && (dVal < 1.0E-99))) continue; if (logData) { if (baseTen) { dVal = log10(dVal); } else { dVal = log(dVal); } } double dx = dVal - mean; var += dx * dx; } var /= double(nOK - 1); realResults[soVar] = var; realResults[soStdDev] = sqrt(var); } } } /* mean results now log data if (logData) { if (baseTen) { realResults[soMean] = InvLgt(realResults[soMean]); } else { realResults[soMean] = exp(realResults[soMean]); } } */ }