Skip to content

Commit faccada

Browse files
adding UTC_offset_hours for array of longitudes
1 parent 9afc440 commit faccada

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=60", "setuptools-scm>=8.0", "wheel"]
33

44
[project]
55
name = "solar_apparent_time"
6-
version = "1.2.0"
6+
version = "1.3.0"
77
description = "methods to translate Python datetime between solar apparent time and Coordinate Universal Time (UTC)"
88
readme = "README.md"
99
authors = [

solar_apparent_time/solar_apparent_time.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Union
2+
13
from datetime import datetime, timedelta
24
import numpy as np
35
import rasters as rt
@@ -28,6 +30,19 @@ def solar_to_UTC(time_solar: datetime, lon: float) -> datetime:
2830
"""
2931
return time_solar - timedelta(hours=(np.radians(lon) / np.pi * 12))
3032

33+
def UTC_offset_hours(lon: Union[float, np.ndarray]) -> Union[float, np.ndarray]:
34+
"""
35+
Calculates the offset in hours from UTC based on the given longitude.
36+
37+
Args:
38+
lon (Union[float, np.ndarray]): The longitude in degrees.
39+
40+
Returns:
41+
Union[float, np.ndarray]: The calculated offset in hours from UTC.
42+
"""
43+
# Convert longitude to radians and calculate the offset in hours from UTC
44+
return np.radians(lon) / np.pi * 12
45+
3146
def UTC_offset_hours_for_area(geometry: rt.RasterGeometry) -> rt.Raster:
3247
"""
3348
Calculates the UTC offset in hours for a given raster geometry.

solar_apparent_time/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.0
1+
1.3.0

0 commit comments

Comments
 (0)