核数据处理课程设计.docx
《核数据处理课程设计.docx》由会员分享,可在线阅读,更多相关《核数据处理课程设计.docx(34页珍藏版)》请在冰点文库上搜索。
核数据处理课程设计
核工程与新能源技术系
课程设计报告
题目课程设计报告
系别核工程与新能源技术系
年级2012级专业核工程与核技术
班级核技术3班学号201220401XXX
学生姓名岳XX
指导教师张艳丽职称讲师
所属课程核数据处理实验
设计时间2014-11-16
课程设计独创性声明:
本课程设计是在老师指导下个人独立完成的。
学生签名:
课程设计评分标准(按教学大纲评定)
课程设计报告成绩:
平时成绩:
总成绩:
指导教师签名:
教研室主任签名:
实验中心主任签名:
目录
一、设计任务及目的页码
二、任务梗概页码
三、任务实现页码
1、设计内容一(计算器制作)页码
(1)任务要求页码
(2)任务步骤页码
(3)任务效果页码
2、设计内容二(制作“输入数据”“显示图像”“五点平滑”页码
(1)任务要求页码
(2)任务步骤页码
(3)任务效果页码
3、设计内容五(制作“左边界”“右边界”“寻峰”按钮)页码
(1)任务要求页码
(2)任务步骤页码
(3)任务效果页码
4、设计内容六(制作左边界、右边界、寻峰、道址能量公式、能量刻度显示编辑框)页码
(1)任务要求页码
(2)任务步骤页码
(3)任务效果页码5、设计内容七(制作求总面积、本地面积、净面积与其编辑框)页码
(1)任务要求页码
(2)任务步骤页码
(3)任务效果页码6、设计内容八(菜单栏、工具栏、状态栏)页码
(1)任务要求页码
(2)任务步骤页码
(3)任务效果页码
四、设计总结(感受)页码
一、设计任务及目的一、实验目的:
1、通过实验学会自主思考设计软件程序;
2、通过实验懂得如何运用一些软件完成程序设并实现预期功能; 3、在软件设计过程中逐步掌握能谱分析的基本过程;
4、通过设计知道怎样才能完成能谱的准确分析得出正确分析结果;
5、通过实验了解我们所运用能谱分析仪的工作过程,特别是其后部分能谱处理原理。
6、掌握图形程序的编写技巧。
二、实验要求:
1、自觉完成实验设计,不抄袭;
2、查阅资料,讨论、了解该设计性实验的实现基本过程; 3、能够团结同学,采纳同学的意见与分析方法、进行合理取舍;
4、运用软件程序完成能谱分析,并实现能谱的准确分析,做到能谱的数据获取、平滑、寻峰、刻度等
5、按时完成实验任务、上交实验成果。
三、实验任务:
1、通过实践培养学生实际动手能力,熟悉核数据处理的过程和方法,打下坚实的核物理实验及核数据处理基础,巩固C语言的学习。
二、任务梗概
1、C语言基础复习。
2、制作计算器。
3、读谱数据文件、保存光滑后的谱数据文件,文件名可选。
4、显示谱数据,各算法要以及函数方式实现、左右边界选取。
5、显示分析谱段范围内,寻得的各峰位道址、能量。
6、能量刻度。
7、显示寻峰级峰面积计算结果。
三、任务实现以
一、计算器制作
1、要求:
最低要求:
能完成双精度型数值的加、减、乘、除计算;编程中使用了动态连接库技术.
较高要求:
能完成双精度型数值的加、减、乘、除计算;编程中使用了动态连接库技术; 能实现表达式的输入,解析与计算。
2、步骤:
1、先建立一个工程,截图如下
2,然后制作计算器的界面
3,建立类向导写程序如下。
voidCJmxjisuanqiDlg:
:
Onjia()
{
UpdateData(true);
m_Result=m_Firtn+m_Secn;
UpdateData(false);
}
voidCJmxjisuanqiDlg:
:
Onjian()
{
UpdateData(true);
m_Result=m_Firtn-m_Secn;
UpdateData(false);
}
voidCJmxjisuanqiDlg:
:
Oncheng()
{
UpdateData(true);
m_Result=m_Firtn-m_Secn;
UpdateData(false);
}
voidCJmxjisuanqiDlg:
:
Onchu()
{
UpdateData(true);
m_Result=m_Firtn/m_Secn;
UpdateData(false);
}
4,运行得到的的界面和结果
二、“输入数据”等按钮
通过对C语言文件相关函数的掌握并熟悉运用可以写出以下实验。
1、创立一个工程文件。
截屏如下:
2、对于按钮键编写属性和建立类向导,建立类向导的程序如下。
voidCJMXDlg:
:
Onduqushuju()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
FILE*fp;
intdatanum=0,data[2048];
floatdata_ph[2048];
inti;
intdata1,data2;
if((fp=fopen("090623.txt","r"))==NULL)
{
printf("Cannotopenthefile.\n");
exit(0);
}
while(!
feof(fp))
{
fscanf(fp,"%d%d",&data1,&data2);
data[datanum++]=data2;
fscanf(fp,"\n");
}
for(i=0;i<2048;i++)
{
if(i<2||i>2045)
data_ph[i]=data[i];
else
data_ph[i]=(data[i-2]+4*data[i-1]+6*data[i]+4*data[i+1]+data[i+2])*1.0/16.0;
printf("%f\n",data_ph[i]);
}
fclose(fp);
if((fp=fopen("OUT1.txt","w"))==NULL)
{
printf("fileopenerror.\n");
exit(0);
}
for(i=0;i<2048;i++)
{
fprintf(fp,"%d%f\n",i+1,data_ph[i]);
}
fclose(fp);
注意:
在编程时要把所给的数据文本文件要在所创立的文件下去编写程序。
所给的数据文本文件090623.txt。
编译连接。
点击读取数据按钮,然后打开生成的OUT1.txt文本文件
三、“显示图像”按钮
建立工程
通过对按钮类向导建立类向导编程
1,对读取数据建立类向导。
voidCxianshitupuDlg:
:
Onduqushuju()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
FILE*fp;
intdatanum=0;
inti;
intdata1,data2;
if((fp=fopen("090623.txt","r"))==NULL)
{printf("Cannotopenthefile.\n");
exit(0);
}
while(!
feof(fp))
{
fscanf(fp,"%d%d",&data1,&data2);
data[datanum++]=data2;
fscanf(fp,"\n");
}
for(i=0;i<2048;i++)
{if(i<2||i>2045)
data_ph[i]=data[i];
else
data_ph[i]=(data[i-2]+4*data[i-1]+6*data[i]+4*data[i+1]+data[i+2])*1.0/16.0;
printf("%d%f\n",i+1,data_ph[i]);
}
fclose(fp);
if((fp=fopen("out.txt","w"))==NULL)
{printf("fileopenerror.\n");
exit(0);
}
for(i=0;i<2048;i++)
{fprintf(fp,"%d%f\n",i+1,data_ph[i]);
}
fclose(fp);
}
2.对显示原图普按钮建立内向导
voidCXianshitupuDlg:
:
OnYuantupu()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
doublexViewport,yViewport;
intmax;
CWnd*pWnd=GetDlgItem(IDC_P1);
CDC*pDC=pWnd->GetDC();
pDC->SetMapMode(MM_ANISOTROPIC);
CRectrect;
doublescale;
GetDlgItem(IDC_P1)->GetWindowRect(&rect);
scale=25.4*10/pDC->GetDeviceCaps(LOGPIXELSX);
CDCMemDC;
CBitmapMemBitmap;
MemDC.CreateCompatibleDC(NULL);
MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
MemDC.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(255,255,255));
max=data[0];
for(inti=1;i<2048;i++)
{if(data[i]>max)
max=data[i];
}
for(i=0;i<2048;i++)
{
xViewport=(i+1)*rect.Width()/2048;
yViewport=(0.67*data[i]*rect.Height())/max+10;
pDC->SetPixel(xViewport,rect.Height()-yViewport-1,RGB(255,0,0));
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY);
}
MemBitmap.DeleteObject();
MemDC.DeleteDC();
pDC->DeleteDC();
}
3.对显示五点平滑图谱建立内向导
voidCXianshitupuDlg:
:
OnXianshiwudian()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
doublexViewport,yViewport;
floatmax;
CWnd*pWnd=GetDlgItem(IDC_P2);
CDC*pDC=pWnd->GetDC();
pDC->SetMapMode(MM_ANISOTROPIC);
CRectrect;
doublescale;
GetDlgItem(IDC_P2)->GetWindowRect(&rect);
scale=25.4*10/pDC->GetDeviceCaps(LOGPIXELSX);
CDCMemDC;
CBitmapMemBitmap;
MemDC.CreateCompatibleDC(NULL);
MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
MemDC.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(255,255,255));
max=data_ph[0];
for(inti=1;i<2048;i++)
{if(data_ph[i]>max)
max=data_ph[i];
}
for(i=0;i<2048;i++)
{
xViewport=(i+1)*rect.Width()/2048;
yViewport=(0.67*data_ph[i]*rect.Height())/max+10;
pDC->SetPixel(xViewport,rect.Height()-yViewport-1,RGB(255,0,0));
}
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY);
MemBitmap.DeleteObject();
MemDC.DeleteDC();
pDC->DeleteDC();
效果图
寻峰及道指换算
建立工程
1.对左边界建立内向导
voidCxunfengjidaozhihuansuanDlg:
:
Onzuobianjie()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
LButton_Clicked=1;
left_flag=1;
Left_x=x_old;
Left_y=y_old;
}
2.右边界五点寻峰建立内向导
voidCxunfengjidaozhihuansuanDlg:
:
Onyoubianjiewudianxunfeng()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
inti,j,xl,xr,max=0,maxi=0;
floatnewx;
CRectrect1;
CWnd*pWnd=GetDlgItem(IDC_P1);
pWnd->GetWindowRect(rect1);
ScreenToClient(&rect1);
CDC*pDC=pWnd->GetDC();
RButton_Clicked=1;
if(left_flag==1)
{Right_x=x_old;
Right_y=y_old;
//GetDlgItem(IDC_P1)->GetWindowRect(&rect1);
xl=2048*(Left_x-rect1.left)/rect1.Width();
xr=2048*(Right_x-rect1.left)/rect1.Width();
for(i=xl+2;i{
if((data[i]-1.0*sqrt(data[i])>data[i-2])&&(data[i]-1.0*sqrt(data[i])>data[i+2]))
{
for(j=i-2;j
{
if(data[j]>max)
{
max=data[j];
maxi=j;
}
m_e3=maxi;
UpdateData(false);
}
}
}
newx=maxi*rect1.Width()/2048;
CDC*pDC=pWnd->GetDC();
CPenlpen(PS_SOLID,1,RGB(0,0,255));
CPen*pOldPen=pDC->SelectObject(&lpen);
//scale=25.4*10/pDC->GetDeviceCaps(LOGPIXELSX);
pDC->MoveTo(newx,0);
pDC->LineTo(newx,rect1.Height());
lpen.DeleteObject();
}
RButton_Clicked=0;
LButton_Clicked=0;
}
3.左道址建立内向导
voidCxuanfengjidaozhihuansuanDlg:
:
OnZuodaozhi()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
CRectrect1;
intchx;
CWnd*pWnd=GetDlgItem(IDC_P1);
pWnd->GetWindowRect(rect1);
ScreenToClient(&rect1);
chx=2048*(x_old-rect1.left)/rect1.Width();
m_e1=chx;
UpdateData(false);
}
4.右道指建立内向导
voidCxunfengjidaozhihuansuanDlg:
:
OnYoudaozhi()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
CRectrect1;
intchx;
CWnd*pWnd=GetDlgItem(IDC_P1);
pWnd->GetWindowRect(rect1);
ScreenToClient(&rect1);
chx=2048*(x_old-rect1.right)/rect1.Width();
m_e2=chx;
UpdateData(false);
}
显示图谱的结果
五。
求峰面积
建立工作空间
1.读取数据,建立内向导
voidCqiufengmianjiDlg:
:
OnDuqushuju()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
FILE*fp;
intdatanum=0;
inti;
intdata1,data2;
if((fp=fopen("090623.txt","r"))==NULL)
{printf("Cannotopenthefile.\n");
exit(0);
}
while(!
feof(fp))
{
fscanf(fp,"%d%d",&data1,&data2);
data[datanum++]=data2;
fscanf(fp,"\n");
}
for(i=0;i<2048;i++)
{if(i<2||i>2045)
data_ph[i]=data[i];
else
data_ph[i]=(data[i-2]+4*data[i-1]+6*data[i]+4*data[i+1]+data[i+2])*1.0/16.0;
printf("%d%f\n",i+1,data_ph[i]);
}
fclose(fp);
if((fp=fopen("out.txt","w"))==NULL)
{printf("fileopenerror.\n");
exit(0);
}
for(i=0;i<2048;i++)
{fprintf(fp,"%d%f\n",i+1,data_ph[i]);
}
fclose(fp);
}
2.原始图谱,建立内向导
voidCqufengmiangjiDlg:
:
OnYuanshitupu()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
doublexViewport,yViewport;
intmax;
CWnd*pWnd=GetDlgItem(IDC_P1);
CDC*pDC=pWnd->GetDC();
pDC->SetMapMode(MM_ANISOTROPIC);
CRectrect;
doublescale;
GetDlgItem(IDC_P1)->GetWindowRect(&rect);
scale=25.4*10/pDC->GetDeviceCaps(LOGPIXELSX);
CDCMemDC;
CBitmapMemBitmap;
MemDC.CreateCompatibleDC(NULL);
MemBitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
MemDC.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(255,255,255));
max=data[0];
for(inti=1;i<2048;i++)
{
if(data[i]>max)
max=data[i];
}
for(i=0;i<2048;i++)
{
xViewport=(i+1)*rect.Width()/2048;
yViewport=(0.67*data[i]*rect.Height())/max+10;
pDC->SetPixel(xViewport,rect.Height()-yViewport-1,RGB(255,0,0));
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY);
}
MemBitmap.DeleteObject();
MemDC.DeleteDC();
pDC->DeleteDC;
}
3.显示五点平滑图谱。
建立内向导
voidCqiufengmianjiDlg:
:
Onxianshiwudianpinghuatupu()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
doublexViewport,yViewport;
floatmax;
CWnd*pWnd=GetDlgItem(IDC_P2);
CDC*pDC=pWnd->GetDC();
pDC->SetMapMode(MM_ANISOTROPIC);
CRectrect;
doublescale;
GetDlgItem(IDC_P2)->GetWindowRect(&rect);
scale=25.4*10/pDC->GetDeviceCaps(LOGPIXELSX);
CDCMemDC;
CBitmapMemBitmap;
MemDC.