Skip to content

Ska3 runtime environment for users

Tom Aldcroft edited this page Dec 19, 2020 · 73 revisions

The Ska3 runtime environment consists of an integrated suite of Python-3 packages and associated applications. The installation and update of these packages is done using the Anaconda Python distribution and the Conda package manager. This allows simple installation on linux machines or Mac laptops. Similar support for Windows is under consideration.

  1. Installing Ska3 runtime environment
  2. Testing Ska3
  3. Ska Data
  4. Maintaining Ska3 runtime environment

For discussion about motivation for Python 3, new features, and converting from Python 2.7 to Python 3, see:

Power users note: on the HEAD linux network there can be a substantial improvement in package import times if you install and maintain your own Ska3 installation on a local disk. The production installation on /proj/sot is served via a remote NetApp which can be quite slow.

Installing Ska3 runtime environment

Installing conda on linux CentOS-7+, MacOSX, or Windows 10

The basis for installing, managing, and using Ska3 is the Conda package manager and this needs to be installed before anything else can be done. If you already have the conda package manager installed with version 4.8 or higher (conda --version), then you can skip these steps and go to the Create Ska3 environment section.

Important note about older conda

If you have a version of conda older than 4.8, this is not compatible with ska3. We recommend deleting that old conda and the associated environment.

The steps for creating a new conda environment are as follows:

  1. Get one of the following files by URL:
https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.3-Linux-x86_64.sh
https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.3-MacOSX-x86_64.sh
https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.3-Windows-x86_64.exe

For Windows follow the instructions for Installing on Windows or consult your local Windows expert.

For linux and MacOSX proceed with the following steps.

  1. Open a terminal window and change to the downloads directory for your browser.

  2. The installer is called something like Miniconda--py38_4.8.3-<OS>.sh. Find it and then enter the following (without the %, which is used as the linux prompt in all these examples):

% bash Miniconda3-py38_4.8.3-MacOSX-x86_64.sh  
  1. Hit ENTER, then agree to the license terms, and finally specify the installation directory. This will be created by the installer and needs to be a directory that doesn t currently exist. A fine choice is the default of ~/miniconda3 (which is what is assumed for the rest of the installation), but you may want to install to a different directory depending on the details of your system.

  2. At the end it asks about updating your .bashrc or .bash-profile or .cshrc file. We recommend accepting (say yes).

  3. Now create a new terminal window.

This gives you a minimal working Python along with the package manager utility conda. Check hat this is working by doing:

% which python
--> shows the expected path, e.g. $HOME/miniconda3/bin/python

Create Ska3 environment

Now you can install all the Ska3 packages and required dependencies to an environment named ska3 by copy-pasting this long command:

% conda create -n ska3 ska3-flight --override-channels -c https://icxc.cfa.harvard.edu/aspect/ska3-conda/flight

On linux and MacOSX you can optionally install ska3-perl as well. This is mostly for aspect-specific apps like starcheck.

After you see the list of packages, accept, and see that the install finished. Then you can get into the Ska3 environment

% conda activate ska3

It's done and now you have a ska3 flight environment! The name ska3 is not magic, and you could have called it my-ska or whatever you want.

If you make a new shell window then you need to conda activate ska3 to get into Ska3 again.

Testing Ska3

Congratulations, you should now have all the Ska3 packages installed!

As a quick smoke test that things are working, confirm that the following works and makes a line plot:

% ipython --matplotlib
>>> import matplotlib.pyplot as plt
>>> from Chandra.Time import DateTime
>>> import ska_path
>>>
>>> plt.plot([1, 2])
>>> DateTime(100).date
'1998:001:00:00:36.816'

Ska data

To make full use of the Ska environment you need various package data, e.g.:

  • Ska engineering archive
  • Kadi databases
  • Commanded states databases
  • AGASC star catalog
  • Telemetry database (MSIDs)

The very first thing to do is define the disk location where you want to store the Ska data. Packages and applications in the Ska runtime environment use an environment variable SKA to define the root directory of data and other shared resources. On the HEAD or GRETA networks this root is the familiar /proj/sot/ska3/flight.

For a machine (e.g. your laptop) not on the HEAD or GRETA networks you need to make a directory that will hold the Ska data. A reasonable choice is putting this in a ska directory in your home directory:

% mkdir ~/ska
% setenv SKA ${HOME}/ska  # csh / tcsh
% export SKA=${HOME}/ska  # bash

If you have made a local Ska environment on a machine on the HEAD or GRETA networks, you can just set the SKA environment variable to point at the existing root:

% setenv SKA /proj/sot/ska  # csh / tcsh
% export SKA=/proj/sot/ska  # bash

Syncing data

For a machine not on the HEAD or GRETA networks you need to get at least a subset of the data on your machine. FOT users may want to start up MATLAB which will run a task to update the Ska data used by those tools. Other users or FOT users with different data needs will use a script called ska_sync that is installed as part of Ska. This assume you have set the SKA environment variable and created a directory as shown above.

The first thing is to try running it and getting the online help:

% ska_sync --help
usage: ska_sync [-h] [--user USER] [--install] [--force]

Synchronize data files for Ska runtime environment

Arguments
=========

optional arguments:
  -h, --help   show this help message and exit
  --user USER  User name for remote host
  --install    Install sync config file in default location
  --force      Force overwrite of sync config file

Next you need to install a copy of the template configuration file into your Ska root directory. This will let you customize which data you want and how to get it. This installation is done with:

% echo $SKA  # Check the SKA root directory
/Users/aldcroft/ska

% ska_sync --install
Wrote ska sync config file to /Users/aldcroft/ska/ska_sync_config

Now you need to edit the file it just created and set the remote host for getting data and the remote host user name. Choose either kadi.cfa.harvard.edu (HEAD) or the IP address for cheru (OCC) and edit accordingly. Likewise put in the corresponding user name:

# Host machine to supply Ska data (could also be chimchim but kadi works
# from OCC VPN just as well).
host: kadi.cfa.harvard.edu

# Remote host user name.  Default is local user name.
# user: name

If you want Ska engineering archive access then following the instructions in Syncing Ska engineering archive data

Finally do the sync step:

% ska_sync
Loaded config from /Users/aldcroft/ska/ska_sync_config

This prints something like below:

COPY and PASTE the following at your terminal command line prompt:

  rsync -arzv --progress --size-only --files-from="/Users/aldcroft/ska/ska_sync_files" \
    aldcroft@kadi.cfa.harvard.edu:/proj/sot/ska/ "/Users/aldcroft/ska/"

As instructed copy and paste the rsync line, after which you will need to enter your password. At this point it will sync the relevant Ska data files into your local Ska root.

NOTE for Windows users (but not on FOT laptops): one possibility for running the rsync command is to use Windows Subsystem for Linux. This has been successfully demonstrated for a standalone Windows machine.

As long as you don t change your config file, you can just re-run that same command to re-sync as needed.

To test that the data are really there make sure you can reproduce the following:

% ipython --matplotlib
>>> from Ska.tdb import msids
>>> msids.find('tephin')
[<MsidView msid="TEPHIN" technical_name="EPHIN SENSOR HOUSING TEMP">]

>>> from kadi import events
>>> events.normal_suns.filter('2014:001')
<NormalSun: start=2014:207:07:04:09.331 dur=65207>

>>> from Chandra.cmd_states import fetch_states
>>> fetch_states('2011:100', '2011:101', vals=['obsid'])
    ...
    SOME WARNINGS WHICH ARE OK and will get patched up later
    ...
[ ('2011:100:11:53:12.378', '2011:101:00:26:01.434', 418823658.562, 418868827.618, 13255)
  ('2011:101:00:26:01.434', '2011:102:13:39:07.421', 418868827.618, 419002813.605, 12878)]

Syncing Ska engineering archive data

Syncing Ska engineering data to your standalone installation (laptop) is feasible. Circa mid-2019, the archive about 170 Gb. Copying the entire archive over VPN network will take a while, but it has been done.

Keeping the archive up to date should be done using cheta_sync, which is documented in the Cheta telemetry archive tutorial.

Mission planning backstop and OR-lists

rsync -av --prune-empty-dirs --exclude='/*/*/*/' --include='*/' \
 --include='???????/ofls?/*.backstop' --include='???????/ofls?/*.or' --exclude='*' \
 kady:/data/mpcrit1/mplogs/2019/ $SKA/data/mpcrit1/mplogs/2019/

Maintaining Ska3 runtime environment

Maintaining your environment is straightforward. When there is a new release (or just periodically) do:

% conda update -c $ska3conda ska3-flight
Clone this wiki locally