assign_simode

The assign_simode script automates the process of assigning SIMODEs and/or dropping chips. It runs all of the steps which one would normally run manually, including ocatByObsid, obsparams, apr2smt, simode_update, obsparams -u, make checkin, and the copying of the .smt file. It stops at a couple of points to prompt the user to make sure that what they are about to do is really what they want. It also dumps log files corresponding to the various steps in the process, e.g. obsparams.log, so one can inspect output.

Normal SIMODE Assignment

Setup SACGS:

> newgrp acisops
> setsacgs

**************************************
*** Welcome to the CXC Data System ***
**************************************
CIAO configuration is complete...
10.10  Thursday, June 03, 2021
  bindir      : /home/ascds/DS.release/bin
  CALDB       : 4.9.5
setting production environment for Mission Planning...
setting production environment for Proposal applications....
CXC Data System, version: 10.10  Thursday, June 03, 2021

Set up a directory to do your work in.

> cd SACGS/
> set myroot = update_25207
> mkdir $myroot
> cd $myroot

Just for convenience, here’s the usage message for assign_simode:

> assign_simode --help
usage: assign_simode [-h] [-w WEEK] [-drop OBSID NCHIPS] [-y] [--dry-run]
                     myroot [obsids ...]

Assign SIMODEs or drop chips.

positional arguments:
  myroot                The root name for the files produced.
  obsids                The obsid(s) to check. Can be a space-separated list
                        in the CLI, or a single-column list in an ASCII file,
                        prepended by an @ symbol.

optional arguments:
  -h, --help            show this help message and exit
  -w WEEK, --week WEEK  The week we are dropping chips from
  -drop OBSID NCHIPS    Drop chips from this obsid. Must be of the form
                        "-drop 23001 2" in the CLI, or a double-column list
                        in an ASCII file, prepended by an @ symbol.
  -y, --yes             Automatically answer "yes" to all queries. Very
                        dangerous.
  --dry-run             Show what would have been done, but don't actually do
                        anything.

Now we can run the command to assign the SIMODE to OBSID 25207, in this case providing it with the prefix $myroot we decided above, and then the name of the OBSID we’re going to assign the SIMODE to (you can also provide more than one). After running it, it will ask for your arcops username and password. Following this, you will see some messages, and then it will show you the ocatByObsid call it wants to run and ask if it is correct. If it’s good, answer y/Y, otherwise bail out with n/N!

> assign_simode $myroot 25207

SQL Server Username: jzuhone
Password:

...

I'm going to run this ocatByObsid call:
ocatByObsid -i -o update_25207 25207
Look ok? (Y/N)y

If it’s good, then the ocatByObsid call will be run. After some other text goes by, you will get to the point where obsparams has been called, and the napc2par.log file will be created. At this point, the script will display the contents of napc2par.log on the screen, and prompt you to verify it looks ok:

Contents of napc2par.log:

Compiling rules from /home/jzuhone/SACGS/sch/ap2apr_pre.rul
Compiling rules from /home/jzuhone/SACGS/sch/ap2apr.rul
Compiling rules from /home/jzuhone/SACGS/sch/ap2apr_post.rul
Disposition of obsId 25207: simode TE_004A6, parameterBlockId0x004a6024
Next unused TE id: 3462
Next unused CC id: 372
Next unused Window id: 310
Last used commandIdentifier: 18081

Please inspect the contents of napc2par.log above. Look ok? (Y/N)y

Next, the script will stop at the point where the SIMODE needs to actually be updated in the OBSCAT. You will get a chance to look which SIMODE will be assigned and what the dropped chip count will be, if any. In this case we didn’t drop chips. If it’s good, answer y/Y, otherwise bail out with n/N! This is the last place the script will stop before finishing the job. The napc2par.log file will be renamed to napc2par.log.orig, otherwise it will be clobbered by the obsparams -u call.

...

Please inspect ./update_25207.smt and issue the command
simode_update -f ./update_25207.smt -a
 This will change the obsCat.
DANGER, WILL ROBINSON! obscat records for
Contents of update_25207.smt:

obsid       si_mode dropped_chip_count
-----       ------- ------------------
25207       TE_004A6        NOCHANGE

Please inspect the contents of update_25207.smt above. Look ok? (Y/N)y

Running simode_update -f ./update_25207.smt -a.

...

Renaming napc2par.log to napc2par.log.orig.

...

If you have a long list of OBSIDs to assign SIMODEs to, you can put them in a single-column text file like so (these are totally made-up numbers):

> cat obsids.txt
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217

And you can run the assign_simode command with this file as an argument, prepending it with an @ symbol:

> assign_simode $myroot @obsids.txt

All of the same steps will be performed, but for each OBSID in the file. You will still be able to check each step as usual.

Note

The following error or warning messages may be seen, and are benign:

mkdir: cannot create directory ‘/home/jzuhone/SACGS/ckpoint’: File exists make: [setup] Error 1 (ignored) mkdir: cannot create directory ‘/home/jzuhone/SACGS/sch’: File exists make: [setup] Error 1 (ignored) mkdir: cannot create directory ‘/home/jzuhone/SACGS/idp’: File exists make: [setup] Error 1 (ignored)

stty: standard input: Inappropriate ioctl for device rm: No match.

foreach: No match. mkdir: cannot create directory ‘/data/acis-bak/cmdgen/sacgs/archive/’: File exists make: [checkin_bak] Error 1 (ignored) mkdir: cannot create directory ‘/data/acis/cmdgen/sacgs/archive/’: File exists make: [checkin] Error 1 (ignored)

Dropping Chips

