sot / kadi

Chandra commands and events
https://sot.github.io/kadi
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

Kadi problem: orbit_points event does not work #49

Open Gregg140 opened 10 years ago

Gregg140 commented 10 years ago

According to the Kadi documentation,

http://cxc.cfa.harvard.edu/mta/ASPECT/tool_doc/kadi/index.html

an available event is "orbit_points". When I try to use that, I get the following failure:

In [95]: orbpts = events.orbit_points.filter( start="2014:188", stop="2014:195").table
ERROR: AttributeError: 'module' object has no attribute 'orbit_points' [IPython.core.interactiveshell]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-95-0e9caf8c9705> in <module>()
----> 1 orbpts = events.orbit_points.filter( start="2014:188", stop="2014:195").table

AttributeError: 'module' object has no attribute 'orbit_points'

Other events work fine. For example:

myorbits = events.orbits.filter( start="2014:188", stop="2014:195").table

succeeds:

In [93]: myorbits = events.orbits.filter( start="2014:188", stop="2014:195").table

In [94]: myorbits
Out[94]:
<Table rows=4 names=('start','stop','tstart','tstop','dur','orbit_num','perigee','apogee','t_perigee','start_radzone','stop_radzone','dt_start_radzone','dt_stop_radzone')>
array([ ('2014:186:11:10:57.622', '2014:189:02:40:15.201', 520945924.806, 521174482.385, 228557.578125, 2060, '2014:189:01:16:27.562', '2014:187:17:31:43.880', 521169454.74600005, '2014:188:18:57:37.156', '2014:189:07:20:56.156', -22730.40625, 21868.59375),
       ('2014:189:02:40:15.201', '2014:191:18:10:49.572', 521174482.385, 521403116.75600004, 228634.375, 2061, '2014:191:16:46:37.217', '2014:190:09:01:04.710', 521398064.40099996, '2014:191:10:00:21.414', '2014:191:23:29:40.414', -24375.802734375, 24183.197265625),
       ('2014:191:18:10:49.572', '2014:194:09:41:39.071', 521403116.75600004, 521631766.255, 228649.5, 2062, '2014:194:08:16:29.028', '2014:193:00:30:38.359', 521626656.212, '2014:194:01:09:51.404', '2014:194:14:21:10.404', -25597.623046875, 21881.376953125),
       ('2014:194:09:41:39.071', '2014:197:01:10:53.434', 521631766.255, 521860320.618, 228554.359375, 2063, '2014:196:23:44:41.883', '2014:195:15:59:42.808', 521855149.067, '2014:196:17:27:52.091', '2014:197:05:57:11.091', -22609.79296875, 22349.20703125)],
      dtype=[('start', '|S21'), ('stop', '|S21'), ('tstart', '<f8'), ('tstop', '<f8'), ('dur', '<f8'), ('orbit_num', '<i8'), ('perigee', '|S21'), ('apogee', '|S21'), ('t_perigee', '<f8'), ('start_radzone', '|S21'), ('stop_radzone', '|S21'), ('dt_start_radzone', '<f8'), ('dt_stop_radzone', '<f8')])

Please let me know if my usage is incorrect.

thanks

taldcroft commented 10 years ago

@Gregg140

Sorry, this is indeed a documentation error and the OrbitPoint and ManvrSeq models are not kadi events which can be queried using the usual mechanism. These are not "events" because they have no duration and instead correspond to points in time. (Yes the English is a bit ambiguous, but for kadi an "event" is something with a distinct start and stop time). You can still work with these models, but directly using the Django query mechanism. For example:

>>> from kadi.events import models
>>> models.<TAB>
models.AsciiTableEvent      models.Dump                 models.LoadSegment          models.Obsid                models.Scs107               models.get_event_models     models.np
models.BaseEvent            models.Dwell                models.LttBad               models.Orbit                models.TlmEvent             models.get_manvr_templates  models.operator
models.BaseModel            models.Eclipse              models.MAX_GAP              models.OrbitPoint           models.TscMove              models.import_ska           models.os
models.CAP                  models.Event                models.MajorEvent           models.Pad                  models.Update               models.interpolate          models.pyyaks
models.DarkCal              models.FaMove               models.Manvr                models.PassPlan             models.ZERO_DT              models.izip                 models.table
models.DarkCalReplica       models.GratingMove          models.ManvrSeq             models.Quat                 models.count                models.logger               models.utils
models.DateTime             models.IFotEvent            models.MyManager            models.RadZone              models.fetch                models.models               
models.DsnComm              models.IntervalPad          models.NormalSun            models.SafeSun              models.fuzz_states          models.msidset_interpolate  
>>> models.OrbitPoint?
Type:       ModelBase
String Form:<class 'kadi.events.models.OrbitPoint'>
File:       /proj/sot/ska/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/kadi-0.10-py2.7.egg/kadi/events/models.py
Docstring:
Orbit point

**Fields**

=========== ============ ===========
   Field        Type     Description
=========== ============ ===========
     orbit   ForeignKey
      date     Char(21)
      name      Char(9)
 orbit_num      Integer
     descr     Char(50)
=========== ============ ===========
Constructor information:
 Definition:models.OrbitPoint(self, *args, **kwargs)

>>> orbit_points = models.OrbitPoint.objects.filter(date__gte='2010:001:00:00:00', 
                           date__lte='2010:003:00:00:00')
>>> for orbit_point in orbit_points:
...     print orbit_point.date, orbit_point.orbit_num, orbit_point.name, ':', orbit_point.descr
...     
2010:001:03:39:30.249 1437 EAPOGEE : ORBIT APOGEE
2010:001:22:38:25.449 1437 EALT1 : ALTITUDE ZONE ENTRY 1
2010:001:22:38:27.669 1437 XALT1 : ALTITUDE ZONE EXIT 1
2010:002:04:43:55.919 1437 EQF003M : PROTON FLUX ENTRY FOR ENERGY 0 LEVEL 0 KP 3 MEAN
2010:002:04:43:55.919 1437 EQF013M : PROTON FLUX ENTRY FOR ENERGY 0 LEVEL 1 KP 3 MEAN
2010:002:04:43:56.035 1437 OORMPDS : RADMON DISABLE
2010:002:06:52:08.035 1437 EEF1000 : ELECTRON 1 RADIATION ENTRY 0
2010:002:09:52:45.649 1437 EALT0 : ALTITUDE ZONE ENTRY0
2010:002:09:52:46.498 1437 XALT0 : ALTITUDE ZONE EXIT 0
2010:002:11:22:03.666 1437 EPERIGEE : ORBIT PERIGEE
2010:002:12:51:20.520 1437 EALT0 : ALTITUDE ZONE ENTRY0
2010:002:12:51:21.380 1437 XALT0 : ALTITUDE ZONE EXIT 0
2010:002:12:57:36.182 1437 XASCNCR : ORBIT ASCENDING NODE CROSSING EXIT
2010:002:12:57:36.182 1438 EASCNCR : ORBIT ASCENDING NODE CROSSING
2010:002:15:42:08.035 1438 XEF1000 : ELECTRON 1 RADIATION EXIT 0
2010:002:17:23:55.035 1438 OORMPEN : RADMON ENABLE
2010:002:17:23:55.919 1438 XQF013M : PROTON FLUX EXIT FOR ENERGY 0 LEVEL 1 KP 3 MEAN
2010:002:19:17:55.919 1438 XQF003M : PROTON FLUX EXIT FOR ENERGY 0 LEVEL 0 KP 3 MEAN
taldcroft commented 10 years ago

As an action from this I will update the docs to reflect the correct list of query-able events and show this example for using OrbitPoints.