{ "cells": [ { "cell_type": "markdown", "id": "c86bee9f", "metadata": {}, "source": [ "# First example\n", "## Introduction\n", "In this first example, we will run the LIFE Target Database data generation with a distance cut of 10 parsec.\n", "\n", "## File location\n", "Make sure to have this file saved in the correct directory (data_generation/life_td_data_generation) before running it. The file in data_generation/docs/source/tutorials is only intended for proper display on the webpage." ] }, { "cell_type": "markdown", "id": "1d822e99", "metadata": {}, "source": [ "## Getting started\n", "We start by turning off the astropy warnings. Those are useful for development but not needed in this tutorial." ] }, { "cell_type": "code", "id": "bc80f8d1", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:48:44.800400Z", "start_time": "2025-09-15T11:48:44.610768Z" } }, "source": [ "import warnings\n", "\n", "from astropy.utils.exceptions import AstropyWarning\n", "\n", "warnings.simplefilter(\"ignore\", category=AstropyWarning)" ], "outputs": [], "execution_count": 1 }, { "cell_type": "markdown", "id": "c62d8183", "metadata": {}, "source": [ "Next we importing the needed functions from the modules." ] }, { "cell_type": "code", "id": "6c755c92", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:48:47.684546Z", "start_time": "2025-09-15T11:48:47.197782Z" } }, "source": "from life_td import create_life_td", "outputs": [], "execution_count": 2 }, { "cell_type": "markdown", "id": "32baea67", "metadata": {}, "source": [ "We will use a distance cut of 10 pc as opposed to the 30 pc used in the published database because the data generation would take much longer otherwise." ] }, { "cell_type": "code", "id": "7be06507", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:48:48.478998Z", "start_time": "2025-09-15T11:48:48.474820Z" } }, "source": [ "distance_cut = 10.0" ], "outputs": [], "execution_count": 3 }, { "cell_type": "markdown", "id": "7b3a7acc", "metadata": {}, "source": [ "## Initiating data generation" ] }, { "metadata": {}, "cell_type": "markdown", "source": "First we make sure that the servers where we optain the data for the database are reachable.", "id": "a3be6784b2427d26" }, { "metadata": { "ExecuteTime": { "end_time": "2025-09-15T12:00:00.642339Z", "start_time": "2025-09-15T11:59:49.386296Z" } }, "cell_type": "code", "source": "!pytest integration_tests/pre_db_creation/integration_test_provider_queries.py", "id": "5881a069d38e2941", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001B[1m============================= test session starts ==============================\u001B[0m\r\n", "platform linux -- Python 3.13.5, pytest-8.3.4, pluggy-1.5.0\r\n", "rootdir: /home/franziska/PycharmProjects/life_td\r\n", "configfile: pyproject.toml\r\n", "plugins: anyio-4.8.0\r\n", "collected 7 items \u001B[0m\u001B[1m\r\n", "\r\n", "integration_tests/pre_db_creation/integration_test_provider_queries.py \u001B[32m.\u001B[0m\u001B[32m [ 14%]\r\n", "\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m [100%]\u001B[0m\r\n", "\r\n", "\u001B[32m============================== \u001B[32m\u001B[1m7 passed\u001B[0m\u001B[32m in 10.57s\u001B[0m\u001B[32m ==============================\u001B[0m\r\n" ] } ], "execution_count": 11 }, { "metadata": {}, "cell_type": "markdown", "source": "Now we actually run the database creation module.", "id": "26d6be2f72e29941" }, { "cell_type": "code", "id": "002d443a", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:49:58.424730Z", "start_time": "2025-09-15T11:48:50.178774Z" } }, "source": "provider_tables_dict, database_tables = create_life_td(distance_cut)", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Building life_td data with distance cut of 10.0 pc\n", "Trying to create SIMBAD tables from 2025-09-15...\n", " sorting object types...\n", "removing 4 objects that had object types: ['BD?|MIR|NIR', 'BD?|NIR']\n", "example object of them: WISE J083011.97+283716.6\n", "Trying to create Grant Kennedy Disks tables from 2024-02-09...\n", "Trying to create WDS tables from 2025-09-15...\n", "Creating WDS tables ...\n", " querying VizieR for WDS...\n", " performing distance cut...\n", "Trying to create Exo-MerCat tables from 2025-09-15...\n", "Trying to create LIFE tables from 2025-09-15...\n", "Trying to create Gaia tables from 2025-09-15...\n", "Building sources table ...\n", "Building objects table ...\n", "Building provider table ...\n", "Building ident table ...\n", "Building best_h_link table ...\n", "warning: empty table best_h_link\n", "Building star_basic table ...\n", "Building planet_basic table ...\n", "Building disk_basic table ...\n", "Building mes_mass_pl table ...\n", "Building mes_teff_st table ...\n", "Building mes_radius_st table ...\n", "Building mes_mass_st table ...\n", "Building mes_binary table ...\n", "Building mes_sep_ang table ...\n", "Building h_link table ...\n", "Unifying null values...\n", "Saving data...\n" ] } ], "execution_count": 4 }, { "cell_type": "markdown", "id": "9b5108a9", "metadata": {}, "source": [ "## Sanity tests\n", "Now lets have a look at our generated tables to make sure the data makes sense." ] }, { "cell_type": "code", "id": "e33ede97", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T12:03:56.615502Z", "start_time": "2025-09-15T12:03:51.920358Z" } }, "source": "!pytest integration_tests/post_db_creation/integration_test_building.py", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001B[1m============================= test session starts ==============================\u001B[0m\r\n", "platform linux -- Python 3.13.5, pytest-8.3.4, pluggy-1.5.0\r\n", "rootdir: /home/franziska/PycharmProjects/life_td\r\n", "configfile: pyproject.toml\r\n", "plugins: anyio-4.8.0\r\n", "collected 11 items \u001B[0m\u001B[1m\r\n", "\r\n", "integration_tests/post_db_creation/integration_test_building.py \u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m [ 72%]\r\n", "\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m.\u001B[0m\u001B[32m [100%]\u001B[0m\r\n", "\r\n", "\u001B[32m============================== \u001B[32m\u001B[1m11 passed\u001B[0m\u001B[32m in 3.83s\u001B[0m\u001B[32m ==============================\u001B[0m\r\n" ] } ], "execution_count": 14 }, { "metadata": {}, "cell_type": "markdown", "source": [ "Now this integration test actually has some nice plots to look at but I haven't figured out how to show them through the jupyter notebook yet. I can produce them by running the tests in my pycharm or via terminal using\n", "\n", "life_td/data_generation/life_td_data_generation$ python -m pytest integration_tests/post_db_creation/integration_test_building.py" ], "id": "d664d5eac8151438" } ], "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.10.12" } }, "nbformat": 4, "nbformat_minor": 5 }