A library that computes the ephemerides.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

72 lignes
1.9 KiB

  1. #!/usr/bin/env python3
  2. # Kosmorrolib - The Library To Compute Your Ephemerides
  3. # Copyright (C) 2021 Jérôme Deuchnord <jerome@deuchnord.fr>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU Affero General Public License as
  7. # published by the Free Software Foundation, either version 3 of the
  8. # License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Affero General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. from warnings import warn
  18. from skyfield.api import Loader
  19. from skyfield.timelib import Time
  20. from skyfield.nutationlib import iau2000b
  21. from skyfield_data import get_skyfield_data_path
  22. LOADER = Loader(get_skyfield_data_path())
  23. def get_timescale():
  24. return LOADER.timescale()
  25. def get_skf_objects():
  26. return LOADER("de421.bsp")
  27. def get_iau2000b(time: Time):
  28. return iau2000b(time.tt)
  29. def flatten_list(the_list: list):
  30. new_list = []
  31. for item in the_list:
  32. if isinstance(item, list):
  33. for item2 in flatten_list(item):
  34. new_list.append(item2)
  35. continue
  36. new_list.append(item)
  37. return new_list
  38. def alert_deprecation(message):
  39. """Show the given message as a deprecation warning.
  40. >>> alert_deprecation("This is deprecated.")
  41. sys:1: DeprecationWarning: This is deprecated.
  42. """
  43. warn(message, DeprecationWarning, stacklevel=2)
  44. def deprecated(message):
  45. def inner(decorated):
  46. def f(*args, **kwargs):
  47. alert_deprecation(message)
  48. return decorated(*args, **kwargs)
  49. return f
  50. return inner