A library that computes the ephemerides.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

core.py 1.4 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 skyfield.api import Loader
  18. from skyfield.timelib import Time
  19. from skyfield.nutationlib import iau2000b
  20. from skyfield_data import get_skyfield_data_path
  21. LOADER = Loader(get_skyfield_data_path())
  22. def get_timescale():
  23. return LOADER.timescale()
  24. def get_skf_objects():
  25. return LOADER("de421.bsp")
  26. def get_iau2000b(time: Time):
  27. return iau2000b(time.tt)
  28. def flatten_list(the_list: list):
  29. new_list = []
  30. for item in the_list:
  31. if isinstance(item, list):
  32. for item2 in flatten_list(item):
  33. new_list.append(item2)
  34. continue
  35. new_list.append(item)
  36. return new_list