Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the assemble_archive_from_position function into the docs #380

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
9 changes: 9 additions & 0 deletions docs/source/daxa.mission.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ mission.base module
:undoc-members:
:show-inheritance:

mission.tools module
-------------------

.. automodule:: daxa.mission.tools
:members:
:undoc-members:
:show-inheritance:


mission.xmm module
----------------------

Expand Down
261 changes: 256 additions & 5 deletions docs/source/notebooks/tutorials/case_studies/all_obs_of_object.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@
"source": [
"from warnings import warn\n",
"\n",
"from daxa.mission import XMMPointed, Chandra, ASCA, Suzaku, ROSATPointed, ROSATAllSky\n",
"from astropy.coordinates import SkyCoord\n",
"\n",
"from daxa.archive import Archive\n",
"from daxa.exceptions import NoObsAfterFilterError"
"from daxa.archive.assemble import assemble_archive_from_positions\n",
"from daxa.exceptions import NoObsAfterFilterError\n",
"from daxa.mission import XMMPointed, Chandra, ASCA, Suzaku, ROSATPointed, ROSATAllSky, \\\n",
" MISS_INDEX\n",
"from daxa.mission.tools import multi_mission_filter_on_positions"
]
},
{
Expand All @@ -60,19 +65,260 @@
"Reading through these should give you a good understanding of how DAXA can be used to acquire, organise, and process multi-mission X-ray datasets for your specific use case."
]
},
{
"cell_type": "markdown",
"id": "c39e054d",
"metadata": {},
"source": [
"## One-line solution\n",
"Though we provide individual functions that wrap the various steps required to collect all data at a given position for various telescope archives, we also include a one-line solution which executes these steps; the [assemble_archive_from_positions() function](../../../daxa.archive.html#daxa.archive.assemble.assemble_archive_from_positions). This function will by default initialise all available missions within DAXA, and then calls each mission's `filter_on_positions()` method. The return is a list of mission objects that have had the positional filtering applied, note that if no observations are returned after filtering then this mission is excluded.\n",
"\n",
"In this tutorial we assume knowledge of the `BaseMission.filter_on_positions()` method, if you are unfamiliar please consult the [relevant tutorial](../missions.html#Filtering-on-position).\n",
"\n",
"In this case study, the goal is to collect all observations of M51 from XMM, Chandra, ASCA, Suzaku, ROSAT Pointed, and ROSAT All-Sky missions (note that other missions are supported by DAXA). We present here how to achieve this with the one line solution.\n",
"\n",
"Firstly, in order to see how to format the input to the `missions` argument of `assemble_archive_from_positions()`, we can look at the `MISS_INDEX` dictionary:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "6e9bc673",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'xmm_pointed': daxa.mission.xmm.XMMPointed,\n",
" 'nustar_pointed': daxa.mission.nustar.NuSTARPointed,\n",
" 'erosita_calpv': daxa.mission.erosita.eROSITACalPV,\n",
" 'erosita_all_sky_de_dr1': daxa.mission.erosita.eRASS1DE,\n",
" 'chandra': daxa.mission.chandra.Chandra,\n",
" 'rosat_all_sky': daxa.mission.rosat.ROSATAllSky,\n",
" 'rosat_pointed': daxa.mission.rosat.ROSATPointed,\n",
" 'swift': daxa.mission.swift.Swift,\n",
" 'suzaku': daxa.mission.suzaku.Suzaku,\n",
" 'asca': daxa.mission.asca.ASCA,\n",
" 'integral_pointed': daxa.mission.integral.INTEGRALPointed}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"MISS_INDEX"
]
},
{
"cell_type": "markdown",
"id": "974dbdf7",
"metadata": {},
"source": [
"We can therefore use the following list to input into the `missions` argument of the `assemble_archive_from_positions()` function:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b3e63b1a",
"metadata": {},
"outputs": [],
"source": [
"missions = ['xmm_pointed', 'chandra', 'asca', 'suzaku', 'rosat_pointed', 'rosat_all_sky']"
]
},
{
"cell_type": "markdown",
"id": "c8584da9",
"metadata": {},
"source": [
"We then input the position of M51 in the SkyCoord format:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "8c0bdee5",
"metadata": {},
"outputs": [],
"source": [
"position = SkyCoord(202.47,\t47.2, unit='deg')"
]
},
{
"cell_type": "markdown",
"id": "cb9e06e9",
"metadata": {},
"source": [
"So we can finally run the `assemble_archive_from_positions()` function with our inputs (note that the `missions` argument is optional, and by default all missions within DAXA would be searched):"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "cee83d71",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/xmm.py:83: UserWarning: 140 of the 18123 observations located for this mission have been removed due to NaN RA or Dec values\n",
" self._fetch_obs_info()\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/base.py:1373: UserWarning: Chandra FoV are difficult to define, as they can be strongly dependant on observation mode; as such take these as very approximate.\n",
" fov = self.fov\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/asca.py:125: UserWarning: 5 of the 3079 observations located for ASCA have been removed due to all instrument exposures being zero.\n",
" self._fetch_obs_info()\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/base.py:98: UserWarning: There are multiple chosen instruments SIS0, SIS1, GIS2, GIS3 for asca with different FoVs, but they observe simultaneously. As such the search distance has been set to the largest FoV of the chosen instruments.\n",
" any_ret = change_func(*args, **kwargs)\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/suzaku.py:109: UserWarning: 14 of the 3055 observations located for Suzaku have been removed due to all instrument exposures being zero.\n",
" self._fetch_obs_info()\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/suzaku.py:297: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value '['EGS' 'GS' 'EGS' ... 'GCL' 'GCL' 'EGS']' has dtype incompatible with int16, please explicitly cast to a compatible dtype first.\n",
" rel_suzaku.loc[type_recog, 'target_category'] = rel_suzaku.loc[type_recog, 'target_category'].apply(\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/archive/assemble.py:61: UserWarning: No observations found after the filter for suzaku, will not be included in the output dictionary.\n",
" miss_list = multi_mission_filter_on_positions(positions, search_distance, missions)\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/archive/base.py:196: UserWarning: Proprietary data have been selected, but no credentials provided; as such the proprietary data have been excluded from download and further processing.\n",
" mission.download(download_products=download_products[mission.name])\n",
"Downloading XMM-Newton Pointed data: 100%|██████████| 16/16 [1:30:41<00:00, 340.11s/it]\n",
"Downloading Chandra data: 100%|██████████| 28/28 [59:09<00:00, 126.78s/it] \n",
"Downloading ASCA data: 100%|██████████| 2/2 [09:06<00:00, 273.26s/it]\n",
"Downloading ROSAT Pointed data: 100%|██████████| 6/6 [00:59<00:00, 9.90s/it]\n",
"Downloading RASS data: 100%|██████████| 2/2 [00:52<00:00, 26.14s/it]\n"
]
}
],
"source": [
"# M51 is the name of the archive\n",
"arch = assemble_archive_from_positions('M51', positions=position, missions=missions, \n",
" download_products=False)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "9f6ff6ea",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"-----------------------------------------------------\n",
"Version - 0.0.0\n",
"Number of missions - 5\n",
"Total number of observations - 54\n",
"Beginning of earliest observation - 1990-07-11 00:00:00\n",
"End of latest observation - 2022-01-08 17:51:21\n",
"\n",
"-- XMM-Newton Pointed --\n",
" Internal DAXA name - xmm_pointed\n",
" Chosen instruments - M1, M2, PN\n",
" Number of observations - 16\n",
" Fully Processed - False\n",
"\n",
"-- Chandra --\n",
" Internal DAXA name - chandra\n",
" Chosen instruments - ACIS, HRC\n",
" Number of observations - 28\n",
" Fully Processed - False\n",
"\n",
"-- ASCA --\n",
" Internal DAXA name - asca\n",
" Chosen instruments - SIS0, SIS1, GIS2, GIS3\n",
" Number of observations - 2\n",
" Fully Processed - False\n",
"\n",
"-- ROSAT Pointed --\n",
" Internal DAXA name - rosat_pointed\n",
" Chosen instruments - PSPCB, PSPCC, HRI\n",
" Number of observations - 6\n",
" Fully Processed - False\n",
"\n",
"-- RASS --\n",
" Internal DAXA name - rosat_all_sky\n",
" Chosen instruments - PSPC\n",
" Number of observations - 2\n",
" Fully Processed - False\n",
"-----------------------------------------------------\n",
"\n"
]
}
],
"source": [
"arch.info()"
]
},
{
"cell_type": "markdown",
"id": "0f7b18f4",
"metadata": {},
"source": "To perform the search without creating an Archive object, we can use the [multi_mission_filter_on_positions() function](../../../daxa.mission.html#daxa.mission.tools.multi_mission_filter_on_positions):"
},
{
"cell_type": "code",
"execution_count": 4,
"id": "96ef7008",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/xmm.py:83: UserWarning: 140 of the 18126 observations located for this mission have been removed due to NaN RA or Dec values\n",
" self._fetch_obs_info()\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/base.py:1373: UserWarning: Chandra FoV are difficult to define, as they can be strongly dependant on observation mode; as such take these as very approximate.\n",
" fov = self.fov\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/asca.py:125: UserWarning: 5 of the 3079 observations located for ASCA have been removed due to all instrument exposures being zero.\n",
" self._fetch_obs_info()\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/base.py:108: UserWarning: There are multiple chosen instruments SIS0, SIS1, GIS2, GIS3 for asca with different FoVs, but they observe simultaneously. As such the search distance has been set to the largest FoV of the chosen instruments.\n",
" any_ret = change_func(*args, **kwargs)\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/suzaku.py:109: UserWarning: 14 of the 3055 observations located for Suzaku have been removed due to all instrument exposures being zero.\n",
" self._fetch_obs_info()\n",
"/Users/jp735/Desktop/DAXA_dev/DAXA/daxa/mission/suzaku.py:297: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value '['EGS' 'GS' 'EGS' ... 'GCL' 'GCL' 'EGS']' has dtype incompatible with int16, please explicitly cast to a compatible dtype first.\n",
" rel_suzaku.loc[type_recog, 'target_category'] = rel_suzaku.loc[type_recog, 'target_category'].apply(\n",
"/var/folders/86/x534hjnd60nfqyng9m_xwb740000gr/T/ipykernel_46523/339423454.py:1: UserWarning: No observations found after the filter for suzaku, will not be included in the output dictionary.\n",
" multi_mission_filter_on_positions(position, missions=missions)\n"
]
},
{
"data": {
"text/plain": [
"[<daxa.mission.xmm.XMMPointed at 0x122b0dbe0>,\n",
" <daxa.mission.chandra.Chandra at 0x123d757f0>,\n",
" <daxa.mission.asca.ASCA at 0x123d77770>,\n",
" <daxa.mission.rosat.ROSATPointed at 0x123d76270>,\n",
" <daxa.mission.rosat.ROSATAllSky at 0x123d77620>]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"multi_mission_filter_on_positions(position, missions=missions)"
]
},
{
"cell_type": "markdown",
"id": "cda7ed3b",
"metadata": {},
"source": [
"## Defining missions"
"## Breaking Down the Steps\n",
"\n",
"To better understand what the `assemble_archive_from_positions()` function is doing, we show the individual steps that have taken place."
]
},
{
"cell_type": "markdown",
"id": "1db78091",
"metadata": {},
"source": [
"## Defining Missions\n",
"\n",
"We create instances of the XMM, Chandra, ASCA, Suzaku, ROSAT Pointed, and ROSAT All-Sky missions in order to search their archives - other missions are supported by DAXA (and can be found in the missions tutorial), but these are a subset likely to have observations of M51:"
]
},
Expand Down Expand Up @@ -462,7 +708,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3.13.1 ('daxa_dev': venv)",
"language": "python",
"name": "python3"
},
Expand All @@ -476,7 +722,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
"version": "3.13.1"
},
"vscode": {
"interpreter": {
"hash": "b745ee2e03c74046425ba0075c6a485bd3a0b3209d382eeafefb40aa57902723"
}
}
},
"nbformat": 4,
Expand Down