GithubHelp home page GithubHelp logo

kosmorro / kosmorro Goto Github PK

View Code? Open in Web Editor NEW
59.0 4.0 7.0 1.61 MB

A program to calculate your ephemerides.

Home Page: https://kosmorro.space

License: GNU Affero General Public License v3.0

Python 90.29% TeX 8.12% Makefile 1.59%
astronomy python kosmorro ephemeris-calculations ephemerides ephemeris

kosmorro's Introduction

Kosmorro

Version on PyPI Packaging status Help translating Kosmorro!

Kosmorro is a program that calculates your astronomical ephemerides.

Installation

Installing Kosmorro is documented on the official website. Just select your operating system and follow the instructions!

Development environment

To contribute to Kosmorrolib, you will need Poetry, a software to manage the project from development to publishing.

Clone this repository and run poetry install to install the dependencies. And that's all, your development environment is ready!

To run Kosmorro, invoke poetry run kosmorro. For comfort, you may also want to invoke poetry shell, which will expose the kosmorro command directly.

Using Kosmorro

Using Kosmorro is as simple as invoking kosmorro in your terminal!

By default, it will give you the current Moon phase and, if any, the events that will occur today.

Kosmorro has a lot of available options to get exactly what you want, including the possibility to get planets rise and set. To get a list of them, run kosmorro --help, or read its manual with man kosmorro. You can also find usage examples in the tldr manual with tldr kosmorro.

Help translating Kosmorro!

Kosmorro is translated on Weblate, a popular free platform for crowd-sourced internationalization. If you speak a language that is not supported yet, feel free to contribute!

Translation state per language

kosmorro's People

Contributors

allcontributors[bot] avatar brainface1 avatar damgermys avatar dependabot-preview[bot] avatar dependabot[bot] avatar deuchnord avatar nicfb avatar weblate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kosmorro's Issues

Provide a GUI

Currently, Kosmorro is usable in a terminal only. Most people prefer using a graphical user interface (GUI).

NB: if new dependencies are needed, they must be implemented in a way that Kosmorro can work even if they're is not installed (as long as user doesn't try to start the GUI).

Mockups

Below are some mockups I made with PlantUML to show how I imagine Kosmorro's GUI.

Main window

Similarly to the command line, the main window's goal is to provide the ephemerides, expected events and moon phase for given date and position. As these information are crucial to compute the data, so is it to make it sure that the user can change them easily.
To make this possible, the position and the date are immediately accessible at the top of the window. Then, below the computed data are displayed. Like in the command line, the position is optional and is presented as an unchecked checkbox by default.

Position unset (default value)

If the position is not set, then the ephemerides are not computed, and a message explaining why is displayed instead.

main-window-no-position

Position set

main-window

Change location dialog

When the user clicks on the Change button next to the position, a dialog window opens and invite them to set their position.
Three ways are possible:

  • By searching their city
  • By giving their coordinates (latitude, longitude), exactly like they would in the command line
  • By automatically localization (to implement later)

By default, the search option is chosen, because it is the simplest without being a potential problem for privacy.
If user chooses the third choice, a message box will ask them to confirm they really want this. Once the program got the location this way, it is then converted to simple coordinates. The user will have to ask again if they want to be automatically localized (with the same message box asking confirmation).

An option is also available to save the user's position for the later times Kosmorro's GUI is opened. Note that this configuration does not affect the command line.

Search position

choose-position

When user types something and clicks search, a list of results is displayed.

search-position

Clicking a result will close the list and update the coordinates below.

Document the different kinds of supported events

Is your feature request related to a problem? Please describe.
It is frustrating, when Kosmorro says an event will happen but does not explain what it is.

Describe the solution you'd like
Two solutions can be considered:

  • the program can provide a definition of the mentioned events (e.g if an opposition and a conjunction are reported, it gives their definitions);
  • a man page (in section 7) can be created with all the definitions.

Describe alternatives you've considered
Searching on Wikipedia.

Timezone not correctly used on next Moon phase date

I have searched for an opened issue and didn't find my bug

  • I confirm I didn't find any issue regarding my bug

