[docs]classTemporalFrame(CoordinateFrame):""" A coordinate frame for time axes. Parameters ---------- reference_frame : `~astropy.time.Time` A Time object which holds the time scale and format. If data is provided, it is the time zero point. To not set a zero point for the frame initialize ``reference_frame`` with an empty list. unit : str or `~astropy.units.Unit` Time unit. axes_names : str Time axis name. axes_order : tuple or int A dimension in the data that corresponds to this axis. name : str Name for this frame. """def__init__(self,reference_frame,unit=u.s,axes_order=(0,),axes_names=None,name=None,axis_physical_types=None,):axes_names=(axes_namesorf"{reference_frame.format}({reference_frame.scale}; "f"{reference_frame.location}")pht=axis_physical_typesorself._default_axis_physical_types()super().__init__(naxes=1,axes_type="TIME",axes_order=axes_order,axes_names=axes_names,reference_frame=reference_frame,unit=unit,name=name,axis_physical_types=pht,)self._attrs={}forainself.reference_frame.info._represent_as_dict_extra_attrs:withcontextlib.suppress(AttributeError):self._attrs[a]=getattr(self.reference_frame,a)def_default_axis_physical_types(self):return("time",)def_convert_to_time(self,dt,*,unit,**kwargs):if(notisinstance(dt,time.TimeDelta)andisinstance(dt,time.Time))orisinstance(self.reference_frame.value,np.ndarray):returntime.Time(dt,**kwargs)ifnothasattr(dt,"unit"):dt=dt*unitreturnself.reference_frame+dt@propertydefworld_axis_object_classes(self):comp=(time.Time,(),{"unit":self.unit[0],**self._attrs},self._convert_to_time,)return{"temporal":comp}@propertydef_native_world_axis_object_components(self):ifisinstance(self.reference_frame.value,np.ndarray):return[("temporal",0,"value")]defoffset_from_time_and_reference(time):return(time-self.reference_frame).secreturn[("temporal",0,offset_from_time_and_reference)]