solarmoonpy 1.0.6__tar.gz → 1.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: solarmoonpy
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: Precise solar and lunar calculations for astronomical applications
5
5
  Author-email: figorr <jdcuartero@yahoo.es>
6
6
  License: Apache License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "solarmoonpy"
7
- version = "1.0.6"
7
+ version = "1.0.7"
8
8
  description = "Precise solar and lunar calculations for astronomical applications"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "figorr", email = "jdcuartero@yahoo.es" }]
@@ -1,7 +1,7 @@
1
1
  from dataclasses import dataclass
2
2
  from datetime import date, datetime, timezone
3
3
  from zoneinfo import ZoneInfo
4
- from typing import Optional, Union, Literal
4
+ from typing import Optional, Union, Literal, Dict
5
5
 
6
6
  from .sun import sunrise_sunset, noon, dawn, dusk, midnight # Importar funciones de sun.py
7
7
 
@@ -257,57 +257,6 @@ class Location:
257
257
  date=date,
258
258
  timezone=self.tzinfo if local else timezone.utc
259
259
  )
260
-
261
- def sun_events(
262
- self,
263
- date: Optional[date] = None,
264
- local: bool = True,
265
- elevation: Optional[float] = None
266
- ) -> dict:
267
- """
268
- Devuelve un diccionario con sunrise, noon y sunset para una fecha dada.
269
-
270
- Args:
271
- date: Fecha para la cual calcular los eventos solares. Si es None, usa la fecha actual.
272
- local: True para devolver las horas en la zona horaria local, False para UTC.
273
- elevation: Elevación del observador en metros. Si es None, usa self.elevation.
274
-
275
- Returns:
276
- dict: {
277
- "sunrise": datetime,
278
- "noon": datetime,
279
- "sunset": datetime
280
- }
281
- """
282
- if local and self.timezone is None:
283
- raise ValueError("Se solicitó hora local pero no se definió una zona horaria.")
284
-
285
- tz = self.tzinfo if local else timezone.utc
286
- date = date or datetime.now(tz).date()
287
- elevation = elevation if elevation is not None else self.elevation
288
-
289
- # Calcular amanecer y atardecer
290
- sunrise, sunset = sunrise_sunset(
291
- latitude=self.latitude,
292
- longitude=self.longitude,
293
- date=date,
294
- elevation=elevation,
295
- timezone=tz,
296
- with_refraction=True,
297
- )
298
-
299
- # Calcular mediodía solar
300
- noon_time = noon(
301
- longitude=self.longitude,
302
- date=date,
303
- timezone=tz,
304
- )
305
-
306
- return {
307
- "sunrise": sunrise,
308
- "noon": noon_time,
309
- "sunset": sunset,
310
- }
311
260
 
312
261
  def dawn(
313
262
  self,
@@ -372,4 +321,139 @@ class Location:
372
321
  longitude=self.longitude,
373
322
  date=date,
374
323
  timezone=self.tzinfo if local else timezone.utc
375
- )
324
+ )
325
+
326
+ def sun_events(
327
+ self,
328
+ date: Optional[date] = None,
329
+ local: bool = True,
330
+ elevation: Optional[float] = None,
331
+ ) -> Dict:
332
+ """
333
+ Devuelve un diccionario con los eventos solares para una fecha dada, incluyendo todos los tipos de crepúsculo.
334
+
335
+ Args:
336
+ date: Fecha para la cual calcular los eventos solares. Si es None, usa la fecha actual.
337
+ local: True para devolver las horas en la zona horaria local, False para UTC.
338
+ elevation: Elevación del observador en metros. Si es None, usa self.elevation.
339
+
340
+ Returns:
341
+ dict: {
342
+ "dawn_civil": datetime | None,
343
+ "dawn_nautical": datetime | None,
344
+ "dawn_astronomical": datetime | None,
345
+ "sunrise": datetime,
346
+ "noon": datetime,
347
+ "sunset": datetime,
348
+ "dusk_civil": datetime | None,
349
+ "dusk_nautical": datetime | None,
350
+ "dusk_astronomical": datetime | None,
351
+ "midnight": datetime,
352
+ "daylight_duration": float | None
353
+ }
354
+ """
355
+ if local and self.timezone is None:
356
+ raise ValueError("Se solicitó hora local pero no se definió una zona horaria.")
357
+
358
+ tz = self.tzinfo if local else timezone.utc
359
+ date = date or datetime.now(tz).date()
360
+ elevation = elevation if elevation is not None else self.elevation
361
+
362
+ # Calcular amanecer y atardecer
363
+ sunrise, sunset = sunrise_sunset(
364
+ latitude=self.latitude,
365
+ longitude=self.longitude,
366
+ date=date,
367
+ elevation=elevation,
368
+ timezone=tz,
369
+ with_refraction=True,
370
+ )
371
+
372
+ # Calcular mediodía solar
373
+ noon_time = noon(
374
+ longitude=self.longitude,
375
+ date=date,
376
+ timezone=tz,
377
+ )
378
+
379
+ # Calcular medianoche solar
380
+ midnight_time = midnight(
381
+ longitude=self.longitude,
382
+ date=date,
383
+ timezone=tz,
384
+ )
385
+
386
+ # Calcular duración del día (en horas)
387
+ daylight_duration = None
388
+ if sunrise and sunset:
389
+ daylight_duration = (sunset - sunrise).total_seconds() / 3600
390
+
391
+ # Calcular dawn y dusk para cada tipo de crepúsculo
392
+ dawn_civil = dawn(
393
+ latitude=self.latitude,
394
+ longitude=self.longitude,
395
+ date=date,
396
+ twilight_type="civil",
397
+ elevation=elevation,
398
+ timezone=tz,
399
+ with_refraction=True,
400
+ )
401
+ dusk_civil = dusk(
402
+ latitude=self.latitude,
403
+ longitude=self.longitude,
404
+ date=date,
405
+ twilight_type="civil",
406
+ elevation=elevation,
407
+ timezone=tz,
408
+ with_refraction=True,
409
+ )
410
+ dawn_nautical = dawn(
411
+ latitude=self.latitude,
412
+ longitude=self.longitude,
413
+ date=date,
414
+ twilight_type="nautical",
415
+ elevation=elevation,
416
+ timezone=tz,
417
+ with_refraction=True,
418
+ )
419
+ dusk_nautical = dusk(
420
+ latitude=self.latitude,
421
+ longitude=self.longitude,
422
+ date=date,
423
+ twilight_type="nautical",
424
+ elevation=elevation,
425
+ timezone=tz,
426
+ with_refraction=True,
427
+ )
428
+ dawn_astronomical = dawn(
429
+ latitude=self.latitude,
430
+ longitude=self.longitude,
431
+ date=date,
432
+ twilight_type="astronomical",
433
+ elevation=elevation,
434
+ timezone=tz,
435
+ with_refraction=True,
436
+ )
437
+ dusk_astronomical = dusk(
438
+ latitude=self.latitude,
439
+ longitude=self.longitude,
440
+ date=date,
441
+ twilight_type="astronomical",
442
+ elevation=elevation,
443
+ timezone=tz,
444
+ with_refraction=True,
445
+ )
446
+
447
+ return {
448
+ "dawn_civil": dawn_civil,
449
+ "dawn_nautical": dawn_nautical,
450
+ "dawn_astronomical": dawn_astronomical,
451
+ "sunrise": sunrise,
452
+ "noon": noon_time,
453
+ "sunset": sunset,
454
+ "dusk_civil": dusk_civil,
455
+ "dusk_nautical": dusk_nautical,
456
+ "dusk_astronomical": dusk_astronomical,
457
+ "midnight": midnight_time,
458
+ "daylight_duration": daylight_duration,
459
+ }
@@ -0,0 +1,2 @@
1
+ # version.py
2
+ __version__ = "1.0.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: solarmoonpy
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: Precise solar and lunar calculations for astronomical applications
5
5
  Author-email: figorr <jdcuartero@yahoo.es>
6
6
  License: Apache License
@@ -1,2 +0,0 @@
1
- # version.py
2
- __version__ = "1.0.6"
File without changes
File without changes
File without changes