The topic of astronomy is closely related to astrometry, and it is covered as a continuation of the topics examined within the Gaia-related lecture and seminar. Herschel and Hubble Space telescopes will be used to demonstrate concepts related to processing of the astronomical data. The covered topics include accessing archives of astronomical data and working with FITS files. The lab activities also include several demonstrations, such as, example aperture photometry on Herschel SPIRE data. Students will continue working with the Astropy library, Activities will also include work with the ESASky web application. The topic of astronomy is closely related to astrometry, and it is covered as a continuation of the topics examined within the Gaia-related lecture and seminar. Herschel and Hubble Space telescopes will be used to demonstrate concepts related to processing of the astronomical data. The covered topics include archives of the space telescope data, working with FITS files, HiPS and MOC formats. Topic of exoplanet search was also incorporated into this lecture in the revised syllabus of the course. The students should also learn how to access TESS data and about methods of planetary transit detection in a light curve.

## Lecture slides

### Lab activities

A subset of the lab activities are based on examples of the Astropy package, specifically examples focused on operations with FITS files. However, these were extended with additional references and code in order to simplify the activity for students.

Another activity, the demonstration of the ESASky astroquery module, is taken from the public Github repository of the ESAC Science Data Centre.

The lab also contains two Herschel-focused activities based on publicly available Github repository by Ivan Valtchanov (working at ESA).

All Jupyter notebooks used in this lab are grouped in a repository on Gitlab. Unlike the other lab supplementary materials, these are not made publically available because these materials include many third party notebooks. You can also acquire these notebooks at their source.

The link to the repository for students attending the course is the following: https://git.kpi.fei.tuke.sk/svd/lab-astronomy

Lab activities include the following:

- Activities based on Astropy examples
- Creating an RGB image from Hubble data in SAOIMAGE DS9
- The activity is based on “A Beginner’s Guide To Working With Astronomical Data” by Markus Pössel
*(Max Planck Institute for Astronomy)*Available at: arxiv.org/abs/1905.13189 (CC BY 4.0) - Page 18: Chapter 3

- The activity is based on “A Beginner’s Guide To Working With Astronomical Data” by Markus Pössel
- Stars subtraction in AMON ACC data (demonstration)
- ESAC Science Data Centre (demonstrations)
- ESASky astroquery use cases
- Cluster Analysis example
- ESASky demonstration: “What can you do with pyESASky?“ (demonstration)

- Ivan Valtchanov’s notebooks (demonstrations)
- SPIRE Aperture Photometry for Point Sources
- Using the
*Herschel*-SPIRE Point Source Catalogue (spsc_demo1)

- TESS-related activities by STScI (Space Telescope Science Institute)
- Finding planet candidates using the Box Least Squares (BLS) algorithm
- Read and Display A TESS Target Pixel File
- Beginner: A Tour of the Contents of the TESS 2-minute Cadence Data
- Beginner: Cutout of the TESS FFIs using Astrocut and Astroquery

### Activities based on Astropy examples

The original notebooks were modified by inclusion of additional specifications of the tasks.

The complete set of the original tutorials is available at the official Github repository: https://github.com/astropy/astropy-tutorials/tree/master/tutorials/notebooks or via https://learn.astropy.org/

#### Working with FITS headers (Edit a FITS header)

- The tutorial is based on the official astropy tutorial. It was extended by additional information about the tasks.
- See:

**TASK #1: Read in the file you just wrote and add three header keywords.**

- ‘RA’ for the Right Ascension of M31
- ‘DEC’ for the Declination of M31
- ‘RADECSRC’ with text indicating where you found the RA/Dec (web URL, textbook name, your photographic memory, etc.)

- Then write the updated header back out to a new file.
- A possible approach is to use Simbad. See Simbad.query_object() method.
- See: https://astroquery.readthedocs.io/en/latest/simbad/simbad.html

#### Viewing and manipulating data from FITS tables

- The tutorial is based on the official astropy tutorial. It was extended by additional information about the tasks.
- See:

**TASK #1: Make a scatter plot of the same data you histogrammed above.**

- The plt.scatter function is your friend for this.
- Play around with values of the parameters in order to get a picture with recognizable features.
- Suggested parameters for experimentation: alpha (try low values), edgecolors (try ‘none’), s, marker, color (try black)
- Observe the effect of the figure size

- What are the pros and cons of doing it this way?
- See: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter

**TASK #2: Try the same with the ****plt.hexbin**** plotting function.**

- Experiment with values of parameters:
- Suggested parameters for experimentation: gridsize, cmap, norm (try LogNorm())

- Which do you think looks better for this kind of data?
- See: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.hexbin

**TASK #3: Create a mask to select only events (rows) in the specified range of energies**

- Lower bound of the energy bin is in variable energy_low
- Bin width is stored in variable energy_bin_width
- Do not forget to include mask of CCDs (ii) in your mask

#### Working with FITS images

- The tutorial is based on the official astropy tutorial. It was extended by additional information about the tasks and by providing a guide to resolve the tasks.
- See:

**TASK #1: Use ****numpy.interp**** function to rescale the values into **[−1,+1] **range**

- Scikit-image functions require either float values in [−1,+1] or in int8 values in [0,255] range
- See: https://numpy.org/doc/stable/reference/generated/numpy.interp.html

**TASK #2: Apply ranked mean filter to the rescaled image**

- Segmentation of the image was tested with skimage.filters.rank.mean, but examination of other methods for segmentation are encouraged.
- See: https://scikit-image.org/docs/stable/api/skimage.filters.rank.html#skimage.filters.rank.mean

**TASK #3: Select appropriate threshold to select only M13**

