# Switch from IDL to Python

## Installing Python for the first time

Anaconda Python (the compact installer is called Miniconda) is a small download and install–it won’t take several gigabytes of space like Matlab and IDL.

Package distribute can occur via a website or preferably, a centralized `conda`

or `pip`

repo.
For example, to install popular data analysis modules:

```
conda install pandas scipy matplotlib spyder
```

## IDL vs. Python syntax

table of NumPy/Python equivalents to common IDL commands

IDL is a bit distinctive in its syntax. IDL and Matlab syntax remind me a bit of Fortran, while Python is C-based, including that Python has 0-based indexing and C-order array axes.

Mayavi also gives advanced 3-D visualization.

### Ipyvolume 3-D example

Jupyter Notebook makes an IDE in your web browser, and you can make remarkable animated, interactive 3-D plots as well with Ipyvolume.

```
conda install jupyter
pip install ipyvolume
```

### HDF5

HDF5 can handle enormous datasets quickly and easily.
Assume you have an HDF5 file `terabyte.h5`

with double-precision float variable X of size 100000x2048x2048 (3.4 TB).
Let’s load the first frame of the 2048x2048 image data, and write it variable `first`

to `image.h5`

.
The `with`

syntax uses Python’s context manager, which closes the file upon exiting the indented code section under `with`

.

```
import h5py
with h5py.File('terabyte.h5') as f:
img = f['X'][0,...]
with h5py.File('image.h5') as f:
f['first'] = img
```

## IDL ↔ Python

IDL ≥ 8.6.1 supports Python 2.7 and 3.6.

## Call GDL from Python

GDL Gnu Data Language is free open-source alternative to IDL, compatible through IDL 7 and much of IDL 8.

from Python, call IDL/GDL functions by simply `import GDL`

. See PYTHON.TXT

## Call Matlab from Python and Python from Matlab

In case you or a collaborator uses Matlab or Matlab code, you can:

## Leave a Comment