Browse Source

Fix Python files header

tags/v0.1.0
Jérôme Deuchnord 4 years ago
parent
commit
f545dfd0cd
No known key found for this signature in database GPG Key ID: BC6F3C345B7D33B0
4 changed files with 21 additions and 15 deletions
  1. +1
    -1
      .pylintrc
  2. +2
    -0
      dumper.py
  3. +16
    -14
      ephemeris.py
  4. +2
    -0
      kosmorro.py

+ 1
- 1
.pylintrc View File

@@ -30,7 +30,7 @@ limit-inference-results=100
# usually to register additional checkers.
load-plugins=pylintfileheader

file-header=# Kosmorro - Compute The Next Ephemeris\n# Copyright \(C\) 2019 Jérôme Deuchnord <jerome@deuchnord.fr>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Affero General Public License as\n# published by the Free Software Foundation, either version 3 of the\n# License, or \(at your option\) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU Affero General Public License for more details.\n#\n# You should have received a copy of the GNU Affero General Public License\n# along with this program. If not, see <https://www.gnu.org/licenses/>.
file-header=#!/usr/bin/env python3\n\n# Kosmorro - Compute The Next Ephemeris\n# Copyright \(C\) 2019 Jérôme Deuchnord <jerome@deuchnord.fr>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Affero General Public License as\n# published by the Free Software Foundation, either version 3 of the\n# License, or \(at your option\) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU Affero General Public License for more details.\n#\n# You should have received a copy of the GNU Affero General Public License\n# along with this program. If not, see <https://www.gnu.org/licenses/>.\n\n

# Pickle collected data for later comparisons.
persistent=yes


+ 2
- 0
dumper.py View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3

# Kosmorro - Compute The Next Ephemeris
# Copyright (C) 2019 Jérôme Deuchnord <jerome@deuchnord.fr>
#


+ 16
- 14
ephemeris.py View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3

# Kosmorro - Compute The Next Ephemeris
# Copyright (C) 2019 Jérôme Deuchnord <jerome@deuchnord.fr>
#
@@ -37,18 +39,6 @@ class Ephemeris:
self.longitude = position['lon']
self.position = Topos(latitude_degrees=position['lat'], longitude_degrees=position['lon'])

def compute_ephemeris_for_day(self, year: int, month: int, day: int) -> dict:
ephemeris = {}
time1 = self.timescale.utc(year, month, day, 2)
time2 = self.timescale.utc(year, month, day + 1, 2)

# Compute sunrise and sunset
ephemeris['sun'] = self.get_sun(time1, time2)
ephemeris['moon'] = self.get_moon(year, month, day)
ephemeris['planets'] = self.get_planets(year, month, day)

return ephemeris

def get_sun(self, start_time, end_time) -> dict:
times, is_risen = almanac.find_discrete(start_time,
end_time,
@@ -167,6 +157,18 @@ class Ephemeris:
'set': set_time if set_time is not None else None
}

def compute_ephemerides_for_day(self, year: int, month: int, day: int) -> dict:
ephemeris = {}
time1 = self.timescale.utc(year, month, day, 2)
time2 = self.timescale.utc(year, month, day + 1, 2)

# Compute sunrise and sunset
ephemeris['sun'] = self.get_sun(time1, time2)
ephemeris['moon'] = self.get_moon(year, month, day)
ephemeris['planets'] = self.get_planets(year, month, day)

return ephemeris

def compute_ephemerides_for_month(self, year: int, month: int) -> list:
if month == 2:
is_leap_year = (year % 4 == 0 and year % 100 > 0) or (year % 400 == 0)
@@ -179,7 +181,7 @@ class Ephemeris:
ephemerides = []

for day in range(1, max_day + 1):
ephemerides.append(self.compute_ephemeris_for_day(year, month, day))
ephemerides.append(self.compute_ephemerides_for_day(year, month, day))

return ephemerides

@@ -216,7 +218,7 @@ class Ephemeris:

def compute_ephemeris(self, year: int, month: int, day: int):
if day is not None:
return self.compute_ephemeris_for_day(year, month, day)
return self.compute_ephemerides_for_day(year, month, day)

if month is not None:
return self.compute_ephemerides_for_month(year, month)


+ 2
- 0
kosmorro.py View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3

# Kosmorro - Compute The Next Ephemeris
# Copyright (C) 2019 Jérôme Deuchnord <jerome@deuchnord.fr>
#


Loading…
Cancel
Save