.. include:: .. _deployment: ******************** Deploy an Instrument ******************** Purpose of this Chapter ======================= The aim of this chapter is to explain how to deploy an instrument. .. figure:: ../../graphics/deployment.svg :width: 100% Create a Project ================ During a project several deployments will be performed. Every deployment must be assigned to a project. A project has a *name*, a *long name*, a *period*, and a *description*. There are third-party funding projects and research infrastructures. Third-party funding projects run over 3-4 years, and research infrastructures run for over 20 years. For demonstration purposes, we will create an entry for the IAGOS-CORE project. Via Python ---------- The following code snippet shows how to create a project. .. code-block:: python from datetime import datetime from IAGOS.apps.database.deployments import models as deployments project, _ = deployments.Project.objects.get_or_create( name="IAGOS-CORE", long_name= "In-Service Aircraft for a Global Observing System", start=datetime(2011, 1, 1), is_infrastructure=True ) Via Web Interface ----------------- 1. Make sure that you have the permissions to create new entries *(admin)* 2. Go to the menu *Projects* |rarr| *Projects* 3. Create the project **IAGOS-CORE** by clicking the button on the top right corner. Create a Location ================= Components can be installed into an aircraft or at a fixed measurement location *(also known as station)*. For this reason, there are a section for creating an aircraft and a section for creating a station which are independent from each other. Create an Aircraft ------------------ Let's assume that we want to create the aircraft **IAGOS-01** *(type: A340-313)* from the airline **Lufthansa**. As already mentioned, every aircraft needs to be assigned to an *aircraft type* and an *airline*. Therefore, we have to create them first and after it we can create the aircraft. Via Python ^^^^^^^^^^ .. code-block:: python from datetime import datetime from IAGOS.apps.database.deployments import models as deployments airline, _ = deployments.Airline.objects.get_or_create(name="Lufthansa", code="DLH") aircraft_type, _ = deployments.AircraftType.objects.get_or_create(name="A340-313") aircraft, _ = deployments.Aircraft.objects.get_or_create( name="IAGOS-01", aircraft_type=aircraft_type, airline=airline, registration_code="D-AIGT", serial_no="304", internal_no=6, active_from=datetime(2012, 1, 1), active_to=datetime(2021, 1, 1) ) Via Web Interface ^^^^^^^^^^^^^^^^^ 1. Make sure that you have the permissions to create new entries *(admin)* 2. Go to the menu *Locations* |rarr| *Airlines* 3. Create the airline **Lufthansa** by clicking the button on the top right corner. 4. Go to the menu *Locations* |rarr| *Aircraft types* 5. Create the type **A340-313** by clicking the button on the top right corner. 6. Go to the menu *Locations* |rarr| *Aircraft* 7. Create the aircraft **IAGOS-01** by clicking the button on the top right corner. Create a Station ---------------- An instrument can be installed at a station. Each station has unique name, a position, and an availability period. Moreover, it has to be assigned to a country. Let's assume that we want to create the **SAPHIR chamber**. Therefore, we create the country first and then the location. Via Python ^^^^^^^^^^ .. code-block:: python from datetime import datetime from IAGOS.apps.database.deployments import models as deployments country, _ = deployments.Country.objects.get_or_create(name="Germany") station, _ = deployments.MeasurementLocation.objects.get_or_create( name="SAPHIR chamber", altitude=93.00, latitude=50.905, longitude=6.4122, country=country, active_from=datetime(2012, 1, 1) ) Via Web Interface ^^^^^^^^^^^^^^^^^ 1. Make sure that you have the permissions to create new entries *(admin)* 2. Go to the menu *Locations* |rarr| *Countries* 3. Create the country **Germany** by clicking the button on the top right corner. 4. Go to the menu *Locations* |rarr| *Stations* 5. Create the country **SAPHIR chamber** by clicking the button on the top right corner. Create a Deployment =================== For each instrument that is deployed, a database entry will be created. Deployed instruments are usually assembled. For example, the *Transmitterbox* will be installed into the component *ICH unit* and the *ICH unit* into an aircraft. In that case, an entry will be created only for the *ICH unit* and not for the *Transmitterbox*. This approach reduces the memory space and management. Via Python ---------- .. warning:: The following code snippet shows how you can deploy your instrument into an aircraft. If you want to deploy your instrument at a location, use *measurement_location=station* instead of *aircraft=aircraft* .. code-block:: python :emphasize-lines: 9 from datetime import datetime from IAGOS.apps.database.deployments import models as deployments deployment, _ = deployments.Deployment.objects.get_or_create( project=project, start=datetime(2020, 2, 1), end=datetime(2020, 10, 1), component=instances["ICH"], aircraft=aircraft ) Via Web Interface ----------------- 1. Make sure that you have the permissions to create new entries *(admin)* 2. Go to the menu *Deployments* |rarr| *Deployments* 3. Create a deployment by clicking the button on the top right corner.