-
Notifications
You must be signed in to change notification settings - Fork 11
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
Request for consistent handling of time values between spacecraft frames and tte objects #30
Comments
I'm not a big fan of making all time values an instance of Time. Mainly because it adds considerable overhead even when the library or end user is only interested in working with the primitive floating point value (regardless of scale). We could add a convention that states that the mission extension should consider integer/floating point values to represent seconds from that mission's epoch value, and define a function similar to: def time_val(value: Union[int, float, Time, dt.datetime]) -> Time:
if isinstance(value, Time):
return value
elif isinstance(value, dt.datetime):
return Time(value, format='datetime')
elif isinstance(value, (int, float)):
return Time(value, format=mission_format)
throw TypeError() That way functions like at(...) can convert primitive values to time with a simple function call. That said, I'm still open to the idea of keeping time values in Time objects but with an eye towards taking advantage of its array support for returning multiple time values. |
I completely agree with you. I also want to keep the internal values as floats, not Time objects. I may have been unclear with my earlier description. What I was proposing is the ability to pass a Time object as an argument to something like The goal here is to provide a function that does the time manipulation for the user without the user needing to know that the internal format is different. I suppose the tricker thing is returning trigtime, tstart, tstop values. What about methods in the same spirit as get_spacecraft_frames() such as
? |
After discussing this more with @joshuarwood, I'm okay with standardizing the time parameters for functions expecting a Time object, and functions returning time as a Time object. The benefits from having a consistent and simple rule for handling time will offset any performance hits from using astropy Time. |
@BillCleveland-USRA @AdamGoldstein-USRA
Currently when working with poshist history information from the GBM mission a user can do:
where a Time object is used to retrieve a spacecraft frame. In this case, the user does not need knowledge of the underlying time format used in the mission. They only need to create a valid time object.
However, this is incompatible with the time format in tte files:
because the tte class has no inherent knowledge of the underlying time format from the mission.
Would it be possible to require knowledge of the time format in the core tte class? Inherited classes from missions would then be required to set this value, similar to how GbmPosHist knows the underlying time format needed to generate spacecraft frames. Functions like splice_time could then allow for either float or time class input with something like:
this would allow users the ability to provide Time values instead of needing to know the internal mission time formats themselves. You could also have a separate splice_time function for a formatted input if you want to avoid slowing down the regular float method. The benefit here is that you avoid having to caste the underlying data to astropy time objects.
There is also a need to return a Time class value for tte.trigtime
What do you think? Should I prototype this for a pull request?
The text was updated successfully, but these errors were encountered: