fix:旧beta增加能量刻度自动校正数据
This commit is contained in:
parent
a762d4abab
commit
c9b406633d
|
@ -1,19 +1,13 @@
|
||||||
package org.jeecg.common.util;
|
package org.jeecg.common.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.google.common.cache.Cache;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.net.ftp.FTP;
|
import org.apache.commons.math3.fitting.WeightedObservedPoints;
|
||||||
import org.apache.commons.net.ftp.FTPClient;
|
|
||||||
import org.apache.commons.net.ftp.FTPFile;
|
|
||||||
import org.jeecg.common.properties.ParameterProperties;
|
import org.jeecg.common.properties.ParameterProperties;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
|
||||||
import org.jeecg.modules.base.abstracts.AbstractLogOrReport;
|
import org.jeecg.modules.base.abstracts.AbstractLogOrReport;
|
||||||
import org.jeecg.modules.base.entity.rnman.GardsXeResults;
|
import org.jeecg.modules.base.entity.rnman.GardsXeResults;
|
||||||
import org.jeecg.modules.base.enums.DataType;
|
|
||||||
import org.jeecg.modules.base.enums.DataTypeAbbr;
|
import org.jeecg.modules.base.enums.DataTypeAbbr;
|
||||||
import org.jeecg.modules.base.enums.XeNuclideName;
|
import org.jeecg.modules.base.enums.XeNuclideName;
|
||||||
import org.jeecg.modules.entity.*;
|
import org.jeecg.modules.entity.*;
|
||||||
|
@ -27,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -861,6 +854,49 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
||||||
path.append("Spectrum");
|
path.append("Spectrum");
|
||||||
path.append(StringPool.SLASH+"Xenon");
|
path.append(StringPool.SLASH+"Xenon");
|
||||||
path.append(StringPool.SLASH+"Spalax");
|
path.append(StringPool.SLASH+"Spalax");
|
||||||
|
} else if (systemType.contains("C")) {
|
||||||
|
path.append("Spectrum");
|
||||||
|
path.append(StringPool.SLASH+"Xenon");
|
||||||
|
path.append(StringPool.SLASH+"Self");
|
||||||
|
}
|
||||||
|
if(dataType.contains("SAMPLEPHD")) {
|
||||||
|
path.append(StringPool.SLASH+"Samplephd");
|
||||||
|
} else if(dataType.contains("DETBKPHD")) {
|
||||||
|
path.append(StringPool.SLASH+"Detbkphd");
|
||||||
|
} else if(dataType.contains("GASBKPHD")) {
|
||||||
|
path.append(StringPool.SLASH+"Gasbkphd");
|
||||||
|
} else if(dataType.contains("QCPHD")) {
|
||||||
|
path.append(StringPool.SLASH+"Qcphd");
|
||||||
|
}
|
||||||
|
int pos = fileName.indexOf('-');
|
||||||
|
if(-1 == pos) {
|
||||||
|
|
||||||
|
} else if(fileName.length() >= pos+7) {
|
||||||
|
path.append(StringPool.SLASH+fileName.substring(pos+1,pos+5));
|
||||||
|
path.append(StringPool.SLASH+fileName.substring(pos+5,pos+7));
|
||||||
|
}
|
||||||
|
path.append(StringPool.SLASH+fileName);
|
||||||
|
return path.toString();
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return path.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String NameStandardBy(String fileName, String systemType,String dataType) {
|
||||||
|
StringBuffer path = new StringBuffer();
|
||||||
|
try {
|
||||||
|
if(systemType.contains("B")) {
|
||||||
|
path.append("Spectrum");
|
||||||
|
path.append(StringPool.SLASH+"Xenon");
|
||||||
|
path.append(StringPool.SLASH+"Sauna");
|
||||||
|
} else if(systemType.contains("G")) {
|
||||||
|
path.append("Spectrum");
|
||||||
|
path.append(StringPool.SLASH+"Xenon");
|
||||||
|
path.append(StringPool.SLASH+"Spalax");
|
||||||
|
} else if (systemType.contains("C")) {
|
||||||
|
path.append("Spectrum");
|
||||||
|
path.append(StringPool.SLASH+"Xenon");
|
||||||
|
path.append(StringPool.SLASH+"Self");
|
||||||
}
|
}
|
||||||
if(dataType.contains("SAMPLEPHD")) {
|
if(dataType.contains("SAMPLEPHD")) {
|
||||||
path.append(StringPool.SLASH+"Samplephd");
|
path.append(StringPool.SLASH+"Samplephd");
|
||||||
|
@ -891,39 +927,44 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
||||||
List<String> fileNames = new LinkedList<>();
|
List<String> fileNames = new LinkedList<>();
|
||||||
String station = sampleFileName.substring(0, 9);
|
String station = sampleFileName.substring(0, 9);
|
||||||
//连接ftp
|
//连接ftp
|
||||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
// FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||||
if (Objects.isNull(ftpClient)){
|
// if (Objects.isNull(ftpClient)){
|
||||||
return fileNames;
|
// return fileNames;
|
||||||
}
|
// }
|
||||||
try {
|
try {
|
||||||
//被动模式
|
//被动模式
|
||||||
ftpClient.enterLocalPassiveMode();
|
// ftpClient.enterLocalPassiveMode();
|
||||||
//设置文件类型--二进制文件
|
// //设置文件类型--二进制文件
|
||||||
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
// ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
||||||
//
|
// //
|
||||||
ftpClient.setControlEncoding("UTF-8");
|
// ftpClient.setControlEncoding("UTF-8");
|
||||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||||
//切换文件路径
|
// //切换文件路径
|
||||||
ftpClient.changeWorkingDirectory(filePath);
|
// ftpClient.changeWorkingDirectory(filePath);
|
||||||
//获取路径下所有文件信息
|
// //获取路径下所有文件信息
|
||||||
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
|
// List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
|
||||||
|
File file = new File(filePath);
|
||||||
|
List<File> ftpFiles = Arrays.asList(file.listFiles());
|
||||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
||||||
fileNames = ftpFiles.stream().filter(item-> item.getName().contains(station)).map(FTPFile::getName).collect(Collectors.toList());
|
fileNames = ftpFiles.stream().filter(item-> item.getName().contains(station)).map(File::getName).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
// try {
|
||||||
ftpClient.disconnect();
|
// ftpClient.disconnect();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
return fileNames;
|
return fileNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetMatchFile(String tmpFileName, List<String> fileNames, String type) {
|
public String GetMatchFile(String tmpFileName, List<String> fileNames, String type) {
|
||||||
String matchFileName = "";
|
String matchFileName = "";
|
||||||
|
if (StringUtils.isBlank(tmpFileName)) {
|
||||||
|
return matchFileName;
|
||||||
|
}
|
||||||
fileNames = fileNames.stream().filter(item-> item.contains(type)).sorted().collect(Collectors.toList());
|
fileNames = fileNames.stream().filter(item-> item.contains(type)).sorted().collect(Collectors.toList());
|
||||||
//用于比较的字符串
|
//用于比较的字符串
|
||||||
String fileCompare = tmpFileName.substring(0,23);
|
String fileCompare = tmpFileName.substring(0,23);
|
||||||
|
@ -2735,6 +2776,94 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
||||||
return xeResultsViewList;
|
return xeResultsViewList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取beta刻度校正数据
|
||||||
|
* @param gEtoCParam gamma e2c公式参数
|
||||||
|
* @param bElectronEnergy beta energy
|
||||||
|
* @param bEtoCParam beta e2c公式参数
|
||||||
|
* @param numGChannel gamma 道址数
|
||||||
|
* @param qcStruct
|
||||||
|
*/
|
||||||
|
public List<TableWidget> getBetaCalibrationCorrection(List<Double> gEtoCParam, List<Double> bElectronEnergy,
|
||||||
|
List<Double> bEtoCParam, long numGChannel,
|
||||||
|
EnergySpectrumStruct qcStruct) {
|
||||||
|
// E_β=661.6-E_γ,E_γ=F(C)
|
||||||
|
// 中心:C_β=F(E_β),范围:左[C_β-3√(C_β ), C_β+3√(C_β )]右
|
||||||
|
// 高斯函数拟合得到拟合的中心道址,显示Energy vs. Channel
|
||||||
|
// 页面展示的表单数据数组
|
||||||
|
List<TableWidget> table = new LinkedList<>();
|
||||||
|
for (int i = 0; i < bElectronEnergy.size(); i++) {
|
||||||
|
// 获取beta energy
|
||||||
|
Double be = bElectronEnergy.get(i);
|
||||||
|
// energy 转化为 channel
|
||||||
|
double bc = bEtoCParam.get(0) + bEtoCParam.get(1) * be + bEtoCParam.get(2) * Math.sqrt(be);
|
||||||
|
// 计算得到gamma energy
|
||||||
|
Double ge = 661.656 - be;
|
||||||
|
// gamma energy 转化 channel
|
||||||
|
double gc = gEtoCParam.get(0) + gEtoCParam.get(1) * ge + gEtoCParam.get(2) * Math.sqrt(ge);
|
||||||
|
// 通过gamma channel获取gammaGate数据
|
||||||
|
List<SeriseData> seriseDatas = this.getGammaGated((int) numGChannel, 5, (int) gc, qcStruct);
|
||||||
|
// 开始计算中心道址, 范围:左[C_β-3√(C_β ), C_β+3√(C_β )]右
|
||||||
|
WeightedObservedPoints points = new WeightedObservedPoints();
|
||||||
|
double left = bc - Math.cbrt(bc);
|
||||||
|
double right = bc + Math.cbrt(bc);
|
||||||
|
int sum = 0;
|
||||||
|
for (SeriseData f : seriseDatas) {
|
||||||
|
if(left < f.getX() && right > f.getX()){
|
||||||
|
points.add(f.getX(), f.getY());
|
||||||
|
sum += f.getX();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// todo 高斯拟合有问题,暂时使用平均值
|
||||||
|
Double channel = sum / (right - left);
|
||||||
|
//表单数据信息
|
||||||
|
TableWidget tableWidget = new TableWidget();
|
||||||
|
tableWidget.setRowCount(i+1);
|
||||||
|
tableWidget.setChannel(channel);
|
||||||
|
tableWidget.setEnergy(be);
|
||||||
|
table.add(tableWidget);
|
||||||
|
}
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param chartHeight 图形高度
|
||||||
|
* @param channelWidth 图形宽度
|
||||||
|
* @param gammaChannel gamma道址
|
||||||
|
* @param struct qc数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<SeriseData> getGammaGated(int chartHeight, int channelWidth, int gammaChannel, EnergySpectrumStruct struct){
|
||||||
|
List<SeriseData> series_data = new LinkedList<>();
|
||||||
|
//选择矩形框高度
|
||||||
|
int flagHeight = channelWidth * (chartHeight / 256);
|
||||||
|
int value = Double.valueOf(flagHeight / 2).intValue();
|
||||||
|
//计算得到最高值
|
||||||
|
int up = gammaChannel - value;
|
||||||
|
if (up < 0){
|
||||||
|
up = 0;
|
||||||
|
}
|
||||||
|
//计算得到最低值
|
||||||
|
int down = up + value;
|
||||||
|
if (Objects.nonNull(struct)) {
|
||||||
|
//Beta-Gamma Spectrum: QC
|
||||||
|
long bChannels = struct.b_channels;
|
||||||
|
|
||||||
|
List<Long> hCounts = struct.h_counts;
|
||||||
|
for ( int i=0; i < bChannels; ++i ) {
|
||||||
|
long count = 0;
|
||||||
|
for (int j = up; j <= down; ++j) {
|
||||||
|
long index = j * bChannels + i;
|
||||||
|
count += hCounts.get((int) index);
|
||||||
|
}
|
||||||
|
SeriseData temp = new SeriseData();
|
||||||
|
temp.setX(i);
|
||||||
|
temp.setY(count);
|
||||||
|
series_data.add(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return series_data;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2120,12 +2120,12 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
||||||
}
|
}
|
||||||
map.put("CToE", fittingParaStr);
|
map.put("CToE", fittingParaStr);
|
||||||
List<Double> channel = new LinkedList<>();
|
List<Double> channel = new LinkedList<>();
|
||||||
for (int i=0; i<255; ++i) {
|
for (int i = 0; i < numBChannel - 1; ++i) {
|
||||||
channel.add(Double.valueOf(i));
|
channel.add(Double.valueOf(i));
|
||||||
}
|
}
|
||||||
List<Double> energy = EnergySpectrumHandler.GetFileFittingData(channel, fittingPara);
|
List<Double> energy = EnergySpectrumHandler.GetFileFittingData(channel, fittingPara);
|
||||||
List<SeriseData> oldLineSeries = new LinkedList<>();
|
List<SeriseData> oldLineSeries = new LinkedList<>();
|
||||||
for (int i=0; i<channel.size(); i++) {
|
for (int i = 0; i < channel.size(); i++) {
|
||||||
SeriseData tmp = new SeriseData();
|
SeriseData tmp = new SeriseData();
|
||||||
tmp.setX(channel.get(i));
|
tmp.setX(channel.get(i));
|
||||||
tmp.setY(energy.get(i));
|
tmp.setY(energy.get(i));
|
||||||
|
@ -2135,11 +2135,16 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
||||||
//E to C
|
//E to C
|
||||||
List<Double> fittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(energy, channel);
|
List<Double> fittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(energy, channel);
|
||||||
List<String> fittingParaToUiStr = new LinkedList<>();
|
List<String> fittingParaToUiStr = new LinkedList<>();
|
||||||
for (Double para:fittingParaToUi) {
|
for (Double para : fittingParaToUi) {
|
||||||
fittingParaToUiStr.add(String.valueOf(para));
|
fittingParaToUiStr.add(String.valueOf(para));
|
||||||
}
|
}
|
||||||
map.put("EToC", fittingParaToUiStr);
|
map.put("EToC", fittingParaToUiStr);
|
||||||
|
|
||||||
|
// 得到gamma谱 e2c公式
|
||||||
|
List<Double> gFittingPara = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel);
|
||||||
|
map.put("tableWidgets", phdFileUtil.getBetaCalibrationCorrection(gFittingPara, bElectronEnergy,
|
||||||
|
fittingParaToUi, numGChannel, betaDataFile.getQcStruct()));
|
||||||
|
|
||||||
//判断人工交互的道值与能量对应参数数组是否为空
|
//判断人工交互的道值与能量对应参数数组是否为空
|
||||||
if (Objects.nonNull(betaDataFile.getBgPara()) && CollectionUtils.isNotEmpty(betaDataFile.getBetaList())) {
|
if (Objects.nonNull(betaDataFile.getBgPara()) && CollectionUtils.isNotEmpty(betaDataFile.getBetaList())) {
|
||||||
//存储计算参数道值
|
//存储计算参数道值
|
||||||
|
|
Loading…
Reference in New Issue
Block a user