📄 solarradiation.cpp
字号:
///////////////////////////////////////////////////////////
// //
// SAGA //
// //
// System for Automated Geoscientific Analyses //
// //
// Module Library: //
// ta_lighting //
// //
//-------------------------------------------------------//
// //
// SolarRadiation.cpp //
// //
// Copyright (C) 2003 by //
// Olaf Conrad //
// //
//-------------------------------------------------------//
// //
// This file is part of 'SAGA - System for Automated //
// Geoscientific Analyses'. SAGA is free software; you //
// can redistribute it and/or modify it under the terms //
// of the GNU General Public License as published by the //
// Free Software Foundation; version 2 of the License. //
// //
// SAGA is distributed in the hope that it will be //
// useful, but WITHOUT ANY WARRANTY; without even the //
// implied warranty of MERCHANTABILITY or FITNESS FOR A //
// PARTICULAR PURPOSE. See the GNU General Public //
// License for more details. //
// //
// You should have received a copy of the GNU General //
// Public License along with this program; if not, //
// write to the Free Software Foundation, Inc., //
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
// USA. //
// //
//-------------------------------------------------------//
// //
// e-mail: oconrad@saga-gis.org //
// //
// contact: Olaf Conrad //
// Institute of Geography //
// University of Goettingen //
// Goldschmidtstr. 5 //
// 37077 Goettingen //
// Germany //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
#include "SolarRadiation.h"
#include "HillShade.h"
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
CSolarRadiation::CSolarRadiation(void)
{
CSG_Parameter *pNode_0, *pNode_1, *pNode_2;
//-----------------------------------------------------
Set_Name(_TL("Incoming Solar Radiation"));
Set_Author(_TL("Copyrights (c) 2001 by Olaf Conrad"));
Set_Description (_TW(
"Calculation of the potential incoming solar radiation.\n\n"
"Reference:\n"
"- Wilson, J.P., Gallant, J.C., (Eds.), 2000:\n"
" 'Terrain analysis - principles and applications',\n"
" New York, John Wiley & Sons, Inc.")
);
//-----------------------------------------------------
pNode_0 = Parameters.Add_Grid(
NULL , "ELEVATION" , _TL("Elevation"),
_TL(""),
PARAMETER_INPUT
);
//-----------------------------------------------------
pNode_0 = Parameters.Add_Grid(
NULL , "INSOLAT" , _TL("Solar Radiation"),
_TL(""),
PARAMETER_OUTPUT
);
pNode_0 = Parameters.Add_Grid(
NULL , "DURATION" , _TL("Duration of Insolation"),
_TL(""),
PARAMETER_OUTPUT
);
pNode_1 = Parameters.Add_Value(
pNode_0 , "UPDATE" , _TL("Update View"),
_TL("Show each time step during calculation."),
PARAMETER_TYPE_Bool , true
);
pNode_1 = Parameters.Add_Choice(
pNode_0 , "UNIT" , _TL("Unit"),
_TL(""),
CSG_String::Format(SG_T("%s|%s|"),
_TL("kWh/m\xc2\xb2"),
_TL("J/m\xc2\xb2")
), 0
);
//-----------------------------------------------------
pNode_0 = Parameters.Add_Node(
NULL , "NODE_SOLAR" , _TL("Solar Radiation"),
_TL("")
);
pNode_1 = Parameters.Add_Value(
pNode_0 , "SOLCONST" , _TL("Solar Constant [W/m\xc2\xb2]"),
_TL(""),
PARAMETER_TYPE_Double , 1367
);
pNode_1 = Parameters.Add_Choice(
pNode_0 , "METHOD" , _TL("Atmospheric Effects"),
_TL("Account for atmospheric effects using either a lumped atmospheric transmittance approach or by calculating the components (water and dust)."),
CSG_String::Format(SG_T("%s|%s|"),
_TL("Lumped atmospheric transmittance"),
_TL("Calculating the components")
), 0
);
pNode_1 = Parameters.Add_Value(
pNode_0 , "TRANSMITT" , _TL("Lumped Transmittance [%]"),
_TL("The transmittance of the atmosphere (usually between 60 and 80%)"),
PARAMETER_TYPE_Double , 70,
0.0 , true,
100.0 , true
);
pNode_1 = Parameters.Add_Value(
pNode_0 , "PRESSURE" , _TL("Atmospheric Pressure [mb]"),
_TL(""),
PARAMETER_TYPE_Double , 1013,
0.0 , true
);
pNode_1 = Parameters.Add_Value(
pNode_0 , "WATER" , _TL("Water Content [cm]"),
_TL("Water content of a vertical slice of atmosphere in cm: 1.5 to 1.7, average=1.68"),
PARAMETER_TYPE_Double , 1.68,
0.0 , true
);
pNode_1 = Parameters.Add_Value(
pNode_0 , "DUST" , _TL("Dust [ppm]"),
_TL("Dust factor: 100 ppm (standard)"),
PARAMETER_TYPE_Double , 100,
0.0 , true
);
pNode_1 = Parameters.Add_Value(
pNode_0 , "LATITUDE" , _TL("Latitude [Degree]"),
_TL(""),
PARAMETER_TYPE_Double , 53.5,
-90.0 , true,
90.0 , true
);
//-----------------------------------------------------
// Daily Time Resolution...
pNode_0 = Parameters.Add_Node(
NULL , "NODE_HOUR" , _TL("Daily Time Resolution"),
_TL("")
);
pNode_1 = Parameters.Add_Range(
pNode_0 , "HOUR_RANGE" , _TL("Time Span [h]"),
_TL("Time span used for the calculation of daily radiation sums."),
0.0 , 24.0,
0.0 , true,
24.0 , true
);
pNode_1 = Parameters.Add_Value(
pNode_0 , "HOUR_STEP" , _TL("Time Step [h]"),
_TL("Time step size used for the calculation of daily radiation sums."),
PARAMETER_TYPE_Double , 1.0,
0.001 , true,
12.0 , true
);
//-----------------------------------------------------
// Time Settings...
pNode_0 = Parameters.Add_Choice(
NULL , "TIMESPAN" , _TL("Simulation Time"),
_TL(""),
CSG_String::Format(SG_T("%s|%s|%s|"),
_TL("Single Day"),
_TL("Range of Days"),
_TL("One Year")
), 0
);
//-----------------------------------------------------
pNode_1 = Parameters.Add_Node(
pNode_0 , "NODE_SINGLE_DAY" , _TL("Single Day"),
_TL("")
);
pNode_2 = Parameters.Add_Choice(
pNode_1 , "SINGLE_DAY_DAY" , _TL("Day"),
_TL(""),
SG_T(" 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|")
SG_T(" 11| 12| 13| 14| 15| 16| 17| 18| 19| 20|")
SG_T(" 21| 22| 23| 24| 25| 26| 27| 28| 29| 30|")
SG_T(" 31|"), 20
);
pNode_2 = Parameters.Add_Choice(
pNode_1 , "SINGLE_DAY_MONTH" , _TL("Month"),
_TL(""),
CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"),
_TL("January"),
_TL("February"),
_TL("March"),
_TL("April"),
_TL("May"),
_TL("June"),
_TL("July"),
_TL("August"),
_TL("September"),
_TL("October"),
_TL("November"),
_TL("December")
), 2
);
//-----------------------------------------------------
// Range of Days...
pNode_1 = Parameters.Add_Node(
pNode_0 , "NODE_DAY_RANGE" , _TL("Range of Days"),
_TL("")
);
pNode_2 = Parameters.Add_Range(
pNode_1 , "DAY_RANGE" , _TL("Time Span [day of year]"),
_TL(""),
1 , 31,
-365 , true,
366 , true
);
pNode_2 = Parameters.Add_Value(
pNode_1 , "DAY_STEP" , _TL("Time Step [number of days]"),
_TL(""),
PARAMETER_TYPE_Int, 5,
1 , true,
100 , true
);
}
//---------------------------------------------------------
CSolarRadiation::~CSolarRadiation(void)
{}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
bool CSolarRadiation::On_Execute(void)
{
static const int Month2Day[12] = { 0, 31, 49, 80, 109, 140, 170, 201, 232, 272, 303, 333 };
//-----------------------------------------------------
int Day_Step, Day_Start, Day_Stop;
double Latitude, Hour_Step, Hour_Start, Hour_Stop;
CSG_Colors Colors;
//-----------------------------------------------------
m_pDTM = Parameters("ELEVATION") ->asGrid();
m_pRadiation = Parameters("INSOLAT") ->asGrid();
m_pDuration = Parameters("DURATION") ->asGrid();
m_SolarConstant = Parameters("SOLCONST") ->asDouble() / 1000.0; // [kW / m瞉
m_Method = Parameters("METHOD") ->asInt();
m_Transmittance = Parameters("TRANSMITT") ->asDouble() / 100.0;
m_Pressure = Parameters("PRESSURE") ->asDouble();
m_Water = Parameters("WATER") ->asDouble();
m_Dust = Parameters("DUST") ->asDouble();
Latitude = Parameters("LATITUDE") ->asDouble() * M_DEG_TO_RAD;
Day_Step = Parameters("DAY_STEP") ->asInt();
Hour_Step = Parameters("HOUR_STEP") ->asDouble();
Hour_Start = Parameters("HOUR_RANGE") ->asRange()->Get_LoVal();
Hour_Stop = Parameters("HOUR_RANGE") ->asRange()->Get_HiVal();
//-----------------------------------------------------
m_pSum = SG_Create_Grid(m_pDTM);
//-----------------------------------------------------
switch( Parameters("TIMESPAN")->asInt() )
{
case 0: // single day...
Day_Start = Parameters("SINGLE_DAY_MONTH")->asInt();
Day_Start = Parameters("SINGLE_DAY_DAY") ->asInt() + (Day_Start >= 0 && Day_Start < 12 ? Month2Day[Day_Start] : 0);
Execute_DailySum (Latitude, Hour_Step, Hour_Start, Hour_Stop, Day_Start);
break;
case 1: // range of days...
Day_Start = (int)Parameters("DAY_RANGE") ->asRange()->Get_LoVal() - 1;
Day_Stop = (int)Parameters("DAY_RANGE") ->asRange()->Get_HiVal() - 1;
Execute_SumOfDays(Latitude, Hour_Step, Hour_Start, Hour_Stop, Day_Step, Day_Start, Day_Stop);
break;
case 2: // one year...
Day_Start = -10; // winter solstitute...
Day_Stop = 173; // until half year has passed...
Execute_SumOfDays(Latitude, Hour_Step, Hour_Start, Hour_Stop, Day_Step, Day_Start, Day_Stop);
*m_pRadiation *= 2.0; // two times...
*m_pDuration *= 2.0; // two times...
break;
}
//-----------------------------------------------------
delete( m_pSum );
Colors.Set_Count(100);
Colors.Set_Ramp(SG_GET_RGB( 0, 0, 64), SG_GET_RGB(255, 159, 0), 0, 50);
Colors.Set_Ramp(SG_GET_RGB(255, 159, 0), SG_GET_RGB(255, 255, 255), 50, 99);
DataObject_Set_Colors(m_pRadiation, Colors);
DataObject_Set_Colors(m_pDuration , Colors);
m_pDuration->Set_Unit(_TL("h"));
if( Parameters("UNIT")->asInt() == 1 ) // Joule...
{
*m_pRadiation *= 10.0 / 36.0; // 1 J = 1 Ws = 1/(60*60) Wh = 1/3600 Wh >> 1 J = 1000/3600 kWh = 10/36 kWh
m_pRadiation->Set_Unit(_TL("J/m\xc2\xb2"));
}
else
{
m_pRadiation->Set_Unit(_TL("kWh/m\xc2\xb2"));
}
//-----------------------------------------------------
return( true );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
void CSolarRadiation::Execute_DailySum(double Latitude_RAD, double Hour_Step, double Hour_Start, double Hour_Stop, int Day)
{
Get_DailySum(Latitude_RAD, Hour_Step, Hour_Start, Hour_Stop, Day);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -