sbpy icon indicating copy to clipboard operation
sbpy copied to clipboard

Write observations to file in MPC and/or DES format

Open monocongo opened this issue 2 years ago • 3 comments

This is a request for

  • [X] a new feature
  • [ ] an enhancement to existing sbpy functionality
  • [ ] somethings else: [explain here]

The requested changes will be implemented by

  • [X] me
  • [ ] the sbpy developers

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')

monocongo avatar Jun 22 '22 20:06 monocongo

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 avatar Jun 24 '22 20:06 mkelley

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 avatar Jun 24 '22 20:06 mkelley

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.

mkelley avatar Jun 09 '23 13:06 mkelley