Skip to content

[F&E]: Time Conversion Issues for Legacy MPC Observations #507

@luigigisolfi

Description

@luigigisolfi

Description:

Functions from the DateTime module do not work before a given date (1958-09-18 19:31:01).
This is not a problem for most applications, but it arises whenever we want to MPC-query objects like Eros, for which observations are available starting from 1893-10-29.

For context, I would like to change the following code:

                # convert JD to J2000 and UTC, convert deg to rad
                obs = (
                    obs.assign(
                        epochJ2000secondsTDB=lambda x: (
                            Time(x.epoch, format="jd", scale="utc").tdb.value
                            - 2451545.0
                        )
                        * 86400
                    )
                    .assign(RA=lambda x: np.radians(x.RA))
                    .assign(DEC=lambda x: np.radians(x.DEC))
                    .assign(epochUTC=lambda x: Time(x.epoch, format="jd").to_datetime())
                )

to the following (faster and more robust, leveraging tudatpy's DateTime)

                dt_objects = [DateTime.from_julian_day(jd) for jd in obs.epoch]

                # Convert DateTime objects to epochJ2000secondsTDB
                obs['epochJ2000secondsTDB'] = [
                    time_scale_converter.convert_time(
                        input_scale=time_representation.utc_scale,
                        output_scale=time_representation.tdb_scale,
                        input_value=dt_obj.epoch()
                    ) for dt_obj in dt_objects
                ]

                # Convert DateTime objects to Python datetime objects for epochUTC
                obs['epochUTC'] = [DateTime.to_python_datetime(dt_obj) for dt_obj in dt_objects]

However, this is not possible because it would break Eros's estimation example, since the current way to query an object from the MPC only allows date filtering AFTER querying all observations for the object itself. In other words, the mpc wrapper will ask for all dates and only then one could perform: batch.filter(start_date,end_date)

This breaks the workflow of the get_observations() function in mpc.py.

Metadata

Metadata

Labels

type: bugProblem that affects expected behaviortype: featureNew feature or request

Type

Projects

Status

Pull request

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions