Skip to content

Commit

Permalink
Fixing docstring structure issue
Browse files Browse the repository at this point in the history
  • Loading branch information
davidorme committed Sep 16, 2024
1 parent c6dd308 commit 8e2d751
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions pyrealm/core/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,29 +129,6 @@ class LocationDateTime:
radians, the Julian days from the date-time information, and a decimal
representation of the local time.
Attributes:
latitude : The latitude of the location in degrees.
latitude_rad : The latitude of the location in radians, calculated
automatically.
longitude : The longitude of the location in degrees.
longitude_rad : The longitude of the location in radians, calculated
automatically.
UTC_offset : The offset from Coordinated Universal Time (UTC) for the
location.
year_date_time : An array of bp.datetime64 values corresponding to observations
at the location.
julian_days : An array of Julian day of the year numbers calculated
from the `year_date_time`.
local_time : An array of local times in decimal hour format
calculated from the `year_date_time`.
Methods:
__post_init__() : Initializes calculated fields like `latitude_rad`,
`longitude_rad`, `julian_days`, and `local_time` after the
object is instantiated.
decimal_hour() : Converts the `year_date_time` to a decimal
representation of hours.
Example:
>>> import numpy as np
>>> ldt = LocationDateTime(
Expand All @@ -167,24 +144,39 @@ class LocationDateTime:
"""

latitude: float
"""The latitude of the location in degrees."""
latitude_rad: float = field(init=False)
"""The latitude of the location in radians, calculated automatically."""
longitude: float
"""The longitude of the location in degrees."""
longitude_rad: float = field(init=False)
"""The longitude of the location in radians, calculated automatically."""
UTC_offset: int
"""The offset from Coordinated Universal Time (UTC) for the location."""
year_date_time: np.ndarray
"""An array of np.datetime64 values corresponding to observations at the
location."""
julian_days: np.ndarray = field(init=False)
"""An array of Julian day of the year numbers calculated from the
``year_date_time``."""
local_time: np.ndarray = field(init=False)
"""An array of Julian day of the year numbers calculated from the
``year_date_time``."""

def __post_init__(self) -> None:
"""Initialise calculated attributes.
Initializes calculated attributes like ``latitude_rad``, ``longitude_rad``,
``julian_days``, and ``local_time`` after the object is instantiated.
"""

self.julian_days = Calendar(self.year_date_time).julian_day
self.local_time = self.decimal_hour()
self.latitude_rad = self.latitude * np.pi / 180
self.longitude_rad = self.longitude * np.pi / 180

def decimal_hour(self) -> np.ndarray:
"""Convert year_date_time to a decimal representation of hours.
.. :no-index:
"""Convert ``year_date_time`` to a decimal representation of hours.
This method extracts the hours and minutes from the `year_date_time` attribute
and converts them into a decimal representation of hours.
Expand Down

0 comments on commit 8e2d751

Please sign in to comment.