Attitude Generator Module#

Note

At the moment, only JUICE AGM API interface is publicly available. In the future, the module will be able to run AGM directly if you have it installed locally.

When you have a valid PTR, read from a file with read_ptr() or manually created, you can try to submit it to ESA Attitude Generator Module (AGM) to know if the new attitude is valid and retrieve the generated camera kernel (ck).

Call AGM programmatically#

from ptr import agm_simulation

To call AGM, you need to identify which metakernel will be use as our baseline (here juice_crema_5_0). You will also need to choose, which AGM endpoint you want to use (currently on JUICE_API is available):

Hint

Instead of calling agm_simulation on example.ptx filename, you can provide a pointing request message directly.

You can also call AGM direct on the PRM object:

prm.simulate('juice_crema_5_0', 'JUICE_API')
results = agm_simulation('juice_crema_5_0', 'example.ptx', 'JUICE_API')

results

Success


    • AGM Endpoint: https://juicept.esac.esa.int/agm
    • Metakernel: juice_crema_5_0
    • <prm>
        <body>
          <segment>
            <data>
              <timeline frame="SC">
                  <block ref="OBS">
                     <metadata>
                        <comment> Occultation by star HD157056 </comment>
                        <solarArrays>
                           <fixedRotationAngle units="deg">-50</fixedRotationAngle>
                        </solarArrays>
                     </metadata>
                     <startTime> 2032-07-02T04:18:40 </startTime>
                     <endTime> 2032-07-02T04:32:00 </endTime>
                     <attitude ref="inertial">
                        <boresight ref="SC_Zaxis" />
                        <phaseAngle ref="align">
                           <SCAxis frame="SC">
                              <x> 0 </x>
                              <y> -1 </y>
                              <z> 0 </z>
                           </SCAxis>
                           <inertialAxis ref="EU2SC" />
                        </phaseAngle>
                        <target frame="EME2000">
                           <lon units="deg"> 260.504 </lon>
                           <lat units="deg"> -24.999 </lat>
                        </target>
                     </attitude>
                  </block>
              </timeline>
            </data>
          </segment>
        </body>
      </prm>
    • CK: https://juicept.esac.esa.int/agm_output/20221021T152145212024/OUTPUT/test.ck
    • timeqxqyqzqw
      2032-07-02 04:18:40-0.6697849293235570.512532311431917-0.2516532457148540.474730894413323
      2032-07-02 04:18:50-0.6689255330084210.513653436764621-0.2524480347230740.474308726415351
      2032-07-02 04:19:00-0.6680775736522070.514755842505634-0.2532298591434960.47389177733683
      2032-07-02 04:19:10-0.6672408492456340.515839966373944-0.2539990152502150.473479966251177
      2032-07-02 04:19:20-0.6664151616438710.516906233413642-0.2547557909468460.473073213327854
      2032-07-02 04:19:30-0.6656003164489520.517955056499848-0.2555004660967840.472671439811652
      2032-07-02 04:19:40-0.6647961230513540.518986836621695-0.2562333126966490.472274568078566
      2032-07-02 04:19:50-0.6640023944727080.520001963405155-0.2569545952213340.471882521591905
      2032-07-02 04:20:00-0.6632189473882170.521000815388969-0.2576645707950340.471495224945391
      2032-07-02 04:20:10-0.6624456020456580.521983760418915-0.2583634894474960.471112603853694
      2032-07-02 04:20:20-0.661682182185020.522951156026618-0.259051594360490.470734585141757
      2032-07-02 04:20:30-0.6609285150536050.5239033496741-0.2597291220198910.470361096779986
      2032-07-02 04:20:40-0.6601844312452870.524840679208503-0.2603963025182940.469992067831038
      2032-07-02 04:20:50-0.659449764736150.525763473056224-0.2610533596732590.469627428492628
      2032-07-02 04:21:00-0.6587243527958950.526672050563094-0.2617005112503710.469267110077607
      2032-07-02 04:21:10-0.6580080358971810.52756672232566-0.262337969180930.468911044991819
      2032-07-02 04:21:20-0.6573006576513430.528447790478698-0.2629659397493730.46855916672393
      2032-07-02 04:21:30-0.6566020648468180.529315548845489-0.2635846236836520.468211409885365
      2032-07-02 04:21:40-0.6559121072917310.530170283323035-0.2641942164138420.467867710151887
      2032-07-02 04:21:50-0.6552306377640810.531012272123707-0.2647949082292060.467528004257692
      2032-07-02 04:22:00-0.6545575120378370.531841785915269-0.2653868843634450.467192230026525
      2032-07-02 04:22:10-0.6538925886814970.53265908823385-0.2659703252753550.466860326288512
      2032-07-02 04:22:20-0.6532357291639930.533464435510271-0.2665454066542460.466532232949468
      2032-07-02 04:22:30-0.6525867976830980.534258077431147-0.2671122996648710.466207890921034
      2032-07-02 04:22:40-0.6519456611766480.53504025706824-0.267671171027530.46588724214132
      Use print() to display all elements.
  • INFOAGEAttitude Generation Module initialization started
    INFOAGEAGE module setup started
    INFOAGEAGE module setup successfully completed
    INFOAGEAttitude Generation Module initialization completed
    INFOAGELoading Attitude Timeline
    INFOAGEChecking Attitude Timeline
    INFOAGEInitializing Attitude Timeline
    INFOAGEWriting Attitude Spice CK File: /agm_output/20221021T152145212024/OUTPUT/test.ck
    INFOAGEWriting Attitude Text File: /agm_output/20221021T152145212024/OUTPUT/quaternions.csv