- One possible approach is to use 99th percentile of values in the filtered image.
- Use numpy.quantile function.
- However, examination of other methods for threshold selection is encouraged.
- See: https://numpy.org/devdocs/reference/generated/numpy.quantile.html

**TASK #4: Use appropriate method to convert coordinates of the maximum-value pixel to world coordinates**

**TASK #5: Lookup for a source in Gaia catalogue associated with the brightest point/star.**

- Store the result in variable max_star_mag
- Presume there is at least one result without checks.
- Use value from column phot_g_mean_mag.
- The Gaia documentation states the following:
**phot_g_mean_mag**: G-band mean magnitude (float, Magnitude[mag])*Mean magnitude in the G band. This is computed from the G-band mean flux applying the magnitude zero-point in the Vega scale.*

- See:

**TASK #5: Write out the image you just created, preserving the header the original image had, but add a keyword ‘UNITS’ with the value ‘mag per sq arcsec’**

- There are several approaches possible
- One possible approach:
- Make a copy of primary_header
- Set UNITS keyword/attribute’s values
- Create a new fits.PrimaryHDU
- Create a new fits.HDUList
- Write-out the HDUList into a file

- See:

#### Working with FITS cubes

- The tutorial is based on the official astropy tutorial. It was extended by a few additional information about the tasks.
- See:

**TASK #1: Try messing around with slicing the cube along different axes, or picking out different spectra**

**TASK #2: Create a new spectral slab isolating just the SMC and slice along a different dimension to create a latitude-velocity diagram**

- You can base your implementation heavily on the previous code
- Note that order of spectral cube array is the following: (n_spectral, n_y, n_x)
- Pay attention to the specification of slices when using cube’s WCS as aa base for axes projection.
- The order of dimensions is based on WCS
- See: https://docs.astropy.org/en/stable/visualization/wcsaxes/slicing_datacubes.html

### Creating an RGB image from Hubble data in SAOIMAGE DS9

- An activity based on “A Beginner’s Guide To Working With Astronomical Data” by Markus Pössel
- Pössel, M., “A Beginner’s Guide to Working with Astronomical Data”, The Open Journal of Astrophysics, vol. 3, no. 1, 2020. doi:10.21105/astro.1905.13189, ArXiv: 1905.13189. (CC BY 4.0)
**Chapter 3. “Saoimage DS9 And Astronomical Images”, pages 18-22**

### Creating an RGB image from Hubble data in Astropy

*In preparation*…

### Stars subtraction in AMON ACC data (demonstration)

- Based on demonstration created by Šimon Mackovjak (IEP SAS)
- The demonstration was created based on discussions related to this project. Therefore, it is included in this appendix.
- The original is available at:

### ESAC Science Data Centre (demonstrations)

**ESASky astroquery use cases**- The original is available at: https://github.com/esdc-esac-esa-int/notebooks/blob/master/ESASky_astroquery_use_cases.ipynb

**Cluster Analysis example**- The original is available at: https://github.com/esdc-esac-esa-int/notebooks/blob/master/Cluster_Analysis_example.ipynb

**ESASky demonstration: “What can you do with pyESASky?“ (demonstration)**- The original is available at:

https://github.com/esdc-esac-esa-int/pyesasky/blob/master/samples/What_can_you_do_with_pyESASky.ipynb

- The original is available at:

### Ivan Valtchanov’s notebooks (demonstrations)

**SPIRE Aperture Photometry for Point Sources**- The original is available at:

https://github.com/ivvv/herspy/blob/master/notebooks/SPIRE%20aperture%20photometry%20of%20point%20sourcesNEW.ipynb

- The original is available at:
**Using the Herschel-SPIRE Point Source Catalogue: demo #1 (spsc_demo1)**- The original is available at: https://github.com/ivvv/herspy/blob/master/notebooks/spsc_demo1.ipynb

### TESS-related activities by STScI (Space Telescope Science Institute)

#### Tutorials created as a part of “TESS Workshop Tutorials”

- All tutorials are available at the following Github repository: https://github.com/spacetelescope/tessworkshop_tutorials
**bls: Finding planet candidates using the Box Least Squares (BLS) algorithm**- The original is available at:
**Exercise 1:**Select a known planet candidate from the TESS Data Alerts page at MAST. Can you recover the reported candidate from the light curve using BLS yourself?**Exercise 2:**Create a folded light curve and compute the BLS statistics of the known candidate. Does it resemble a true planet?**Exercise 3:**Using transit masking explained above, can you find signs of additional, unknown transit signal candidates in addition to the known candidate?

#### Curated set of Jupyter notebooks demonstrating work at STScI

- All tutorials are available at the following Github repository: https://github.com/spacetelescope/notebooks
**Beginner: Read and Display A TESS Target Pixel File**- The original is available at: https://github.com/spacetelescope/notebooks/tree/master/notebooks/MAST/TESS/beginner_how_to_use_tp

**Beginner: Read and Plot A TESS Data Validation Timeseries File**- The original is available at:

https://github.com/spacetelescope/notebooks/blob/master/notebooks/MAST/TESS/beginner_how_to_use_dvt

- The original is available at:
**Beginner: A Tour of the Contents of the TESS 2-minute Cadence Data**- The original is available at:

https://github.com/spacetelescope/notebooks/tree/master/notebooks/MAST/TESS/beginner_tour_lc_tp

- The original is available at:
**Beginner: Cutout of the TESS FFIs using Astrocut and Astroquery**- The original is available at:

https://github.com/spacetelescope/notebooks/tree/master/notebooks/MAST/TESS/interm_tesscut_astroquery

- The original is available at: