⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unpressctrl.cpp

📁 雷达资料的处理和应用
💻 CPP
字号:
// UnpressCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "FuShe.h"
#include "UnpressCtrl.h"
#include "Reference.h"
#include "math.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CUnpressCtrl dialog


CUnpressCtrl::CUnpressCtrl(CWnd* pParent /*=NULL*/)
	: CDialog(CUnpressCtrl::IDD, pParent)
{
	//{{AFX_DATA_INIT(CUnpressCtrl)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CUnpressCtrl::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUnpressCtrl)
	DDX_Control(pDX, IDC_PROGRESS1, m_Unpress);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUnpressCtrl, CDialog)
	//{{AFX_MSG_MAP(CUnpressCtrl)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUnpressCtrl message handlers

BOOL CUnpressCtrl::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CProgressCtrl *Progress=(CProgressCtrl *)GetDlgItem(IDC_PROGRESS1);
	Progress->SetStep(1);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CUnpressCtrl::UnpressData(CFile *sFile)
{
	unsigned char header[384];
	char strName[13];

	sFile->Read(header,384);    /////读出文件头	
	CString newName=sFile->GetFilePath();
	int Length = newName.GetLength();
		
	//  生成雷达资料文件名(从原来的DAT文件中读出)
	//  并用日期和时间命名,再加上类型“I”、“V”.	    
		 
	if (header[175]==1)
	    wsprintf(strName,"%02d%02d%02d%02d.%02d%s",header[67],header[71],
	         header[75],header[79],header[83],"I");         ///强度场资料
	if (header[175]==2)
	    wsprintf(strName,"%02d%02d%02d%02d.%02d%s",header[67],header[71],
	         header[75],header[79],header[83],"V");		    ///速度场资料
	for (int k=0; k<12; k++ ) 
		newName.SetAt((Length-12+k),strName[k]);  
	if (header[131]==1)
		newName.SetAt(Length-12,'P');                      ///PPI扫描
	if (header[131]==2)
		newName.SetAt(Length-12,'R');                      ///RHI扫描
	
	// Open the new files to save data.
	unsigned char *buff = new unsigned char[260];
			
	CFile pFile(newName,CFile::modeCreate|CFile::modeWrite);
	pFile.Write(header,384);                              ///写文件头
	sFile->Seek(3712L,CFile::current);
	for (int i=0; i<370; i++) {
		sFile->Read(buff,260);
		pFile.Write(buff,4);
		if (header[175]==1)
			for (int j=4; j<260; j++) {			
				unsigned char dbz=CalculateConstant(buff[j],1);
				if(dbz>80)dbz=0;
				pFile.Write(&dbz,1);
			}
		else
			for (int j=4; j<260; j++) {
				char vel=buff[j];
				pFile.Write(&vel,1);
			}
	}
	delete [] buff;

    sFile->Seek(6200L,CFile::current);
	pFile.Close();
}

unsigned char CUnpressCtrl::CalculateConstant(int buffer, int raintype)
{
	double mPower=40.0, loss=9.0, pr, reflectivity;
	double pt=mPower*1e6;
	double tau=0.5*1e-6;
	double f=9.415*1e9;
	double cv=3.0*1e10;
	double G=42.9;
	double zeta=1.97*1e-2;
	double epsilon=2.02*1e-2;
	double E=0.93;
	double Kg=0.01;
	double r=6.4*1e6;
	double nodata=0.0;

	if (buffer>0) {
		if (buffer<=21)
			pr=-142.832+3.474*buffer-0.074*buffer*buffer;
		else 
			pr=-109.1+80.0/255.0*buffer;
		reflectivity=-10.0*log10(PAI*PAI*PAI/pow(2.0,10)/log(2.0))
			-10.0*log10(pt)-10.0*log10(f*f*tau*E/cv)
			-2.0*G-10.0*log10(zeta*epsilon)
			+20.0*log10(r)+120.0+2.0*Kg*r*1e-5+loss+pr;
		if (raintype==0)
			reflectivity=reflectivity+7.2;
	}		
	else		
		reflectivity=nodata;

	return ((unsigned char)reflectivity);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -