Calculate Sunrise and Sunset Time (sunrise)
Calculate sunrise and sunset time, day length, and night length based on location and date.
Calculate Sunrise and Sunset Time
Purpose
This function calculates and returns the sunrise and sunset times for a given location and date. It also provides the length of the day and night.
Use Cases
- Plan outdoor activities based on daylight hours
- Know when it's safe to be outside during sunrise and sunset
How to Use
- Enter the latitude and longitude of your location
- Select the date you want to calculate the sunrise and sunset times for
- Choose the time zone of your location
Input Values
- Latitude: The north-south position of your location
- Default unit is degrees
- Longitude: The east-west position of your location
- Default unit is degrees
- Elevation: The height above sea level of your location
- Default unit is feet
- On Date: The date for which you want to calculate sunrise and sunset times
- Time Zone: The time zone of your location
Output Values
- Sunrise: The time when the sun rises
- Sunset: The time when the sun sets
- Day Length: The duration of daylight hours
- Unit of measurement: hours
- Night Length: The duration of nighttime hours
- Unit of measurement: hours
Any other Instruction
- Make sure to enter the correct latitude, longitude, and time zone for accurate results
- Check the date to ensure you are calculating sunrise and sunset times for the correct day
Code Analysis
- The function calculates the sunrise and sunset times based on the provided latitude, longitude, elevation, date, and time zone.
- It uses the EarthRotation class to determine the sunrise and sunset times.
- The function returns the sunrise time, sunset time, day length, and night length.
Technical Parameters
latitude, longitude, elevation, on_date, time_zone
Return Values
sunrise, sunset, day_length, night_length
Example Expressions
You can use the following expressions to directly evaluate in a non-interactive manner using eval():
- Calculate sunrise and sunset for New York on July 1st, 2022:
sunrise(latitude='40.7128 deg', longitude='-74.0060 deg', elevation='0.0 ft', on_date=date(2022, 7, 1), time_zone='EST')
- Calculate sunrise and sunset for Sydney on December 25th, 2022:
sunrise(latitude='-33.8688 deg', longitude='151.2093 deg', elevation='0.0 ft', on_date=date(2022, 12, 25), time_zone='AEST')
Click on Help icon to open the help page on a separate window.