.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_functions_and_outputs.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_functions_and_outputs.py: Functions & Outputs =================== Script showing a quick example on how to use the functions. The chosen telescope for the example is Telescope 2 with photon path: - Thermal blanket -> Marshall 10-shell X-7 -> Al (0.015") -> CdTe4 Mainly a quick example on unit aware objects and how to access the returned data-class objects. This example shows the use of nice high level functions that are tied to FOXSI-4 telescopes. * The ``responses`` module. * The ``telescope_parts`` module This means we will eventually be dealing with high-level telescope response products such as the Ancillary Response Function (ARF) and the Redistribution Matrix Function (RMF). If you're looking for access to response data of the individual components with more freedom then you'll likely be interested in the longer named moduels in the package like: * The ``attenuation`` module. * The ``detector_response`` module. * The ``effective_area`` module. * The ``quantum_efficiency`` module. .. GENERATED FROM PYTHON SOURCE LINES 35-48 .. raw:: html .. role:: colour :colour:`Please look over the FOXSI-4 observation resources to add` :colour:`more context as to how a user might decide on their choice` :colour:`of the function parameters. Additionally, look over the` :colour:`FOXSI-4 instrumentation resources when deciding which` :colour:`functions to use.` Let's start with importing trusty Numpy as I'm sure we'll need it. .. GENERATED FROM PYTHON SOURCE LINES 49-53 .. code-block:: Python import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 54-64 For high-level user engagement, the following two modules are the ones likely to use. The `telescope_parts` are well-named functions tied to FOXSI positions: E.g., `foxsi4_position2_optics` will return FOXSI-4's optical information for Position/Telescope 2. The `responses` module will contains functions that combine the relevant `telescope_parts` functions into one to return higher level products such as the telescope's Ancillary Response Function (ARF), Redistribution Matrix Function (RMF), and/or Spectral Response Matrix (SRM). .. GENERATED FROM PYTHON SOURCE LINES 64-68 .. code-block:: Python import response_tools.responses as responses import response_tools.telescope_parts as telescope_parts .. GENERATED FROM PYTHON SOURCE LINES 69-72 Let's look at the `foxsi4_position2_optics` function since we mentioned it earlier. To see the documentation for this, and any function, we can always run: .. GENERATED FROM PYTHON SOURCE LINES 72-75 .. code-block:: Python help(telescope_parts.foxsi4_position2_optics) .. rst-class:: sphx-glr-script-out .. code-block:: none Help on function foxsi4_position2_optics in module response_tools.telescope_parts: foxsi4_position2_optics(mid_energies, off_axis_angle) Position 2 MSFC heritage X-7 optic effective areas. Parameters ---------- mid_energies : `astropy.units.quantity.Quantity` The energies at which the position 2 optics is required. If `numpy.nan<foxsi4_position2_optics', 'mid_energies': , 'off_axis_angle': , 'effective_areas': , 'optic_id': 'X-7', 'model': False} .. GENERATED FROM PYTHON SOURCE LINES 134-136 The above might be a bit cumbersome and you may only wish to look at the data fields contained in the output. For this we can simply run: .. GENERATED FROM PYTHON SOURCE LINES 136-139 .. code-block:: Python print(pos2_optics.fields) .. rst-class:: sphx-glr-script-out .. code-block:: none ['filename', 'function_path', 'mid_energies', 'off_axis_angle', 'effective_areas', 'optic_id', 'model'] .. GENERATED FROM PYTHON SOURCE LINES 140-148 which might be a bit easier to read. Note: there is a method called `print_contents()` you can use on the function output that might format the contents a little nicer than the above you may wish to use. Each field can be accessed with the displayed name. For example, to get the effective areas of the optics, simply: .. GENERATED FROM PYTHON SOURCE LINES 148-151 .. code-block:: Python print(pos2_optics.effective_areas) .. rst-class:: sphx-glr-script-out .. code-block:: none [ nan 25.6 25.74165016 25.7 25.38849205 25.2 25.46950326 25.8 25.78844674 25.6 25.39954011 24.8 23.59040948 21.83303833 19.4 16.44237079 13.42648954 10.69736352 8.6 7.13809917 6.02641095 5.17651726 4.5 3.92313899 3.43100572 3.02336959 2.7 2.47505764 2.32313356 2.18464269 2. 1.75121039] cm2 .. GENERATED FROM PYTHON SOURCE LINES 152-163 Notice that these are also unit-aware, help you see at a glance you're working with a product that you might expect. The `telescope_parts.foxsi4_position2_optics` function is helpful but an even higher level exists that will allow a user to specify a FOXSI-4 telescope to obtain the Ancillary Response Function (ARF), Redistribution Matrix Function (RMF), and/or Spectral Response Matrix (SRM). First, we can get the RMF for a telescope, say, Telescope 2 to be consistent with using position 2's components previously. .. GENERATED FROM PYTHON SOURCE LINES 163-166 .. code-block:: Python tel2_rmf = responses.foxsi4_telescope2_rmf(region=0) .. GENERATED FROM PYTHON SOURCE LINES 167-176 We need to pass the detector region we are interested in for the correct response to be returned for the CdTe detectors. A user can define the detector area of interest another way using the strip pitch values for the CdTe detector. Feel free to make use of the ``help`` function to see how else the following function can be used. The RMF defined the input and output energy axes for the detector so we might as well access the RMF input energies for those energies we want the ARF values for: .. GENERATED FROM PYTHON SOURCE LINES 176-182 .. code-block:: Python mid_energies = (tel2_rmf.input_energy_edges[:-1]\ +tel2_rmf.input_energy_edges[1:])/2 tel2_arf = responses.foxsi4_telescope2_arf(mid_energies=mid_energies, off_axis_angle=0<, attenuation_type='Thermal-Blanket', model=True, mid_energies=, off_axis_angle=, times=), EffAreaOutput(filename='tilt:/home/runner/work/response-tools/response-tools/response_tools/response-information/effective-area-data/FOXSI3_Module_X-7_EA_tilt_v1.txt, pan:/home/runner/work/response-tools/response-tools/response_tools/response-information/effective-area-data/FOXSI3_Module_X-7_EA_pan_v1.txt', function_path='eff_area_msfc_10shell\n->foxsi4_position2_optics\n->foxsi4_telescope2_arf', mid_energies=, off_axis_angle=, effective_areas=, optic_id='X-7', model=False), AttOutput(filename='/home/runner/work/response-tools/response-tools/response_tools/response-information/attenuation-data/unif_att_p2_theoretical_v1.csv', function_path='att_uniform_al_cdte\n->foxsi4_position2_uniform_al\n->foxsi4_telescope2_arf', transmissions=, attenuation_type='Uniform-Al-Filter', model=True, mid_energies=, off_axis_angle=, times=)) .. GENERATED FROM PYTHON SOURCE LINES 201-204 We find that the `elements` field contains all the data-classes that produced the Telescope 2 ARF such as the thermal blanket transmission (dimensionless), the Marshall 10-shell X-7 optics effective areas (cm^2), and the Al (0.015") attenuator transmissions (dimensionless). .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.032 seconds) .. _sphx_glr_download_auto_examples_plot_functions_and_outputs.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_functions_and_outputs.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_functions_and_outputs.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_functions_and_outputs.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_