skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.4k stars 211 forks source link

Query Simbad database #668

Open lucaberti opened 2 years ago

lucaberti commented 2 years ago

Hello, I started a project where I wanted to calculate deep sky objects ephemeris. This quickly led me to manually create Stars object based on SIMBAD database (http://simbad.u-strasbg.fr/simbad/). Since i could not find a native way to access a broader star catalogue - beside hipparcos - and since I needed a quicker way to create the Star object that I needed, I created a script to retrieve the SIMBAD data and automatically create the Star objects. I also added the possibility to output data as DataFrame or as a list of dictionaries. The code works fine, but it is not near as refined as I like. Nevertheless it could be a good add to the skyfield tools. Here is my question: it coudl be added directly to this project or is best to have it separated and installed as a separate package?

brandon-rhodes commented 2 years ago

I was about to say "maybe we should glance at the astroquery package, I've heard it supports lots of different data sources?" but WOW, I just looked at it and, including its 22 dependent packages, it requires 35 MB of Python packages to download and install. So I guess that's going to be way too heavyweight for me to be tempted to recommend it!

How much code was necessary to talk to SIMBAD? If it's within a factor of 2× of the size of something like mpc.py (which looks to be around 260 lines long), then your code might be a good fit for Skyfield's data subpackage!

lucaberti commented 2 years ago

Two files, ~180 lines and about 12KB. (and the divison in two files is just for future new uses)

brandon-rhodes commented 2 years ago

Does it have any dependencies outside the Standard Library and Pandas? I've been trying to keep Skyfield from accumulating too many more :) In any case, yes, I'd be interested to see the code!

lucaberti commented 2 years ago

I added you to the project. You can find it in skyfield/skyfieldquery directory. You can execute the simbad.py (it has an example code as main)

brandon-rhodes commented 2 years ago

Thanks! I'll plan to read over the code tomorrow morning and see what I think.

lucaberti commented 2 years ago

Btw dependencies are Requests, Csv and Pandas. Pandas it's just needed to return a DataFrame, which is there only for compatibility with the Star Object. It could also be avoided, since the class can create Stars objects from its own.

lucaberti commented 2 years ago

Forgot to mention that the code is (still) under the dev branch

brandon-rhodes commented 2 years ago

I've looked over your code, and it does look like the basic function of running a query and returning a dataframe that can become a Star object will be a good fit for Skyfield. It may be a couple of months before other projects give me time to dive in and adapt the code to create a new skyfield.data module, but in the meantime I have forked your repository so that I can always get back to this version of the code even if you need to change or delete the branch in your own repository. Thanks!

lucaberti commented 2 years ago

Thank you for this project! I'm glad (and somewhat proud) that my work helps you in some way to grow it.

lucaberti commented 10 months ago

Hello @brandon-rhodes. Hope you are doing good. I'm thinking of, finally, starting working back on my project. Just wanted to check if SIMBAD integration is gone forward or if I will develop it further by myself. Thank you :)

brandon-rhodes commented 10 months ago

Alas, no, I have not yet sat down to integrate the SIMBAD logic into Skyfield — other priorities keep getting in the way. So please feel free to keep extending and using your own version!