{ "cells": [ { "cell_type": "markdown", "id": "broad-employer", "metadata": {}, "source": [ "# 1. Data Preparation for Gauss Hermite kinematics\n", "\n", "This notebook shows how to prepare input kinematic data files from Gauss-Hermite files from the CALIFA and ATLAS-3D surveys.\n", "\n", "It uses the example script for data preparation ``dynamite/data_prep/generate_kin_input.py`` which works for 4 Gauss-Hermite coefficients out of the box and hence would need to be modified for a different number of coefficients. Also, in case of CALIFA data, the script's ``read_califa(file)`` method forces the errors to fulfil ``dvel ≥ 1``, ``dsig ≥ 1``, ``dh3 ≥ 0.005``, and ``dh4 ≥ 0.005`` and corrects negative sigma values.\n", "\n", "Run this notebook from the directory ``docs/tutorial_notebooks``.\n", "\n", "First, import some modules..." ] }, { "cell_type": "code", "execution_count": null, "id": "2618f546", "metadata": {}, "outputs": [], "source": [ "import os\n", "import dynamite as dyn" ] }, { "cell_type": "markdown", "id": "ecbd021c", "metadata": {}, "source": [ "## CALIFA \n", "\n", "Example galaxy: **NGC 6278**. A Schwarzschild model for this galaxy can be found in [Zhu et al. (2018)](https://ui.adsabs.harvard.edu/abs/2018MNRAS.473.3000Z/abstract)." ] }, { "cell_type": "code", "execution_count": null, "id": "specified-george", "metadata": {}, "outputs": [], "source": [ "from dynamite.data_prep.generate_kin_input import create_kin_input\n", "\n", "# Input directory\n", "in_dir = 'NGC6278_input/'\n", "\n", "# The CALIFA stellar kinematic file for NGC 6278 can be found here:\n", "in_file = 'NGC6278_input/NGC6278.V1200.rscube_INDOUSv2_SN20_stellar_kin.fits'\n", "\n", "# The output will be placed here:\n", "out_dir = 'NGC6278_input/dynamite_input/'\n", "if not os.path.exists(out_dir):\n", " os.makedirs(out_dir)\n", "\n", "# Convert file to ECSV, fit the kinematic PA,\n", "# write aperture.dat and bins.dat files\n", "create_kin_input('NGC6278', in_file, out_dir, expr='', \n", " fit_PA=True, kin_input='CALIFA')\n", "\n", "# Add the PSF to the header of the kinematic file\n", "gh = dyn.kinematics.GaussHermite()\n", "gh.add_psf_to_datafile(sigma=[1.06], weight=[1.0],\n", " datafile=f'{out_dir}/gauss_hermite_kins.ecsv')" ] }, { "cell_type": "markdown", "id": "efficient-prairie", "metadata": {}, "source": [ "The directory `NGC6278_input/dynamite_input` should now contain the following files:\n", "\n", "- `mge.ecsv` (this file was already present)\n", "- `gauss_hermite_kins.ecsv` \n", "- `aperture.dat` \n", "- `bins.dat`\n", "\n", "together with some diagnostic plots. These files are the complete input needed to run DYNAMITE!" ] }, { "cell_type": "markdown", "id": "5c1456c8", "metadata": {}, "source": [ "## ATLAS 3D \n", "\n", "Example galaxy: **NGC 4570**. Schwarzschild models for this galaxy can be found in [Thater et al. (2019)](https://ui.adsabs.harvard.edu/abs/2019A%26A...625A..62T/abstract)." ] }, { "cell_type": "code", "execution_count": null, "id": "blind-hospital", "metadata": { "scrolled": false }, "outputs": [], "source": [ "from dynamite.data_prep.generate_kin_input import create_kin_input\n", "\n", "# Input directory\n", "in_dir = 'NGC4570_input/'\n", "\n", "# For ATLAS3D data, two input/files are needed: the original cube and \n", "# the kinematics cube. They can be found here:\n", "in_files =[in_dir+'MS_NGC4570_r1_C2D.fits',\n", " in_dir+'NGC4570_4moments_ATLAS3d.fits']\n", "\n", "# The output will be placed here:\n", "out_dir = 'NGC4570_input/dynamite_input/'\n", "if not os.path.exists(out_dir):\n", " os.makedirs(out_dir)\n", "\n", "# Convert file to ECSV, fit the kinematic PA, \n", "# write aperture.dat and bins.dat files\n", "create_kin_input('NGC4570', in_files, out_dir, expr='',\n", " fit_PA=True, kin_input='ATLAS3D', ngh=6)\n", "\n", "# Add the PSF to the header of the kinematic file\n", "gh = dyn.kinematics.GaussHermite()\n", "gh.add_psf_to_datafile(sigma=[1.5], weight=[1.0],\n", " datafile=f'{out_dir}/gauss_hermite_kins.ecsv')" ] }, { "cell_type": "markdown", "id": "electric-tracy", "metadata": {}, "source": [ "The directory `NGC4570_input/dynamite_input` should now contain the following files:\n", "\n", "- `gauss_hermite_kins.ecsv`\n", "- `aperture.dat` \n", "- `bins.dat`\n", "\n", "together with some diagnostic plots. These files are your kinematic input for DYNAMITE. In addition, you will only need a file containing a Multi Gaussian Expansion (MGE) describing the stellar surface density of the galaxy." ] }, { "cell_type": "markdown", "id": "db060fcb", "metadata": {}, "source": [ "## Preparing other Gauss Hermite data files \n", "\n", "To prepare DYNAMITE input from other surveys, or from your own fits, we recommend looking at the functions defined in `dynamite/data_prep/generate_kin_input.py` and adjusting them to your needs.\n", "\n", "The file `aperture.dat` contains the spatial extent in arcseconds, the angle (in degrees) `90 - position_angle`, and the size of the grid in pixels:\n", "\n", "```\n", " #counter_rotation_boxed_aperturefile_version_2\n", " min_x min_y\n", " max_x max_y\n", " 90.-position_angle\n", " npix_x n_pix_y\n", "``` \n", "\n", "The file `bins.dat` encodes the spatial (e.g. Voronoi) binning: specifically, it has one header line with the total number of pixels in the grid, followed by the bin ID of each pixel in the grid." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 5 }