Version of Kosmorro

0.10

Version of Python

3.8

Operating system

FreeBSD

Installation source

I have compiled the package from source

Bug description

No difference between UTC and UTC+1. E.g.

$ LC_ALL=C kosmorro
Saturday November 20, 2021

Moon phase: Full Moon
Last Quarter on Saturday November 27, 2021 at 12:27

Note: All the hours are given in UTC.
$ LC_ALL=C kosmorro -t 1 
Saturday November 20, 2021

Moon phase: Full Moon
Last Quarter on Saturday November 27, 2021 at 12:27

Note: All the hours are given in the UTC+1 timezone.

Both display the same time 12:27.

Your .dependabot/config.yml contained invalid details

Dependabot encountered the following error when parsing your .dependabot/config.yml:

The property '#/' contains additional properties ["default_reviewers"] outside of the schema when none are allowed

Please update the config file to conform with Dependabot's specification using our docs and online validator.

Provide a Web REST API

Proposition by Magnus on Twitter: add a webserver to give Kosmorro a Web API consumable by Web front APIs.

NB: if new dependencies are needed, they must be implemented in a way that Kosmorro can work even if they're is not installed (as long as user doesn't try to start the server).

Add option to explain the astronomy terms

Is your feature request related to a problem? Please describe.
It is currently quite difficult to get the meaning of all the information given by the command, especially the astronomy terms.
There is currently a man page dedicated to this, but you have to know it exists, which is not obvious.

Describe the solution you'd like

  • Delete the current kosmorro.7 manpage
  • Add an --explain option that will allow Kosmorro to explain the terms shown by the current command. For instance, if the return of the command tells about a conjunction, explain what is a conjunction.
  • Add support for a KOSMORRO_EXPLAIN environment variable to activate this behavior permanently.
  • Proposal by @Damgermys: add a second --definitions that would list all the words like the manpage currently does. In this case, the program does not make any calculation.

Additional context
The new information should be added at least to the Plain Text output. It could be nice to get it to the PDF output too, though.

Markdown export

Is your feature request related to a problem? Please describe.
The text export format is a good way to quickly export information, but may be difficult to read due to the lack of formatting.

Describe the solution you'd like
Markdown is a light markup language that gained in popularity, providing a way to quickly format a content in a Web context and still being readable in a simple text editor.
For instance, the following return of Kosmorro:

Saturday December 04, 2021

Object     Rise time    Culmination time    Set time
--------  -----------  ------------------  ----------
Sun          08:31           12:38           16:45
Moon         08:45           12:44           16:43
Mercury      08:53           12:50           16:47
Venus        11:38           15:32           19:27
Mars         06:50           11:19           15:49
Jupiter      12:52           17:47           22:42
Saturn       12:13           16:41           21:09
Uranus       15:09           22:29           05:54
Neptune      13:39           19:19           01:04
Pluto        11:40           15:43           19:46

Moon phase: New Moon
First Quarter on Saturday December 11, 2021 at 02:35

Expected events:
10:57  Moon is at its perigee
13:43  Moon occults Mercury

Note: All the hours are given in the UTC+1 timezone.

would look like this in Markdown:

# Saturday December 04, 2021

| Object       | Rise time | Culmination time | Set time
| ------------ |  -------- | ---------------- | --------
| **Sun**      | 08:31     | 12:38            | 16:45
| **Moon**     | 08:45     | 12:44            | 16:43
| **Mercury**  | 08:53     | 12:50            | 16:47
| **Venus**    | 11:38     | 15:32            | 19:27
| **Mars**     | 06:50     | 11:19            | 15:49
| **Jupiter**  | 12:52     | 17:47            | 22:42
| **Saturn**   | 12:13     | 16:41            | 21:09
| **Uranus**   | 15:09     | 22:29            | 05:54
| **Neptune**  | 13:39     | 19:19            | 01:04
| **Pluto**    | 11:40     | 15:43            | 19:46

**Moon phase:** New Moon  
First Quarter on Saturday December 11, 2021 at 02:35

## Expected events

