sunRiseSet( lat, lng, UTCoff, date, PLOT)

版本 2.3.0.0 (4.6 KB) 作者: Richard Droste
Compute accurate apparent sunrise, sunset and noon times in seconds, and solar angles
574.0 次下载
更新时间 2017/11/6

查看许可证

Compute refraction-corrected sunrise, sunset and noon times in seconds at a given latitude, longitude and date.
Compute solar elevation, azimuthal and declination angles of the sun at every second of the day.

The code is also hosted on github.com/rdroste/sunRiseSet

USAGE:
sun_rise_set = sunRiseSet( lat, lng, UTCoff, date) Computes the *apparent* (refraction
corrected) sunrise and sunset times in seconds from mignight and returns them as
sun_rise_set. lat and lng are the latitude (+ to N) and longitude (+ to E), UTCoff is the
timezone, i.e. the local time offset to UTC (Coordinated Universal Time) in hours, and date is
the date in format 'dd-mmm-yyyy' ( see below for an example).

[sun_rise_set, noon] = sunRiseSet( lat, lng, UTCoff, date) additionally returns the solar noon
in seconds from midnight.

[sun_rise_set, noon, opt] = sunRiseSet( lat, lng, UTCoff, date) additionally returns the
information opt, which contains information on every second of the day:
opt.elev_ang_corr : Apparent (refraction corrected) solar elevation in degrees
opt.azmt_ang : Solar azimuthal angle (deg cw from N)
opt.solar_decl : Solar declination in degrees

sun_rise_set = sunRiseSet( ..., PLOT) If PLOT is true, plots of the elevation and azimuthal
angle are created.

EXAMPLE:
lat = 47.377037; % Latitude (Zurich, CH)
lng = 8.553952; % Longitude (Zurich, CH)
UTCoff = 2; % UTC offset
date = '15-jun-2017';

[sun_rise_set, noon, opt] = sunRiseSet( lat, lng, UTCoff, date, 1);

Richard Droste

Reverse engineered from the NOAA Excel:
(https://www.esrl.noaa.gov/gmd/grad/solcalc/calcdetails.html)

The formulas are from:
Meeus, Jean H. Astronomical algorithms. Willmann-Bell, Incorporated, 1991.

引用格式

Richard Droste (2024). sunRiseSet( lat, lng, UTCoff, date, PLOT) (https://www.mathworks.com/matlabcentral/fileexchange/62180-sunriseset-lat-lng-utcoff-date-plot), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2016b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Gravitation, Cosmology & Astrophysics 的更多信息
致谢

启发作品: SOLAR_GUI

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
2.3.0.0

Add github repository to the description
- Function now outputs -1 for sunrise or sunset if it is out of the 24h bounds
- Improved the description of the UTC offset input
- Using datenum if daysact is not available
- Eliminated the trigonometric unit conversion where possible

2.2.0.0

Make PLOT input optional

2.1.0.0

Adapted vargout handling and description

2.0.0.0

Updated function description
- Additionally output noon time in seconds and solar declination over the day.
- Improved precision by adaptions in the formulas.
- Improved performance by vectorization.
- Optionally create plots.
Adapted description
Adapted title

1.0.0.0

Replaced "apparent" with "refraction-corrected" for clarification