(self, event: str, lat: int | float, lon: int | float, **
kwargs: Any)
| 790 | } |
| 791 | |
| 792 | def __init__(self, event: str, lat: int | float, lon: int | float, ** |
| 793 | kwargs: Any) -> None: |
| 794 | self.ephem = __import__('ephem') |
| 795 | self.event = event |
| 796 | self.lat = lat |
| 797 | self.lon = lon |
| 798 | super().__init__(**kwargs) |
| 799 | |
| 800 | if event not in self._all_events: |
| 801 | raise ValueError(SOLAR_INVALID_EVENT.format( |
| 802 | event=event, all_events=', '.join(sorted(self._all_events)), |
| 803 | )) |
| 804 | if lat < -90 or lat > 90: |
| 805 | raise ValueError(SOLAR_INVALID_LATITUDE.format(lat=lat)) |
| 806 | if lon < -180 or lon > 180: |
| 807 | raise ValueError(SOLAR_INVALID_LONGITUDE.format(lon=lon)) |
| 808 | |
| 809 | cal = self.ephem.Observer() |
| 810 | cal.lat = str(lat) |
| 811 | cal.lon = str(lon) |
| 812 | cal.elev = 0 |
| 813 | cal.horizon = self._horizons[event] |
| 814 | cal.pressure = 0 |
| 815 | self.cal = cal |
| 816 | |
| 817 | self.method = self._methods[event] |
| 818 | self.use_center = self._use_center_l[event] |
| 819 | |
| 820 | def __reduce__(self) -> tuple[type, tuple[str, int | float, int | float]]: |
| 821 | return self.__class__, (self.event, self.lat, self.lon) |
no test coverage detected