- **10:57:** Moon is at its perigee
- **13:43:** Moon occults Mercury

*Note: All the hours are given in the UTC+1 timezone.*

The formatting result, e.g. on GitHub, would look like this:

Result

Saturday December 04, 2021

Object Rise time Culmination time Set time
Sun 08:31 12:38 16:45
Moon 08:45 12:44 16:43
Mercury 08:53 12:50 16:47
Venus 11:38 15:32 19:27
Mars 06:50 11:19 15:49
Jupiter 12:52 17:47 22:42
Saturn 12:13 16:41 21:09
Uranus 15:09 22:29 05:54
Neptune 13:39 19:19 01:04
Pluto 11:40 15:43 19:46

Moon phase: New Moon
First Quarter on Saturday December 11, 2021 at 02:35

Expected events

  • 10:57: Moon is at its perigee
  • 13:43: Moon occults Mercury

Note: All the hours are given in the UTC+1 timezone.

Stellarium plugin

Is your feature request related to a problem? Please describe.
As an amateur astronomer and astrophotographer, I often use tools like this one. However, it is also very easy to plan your night when you can see how the thingare evolving. Therefore, I think it would be nice to be able to use this in Stellarium (also open-source). There are many plugins available, and I heard from other members of this community that it is quite easy to create (Stellarium plugin).

Describe the solution you'd like
The solution I have in mind would be to have an overlay, which you can interact with, that would give you these exact answers, as well as being able make them appear brighter in the sky.

Describe alternatives you've considered
Manually making this stuff is okay, but quite redontant and not user-friendly.

Additional context
This would make a nice interface for your program as well, without loosing any of the other aspect (the plugin could be only an interface between your program and Stellarium, though Stellarium can calculate everything as well)

Add support for relative dates in the `--date` argument

Is your feature request related to a problem? Please describe.
Since version 0.7, the --day, --month and --year arguments have been removed in the favor of a single, more simple --date one.
But as a side-effect, calculating the ephemerides of the next days is now much more painful, because we now need to give the entire date: before, we could give the --day only for instance, and the month and year were automatically guessed to the current ones.

Describe the solution you'd like
Add the capacity for the --date argument to understand relative dates. The solution I imagine is something inspired from PHP's DateInterval constructor, but in a more user-friendly style.

The format would follow the following regular expression:

^([+-])(([0-9]+)y)?[ ]?(([0-9]+)m)?[ ]?(([0-9]+)d)?$
  • The string starts with a + or a - character.
  • Each duration period is represented by an integer value followed by one of the following period designators:
    • d for days,
    • m for months,
    • y for years.
  • Each part of the duration value is optional, but there must be at least one of them for the string to be a valid period.
  • There may be spaces between each part of the interval.

Examples of valid intervals:

  • +1d (tomorrow)
  • +1m2d (in one months and two days)
  • +1y2m (in one year and two months)
  • +1y 2m (same)

Describe alternatives you've considered
Currently, the only possible alternative is to give the entire date in the YYYY-MM-DD format.

Print an alert when a new version is available

Is your feature request related to a problem? Please describe.
Depending on the way Kosmorro has been installed, we can easily be using an out of date version without being aware of it. It is especially a problem when the currently installed version has a bug that has already been fixed in a later version.

Describe the solution you'd like
When we run the kosmorro command, print a text into standard error output (stderr) to notify the user if a new version is available.
This can be done by calling the API endpoint at https://kosmorro.space/api/SoftwareApplications/cli.json and checking the softwareVersion value.

Describe alternatives you've considered
Check the last version regularly on the official website. Or just forget to check it.

Additional context

  • Kosmorro must always be usable offline. If the website is not available or if no connection is available when it is invoked, then the program should continue to run normally, without any warning nor error message.
  • Calls to the API endpoint is a simple GET request without any argument. It does not have to provide any tracking information.
  • The check is enabled by default, but in order to prevent users using packages managers (like APT, AUR, etc) to get unwanted notification, or for users who just prefer to check if new version is available by themselves, we should be able to deactivate it at both build (with poetry build) and execution times with an environment variable (KOSMORRO_DISABLE_VERSION_CHECK?). We might want the API endpoint to be configured directly through en environment variable too.
  • The API usually responds in less than 10 ms. For safety, the response timeout can be set to 20 ms.

Conjunction

Event type: Conjunction
Involved objects (check the boxes):

  • Sun
  • Earth's moon
  • Planets

Definition of the event:

In astronomy, a conjunction occurs when two astronomical objects […] have either the same right ascension or the same ecliptic longitude, usually as observed from Earth.

­— Wikipedia, Conjunction

Other useful information (implementation proposal, etc):
Not sure that involving the Sun makes sense here, since such conjunctions would be unobservable.

Refactor the ephemerides computation

The ephemerides.py module is currently quite ugly, needs refactor:

  • Remove the EphemeridesComputer class, the methods become simple functions
  • Prefix the internal functions with an underscore
  • Fix the memory leaks
  • In the main program, separate the MoonPhase from the Ephemeris
  • Increase the unit test coverage
  • Add Vulture to find the dead code

Add support for conjunction with Moon

Event type: Moon conjunctions
Involved objects (check the boxes):

  • Sun
  • Earth's moon
  • Planets

Definition of the event:

See #25

Other useful information (implementation proposal, etc):
Not currently implemented, because of issues that make Kosmorro give wrong conjunctions with the Moon (e.g. on January 1st, 2020):

$ python kosmorro -d 1 -m 1 -y 2020
Wednesday January 01, 2020

Moon phase: Waxing crescent
First Quarter on Mon Jan 3, 2020 04:45

Expected events:

23:59  Mercury and Moon are in conjunction
23:59  Venus and Moon are in conjunction
23:59  Mars and Moon are in conjunction
23:59  Jupiter and Moon are in conjunction
23:59  Saturn and Moon are in conjunction
23:59  Uranus and Moon are in conjunction
23:59  Neptune and Moon are in conjunction
23:59  Pluto and Moon are in conjunction

Note: All the hours are given in UTC.

May be related to #48.

Cannot output in JSON format when no position is given

Describe the bug
When trying to output to JSON format, if no position have been given, a Python TypeError is thrown.

To Reproduce

$ kosmorro -f json
Traceback (most recent call last):
  File "/usr/bin/kosmorro", line 27, in <module>
    sys.exit(main())
  File "/usr/lib/python3.9/site-packages/_kosmorro/main.py", line 126, in main
    print(output)
  File "/usr/lib/python3.9/site-packages/_kosmorro/dumper.py", line 73, in __str__
    return self.to_string()
  File "/usr/lib/python3.9/site-packages/_kosmorro/dumper.py", line 88, in to_string
    "ephemerides": [
TypeError: 'NoneType' object is not iterable

Expected behavior
A JSON output similar to the following should be output:

{
    "ephemerides": [],
    "moon_phase": {
        "phase": "WANING_GIBBOUS",
        "time": null,
        "next": {
            "phase": "LAST_QUARTER",
            "time": "2021-08-30T07:13:13.940776+00:00"
        }
    },
    "events": []
}

Your configuration (please complete the following information):

  • OS: Linux
  • Python version: 3.9.6
  • Kosmorro version: 0.10.1
  • Kosmorrolib version: 0.11.2

Your .dependabot/config.yml contained invalid details

Dependabot encountered the following error when parsing your .dependabot/config.yml:

The property '#/update_configs/1' did not contain a required property of 'package_manager'
The property '#/update_configs/1' did not contain a required property of 'directory'
The property '#/update_configs/1' did not contain a required property of 'update_schedule'

Please update the config file to conform with Dependabot's specification using our docs and online validator.

Moon perigee/apogee

Event type: Perigee, apogee
Involved objects (check the boxes):

  • Sun
  • Earth's moon
  • Planets

Definition of the event:

When discussing a satellite of Earth, including the Moon, the point of least distance is the perigee (/ˈpɛrɪdʒiː/), and of greatest distance, the apogee, (from Ancient Greek: Γῆ (Gē), "land" or "earth").
Wikipedia

The ICRF.distance() function can be used to compute the distance between two objects.

Occultation

Event type: occultation
Involved objects (check the boxes):

  • Sun
  • Earth's moon
  • Planets

Definition of the event:

An occultation is an event that occurs when one object is hidden by another object that passes between it and the observer.

— Wikipedia, Occultation

Other useful information (implementation proposal, etc):
This is a specialization of conjunctions (treated in #25).

Compute more accurate Moon phase

Currently, Kosmorro computes the Moon phase using Skyfield's almanac.moon_phases() function, which can returns 4 possible values only: New Moon, First Quarter, Full Moon, and Last Quarter. It would be useful to have also the intermediate phases: Waxing crescent, Waxing gibbous, Waning gibbous and Waning crescent (see Lunar phase on Wikipedia).

Plus, current implementation (inspired from Skyfield's cookbook is based on the last time the phase has changed, which means that most of the time, the information displayed in the console is out of date. For instance, on 21st Nov., 2019, Kosmorro states current Moon phase is Last Quarter, when it's actually Waning crescent.

Guess the output format based on the --output argument

(Feature request by @AmauryCarrade on Discord)

Is your feature request related to a problem? Please describe.
Currently, to export in a PDF file, we need to give two arguments to the command:

  • --format=pdf
  • --output=myfile.pdf
    Giving both arguments, even though acceptable, is redundant.

Describe the solution you'd like

  • The --format argument becomes optional.
  • If both --format and --output is given, then the behavior stays the same as today: the content is output in the given file using the given format, even though the extension does not match the format.
  • If only --output is given, then guess the format to use from it:
    • --output=myfile.txt ou --output=myfile (without extension) will output a file containing the text usually returned in standard output
    • --output=myfile.json will output a file containing a JSON content
    • --output=myfile.pdf will output a file containing the PDF content
  • If only --output is given, but the file format is not recognized, then an error is returned and nothing is done.

Compute the ephemerides for several days

Is your feature request related to a problem? Please describe.
There is currently no way to compute the ephemerides for several days with Kosmorro.

Describe the solution you'd like
New arguments --from=<date1> and --until=<date2> to compute ephemerides from date1 and date2.

Describe alternatives you've considered
A Bash script that runs Kosmorro foreach date between date1 and date2.

Aphelion

Event type: aphelion
Involved objects (check the boxes):

  • Sun
  • Earth's moon
  • Planets

Definition of the event:
The aphelion is the farthest points of a body's direct orbit around the Sun.

Other useful information (implementation proposal, etc):
There is no point of computing the aphelion for all the planets here. Just the Earth's aphelion should be computed.

Kosmorro detects false conjunctions

Describe the bug
For some dates, Kosmorro gives conjunctions that are possible, given the positions of the planets

To Reproduce

$ kosmorro -y 2020 -m 2 -d 7
Friday February 07, 2020

Moon phase: Waxing gibbous
Full Moon on Sunday February 09, 2020 at 07:33

Expected events:
21:25  Mercury and Venus are in conjunction
21:25  Venus and Mars are in conjunction
21:25  Venus and Jupiter are in conjunction
21:25  Venus and Saturn are in conjunction
21:25  Venus and Uranus are in conjunction
21:25  Venus and Neptune are in conjunction
21:25  Venus and Pluto are in conjunction

Note: All the hours are given in UTC.

There are actually no conjunctions on February 7, 2019.

Screenshots
If applicable, add screenshots to help explain your problem.

Your configuration (please complete the following information):

  • OS: Arch Linux
  • Python version: 3.8.1
  • Kosmorro version: 0.5.1

Simplify the coordinates parameter(s)

(Feature request by @AmauryCarrade on Discord)

Is your feature request related to a problem? Please describe.
The current version of Kosmorro uses the classical GPS coordinates to specify our location, which is quite complex.
Plus, the coordinates are currently separated in two arguments: --latitude and --longitude, which adds more complexity.

Describe the solution you'd like
Add a new argument --position of type str. Its value can have two syntax:

  • Classical coordinates: follows the regular expression ^{float}[,;]{float}$ (where {float} is a floating-point number)
  • Open Location Code (also known as Plus Code), validated and read with the openlocationcode reference implementation in Python.

Release workflow error

The release workflow fails with the following error:

if [ "$POEDITOR_API_ACCESS" != "" ]; then \
        python3 .scripts/build/getlangs.py; \
        python3 setup.py compile_catalog; \
fi
Traceback (most recent call last):
  File ".scripts/build/getlangs.py", line 12, in <module>
    PROJECT_ID = os.environ['POEDITOR_PROJECT_ID']
  File "/usr/lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'POEDITOR_PROJECT_ID'
Traceback (most recent call last):
  File "setup.py", line 20, in <module>
    from setuptools import setup, find_packages
ModuleNotFoundError: No module named 'setuptools'

Complete logs: https://gist.github.com/Deuchnord/f310919a0ec03a180e487b7163876a8b

Add support for the NO_COLOR standard environment variable

Is your feature request related to a problem? Please describe.
If I don't want colors to be displayed on the return of the command, I currently need to add the --no-color argument. But if I want them to never show up, then there is no other solution but always adding this argument.

Describe the solution you'd like
Add support for the NO_COLOR standard: if an environment variable named NO_COLOR exists, disable the display of colors. The environment variable just have to exist, its value is not important.

Export to PDF

Is your feature request related to a problem? Please describe.
Kosmorro may be used to prepare observation nights. At this occasion, the information would be printed, but currently, there is no way to do it easily.

Describe the solution you'd like
Add a way to export PDF.
It may be done through a new Dumper, which would be activated by the --format=pdf argument. Plus, a new --output=<filename> could also be implemented to enable user to tell Kosmorro where they want the PDF to be saved.

Add support for timezones

Is your feature request related to a problem? Please describe.
Currently, Kosmorro is only able to display the times in UTC. Even though it is common doing so in astronomy, it is quite uncomfortable to have to convert them in local time.

Describe the solution you'd like
Add a new optional argument --timezone to display the times in the local time zone instead of UTC.
It can have several forms:

  • the simpler way would be that when the option is activated, Kosmorro computes the local time internally based on the position (but it would require the position to be given) — this library can be useful to guess the time zone based on the position;
  • another way would be that the argument takes as an argument a number corresponding to the time difference between UTC and local time (e.g --timezone=2 for UTC+2, --timezone=-2 for UTC-2)

A good implementation could be:

  • when the --timezone is not given,
    then display the times in UTC
  • when the position and the --timezone argument without an explicit time zone are given,
    then guess the time zone based on the position and display the times with the guessed time zone
  • when the position and the --timezone argument with an explicit time zone are given,
    then use the given time zone and display the times with it (don't guess it)
  • when ony --timezone argument with an explicit time zone is given,
    then use the given time zone and display the times with it (don't guess it)
  • when ony --timezone argument without an explicit time zone is given,
    then return an error explaining that the position is required to guess the time zone and hint the user that they can give it explicitely

Maximal elongation

Event type: maximal elongation
Involved objects (check the boxes):

  • Sun
  • Earth's moon
  • Inferior planets

Definition of the event:

In astronomy, a planet's elongation is the angular separation between the Sun and the planet, with Earth as the reference point.
Wikipedia

When the elongation of an inferior planet (Mercury and Venus) is maximal, it is the best moment to observe it.

Search for events

Currently kosmoro allows you to obtain a list of events from dates. The idea would be to be able to do the opposite, get dates from an event.

I think that it is necessary to define default ranges (we are not going to generate dates ad infinitum) and to be able to specify them. I think we should also indicate if we want future/past/both dates.

Crashes for some parameter combinations involving --format and --output

I have searched for an opened issue and didn't find my bug

  • I confirm I didn't find any issue regarding my bug

Version of Kosmorro

0.10

Version of Python

3.10

Operating system

Linux

Installation source

PyPI

Bug description

When launching with kosmorro --output=ephemeride.pdf, kosmorro crashes with the following trace:

Traceback (most recent call last):
  File "/home/arnaud/.local/bin/kosmorro", line 8, in <module>
    sys.exit(main())
  File "/home/arnaud/.local/lib/python3.10/site-packages/kosmorro/__main__.py", line 316, in main
    sys.exit(run())
  File "/home/arnaud/.local/lib/python3.10/site-packages/kosmorro/__main__.py", line 107, in run
    output_file.write(pdf_content)
TypeError: a bytes-like object is required, not 'str'

I would expect an error for missing/wrong parameters instead of a crash.

Alternatively, kosmorro could guess the desired output based on the extension of the output argument, and inform the user that this decision has been made.


Also, kosmorro --format=json --output=ephemeride.json and kosmorro --format=text --output="ephemeride.txt" crash with similar errors.

Here the expected behavior would be to write a file with the json or text output.

Alternatively kosmorro could ignore the parameter and warn the user about it.


For comparison, the following commands works fine:

kosmorro --format=pdf --output=ephemeride.pdf
kosmorro --format=json
kosmorro --format=text

Kosmorro throws an exception for the 08-11-2022 with JSON

I have searched for an opened issue and didn't find my bug

  • I confirm I didn't find any issue regarding my bug

Version of Kosmorro

0.10

Version of Python

3.10

Operating system

Linux

Installation source

PyPI

Bug description

Hello, kosmorro throws an exception when running it for 2022-11-08 with JSON format because of a LunarEclipse that can't be serialized to JSON

[raouf@dhcppc9 ~]$ kosmorro -f json -lat 36 -lon 5 -d 2022-11-08
Traceback (most recent call last):
  File "/home/raouf/.local/bin/kosmorro", line 24, in <module>
    sys.exit(main())
  File "/home/raouf/.local/lib/python3.10/site-packages/_kosmorro/main.py", line 124, in main
    print(output)
  File "/home/raouf/.local/lib/python3.10/site-packages/_kosmorro/dumper.py", line 80, in __str__
    return self.to_string()
  File "/home/raouf/.local/lib/python3.10/site-packages/_kosmorro/dumper.py", line 93, in to_string
    return json.dumps(
  File "/usr/lib64/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib64/python3.10/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib64/python3.10/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib64/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.10/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib64/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.10/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/lib64/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type LunarEclipseType is not JSON serializable

The set times are incorrrect

Describe the bug
For most of the planets and the Sun, the set time is the same as the rise time.

To Reproduce

kosmorro

Expected behavior
The set time should be correct

Screenshots

Ephemerides of Monday November 18, 2019

Planet     Rise time    Culmination time    Set time
--------  -----------  ------------------  ----------
Sun          05:40           11:43           05:40
Moon         17:11             -             04:48
Mercury      05:44           11:45           05:44
Venus        07:16           13:20           07:16
Mars         04:09           10:12           04:09
Jupiter      08:15           14:18           08:15
Saturn       09:45           15:48           09:45
Uranus       16:42           22:44           04:51
Neptune      13:45           19:47           01:53
Pluto        10:06           16:09           10:06

Moon phase: First Quarter

Note: All the hours are given in UTC.

Your configuration (please complete the following information):

  • OS: Arch Linux
  • Python version: 3.8.0
  • Kosmorro version: 0.2.1

Additional context
Both on JSON and plain text outputs.

ModuleNotFoundError: No module named 'openlocationcode'

I have searched for an opened issue and didn't find my bug

  • I confirm I didn't find any issue regarding my bug

Version of Kosmorro

0.10

Version of Python

3.8

Operating system

FreeBSD

Installation source

I have compiled the package from source

Bug description

Launching kosmorro 0.10.8 produces the following error:

Traceback (most recent call last):
  File "/usr/local/bin/kosmorro", line 20, in <module>
    from _kosmorro.main import main
  File "/usr/local/lib/python3.8/site-packages/_kosmorro/main.py", line 31, in <module>
    from .geolocation import get_position
  File "/usr/local/lib/python3.8/site-packages/_kosmorro/geolocation.py", line 7, in <module>
    from openlocationcode import openlocationcode
ModuleNotFoundError: No module named 'openlocationcode'

Stop using Skyfield's protected methods

Kosmorro is currently using the almanac._find_maxima() function, which is a protected function, because it is not considered stable due some erratic behaviors in the routine (see skyfielders/python-skyfield#300).

For now it seems to work well, but for obvious stability reason, version 1.0.0 cannot be released if it keeps calling protected methods.

No such file or directory when file output is a relative path or the filename only

Describe the bug
When generating a PDF file, if the output file is just a filename of a relative path, a No such file or directory error occurs.

To Reproduce

$ kosmorro --format=pdf --output=test.pdf --debug
Save the planet and paper!
Consider printing your PDF document only if really necessary, and use the other side of the sheet.
[DEBUG] LaTeX content:
...

The file could not be saved in "test.pdf": No such file or directory
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/_kosmorro/main.py", line 107, in main
    with open(args.output, "wb") as output_file:
FileNotFoundError: [Errno 2] No such file or directory: 'test.pdf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/kosmorro", line 27, in <module>
    sys.exit(main())
  File "/usr/lib/python3.9/site-packages/_kosmorro/main.py", line 122, in main
    debug.debug_print(error)
  File "/usr/lib/python3.9/site-packages/_kosmorro/debug.py", line 13, in debug_print
    print_exc(what)
  File "/usr/lib/python3.9/traceback.py", line 163, in print_exc
    print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
  File "/usr/lib/python3.9/traceback.py", line 103, in print_exception
    for line in TracebackException(
  File "/usr/lib/python3.9/traceback.py", line 508, in __init__
    self.stack = StackSummary.extract(
  File "/usr/lib/python3.9/traceback.py", line 340, in extract
    if limit >= 0:
TypeError: '>=' not supported between instances of 'FileNotFoundError' and 'int'

The file is not created.

The same errors occurs with --output=Documents/test.pdf (where Documents is an existing folder with write permissions).
The error does not occur with --output=$HOME/Documents/test.pdf`` (where $HOME` is the path to my home folder).

Expected behavior
Write the file without any error.

Screenshots
If applicable, add screenshots to help explain your problem.

Your configuration (please complete the following information):

  • OS: Linux
  • Python version: 3.9.5
  • Kosmorro version: 0.10.0
  • Kosmorrolib version: 0.11.2

OpenDocument Text export

Is your feature request related to a problem? Please describe.
Kosmorro is currently already able to export the computation results to PDF, which is convenient for printing. But sometimes, we want to edit it to add our own notes, or even delete information we don't need.

Describe the solution you'd like
Make it possible to export to OpenDocument Text (.odt) format.

Describe alternatives you've considered
Annotate manually the PDF

Oppositions

Event type: opposition
Involved objects (check the boxes):

  • Sun
  • Earth's moon
  • Planets

Definition of the event:

In positional astronomy, two astronomical objects are said to be in opposition when they are on opposite sides of the celestial sphere, as observed from a given body (usually Earth).

A planet (or asteroid or comet) is said to be "in opposition" when it is in opposition to the Sun. Because most orbits in the Solar System are nearly coplanar to the ecliptic, this occurs when the Sun, Earth, and the body are configured in an approximately straight line, or syzygy; that is, Earth and the body are in the same direction as seen from the Sun.
Opposition occurs only for superior planets [Mars, Jupiter, Saturn, Uranus, Neptune, Pluto].
Wikipedia

Other useful information (implementation proposal, etc):

The best way to find oppositions may be to compute the angle formed by the Earth and a superior planet from the point of view of the Sun: the opposition would be at the moment when the angle becomes minimal.

Colors are not adapted if terminal has a light background

I have searched for an opened issue and didn't find my bug

  • I confirm I didn't find any issue regarding my bug

Version of Kosmorro

0.10

Version of Python

3.9

Operating system

Linux

Installation source

Arch User Repository (AUR)

Bug description

When using a terminal with light background, the colors displayed by Kosmorro make the text difficult to read.
The issue comes from the style applied here: https://github.com/Kosmorro/kosmorro/blob/master/_kosmorro/dumper.py#L143-L155

We should not use colors that are not visible on both dark and white background for simplicity.

Screenshot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.