guitastro_simple_examples.rst 2.41 KB

Guitastro simple examples

To execute the simple tests, first open a Python console and import guitastro:

For Linux:

cd ~/Documents/guitastro/src
python3

>>> import guitastro

For Windows (using powershell):

cd C:\Users\xxx\Documents\guitastro\src
python

>>> import guitastro

1. Load a FITS image and visualize it

Some images for tests are delivered with the Guitastro installation. We recall that astronomical images are usually stored in the FITS format.

>>> ima1 = guitastro.Ima()
>>> ima1.load("m57")
>>> ima1
Image shape: (237, 347)
Filename loaded: C:\Users\xxx\Documents\guitastro\test\data\m57.fit
Filename saved: None
...

By default the image directory is guitastro/test/data. The file m57.fit is stored in this directory. You can change the image directory:

>>> ima1.path("C:\my_images")

The default FITS file extension is .fit. You can change it:

>>> ima1.extension(".fits")

By this way you are not obliged to recall the directory and the extension when you manipulates images stores in a given directory with a given extension. Anyway, you can write the complete name of a FITS file if you prefer:

>>> ima1.load(r"C:\Users\xxx\Documents\guitastro\test\data\m57.fit")

The Ima class allows to save FITS files (save), manage the header cards (getkwds, getkwd, setkwd).

The Ima class provides many image processing and analysis methods.

2. Get the coordinates of Neptune

>>> eph = guitastro.Ephemeris()
>>> ra, dec = eph.radec("Neptune", date="now")

The first time you get solar system major planet ephemeris, you must be connected to Internet to get the file de421.bsp.

3. Acquire images with a virtual camera

Guitalens alone provides virtual drivers of cameras.

>>> ima1 = guitastro.Ima()
>>> cam1 = guitastro.Camera()
>>> cam1.open()
>>> cam1.ima(ima1)
>>> cam1.properties(print=True)
>>> cam1.exptime(2.0)
>>> cam1.acqwait()
>>> ima1.save("test_camera")
>>> ima1.visu()

If you want to drive real camera you must install packages titled guitastro_camera_* (ascom, indi, etc.).