Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

60 Zeilen
1.6 KiB

  1. #!/usr/bin/env python3
  2. # Kosmorro - Compute The Next Ephemerides
  3. # Copyright (C) 2019 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 shutil import rmtree
  18. from pathlib import Path
  19. from skyfield.api import Loader
  20. from skyfield.timelib import Time
  21. from skyfield.nutationlib import iau2000b
  22. CACHE_FOLDER = str(Path.home()) + '/.kosmorro-cache'
  23. def get_loader():
  24. return Loader(CACHE_FOLDER)
  25. def get_timescale():
  26. return get_loader().timescale()
  27. def get_skf_objects():
  28. return get_loader()('de421.bsp')
  29. def get_iau2000b(time: Time):
  30. return iau2000b(time.tt)
  31. def clear_cache():
  32. rmtree(CACHE_FOLDER)
  33. def flatten_list(the_list: list):
  34. new_list = []
  35. for item in the_list:
  36. if isinstance(item, list):
  37. for item2 in flatten_list(item):
  38. new_list.append(item2)
  39. continue
  40. new_list.append(item)
  41. return new_list