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/20230117T220832891400/OUTPUT/test.ck
    • timeqxqyqzqw
      2032-07-02 04:18:40-0.6697849293295030.512532311424147-0.2516532457093460.474730894416243
      2032-07-02 04:18:50-0.6689255330119180.513653436760066-0.2524480347198440.47430872641707
      2032-07-02 04:19:00-0.6680775736453360.514755842514552-0.2532298591498220.473891777333449
      2032-07-02 04:19:10-0.6672408492367960.515839966385375-0.2539990152583270.473479966246825
      2032-07-02 04:19:20-0.666415161636480.516906233423171-0.254755790953610.473073213324211
      2032-07-02 04:19:30-0.6656003164498020.517955056498756-0.2555004660960080.472671439812071
      2032-07-02 04:19:40-0.6647961230462750.518986836628201-0.256233312701270.472274568076058
      2032-07-02 04:19:50-0.6640023944673090.520001963412049-0.2569545952262330.471882521589237
      2032-07-02 04:20:00-0.6632189473826030.521000815396116-0.2576645708001150.471495224942615
      2032-07-02 04:20:10-0.6624456020347330.52198376043278-0.2583634894573560.471112603848287
      2032-07-02 04:20:20-0.6616821821830630.522951156029093-0.2590515943622510.470734585140788
      2032-07-02 04:20:30-0.6609285150468460.523903349682626-0.2597291220259590.470361096776635
      2032-07-02 04:20:40-0.6601844312473550.524840679205902-0.2603963025164430.469992067832064
      2032-07-02 04:20:50-0.6594497647498190.525763473039079-0.261053359661050.469627428499415
      2032-07-02 04:21:00-0.6587243528052130.52667205055144-0.2617005112420690.469267110082237
      2032-07-02 04:21:10-0.6580080358914040.527566722332865-0.2623379691860650.468911044988946
      2032-07-02 04:21:20-0.6573006576547660.528447790474441-0.2629659397463380.468559166725633
      2032-07-02 04:21:30-0.6566020648514550.529315548839737-0.2635846236795510.468211409887674
      2032-07-02 04:21:40-0.6559121072893490.530170283325982-0.2641942164159440.4678677101507
      2032-07-02 04:21:50-0.655230637769720.531012272116748-0.2647949082242410.467528004260504
      2032-07-02 04:22:00-0.6545575120297690.531841785925199-0.2653868843705320.467192230022499
      2032-07-02 04:22:10-0.6538925886852820.532659088229203-0.2659703252720380.466860326290402
      2032-07-02 04:22:20-0.6532357291738070.533464435498253-0.2665454066456630.466532232954372
      2032-07-02 04:22:30-0.6525867976988290.534258077411932-0.2671122996511440.466207890928898
      2032-07-02 04:22:40-0.6519456611738110.535040257071698-0.2676711710300010.465887242139901
      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/20230117T220832891400/OUTPUT/test.ck
    INFOAGEWriting Attitude Text File: /agm_output/20230117T220832891400/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.6697849293295030 | 0.5125323114241470 | -0.2516532457093460 | 0.4747308944162430
2032-07-02 04:18:50 | -0.6689255330119180 | 0.5136534367600660 | -0.2524480347198440 | 0.4743087264170700
2032-07-02 04:19:00 | -0.6680775736453360 | 0.5147558425145520 | -0.2532298591498220 | 0.4738917773334490
2032-07-02 04:19:10 | -0.6672408492367961 | 0.5158399663853750 | -0.2539990152583270 | 0.4734799662468250
2032-07-02 04:19:20 | -0.6664151616364800 | 0.5169062334231710 | -0.2547557909536100 | 0.4730732133242110
2032-07-02 04:19:30 | -0.6656003164498020 | 0.5179550564987560 | -0.2555004660960080 | 0.4726714398120710
2032-07-02 04:19:40 | -0.6647961230462750 | 0.5189868366282010 | -0.2562333127012700 | 0.4722745680760580
2032-07-02 04:19:50 | -0.6640023944673090 | 0.5200019634120490 | -0.2569545952262330 | 0.4718825215892370
2032-07-02 04:20:00 | -0.6632189473826030 | 0.5210008153961160 | -0.2576645708001150 | 0.4714952249426150
2032-07-02 04:20:10 | -0.6624456020347330 | 0.5219837604327801 | -0.2583634894573560 | 0.4711126038482870
2032-07-02 04:20:20 | -0.6616821821830630 | 0.5229511560290930 | -0.2590515943622510 | 0.4707345851407880
2032-07-02 04:20:30 | -0.6609285150468460 | 0.5239033496826260 | -0.2597291220259590 | 0.4703610967766350
2032-07-02 04:20:40 | -0.6601844312473550 | 0.5248406792059020 | -0.2603963025164430 | 0.4699920678320640
2032-07-02 04:20:50 | -0.6594497647498190 | 0.5257634730390790 | -0.2610533596610500 | 0.4696274284994150
2032-07-02 04:21:00 | -0.6587243528052130 | 0.5266720505514400 | -0.2617005112420690 | 0.4692671100822370
2032-07-02 04:21:10 | -0.6580080358914040 | 0.5275667223328649 | -0.2623379691860650 | 0.4689110449889460
2032-07-02 04:21:20 | -0.6573006576547660 | 0.5284477904744410 | -0.2629659397463380 | 0.4685591667256330
2032-07-02 04:21:30 | -0.6566020648514550 | 0.5293155488397370 | -0.2635846236795510 | 0.4682114098876740
2032-07-02 04:21:40 | -0.6559121072893490 | 0.5301702833259820 | -0.2641942164159440 | 0.4678677101507000
2032-07-02 04:21:50 | -0.6552306377697200 | 0.5310122721167480 | -0.2647949082242410 | 0.4675280042605040
2032-07-02 04:22:00 | -0.6545575120297690 | 0.5318417859251990 | -0.2653868843705320 | 0.4671922300224990
2032-07-02 04:22:10 | -0.6538925886852820 | 0.5326590882292030 | -0.2659703252720380 | 0.4668603262904020
2032-07-02 04:22:20 | -0.6532357291738070 | 0.5334644354982530 | -0.2665454066456630 | 0.4665322329543720
2032-07-02 04:22:30 | -0.6525867976988290 | 0.5342580774119320 | -0.2671122996511440 | 0.4662078909288980
2032-07-02 04:22:40 | -0.6519456611738110 | 0.5350402570716980 | -0.2676711710300010 | 0.4658872421399010
2032-07-02 04:22:50 | -0.6513121891676380 | 0.5358112112044360 | -0.2682221832391740 | 0.4655702295118380
2032-07-02 04:23:00 | -0.6506862538502300 | 0.5365711703595900 | -0.2687654945806130 | 0.4652567969542550
2032-07-02 04:23:10 | -0.6500677299391970 | 0.5373203590991180 | -0.2693012593262380 | 0.4649468893482310
2032-07-02 04:23:20 | -0.6494564946471530 | 0.5380589961810300 | -0.2698296278388050 | 0.4646404525325640
2032-07-02 04:23:30 | -0.6488524276298390 | 0.5387872947365880 | -0.2703507466887030 | 0.4643374332897950
2032-07-02 04:23:40 | -0.6482554109349410 | 0.5395054624415550 | -0.2708647587669390 | 0.4640377793320520
2032-07-02 04:23:50 | -0.6476653289519581 | 0.5402137016813420 | -0.2713718033941760 | 0.4637414392869010
2032-07-02 04:24:00 | -0.6470820683628150 | 0.5409122097106031 | -0.2718720164262070 | 0.4634483626830960
2032-07-02 04:24:10 | -0.6465055180931610 | 0.5416011788076160 | -0.2723655303560790 | 0.4631584999361950
2032-07-02 04:24:20 | -0.6459355692647520 | 0.5422807964231500 | -0.2728524744126380 | 0.4628718023342910
2032-07-02 04:24:30 | -0.6453721151487010 | 0.5429512453242910 | -0.2733329746558170 | 0.4625882220237520
2032-07-02 04:24:40 | -0.6448150511192871 | 0.5436127037337670 | -0.2738071540690390 | 0.4623077119948440
2032-07-02 04:24:50 | -0.6442642746091209 | 0.5442653454640390 | -0.2742751326481790 | 0.4620302260676440
2032-07-02 04:25:00 | -0.6437196850646100 | 0.5449093400475210 | -0.2747370274880740 | 0.4617557188777540
2032-07-02 04:25:10 | -0.6431811839029620 | 0.5455448528616970 | -0.2751929528656610 | 0.4614841458624250
2032-07-02 04:25:20 | -0.6426486744692960 | 0.5461720452509110 | -0.2756430203210060 | 0.4612154632464180
2032-07-02 04:25:30 | -0.6421220620014890 | 0.5467910746360640 | -0.2760873387299310 | 0.4609496280314350
2032-07-02 04:25:40 | -0.6416012535642650 | 0.5474020946575460 | -0.2765260144007570 | 0.4606865979697330
2032-07-02 04:25:50 | -0.6410861580467599 | 0.5480052552408140 | -0.2769591511157570 | 0.4604263315694850
2032-07-02 04:26:00 | -0.6405766860984660 | 0.5486007027317900 | -0.2773868502229730 | 0.4601687880687610
2032-07-02 04:26:10 | -0.6400727500969590 | 0.5491885799923570 | -0.2778092106996130 | 0.4599139274252870
2032-07-02 04:26:20 | -0.6395742641106840 | 0.5497690264992960 | -0.2782263292181250 | 0.4596617103034600
2032-07-02 04:26:30 | -0.6390811438620410 | 0.5503421784405510 | -0.2786383002105730 | 0.4594120980612690
2032-07-02 04:26:40 | -0.6385933066915290 | 0.5509081688080920 | -0.2790452159307470 | 0.4591650527375280
2032-07-02 04:26:50 | -0.6381106715227380 | 0.5514671274876740 | -0.2794471665142510 | 0.4589205370393120
2032-07-02 04:27:00 | -0.6376331588279081 | 0.5520191813459470 | -0.2798442400368540 | 0.4586785143294700
2032-07-02 04:27:10 | -0.6371606905943050 | 0.5525644543146930 | -0.2802365225709550 | 0.4584389486143520
2032-07-02 04:27:20 | -0.6366931902914490 | 0.5531030674722410 | -0.2806240982401880 | 0.4582018045317760
2032-07-02 04:27:30 | -0.6362305828389621 | 0.5536351391224200 | -0.2810070492724080 | 0.4579670473391170
2032-07-02 04:27:40 | -0.6357727945751600 | 0.5541607848709590 | -0.2813854560509990 | 0.4577346429016110
2032-07-02 04:27:50 | -0.6353197532262980 | 0.5546801176995450 | -0.2817593971646450 | 0.4575045576808060
2032-07-02 04:28:00 | -0.6348713878766750 | 0.5551932480373400 | -0.2821289494554030 | 0.4572767587232980
2032-07-02 04:28:10 | -0.6344276289391980 | 0.5557002838304950 | -0.2824941880654810 | 0.4570512136495410
2032-07-02 04:28:20 | -0.6339884081268480 | 0.5562013306092420 | -0.2828551864823960 | 0.4568278906429680
2032-07-02 04:28:30 | -0.6335536584245270 | 0.5566964915531660 | -0.2832120165829410 | 0.4566067584391610
2032-07-02 04:28:40 | -0.6331233140616660 | 0.5571858675543360 | -0.2835647486757370 | 0.4563877863152780
2032-07-02 04:28:50 | -0.6326973104857900 | 0.5576695572781020 | -0.2839134515422140 | 0.4561709440798280
2032-07-02 04:29:00 | -0.6322755843358260 | 0.5581476572229750 | -0.2842581924770380 | 0.4559562020621950
2032-07-02 04:29:10 | -0.6318580734172050 | 0.5586202617773580 | -0.2845990373263790 | 0.4557435311029580
2032-07-02 04:29:20 | -0.6314447166763399 | 0.5590874632758650 | -0.2849360505259800 | 0.4555329025437690
2032-07-02 04:29:30 | -0.6310354541767030 | 0.5595493520528000 | -0.2852692951372740 | 0.4553242882179440
2032-07-02 04:29:40 | -0.6306302270746220 | 0.5600060164949270 | -0.2855988328830910 | 0.4551176604408040
2032-07-02 04:29:50 | -0.6302289775964089 | 0.5604575430917950 | -0.2859247241816750 | 0.4549129920005880
2032-07-02 04:30:00 | -0.6298316490152750 | 0.5609040164853570 | -0.2862470281802980 | 0.4547102561491680
2032-07-02 04:30:10 | -0.6294381856293590 | 0.5613455195174590 | -0.2865658027874030 | 0.4545094265932290
2032-07-02 04:30:20 | -0.6290485327399900 | 0.5617821332762120 | -0.2868811047040280 | 0.4543104774854870
2032-07-02 04:30:30 | -0.6286626366303690 | 0.5622139371410660 | -0.2871929894543710 | 0.4541133834160310
2032-07-02 04:30:40 | -0.6282804445450950 | 0.5626410088261640 | -0.2875015114151820 | 0.4539181194040180
2032-07-02 04:30:50 | -0.6279019046697970 | 0.5630634244228140 | -0.2878067238445890 | 0.4537246608893310
2032-07-02 04:31:00 | -0.6275269661113410 | 0.5634812584406000 | -0.2881086789100160 | 0.4535329837244690
2032-07-02 04:31:10 | -0.6271555788787160 | 0.5638945838470240 | -0.2884074277150960 | 0.4533430641667030
2032-07-02 04:31:20 | -0.6267876938639980 | 0.5643034721064160 | -0.2887030203261250 | 0.4531548788702020
2032-07-02 04:31:30 | -0.6264232628283660 | 0.5647079932125710 | -0.2889955057940330 | 0.4529684048806780
2032-07-02 04:31:40 | -0.6260622383667750 | 0.5651082157444620 | -0.2892849321931130 | 0.4527836196190410
2032-07-02 04:31:50 | -0.6257045739163740 | 0.5655042068728000 | -0.2895713466242510 | 0.4526005008873850

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`.