NASA-Planetary-Science / sbpy

A Python package for small bodies research
https://sbpy.org/
Other
67 stars 34 forks source link

Write observations to file in MPC and/or DES format #351

Open monocongo opened 2 years ago

monocongo commented 2 years ago

This is a request for

The requested changes will be implemented by

High-level concept I would like to query MPC observations for an object and then write the observations data to a file which is suitable as input to OpenOrb for orbit computations. I propose we add a function to the Obs class which would allow writing to file in DES or MPC format.

Please advise if there is already a way to do this using sbpy, I am a novice user still unfamiliar with this package.

Explain the relevance to sbpy This is related to the sbpy.Data.Obs class

Proposal details Write the file in DES and MPC formats using Python standard library.

Example (pseudo-)code

observations = Obs.from_mpc(targetid=designation, id_type='asteroid designation')
file_path = f'/home/james/data/observations_{designation}.mpc'
observations.to_file(path=file_path, format='DES')
mkelley commented 2 years ago

Hi @monocongo , this sounds like a good idea. We have a to_file method in DataClass (from which Obs objects are derived) that passes parameters on to astropy.table.Table.write. Perhaps the Obs object should implement its own version that writes the DES or MPC formats if requested, or else passes on to the DataClass.to_file for other formats. Regardless, please give this a try, starting with methods that format the object into strings, e.g., Obs.to_mpc80 and Obs.to_des.

mkelley commented 2 years ago

I've marked this as a v0.4 milestone, due by Aug 1, but if that timescale isn't good for you, let me know and I can change this to v0.5 (~1 Feb) at any time.

mkelley commented 1 year ago

I'm still happy to have this contribution, but we're going to make a release in the next week, so I will re-milestone this to v0.5.