Skip to content

Run sparkles on a pickle file with a uniform roll search

Tom Aldcroft edited this page Oct 6, 2021 · 1 revision

Summary

This describes how to run sparkles via a standalone script that will search for a better roll option using a brute-force uniform grid search of all available rolls.

Getting the script

Click on the URL below and then hit the Download ZIP button to get the script named sparkles_uniform.py:

https://gist.github.com/taldcroft/12deab65c69433a518fc3f15290e331f

Running the script

Help

From a command line within the Ska3 environment, you can get help as follows:

$ python sparkles_uniform.py --help
usage: sparkles_uniform.py [-h] [--obsid OBSID] [--quiet] [--open-html] [--report-dir REPORT_DIR] [--report-level REPORT_LEVEL]
                           [--roll-level ROLL_LEVEL] [--roll-min-improvement ROLL_MIN_IMPROVEMENT] [--roll-d-roll ROLL_D_ROLL]
                           [--roll-max-roll-dev ROLL_MAX_ROLL_DEV] [--roll-max-roll-options ROLL_MAX_ROLL_OPTIONS]
                           load_name

Sparkles ACA review tool 4.12.2

positional arguments:
  load_name             Load name (e.g. JAN2119A) or full file name

optional arguments:
  -h, --help            show this help message and exit
  --obsid OBSID         Process only this obsid (can specify multiple times, default=all
  --quiet               Run quietly
  --open-html           Open HTML in webbrowser
  --report-dir REPORT_DIR
                        Report output directory (default=<load name>
  --report-level REPORT_LEVEL
                        Make reports for messages at/above level ('all'|'none'|'info'|'caution'|'warning'|'critical') (default='warning')
  --roll-level ROLL_LEVEL
                        Make alternate roll suggestions for messages at/above level ('all'|'none'|'info'|'caution'|'warning'|'critical')
                        (default='critical')
  --roll-min-improvement ROLL_MIN_IMPROVEMENT
                        Min value of improvement metric to accept option (default=No minimum)
  --roll-d-roll ROLL_D_ROLL
                        Delta roll for sampling available roll range
  --roll-max-roll-dev ROLL_MAX_ROLL_DEV
                        maximum roll deviation (deg, default=max allowed by pitch)
  --roll-max-roll-options ROLL_MAX_ROLL_OPTIONS
                        maximum number of roll options to return (default=No maximum)

Running

For example, for the pickle file OCT1121_final_2021_278_10_07_41_080.pkl.gz where obsid 26155 has a critical that needs to be resolved, do the following. This should automatically open a report page in the most recently used browser window (if not you can manually open the index.html page that is created, see below).

$ python sparkles_uniform.py OCT1121_final_2021_278_10_07_41_080.pkl.gz --open-html --obsid=26155
Reading pickle file OCT1121_final_2021_278_10_07_41_080.pkl.gz
Processing obsid 26155
 Exploring roll options method='uniform'
  roll=218.50 roll_min=218.25 roll_max=218.75 add_ids={155202696} drop_ids=set()
   P2_rolled=3.93 n_stars_rolled=5.00 improvement=0.72
  roll=219.00 roll_min=218.75 roll_max=219.25 add_ids={155202696} drop_ids=set()
   P2_rolled=3.82 n_stars_rolled=4.91 improvement=0.63
...
  roll=243.00 roll_min=242.75 roll_max=243.25 add_ids=set() drop_ids=set()
   P2_rolled=2.74 n_stars_rolled=2.91 improvement=-1.12
  roll=243.50 roll_min=243.25 roll_max=243.75 add_ids=set() drop_ids=set()
   P2_rolled=2.53 n_stars_rolled=2.91 improvement=-1.34
Writing output review file OCT1121_final_2021_278_10_07_41_080_sparkles/index.html
Open URL in browser: file:///Users/aldcroft/Downloads/OCT1121_final_2021_278_10_07_41_080_sparkles/index.html

You can also run this from within IPython, e.g.

$ ipython
Python 3.8.3 (default, Jul  2 2020, 11:26:31) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %run sparkles_uniform.py OCT1121_final_2021_278_10_07_41_080.pkl.gz --open-html --obsid=26155                                          
Reading pickle file OCT1121_final_2021_278_10_07_41_080.pkl.gz
Processing obsid 26155
 Exploring roll options method='uniform'
 ...
Writing output review file OCT1121_final_2021_278_10_07_41_080_sparkles/index.html
Open URL in browser: file:///Users/aldcroft/Downloads/OCT1121_final_2021_278_10_07_41_080_sparkles/index.html
Clone this wiki locally