Tip

The calculations are cached locally to avoid, duplication requests if PTR was already submitted.

As you can see, this simulation was successful. You can expand the results and explore the log if you need more details.

This AGMResults object is full compatible with spiceypy and can be used as a regular kernel file.

spiceypy.furnsh(results)

In that case, the generated ck from the simulation will be download and put into the SPICE Pool.

If you need to save this ck locally, you can do:

results.ck.save('example.ck')
PosixPath('example.ck')

Call AGM from the command line interface#

You can query AGM directly from the command line in Jupyter notebooks and in your terminal:

Hint

Remove the ! symbol to run this command in your terminal. But keep it if you run this cell into a Jupyter notebook.

!juice-agm --help
usage: juice-agm [-h] [--mk METAKERNEL] [--endpoint URL] [--quaternions]
                 [--ck FILENAME] [--log] [--no-cache]
                 ptr

Check ESA/JUICE PTR validity with AGM.

positional arguments:
  ptr              PTR/PTX input file.

optional arguments:
  -h, --help       show this help message and exit
  --mk METAKERNEL  Metakernel to use with AGM (default: `juice_crema_5_0`).
  --endpoint URL   AGM API endpoint URL (default: `JUICE_API`).
  --quaternions    Display computed quaternions (optional).
  --ck FILENAME    CK output filename (optional).
  --log            Display AGM log (optional).
  --no-cache       Disable cache (optional).

By default, the tool will use JUICE pointing tool as AGM API endpoint. In the future, it should be possible use locally hosted AGM instances to perform complex queries.

If you just need to test the validity of a ptr file you just have to do:

!juice-agm example.ptx
AGM simulation: Success

You can explicitly say with which metakernel you want to work with:

!juice-agm --mk juice_crema_5_0 example.ptx
AGM simulation: Success

If you are only interested by the quaternions, you can request them:

!juice-agm --quaternions example.ptx
AGM simulation: Success
Quaternions:
2032-07-02 04:18:40 | -0.6697849293235570 | 0.5125323114319170 | -0.2516532457148540 | 0.4747308944133230
2032-07-02 04:18:50 | -0.6689255330084209 | 0.5136534367646211 | -0.2524480347230740 | 0.4743087264153510
2032-07-02 04:19:00 | -0.6680775736522070 | 0.5147558425056340 | -0.2532298591434960 | 0.4738917773368300
2032-07-02 04:19:10 | -0.6672408492456340 | 0.5158399663739440 | -0.2539990152502150 | 0.4734799662511770
2032-07-02 04:19:20 | -0.6664151616438710 | 0.5169062334136419 | -0.2547557909468460 | 0.4730732133278540
2032-07-02 04:19:30 | -0.6656003164489520 | 0.5179550564998480 | -0.2555004660967840 | 0.4726714398116520
2032-07-02 04:19:40 | -0.6647961230513540 | 0.5189868366216950 | -0.2562333126966490 | 0.4722745680785660
2032-07-02 04:19:50 | -0.6640023944727080 | 0.5200019634051550 | -0.2569545952213340 | 0.4718825215919050
2032-07-02 04:20:00 | -0.6632189473882170 | 0.5210008153889690 | -0.2576645707950340 | 0.4714952249453910
2032-07-02 04:20:10 | -0.6624456020456581 | 0.5219837604189150 | -0.2583634894474960 | 0.4711126038536940
2032-07-02 04:20:20 | -0.6616821821850200 | 0.5229511560266180 | -0.2590515943604900 | 0.4707345851417570
2032-07-02 04:20:30 | -0.6609285150536049 | 0.5239033496741000 | -0.2597291220198910 | 0.4703610967799860
2032-07-02 04:20:40 | -0.6601844312452870 | 0.5248406792085030 | -0.2603963025182940 | 0.4699920678310380
2032-07-02 04:20:50 | -0.6594497647361500 | 0.5257634730562240 | -0.2610533596732590 | 0.4696274284926280
2032-07-02 04:21:00 | -0.6587243527958950 | 0.5266720505630940 | -0.2617005112503710 | 0.4692671100776070
2032-07-02 04:21:10 | -0.6580080358971810 | 0.5275667223256600 | -0.2623379691809300 | 0.4689110449918190
2032-07-02 04:21:20 | -0.6573006576513430 | 0.5284477904786981 | -0.2629659397493730 | 0.4685591667239300
2032-07-02 04:21:30 | -0.6566020648468180 | 0.5293155488454890 | -0.2635846236836520 | 0.4682114098853650
2032-07-02 04:21:40 | -0.6559121072917310 | 0.5301702833230350 | -0.2641942164138420 | 0.4678677101518870
2032-07-02 04:21:50 | -0.6552306377640810 | 0.5310122721237071 | -0.2647949082292060 | 0.4675280042576920
2032-07-02 04:22:00 | -0.6545575120378370 | 0.5318417859152690 | -0.2653868843634450 | 0.4671922300265250
2032-07-02 04:22:10 | -0.6538925886814970 | 0.5326590882338500 | -0.2659703252753550 | 0.4668603262885120
2032-07-02 04:22:20 | -0.6532357291639930 | 0.5334644355102710 | -0.2665454066542460 | 0.4665322329494680
2032-07-02 04:22:30 | -0.6525867976830980 | 0.5342580774311469 | -0.2671122996648710 | 0.4662078909210340
2032-07-02 04:22:40 | -0.6519456611766480 | 0.5350402570682400 | -0.2676711710275300 | 0.4658872421413200
2032-07-02 04:22:50 | -0.6513121891727790 | 0.5358112111981870 | -0.2682221832347070 | 0.4655702295144110
2032-07-02 04:23:00 | -0.6506862538595410 | 0.5365711703482980 | -0.2687654945725400 | 0.4652567969589190
2032-07-02 04:23:10 | -0.6500677299406440 | 0.5373203590973680 | -0.2693012593249860 | 0.4649468893489560
2032-07-02 04:23:20 | -0.6494564946543750 | 0.5380589961723130 | -0.2698296278325680 | 0.4646404525361860
2032-07-02 04:23:30 | -0.6488524276396320 | 0.5387872947247940 | -0.2703507466802630 | 0.4643374332947090
2032-07-02 04:23:40 | -0.6482554109315420 | 0.5395054624456390 | -0.2708647587698630 | 0.4640377793303450
2032-07-02 04:23:50 | -0.6476653289552330 | 0.5402137016774160 | -0.2713718033913650 | 0.4637414392885460
2032-07-02 04:24:00 | -0.6470820683598710 | 0.5409122097141240 | -0.2718720164287290 | 0.4634483626816160
2032-07-02 04:24:10 | -0.6465055180884320 | 0.5416011788132610 | -0.2723655303601230 | 0.4631584999338170
2032-07-02 04:24:20 | -0.6459355692649880 | 0.5422807964228700 | -0.2728524744124370 | 0.4628718023344090
2032-07-02 04:24:30 | -0.6453721151422080 | 0.5429512453320080 | -0.2733329746613490 | 0.4625882220204840
2032-07-02 04:24:40 | -0.6448150511216980 | 0.5436127037309080 | -0.2738071540669890 | 0.4623077119960580
2032-07-02 04:24:50 | -0.64
42642746129590 | 0.5442653454594950 | -0.2742751326449200 | 0.4620302260695780
2032-07-02 04:25:00 | -0.6437196850730650 | 0.5449093400375330 | -0.2747370274809100 | 0.4617557188820170
2032-07-02 04:25:10 | -0.6431811839014100 | 0.5455448528635261 | -0.2751929528669730 | 0.4614841458616430
2032-07-02 04:25:20 | -0.6426486744653370 | 0.5461720452555689 | -0.2756430203243480 | 0.4612154632444200
2032-07-02 04:25:30 | -0.6421220619942130 | 0.5467910746446090 | -0.2760873387360660 | 0.4609496280277610
2032-07-02 04:25:40 | -0.6416012535738290 | 0.5474020946463360 | -0.2765260143927080 | 0.4606865979745650
2032-07-02 04:25:50 | -0.6410861580472300 | 0.5480052552402650 | -0.2769591511153620 | 0.4604263315697230
2032-07-02 04:26:00 | -0.6405766860981160 | 0.5486007027321980 | -0.2773868502232660 | 0.4601687880685840
2032-07-02 04:26:10 | -0.6400727501073380 | 0.5491885799802600 | -0.2778092106909210 | 0.4599139274305380
2032-07-02 04:26:20 | -0.6395742641136800 | 0.5497690264958091 | -0.2782263292156200 | 0.4596617103049760
2032-07-02 04:26:30 | -0.6390811438556721 | 0.5503421784479470 | -0.2786383002158900 | 0.4594120980580440
2032-07-02 04:26:40 | -0.6385933066906850 | 0.5509081688090700 | -0.2790452159314510 | 0.4591650527371000
2032-07-02 04:26:50 | -0.6381106715281090 | 0.5514671274814590 | -0.2794471665097820 | 0.4589205370420340
2032-07-02 04:27:00 | -0.6376331588285670 | 0.5520191813451860 | -0.2798442400363070 | 0.4586785143298040
2032-07-02 04:27:10 | -0.6371606905979420 | 0.5525644543104991 | -0.2802365225679380 | 0.4584389486161970
2032-07-02 04:27:20 | -0.6366931902986300 | 0.5531030674639750 | -0.2806240982342390 | 0.4582018045354190
2032-07-02 04:27:30 | -0.6362305828410110 | 0.5536351391200640 | -0.2810070492707120 | 0.4579670473401570
2032-07-02 04:27:40 | -0.6357727945736470 | 0.5541607848726950 | -0.2813854560522490 | 0.4577346429008430
2032-07-02 04:27:50 | -0.6353197532221900 | 0.5546801177042510 | -0.2817593971680340 | 0.4575045576787190
2032-07-02 04:28:00 | -0.6348713878722970 | 0.5551932480423450 | -0.2821289494590080 | 0.4572767587210730
2032-07-02 04:28:10 | -0.6344276289415220 | 0.5557002838278420 | -0.2824941880635700 | 0.4570512136507220
2032-07-02 04:28:20 | -0.6339884081290730 | 0.5562013306067050 | -0.2828551864805680 | 0.4568278906440990
2032-07-02 04:28:30 | -0.6335536584242760 | 0.5566964915534510 | -0.2832120165831470 | 0.4566067584390330
2032-07-02 04:28:40 | -0.6331233140709980 | 0.5571858675437330 | -0.2835647486680940 | 0.4563877863200280
2032-07-02 04:28:50 | -0.6326973104748330 | 0.5576695572905320 | -0.2839134515511760 | 0.4561709440742500
2032-07-02 04:29:00 | -0.6322755843287871 | 0.5581476572309489 | -0.2842581924827880 | 0.4559562020586110
2032-07-02 04:29:10 | -0.6318580734217240 | 0.5586202617722460 | -0.2845990373226920 | 0.4557435311052600
2032-07-02 04:29:20 | -0.6314447166632160 | 0.5590874632906880 | -0.2849360505366730 | 0.4555329025370800
2032-07-02 04:29:30 | -0.6310354541802130 | 0.5595493520488410 | -0.2852692951344180 | 0.4553242882197330
2032-07-02 04:29:40 | -0.6306302270779750 | 0.5600060164911520 | -0.2855988328803660 | 0.4551176604425140
2032-07-02 04:29:50 | -0.6302289775859110 | 0.5604575431036000 | -0.2859247241901960 | 0.4549129919952330
2032-07-02 04:30:00 | -0.6298316490255780 | 0.5609040164737870 | -0.2862470281719450 | 0.4547102561544260
2032-07-02 04:30:10 | -0.6294381856289540 | 0.5613455195179130 | -0.2865658027877310 | 0.4545094265930220
2032-07-02 04:30:20 | -0.6290485327382690 | 0.5617821332781390 | -0.2868811047054200 | 0.4543104774846080
2032-07-02 04:30:30 | -0.6286626366350870 | 0.5622139371357900 | -0.2871929894505600 | 0.4541133834184420
2032-07-02 04:30:40 | -0.6282804445526380 | 0.5626410088177410 | -0.2875015114090960 | 0.4539181194078730
2032-07-02 04:30:50 | -0.6279019046713910 | 0.5630634244210380 | -0.2878067238433050 | 0.4537246608901460
2032-07-02 04:31:00 | -0.6275269661088210 | 0.5634812584434050 | -0.2881086789120440 | 0.4535329837231810
2032-07-02 04:31:10 | -0.6271555788762530 | 0.5638945838497640 | -0.2884074277170770 | 0.4533430641654430
2032-07-02 04:31:20 | -0.6267876938650950 | 0.5643034721051980 | -0.2887030203252440 | 0.4531548788707630
2032-07-02 04:31:30 | -0.6264232628373190 | 0.5647079932026410 | -0.2889955057868520 | 0.4529684048852590
2032-07-02 04:31:40 | -0.6260622383630310 | 0.5651082157486100 | -0.2892849321961120 | 0.4527836196171250
2032-07-02 04:31:50 | -0.6257045739197050 | 0.5655042068691140 | -0.2895713466215850 | 0.4526005008890910

You can also save the generated CK file locally:

!juice-agm --ck example.ck example.ptx
AGM simulation: Success
AGM CK saved in `example.ck`.