In the case where you want to drop chips with assign_simode, the initial setup is the same as above:

Setup SACGS:

> newgrp acisops
> setsacgs

**************************************
*** Welcome to the CXC Data System ***
**************************************
CIAO configuration is complete...
10.10  Thursday, June 03, 2021
  bindir      : /home/ascds/DS.release/bin
  CALDB       : 4.9.5
setting production environment for Mission Planning...
setting production environment for Proposal applications....
CXC Data System, version: 10.10  Thursday, June 03, 2021

Set up a directory to do your work in:

> cd SACGS/
> set myroot = drop_chips_sep2021
> mkdir $myroot
> cd $myroot

Just for convenience, here’s the usage message for assign_simode:

> assign_simode --help
usage: assign_simode [-h] [-w WEEK] [-drop OBSID NCHIPS] [-y] [--dry-run]
                     myroot [obsids ...]

Assign SIMODEs or drop chips.

positional arguments:
  myroot                The root name for the files produced.
  obsids                The obsid(s) to check. Can be a space-separated list
                        in the CLI, or a single-column list in an ASCII file,
                        prepended by an @ symbol.

optional arguments:
  -h, --help            show this help message and exit
  -w WEEK, --week WEEK  The week we are dropping chips from
  -drop OBSID NCHIPS    Drop chips from this obsid. Must be of the form
                        "-drop 23001 2" in the CLI, or a double-column list
                        in an ASCII file, prepended by an @ symbol.
  -y, --yes             Automatically answer "yes" to all queries. Very
                        dangerous.
  --dry-run             Show what would have been done, but don't actually do
                        anything.

In this case, assign_simode needs the week for which chips will be dropped, and then it will need a -drop entry for every obsid that requires dropped chips, in the form of -drop OBSID NUM_DROP. You’ll also have to enter your arcops username and password, and the script will show you which ocatByObsid call it is going to run, and prompt for approval:

> assign_simode $myroot -w SEP2021 -drop 23764 1 -drop 24300 2 -drop 24301 2

SQL Server Username: jzuhone
Password:

...

I'm going to run this ocatByObsid call:
ocatByObsid -i -o drop_chips_sep2021 -w SEP2021 -drop 23764 1 -drop 24300 2 -drop 24301 2
Look ok? (Y/N)y

If it’s good, then the ocatByObsid call will be run. After some other text goes by, you will get to the point where obsparams has been called, and the napc2par.log file will be created. At this point, the script will display the contents of napc2par.log on the screen, and prompt you to verify it looks ok:

Contents of napc2par.log:

Compiling rules from /home/jzuhone/SACGS/sch/ap2apr_pre.rul
Compiling rules from /home/jzuhone/SACGS/sch/ap2apr.rul
Compiling rules from /home/jzuhone/SACGS/sch/ap2apr_post.rul
Disposition of obsId 23764: simode TE_004A6, parameterBlockId0x004a6024
Disposition of obsId 24300: simode TE_00A5A, parameterBlockId0x00a5a024
Disposition of obsId 24301: simode TE_00A5A, parameterBlockId0x00a5a024
Next unused TE id: 3462
Next unused CC id: 372
Next unused Window id: 310
Last used commandIdentifier: 18078

Please inspect the contents of napc2par.log above. Look ok? (Y/N)y

Next, the script will stop at the point where the it actually needs to drop the chips in the OBSCAT. Then, it will show you which operations it is going to perform, and once again prompt for approval. If you approve, the script will drop the chips and finish the rest of the job. The napc2par.log file will be renamed to napc2par.log.orig, otherwise it will be clobbered by the obsparams -u call.

Please inspect ./drop_chips_sep2021.smt and issue the command
simode_update -f ./drop_chips_sep2021.smt -a
 This will change the obsCat.
DANGER, WILL ROBINSON! obscat records for I'm appending to /data/acis/LoadReviews/chipDrops.hst

Contents of drop_chips_sep2021.smt:

obsid       si_mode dropped_chip_count
-----       ------- ------------------
23764       TE_0065A        1
24300       TE_00914        2
24301       TE_00914        2

Please inspect the contents of drop_chips_sep2021.smt above. Look ok? (Y/N)y

Running simode_update -f ./drop_chips_sep2021.smt -a.

...

Renaming napc2par.log to napc2par.log.orig.

...

An alternative to providing the -drop entries on the command line is to put them in a double-column text file like so (first column is the OBSID, second column is the number of dropped chips):

> cat drops.txt
23764 1
24300 2
24301 2

And you can run the assign_simode command with this file as an argument, prepending it with an @ symbol:

> assign_simode $myroot @drops.txt -w SEP2021

All of the same steps will be performed, but for each OBSID in the file. You will still be able to check each step as usual. NOTE that the -w argument must be after the file argument.

Note

The following error or warning messages may be seen, and are benign:

mkdir: cannot create directory ‘/home/jzuhone/SACGS/ckpoint’: File exists make: [setup] Error 1 (ignored) mkdir: cannot create directory ‘/home/jzuhone/SACGS/sch’: File exists make: [setup] Error 1 (ignored) mkdir: cannot create directory ‘/home/jzuhone/SACGS/idp’: File exists make: [setup] Error 1 (ignored)

stty: standard input: Inappropriate ioctl for device rm: No match.

foreach: No match. mkdir: cannot create directory ‘/data/acis-bak/cmdgen/sacgs/archive/’: File exists make: [checkin_bak] Error 1 (ignored) mkdir: cannot create directory ‘/data/acis/cmdgen/sacgs/archive/’: File exists make: [checkin] Error 1 (ignored)