📄 sunraiseset.html
字号:
//* lat : latitude of observer in degrees */
//* solarDec : declination angle of sun in degrees */
//* Return value: */
//* hour angle of sunset in radians */
//***********************************************************************/
// 计算落时太阳时角。
function calcHourAngleSunset(lat, solarDec)
{
var latRad = degToRad(lat);
var sdRad = degToRad(solarDec)
var HAarg = (Math.cos(degToRad(90.833))/(Math.cos(latRad)*Math.cos(sdRad))-Math.tan(latRad) * Math.tan(sdRad));
var HA = (Math.acos(Math.cos(degToRad(90.833))/(Math.cos(latRad)*Math.cos(sdRad))-Math.tan(latRad) * Math.tan(sdRad)));
return -HA; // in radians
}
//***********************************************************************/
//* Name: calcSunriseUTC */
//* Type: Function */
//* Purpose: calculate the Universal Coordinated Time (UTC) of sunrise */
//* for the given day at the given location on earth */
//* Arguments: */
//* JD : julian day */
//* latitude : latitude of observer in degrees */
//* longitude : longitude of observer in degrees */
//* Return value: */
//* time in minutes from zero Z */
//***********************************************************************/
// 计算地球上特定位置特定日太阳升起的UTC时间。
function calcSunriseUTC(JD, latitude, longitude)
{
var t = calcTimeJulianCent(JD);
// *** Find the time of solar noon at the location, and use
// that declination. This is better than start of the
// Julian day
var noonmin = calcSolNoonUTC(t, longitude);
var tnoon = calcTimeJulianCent (JD+noonmin/1440.0);
// *** First pass to approximate sunrise (using solar noon)
var eqTime = calcEquationOfTime(tnoon);
var solarDec = calcSunDeclination(tnoon);
var hourAngle = calcHourAngleSunrise(latitude, solarDec);
var delta = longitude - radToDeg(hourAngle);
var timeDiff = 4 * delta; // in minutes of time
var timeUTC = 720 + timeDiff - eqTime; // in minutes
// alert("eqTime = " + eqTime + "\nsolarDec = " + solarDec + "\ntimeUTC = " + timeUTC);
// *** Second pass includes fractional jday in gamma calc
var newt = calcTimeJulianCent(calcJDFromJulianCent(t) + timeUTC/1440.0);
eqTime = calcEquationOfTime(newt);
solarDec = calcSunDeclination(newt);
hourAngle = calcHourAngleSunrise(latitude, solarDec);
delta = longitude - radToDeg(hourAngle);
timeDiff = 4 * delta;
timeUTC = 720 + timeDiff - eqTime; // in minutes
// alert("eqTime = " + eqTime + "\nsolarDec = " + solarDec + "\ntimeUTC = " + timeUTC);
return timeUTC;
}
//***********************************************************************/
//* Name: calcSolNoonUTC */
//* Type: Function */
//* Purpose: calculate the Universal Coordinated Time (UTC) of solar */
//* noon for the given day at the given location on earth */
//* Arguments: */
//* t : number of Julian centuries since J2000.0 */
//* longitude : longitude of observer in degrees */
//* Return value: */
//* time in minutes from zero Z */
//***********************************************************************/
// 计算地球上特定位置特定日的视中午UTC时间。
function calcSolNoonUTC(t, longitude)
{
// First pass uses approximate solar noon to calculate eqtime
var tnoon = calcTimeJulianCent(calcJDFromJulianCent(t) + longitude/360.0);
var eqTime = calcEquationOfTime(tnoon);
var solNoonUTC = 720 + (longitude * 4) - eqTime; // min
var newt = calcTimeJulianCent(calcJDFromJulianCent(t) -0.5 + solNoonUTC/1440.0);
eqTime = calcEquationOfTime(newt);
// var solarNoonDec = calcSunDeclination(newt);
solNoonUTC = 720 + (longitude * 4) - eqTime; // min
return solNoonUTC;
}
//***********************************************************************/
//* Name: calcSunsetUTC */
//* Type: Function */
//* Purpose: calculate the Universal Coordinated Time (UTC) of sunset */
//* for the given day at the given location on earth */
//* Arguments: */
//* JD : julian day */
//* latitude : latitude of observer in degrees */
//* longitude : longitude of observer in degrees */
//* Return value: */
//* time in minutes from zero Z */
//***********************************************************************/
// 计算地球上特定位置特定日太阳落下的UTC时间。
function calcSunsetUTC(JD, latitude, longitude)
{
var t = calcTimeJulianCent(JD);
// *** Find the time of solar noon at the location, and use
// that declination. This is better than start of the
// Julian day
var noonmin = calcSolNoonUTC(t, longitude);
var tnoon = calcTimeJulianCent (JD+noonmin/1440.0);
// First calculates sunrise and approx length of day
var eqTime = calcEquationOfTime(tnoon);
var solarDec = calcSunDeclination(tnoon);
var hourAngle = calcHourAngleSunset(latitude, solarDec);
var delta = longitude - radToDeg(hourAngle);
var timeDiff = 4 * delta;
var timeUTC = 720 + timeDiff - eqTime;
// first pass used to include fractional day in gamma calc
var newt = calcTimeJulianCent(calcJDFromJulianCent(t) + timeUTC/1440.0);
eqTime = calcEquationOfTime(newt);
solarDec = calcSunDeclination(newt);
hourAngle = calcHourAngleSunset(latitude, solarDec);
delta = longitude - radToDeg(hourAngle);
timeDiff = 4 * delta;
timeUTC = 720 + timeDiff - eqTime; // in minutes
return timeUTC;
}
//*********************************************************************/
// Returns the decimal latitude from the degrees, minutes and seconds entered
// into the form
// 根据表单输入的度数、分、秒获取十进制的纬度。
function getLatitude(latLongForm)
{
var neg = 0;
var strLatDeg = latLongForm["latDeg"].value;
var degs = parseFloat(latLongForm["latDeg"].value);
if (latLongForm["latDeg"].value.charAt(0) == '-')
{
neg = 1;
}
if (strLatDeg.indexOf(".") != -1)
{
latLongForm["latMin"].value = 0;
latLongForm["latSec"].value = 0;
}
if(latLongForm["latMin"].value == "")
{
latLongForm["latMin"].value = 0;
}
if(latLongForm["latSec"].value == "")
{
latLongForm["latSec"].value = 0;
}
var mins = parseFloat(latLongForm["latMin"].value);
var secs = parseFloat(latLongForm["latSec"].value);
if(neg != 1)
{
var decLat = degs + (mins / 60) + (secs / 3600);
} else if(neg == 1)
{
var decLat = degs - (mins / 60) - (secs / 3600);
} else
{
return -9999;
}
return decLat;
}
//*********************************************************************/
// Returns the decimal longitude from the degrees, minutes and seconds entered into the form
// 根据表单输入的度、分、秒获取十进制的经度。
function getLongitude(latLongForm)
{
var neg = 0;
var strLonDeg = latLongForm["lonDeg"].value;
var degs = parseFloat(latLongForm["lonDeg"].value);
if (latLongForm["lonDeg"].value.charAt(0) == '-')
{
neg = 1;
}
if (strLonDeg.indexOf(".") != -1)
{
latLongForm["lonMin"].value = 0;
latLongForm["lonSec"].value = 0;
}
if(latLongForm["lonMin"].value == "")
{
latLongForm["lonMin"].value = 0;
}
if(latLongForm["lonSec"].value == "")
{
latLongForm["lonSec"].value = 0;
}
var mins = parseFloat(latLongForm["lonMin"].value);
var secs = parseFloat(latLongForm["lonSec"].value);
var decLon = degs + (mins / 60) + (secs / 3600);
if(neg != 1)
{
var decLon = degs + (mins / 60) + (secs / 3600);
} else if(neg == 1)
{
var decLon = degs - (mins / 60) - (secs / 3600);
} else
{
return -9999;
}
return decLon;
}
//***********************************************************************/
//* Name: findRecentSunrise */
//* Type: Function */
//* Purpose: calculate the julian day of the most recent sunrise */
//* starting from the given day at the given location on earth */
//* Arguments: */
//* JD : julian day */
//* latitude : latitude of observer in degrees */
//* longitude : longitude of observer in degrees */
//* Return value: */
//* julian day of the most recent sunrise */
//***********************************************************************/
// 搜寻地球上特定位置给定日期以来最近的日出儒略日。
function findRecentSunrise(jd, latitude, longitude)
{
var julianday = jd;
var time = calcSunriseUTC(julianday, latitude, longitude);
while(!isNumber(time)){
julianday -= 1.0;
time = calcSunriseUTC(julianday, latitude, longitude);
}
return julianday;
}
//***********************************************************************/
//* Name: findRecentSunset */
//* Type: Function */
//* Purpose: calculate the julian day of the most recent sunset */
//* starting from the given day at the given location on earth */
//* Arguments: */
//* JD : julian day */
//* latitude : latitude of observer in degrees */
//* longitude : longitude of observer in degrees */
//* Return value: */
//* julian day of the most recent sunset */
//***********************************************************************/
// 搜寻地球上特定位置给定日期以来最近的日落儒略日。
function findRecentSunset(jd, latitude, longitude)
{
var julianday = jd;
var time = calcSunsetUTC(julianday, latitude, longitude);
while(!isNumber(time)){
julianday -= 1.0;
time = calcSunsetUTC(julianday, latitude, longitude);
}
return julianday;
}
//***********************************************************************/
//* Name: findNextSunrise */
//* Type: Function */
//* Purpose: calculate the julian day of the next sunrise */
//* starting from the given day at the given location on earth */
//* Arguments: */
//* JD : julian day */
//* latitude : latitude of observer in degrees */
//* longitude : longitude of observer in degrees */
//* Return value: */
//* julian day of the next sunrise */
//***********************************************************************/
// 搜寻地球上特定位置给定日期以来下一个的日出儒略日。
function findNextSunrise(jd, latitude, longitude)
{
var julianday = jd;
var time = calcSunriseUTC(julianday, latitude, longitude);
while(!isNumber(time)){
julianday += 1.0;
time = calcSunriseUTC(julianday, latitude, longitude);
}
return julianday;
}
//***********************************************************************/
//* Name: findNextSunset */
//* Type: Function */
//* Purpose: calculate the julian day of the next sunset */
//* starting from the given day at the given location on earth */
//* Arguments: */
//* JD : julian day */
//* latitude : latitude of observer in degrees */
//* longitude : longitude of observer in degrees */
//* Return value: */
//* julian day of the next sunset */
//***********************************************************************/
// 搜寻地球上特定位置给定日期以来下一个的日落儒略日。
function findNextSunset(jd, latitude, longitude)
{
var julianday = jd;
var time = calcSunsetUTC(julianday, latitude, longitude);
while(!isNumber(time)){
julianday += 1.0;
time = calcSunsetUTC(julianday, latitude, longitude);
}
return julianday;
}
//***********************************************************************/
//* Name: timeString */
//* Type: Function */
//* Purpose: convert time of day in minutes to a zero-padded string suitable for printing to the form text fields */
//* Arguments: */
//* minutes : time of day in minutes */
//* Return value: */
//* string of the format HH:MM:SS, minutes and seconds are zero padded*/
//***********************************************************************/
// 将分钟转换成HH:MM:SS格式。
function timeString(minutes)
// timeString returns a zero-padded string (HH:MM:SS) given time in minutes
{
var floatHour = minutes / 60.0;
var hour = Math.floor(floatHour);
var floatMinute = 60.0 * (floatHour - Math.floor(floatHour));
var minute = Math.floor(floatMinute);
var floatSec = 60.0 * (floatMinute - Math.floor(floatMinute));
var second = Math.floor(floatSec + 0.5);
var timeStr = hour + ":";
if (minute < 10) // i.e. only one digit
timeStr += "0" + minute + ":";
else
timeStr += minute + ":";
if (second < 10) // i.e. only one digit
timeStr += "0" + second;
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -