Skip to content

Add code for epoch propagation #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2023

Conversation

msdemlei
Copy link
Contributor

@msdemlei msdemlei commented Sep 5, 2022

This PR lays the basis for pg_sphere-based functions for
epoch-propagating positions (i.e., compute their positions, proper
motions, parallaxes and radial velocities after some time based on their
values at epoch X under the assumption of linear motion).

This largely follows what is implemented at the Gaia archive,
https://gea.esac.esa.int/tap-server/tap. In particular, it follows
Lindegren's recipes from ESA-SP1200.

We might consider for a moment to employ SOFA/ERFA (and hence astropy)
-compatible methods, which take into account secular aberration and use
certain relativistic corrections. I'd say we shouldn't. For one,
having secular aberration while assuming linear motions of the objects
is somewhat inconsistent. Having relativistic corrections results in
differences in the few-muas range for objects we are likely to deal
with while making computations a lot more expensive.

We might also consider having a counterpart for ESAC's
epoch_prop_error function, which propagates errors and thus in general
produces fully populated covariance matrices. For now I would suggest
that this kind of math should happen outside of the database (but I
could be swayed).

Copy link

@gmantele gmantele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems very ok. CI passes for Postgres 10 and more.

PgSphere version should probably be increased (from 1.2.1 to 1.2.2) if PR#6 is merged first.

@vitcpp
Copy link
Contributor

vitcpp commented May 24, 2023

Dear @msdemlei @gmantele, thank you for your contribution! We are going to put some fresh air into this repo.

I'm ok with this patch but I'm not sure about version number. Should we increase it up to 1.2.2 because I've already merged the previous commit? I'm going to think about the versioning and releases. I will appreciate if you share some ideas how to maintain this repo.

I have some doubts about adding some astronomy specific functions because PgSphere might be used in other areas. It think it may be a good idea to create another package like pgsphere-astro which will be based on existing pgsphere where all astronomical stuff may be implemented including linkage with SOFA library.

Copy link
Contributor

@vitcpp vitcpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @msdemlei, thank you for your contribution to the project. The recalculation of astronomical objects positions for the current epoch is definitely a useful feature. I think PgSphere was created for astronomical purposes as well. What I'm concerned is to keep PgSphere with the minimal set of functionality that can be applied in different areas, not only for astronomical purposes. PgSphere introduces new types to work with coordinates and areas on the sphere, some operations on these types, several indexing structures and functions. I believe it was the original project scope. This scope allows to use PgSphere in different areas where coordinate system on the sphere is used. Proper motions propagation is one of the big set of astronomical functions. To make a complete solution we should also add some other astronomical stuff that will greatly increase the scope of the project. I'm propose is to skip this pull request because it is out of scope. There is an idea to create a new project with astronomical specific functions that will be based on PgSphere (pgsphere-astro).

@vitcpp
Copy link
Contributor

vitcpp commented Jun 2, 2023

Dear @msdemlei, thank you for your contribution to the project. The recalculation of astronomical objects positions for the current epoch is definitely a useful feature. I think PgSphere was created for astronomical purposes as well. What I'm concerned is to keep PgSphere with the minimal set of functionality that can be applied in different areas, not only for astronomical purposes. PgSphere introduces new types to work with coordinates and areas on the sphere, some operations on these types, several indexing structures and functions. I believe it was the original project scope. This scope allows to use PgSphere in different areas where coordinate system on the sphere is used. Proper motions propagation is one of the big set of astronomical functions. To make a complete solution we should also add some other astronomical stuff that will greatly increase the scope of the project. I'm propose is to skip this pull request because it is out of scope. There is an idea to create a new project with astronomical specific functions that will be based on PgSphere (pgsphere-astro).

@vitcpp vitcpp closed this Jun 2, 2023
@msdemlei
Copy link
Contributor Author

msdemlei commented Jun 2, 2023 via email

@vitcpp
Copy link
Contributor

vitcpp commented Jun 2, 2023

@msdemlei it is great to get some feedback from you! Let's be in touch. So, you have a fork which you'd like to be in sync with postgrespro/pgsphere repo. I understand your problem. I agree there is no sense to create pgsphere-astro for a single function.

What do you think if to create another branch in the repo and push your function into this branch (master-astro, for example)? Having such separate branch may help you to be in sync with this repo. We may merge the master branch into this branch on a regular basis.

IMHO, I do not like the idea to put such function into the main branch because 1) it is out of scope, 2) there are no good tests, 3) users may require some other specific functions to be implemented in pgsphere that may negatively affect the project. May be, we should wait for one more opinions!?

One more question, we would like to move all sources into src subdirectory and make optional healpix+moc compilation. How can it affect you?

Despite of healpix+smoc is a nice stuff it is not required for all users but makes the build process more complex.

@msdemlei
Copy link
Contributor Author

msdemlei commented Jun 6, 2023 via email

@gmantele
Copy link

gmantele commented Jun 6, 2023

As Markus said PgSphere seems to be really an astronomy project. As far as we know, nobody else than astronomy people replied or contributed to any PgSphere fork. Maybe at some time, when it is really clear for everyone it is an astronomy project (that's to say, no one from another domain than astronomy says something), I think it would be a good idea to write explicitly somewhere that this project mainly targets the astronomy domain.

@vitcpp
Copy link
Contributor

vitcpp commented Jun 6, 2023

Creating a new branch
A agree that a separate branch is not a good idea. It was just an idea to somehow resolve the possible merge issues.

Project scope
Today I have answered in pgsphere googlegroups: https://groups.google.com/g/pgsphere/c/RhnCH_q5c3o . There I explained my vision of pgsphere project scope and the fact that the current version doesn't contain any astronomy specific functionality. The function to calculate object positions at any epoch differs completely from other functionality in pgSphere. The pgSphere doc contains the following description of the project scope:

  • input and output of data
  • containing, overlapping, and other operators
  • various input and converting functions and operators
  • circumference and area of an object
  • spherical transformation
  • indexing of spherical data types
  • several input and output formats

epochprop tests
Concerning epochprop tests - may be I spoke to soon. Sorry. This function has test coverage. I just wanted to highlight that we have to create test coverage for each new function.

Cleaning up the project tree
Concerning cleaning up the tree... I would be happy to wait for your changes but could you please share with me your plans? From my side I propose to move source files into src subdirectory. It will decrease the chaos in the project root directory. I also propose not to add update scripts into the public repo that are applicable only to ivoa (or to place them in some other place).

Healpix+smoc
It is great we came to the same conclusion.

pgSphere for astronomers !?
I believe that pgSphere is mostly used for astronomical purposes. There is a "political" decision to think of pgSphere as an astronomical project and to extend the scope of the project. IMHO, I would propose not to do it. It is the dilemma like RISC or CISC :) Furthermore, I think there is no sense to implement astronomical functions from scratch. It would be better to create wrappers for lib SOFA functions, for example. It would be better to create pgsphere-astro contrib and make wrapper functions in this new library.

@msdemlei
Copy link
Contributor Author

msdemlei commented Jun 7, 2023 via email

@vitcpp
Copy link
Contributor

vitcpp commented Jun 7, 2023

@msdemlei I think we might put your function under ifdef. For example, introduce macro PGSPHERE_ASTRO that will enable astronomical functions (by default, it will be OFF). I think it will be a reasonable compromise. Can it be suitable for you?

@gmantele
Copy link

gmantele commented Jun 7, 2023

pgSphere doc contains the following description of the project scope:

  • input and output of data
  • containing, overlapping, and other operators
  • various input and converting functions and operators
  • circumference and area of an object
  • spherical transformation
  • indexing of spherical data types
  • several input and output formats

Hm... would it be too bad if we added "motion in spherical coordinates" to that list?

I, personally, think it is a reasonnable thing to do. Motion on a sphere, does not necessarily apply to astronomy.

@df7cb
Copy link
Contributor

df7cb commented Jun 7, 2023

IMHO, cleanup is foremost required around the upgrade scripts handling. There's a dozen .sql.in files in the root dir, but there's two dozen more files in upgrade_scripts/, and the logic to puzzle everything together in the Makefile is really ugly.

About the idea of trying to avoid making pgsphere astronomy-specific: With that argument, the MOC data type should not have been introduced at all, but yet it was since the existing pgsphere users find it useful. Perhaps that idea might help to decide which extra functionality should go in in the future.

@msdemlei
Copy link
Contributor Author

msdemlei commented Jun 7, 2023 via email

@df7cb
Copy link
Contributor

df7cb commented Jun 7, 2023

It would also have the problem that different installations with the same SQL-level extension version would contain a different set of functions.

@vitcpp
Copy link
Contributor

vitcpp commented Jun 8, 2023

I think to put proper motion calculations under Transformations category is a reasonable compromise and to apply the PR. One of my colleagues proposed to generalize this function as well. It may be the development for the future. Give me please some time to discuss it with my colleagues.

@vitcpp
Copy link
Contributor

vitcpp commented Jun 14, 2023

Dear All, I tried to gather some opinions of my colleagues-astronomers. I think to allow this patch but it would be reasonable to generalize it in the future, not only for astronomical purposes.

@msdemlei Could you please adjust the PR to avoid existing conflicts? I could try to help you if you have no time.

@vitcpp vitcpp reopened this Jun 14, 2023
msdemlei added 2 commits June 15, 2023 11:16
This bumps version to 1.2.1, too.
Also, fixing upgrade script generation.
@msdemlei msdemlei force-pushed the add-proper-motions branch from ceb7017 to 44edb5c Compare June 15, 2023 09:57
@msdemlei
Copy link
Contributor Author

msdemlei commented Jun 15, 2023 via email

(and fixing a duplicated line in the Makefile too trivial to warrant another
rebase)
@vitcpp vitcpp merged commit 1a782ae into postgrespro:master Jun 16, 2023
@vitcpp
Copy link
Contributor

vitcpp commented Jun 16, 2023

@msdemlei Thank you very much for fast response! I appreciate you are ready to help with generalizations. I think we come back to this task a little bit later. We have some plans to do some improvements in pgSphere and I would like to be in sync with you.

In past we discussed that your colleagues would like to pull some cleanups in Makefile. Could you please clarify your plans because I have to wait for your changes and to postpone my changes to be in sync with you.

On my side, the next thing I would like to do is to move all sources into src subdirectory. What do you think if I move all c/cpp/h files into src subdirectory?

@msdemlei
Copy link
Contributor Author

msdemlei commented Jun 19, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants