(User.programs) Item: 83 by _ckluepfel at hpcvbbs.UUCP Author: [Charles Kluepfel] Subj: sunrise/sunset Date: Wed Jun 13 1990 21:03 The attached file, SUNRSET, can be sent to HP-48SX to be a subdirectory to find times of sunrise and sunset. The same programs will work on 28C or 28S. Ordinarily time of sunrise/set does not depend on the particular year, so entry is numeric month, space or comma, numeric day, followed by SRSS. The year is extracted by converting the JD (days elapsed since beginning of 4713 BC in the Julian calendar) to a Gregorian date. The one currently stored is 2448248, which is in 1990. The major effect of a particular year is in determining when daylight saving time is effective, which is taken by this program to be the first sunday in April to the last sunday in October. To change year, type month day year INDAT. The set of programs presented here is from a larger group, in which full dates are needed. Here, we just want to set the year, but month and day are needed for entry. It is necessary to customize for a location and also for the particular meaning of sunrise/set you have in mind. Currently the constants are set for New York City. The latitude is stored in LAT, here 40.75 decimal degrees. DL0 number of degrees west of the time zone meridian the location is. As New York City is 1 degree EAST of the 75th (Eastern Time) meridian, a -1 is stored here currently. DL1 is to get a value of 15 more than DL0 unless the location does not go on daylight saving time, in which case DL1 gets the same value as DL0. The variable DLONG gets set automatically during calculation to one of these depending on the time of year. Remember, that's a zero at the end of DL0, not a letter O. Currently ALT is set to -.75, meaning that the center of the sun is taken to be at theoretical .75 degrees below the horizon at sunrise/set. Due to atmospheric refraction and the .25- degree radius of the sun, this results in the topmost edge of the solar disk just grazing the flat horizon. If you want the visible disk bisected by the horizon, use -.5 instead of the -.75. This takes care of just atmospheric refraction. Before the program proceeds to show the calculated sunrise and set, it reminds you of the altitude and latitude that have been set, and the delta longitude. Press any, key, such as NXT, to get the calculation, showing up as strings in levels 2 and 1. As a subsidiary benefit the \->JD and JD\-> functions can be used to calculate days between dates and the date after an interval. They require dates that are within lists, as {6 30 1990}. Pressing JD\-> on this, gives 2448073, while the same function on {12 31 1989} gives 2447891, and subtraction gives 182 as the day of the year. As there is no input error checking, entry of {1 0 1990} will give the same result as {12 31 1989}. To go forward (backward) from a given date use \->JD then add (subtract) the desired number of days; then use JD\-> to get the desired Gregorian calendar date. -Charles Kluepfel 11 George St Bloomfield, NJ 07003