3. (IMPORTANT) Python Environment#

For these lecture notes, you need some packages to run the codes.

Warning

The intention of this note is for completeness and reference for students when they become researchers. I have not intended to let students go through all these installation steps during class time. Please let TA setup/install everything beforehand.

Depending on your OS and environment, some parts will result in errors. You should take full responsibility for that, unless you use the computers’ set up by the TA.

For Windows users

If you want to use Windows, you have to sacrifice fitsio (unfortunately, their installation assumes gcc). Erase the installation of fitsio from the codes below.

If you are familiar with conda and virtual environments, please feel free to create a new environment for this lecture note. If you don’t understand what this means, please ignore it (you will naturally know what it is after a few years of using conda and having numerous headaches and googling experiences).

Note

If you are sick of the slow speed of conda and adventurous, give mamba a try.

3.1. Installation Script#

Copy and paste the following lines to the terminal (I am assuming you have Anaconda installed, following 00-1_Softwares.md):

conda create -n snuao python=3.10 numpy=1.24 scipy=1.10 astropy=5.2 pandas=1 jupyter=1 sep=1.2 ccdproc=2.4 photutils=1.6 specutils=1.10 -c conda-forge -y
conda activate snuao
conda install -c conda-forge fitsio -y  # Windows will raise error here; ignore this line if it does.

While it is going on, clone the AOclass repo Download ZIP or

git clone --recursive https://github.com/ysBach/SNU_AOclass.git
# Or gh repo clone ysBach/SNU_AOclass

cd SNU_AOclass # Go to the SNU_AOclass directory.
git submodule update --init --recursive

This may take several minutes. Be patient, grab a cup of coffee, and read the “Reading Materials” section below.

AFTER the above is finished, install the submodules:

# Go to the SNU_AOclass directory.
cd submodules/
conda activate snuao
cd version_information && pip install -e . && cd ..
cd astroquery && pip install -e . && cd ..
cd ginga && pip install -e . && cd ..
cd astroalign && pip install -e . && cd ..
cd astroscrappy && pip install -e . && cd ..

(basically, any version of these may not break any part of the notebooks, hopefully…)

Next,

pip install astro-ndslice==0.2 ysfitsutilpy==0.2 ysphotutilpy==0.1.1 --no-deps

Finally, download _tool_visualization.py and put it in the directory where you will run your python files/notebooks.

3.1.1. Reading Materials#

Some things to read during the installation:

Astropy

The name of a project that devotes its human power to developing a single package containing tools useful for astronomers in Python language (GitHub, Official website, The most recent stable distribution documentation).

Affiliated Packages

Since astropy is a “single core” package, it doesn’t have many convenience functionalities for small, specific fields of astronomy. So there are some affiliated packages that help astronomers fulfill their needs. You may find a list of them here.

Note

Astropy (but not affiliated packages) must have been installed on your computer by default while installing Anaconda.

Among the Astropy-affiliated packages, these will be heavily used:

photutils

Photometry-related functionalities

ccdproc

CCD data manipulation

astroscrappy

The cosmic ray rejection tool, which uses L.A.Cosmic algorithm (van Dokkum 2001, PASP).

APLPy

Astronomical image displaying tool (you may use it in the future…?).

astroquery

Querying astronomical catalog data: unlike most other packages, it is recommended to use the “developer’s version” of astroquery rather than the stable version of it. This is why we install astroquery with git clone rather than conda install.

fitsio

The popular cfitsio in python.

Note

fitsio is used (optionally) within ysfitsutilpy to boost the FITS I/O speed (factor of ~ 30x on macOS) when header is unnecessary.

3.2. Check if Installed Correctly#

Some packages have test module. Please run these to check if the installation worked correctly.

3.3. Troubleshoot#

If you have any trouble installing the abovementioned packages, that’s a big problem. Please immediately contact the TA or open an issue at this repo.