fix:解决新beta谱 calibration gateGamma方法

This commit is contained in:
xiaoguangbin 2024-09-03 11:02:15 +08:00
parent d93c519ed0
commit 3287e26a6b
2 changed files with 52 additions and 110 deletions

View File

@ -80,7 +80,7 @@ public class AnalysisManServiceImpl implements AnalysisManService {
analysisRoi.setScacPath(middleData.getAnalyses_scac_filePath());
analysisRoi.setLogPath(middleData.getAnalyses_LogPath());
analysisRoi.setReportPath(middleData.getAnalyses_ReportPath());
analysisRoi.setRoiNum(i-1);
analysisRoi.setRoiNum(i+1);
analysisRoi.setMinX(Double.parseDouble(roiBBoundaryStart.get(i)+""));
analysisRoi.setMaxX(Double.parseDouble(roiBBoundaryStop.get(i)+""));
analysisRoi.setMinY(Double.parseDouble(roiGBoundaryStart.get(i)+""));

View File

@ -1146,31 +1146,6 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
for (ROIParam roiParam : roiParams) {
roiBBoundaryStart.add(roiParam.getRoiNum()-1, roiParam.getStartChannel());
roiBBoundaryStop.add(roiParam.getRoiNum()-1, roiParam.getEndChannel());
// Map<String, Object> resultMap = selfStationUtil.statisticsROIList(roiParam.getStartChannel(), roiParam.getEndChannel(),
// struct.b_channels, struct.g_channels, struct.h_counts);
// if ( CollectionUtils.isNotEmpty(resultMap) ) {
// Integer startChannelValue = (Integer) resultMap.get("startChannel");
// Integer endChannelValue = (Integer) resultMap.get("endChannel");
// List<SeriseData> seriseDataList = (List<SeriseData>) resultMap.get("dataList");
// if (1 == ROINum) {
// map.put("ROIOneList", seriseDataList);
// map.put("ROIOneStart", startChannelValue);
// map.put("ROIOneStop", endChannelValue);
// } else if (2 == ROINum) {
// map.put("ROITwoList", seriseDataList);
// map.put("ROITwoStart", startChannelValue);
// map.put("ROITwoStop", endChannelValue);
// } else if (3 == ROINum) {
// map.put("ROIThreeList", seriseDataList);
// map.put("ROIThreeStart", startChannelValue);
// map.put("ROIThreeStop", endChannelValue);
// } else if (4 == ROINum) {
// map.put("ROIFourList", seriseDataList);
// map.put("ROIFourStart", startChannelValue);
// map.put("ROIFourStop", endChannelValue);
// }
// }
}
result.setSuccess(true);
result.setResult(selfStationUtil.getGammaByROI(struct.system_type, roiBBoundaryStart, roiBBoundaryStop, selfStationData));
@ -2299,7 +2274,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
List<Double> gEnergy = struct.g_energy;
long bChannels = struct.b_channels;
long gChannels = struct.g_channels;
List<Long> hCounts = struct.h_counts;
long[][] hCounts = struct.h_count_arr;
int bRecordCount = struct.b_record_count;
//散点图坐标点关联beta部分相关数据
List<List<Double>> betaEnergyList = new LinkedList<>();
@ -2329,17 +2304,13 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
}
//Beta-Gamma Spectrum: QC 散点图相关数据
List<HistogramData> histogramDataList = new LinkedList<>();
// todo 减少数量 暂时写512
gChannels = 512;
bChannels = 512;
for (int column=0; column<gChannels; column++) {
for (int row=0; row<bChannels; row++) {
Long index = column * bChannels + row;
long count = hCounts.get(index.intValue());
for (int row=0; row < gChannels; row++) {
for (int col=0; col < bChannels; col++) {
long count = hCounts[row][col];
if (count>0) {
HistogramData histogramData = new HistogramData();
histogramData.setB(row);
histogramData.setG(column);
histogramData.setB(col);
histogramData.setG(row);
histogramDataList.add(histogramData);
}
}
@ -2403,7 +2374,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
// gamma energy 转化 channel
Double gc = gFittingPara.get(0) + gFittingPara.get(1) * ge + gFittingPara.get(2) * Math.sqrt(ge);
// 通过gamma channel获取gammaGate数据
List<SeriseData> seriseDatas = getGateGamma(5, 4096, gc.intValue(), betaDataFile);
List<SeriseData> seriseDatas = this.getGammaGated(4096, 5, gc.intValue(), betaDataFile.getQcStruct());
// 开始计算中心道址 范围[C_β-3(C_β ), C_β+3(C_β )]
WeightedObservedPoints points = new WeightedObservedPoints();
double left = bc - Math.cbrt(bc);
@ -4126,12 +4097,6 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
}
//判断是否勾选了sample
spectrum_group.BgCalPara.bApplyNewCalicSample = analyseData.isSampleData();
//判断是否勾选了gas
spectrum_group.BgCalPara.bApplyNewCalicGasBg = analyseData.isGasBgData();
//判断是否勾选了det
spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData();
//判断是否勾选了qc
spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData();
File sampleTmp = null;
File gasTmp = null;
File detTmp = null;
@ -4939,7 +4904,8 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
}
@Override
public Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId, String qcFileName, String sampleFileName, HttpServletRequest request) {
public Result getGammaGated(Integer chartHeight, Integer channelWidth, Integer gammaChannel, Integer sampleId,
String qcFileName, String sampleFileName, HttpServletRequest request) {
Result result = new Result();
Map<String, Object> map = new HashMap<>();
//获取用户名称
@ -4947,14 +4913,31 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
//获取自建台站缓存信息
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
SelfStationData betaDataFile = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName);
// Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
// BetaDataFile betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
if (Objects.isNull(betaDataFile)) {
result.error500("Load basic file information first!");
return result;
}
//选择矩形框高度
Integer flagHeight = channelWidth * (chartHeight/256);
if (null != betaDataFile.getQcStruct()) {
map.put("data", this.getGammaGated(chartHeight, channelWidth, gammaChannel, betaDataFile.getQcStruct()));
}
result.setSuccess(true);
result.setResult(map);
return result;
}
/**
*
* @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> serise_data = new LinkedList<>();
//选择矩形框高度
Integer flagHeight = channelWidth * (chartHeight/512);
int value = Double.valueOf(flagHeight / 2).intValue();
//计算得到最高值
int up = gammaChannel - value;
@ -4963,28 +4946,22 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
}
//计算得到最低值
int down = up + value;
EnergySpectrumStruct struct = betaDataFile.getQcStruct();
if (Objects.nonNull(struct)) {
//Beta-Gamma Spectrum: QC
long bChannels = struct.b_channels;
List<Long> hCounts = struct.h_counts;
List<SeriseData> serise_data = new LinkedList<>();
long[][] hCounts = struct.getH_count_arr();
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(index.intValue());
count += hCounts[j][i];
}
SeriseData temp = new SeriseData();
temp.setX(i);
temp.setY(count);
serise_data.add(temp);
}
map.put("data", serise_data);
}
result.setSuccess(true);
result.setResult(map);
return result;
return serise_data;
}
@Override
@ -5017,38 +4994,6 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
}
}
private List<SeriseData> getGateGamma(int channelWidth, int chartHeight, int gammaChannel, SelfStationData betaDataFile){
List<SeriseData> serise_data = new LinkedList<>();
//选择矩形框高度
Integer flagHeight = channelWidth * (chartHeight/512);
int value = Double.valueOf(flagHeight / 2).intValue();
//计算得到最高值
int up = gammaChannel - value;
if (up<0){
up = 0;
}
//计算得到最低值
int down = up + value;
EnergySpectrumStruct struct = betaDataFile.getQcStruct();
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(index.intValue());
}
SeriseData temp = new SeriseData();
temp.setX(i);
temp.setY(count);
serise_data.add(temp);
}
}
return serise_data;
}
@Override
@ -5562,31 +5507,28 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
PHDFile phd = sampleVueData.getROIOnePHDFile();
BeanUtils.copyProperties(phdFiles.get(0), phd);
GardsSampleDataSpectrum sampleData = spectrumAnalysisMapper.findSampleByFilePath(sampleInputFileName);
if (ObjectUtil.isNotNull(sampleData)) {
phd.setId_sample(sampleData.getSampleId().toString());
phd.setStatus(sampleData.getStatus());
} else {
// 如果sampleData为空 存储数据
//判断文件是否存储过 如果没有则解析文件并进行存储
if (!this.OriginalDataStore(sampleStruct, sampleTmpPath, sampleFilePathName) ){
result.error500("sampleFile save failed");
phd.setId_sample(sampleData.getSampleId().toString());
// 判断文件是否存储过 如果没有则解析文件并进行存储
if (!this.OriginalDataStore(sampleStruct, sampleTmpPath, sampleFilePathName) ){
result.error500("sampleFile save failed");
return result;
}
if (StrUtil.isNotBlank(detFilePathName)){
if (!this.OriginalDataStore(detStruct, detTmpPath, detFilePathName) ){
result.error500("detFile save failed");
return result;
}
if (StrUtil.isNotBlank(detFilePathName)){
if (!this.OriginalDataStore(detStruct, detTmpPath, detFilePathName) ){
result.error500("detFile save failed");
return result;
}
detId = spectrumAnalysisMapper.getSampleId(detFilePathName);
}
if (StringUtils.isNotBlank(qcFilePathName)) {
if (!this.OriginalDataStore(qcStruct, qcTmpPath, qcFilePathName) ){
result.error500("qcFile save failed");
return result;
}
}
sampleData = spectrumAnalysisMapper.findSampleByFilePath(sampleFilePathName);
detId = spectrumAnalysisMapper.getSampleId(detFilePathName);
}
if (StringUtils.isNotBlank(qcFilePathName)) {
if (!this.OriginalDataStore(qcStruct, qcTmpPath, qcFilePathName) ){
result.error500("qcFile save failed");
return result;
}
}
sampleData = spectrumAnalysisMapper.findSampleByFilePath(sampleFilePathName);
sampleId = sampleData.getSampleId();
// 根据sampleId 查询idAnalysis
String idAnalysisStr = spectrumAnalysisMapper.getIdAnalysisByIdAnalyst(sampleId.toString(), userName);