Proposal Preparation Solution#

The Story: Suppose that you are preparing to write a proposal on NGC1365, aiming to investigate the intriguing black hole spin this galaxy with Chandra grating observations (see: Monster Blackhole Spin Revealed)

In writing proposals, there are often the same tasks that are required: including finding and analyzing previous observations of the proposal, and creating figures that include, e.g., multiwavelength images and spectrum for the source.

# As a hint, we include the code block for Python modules that you will likely need to import:
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline

# For downloading files
from astropy.utils.data import download_file
from astropy.io import fits

import pyvo as vo

## There are a number of relatively unimportant warnings that
## show up, so for now, suppress them:
import warnings
warnings.filterwarnings("ignore", module="astropy.io.votable.*")
warnings.filterwarnings("ignore", module="pyvo.utils.xml.*")

Step 1: Find out what the previously quoted Chandra 2-10 keV flux of the central source is for NGC 1365#

Hint: Do a Registry search for tables served by the HEASARC (where high energy data are archived) to find potential table with this information

#  This gets all services matching, which should be a list of only one:
tap_services=vo.regsearch(servicetype='table',keywords=['heasarc'])
#  This fetches the list of tables that this service serves:
heasarc_tables=tap_services[0].service.tables

Hint: The Chansngcat table is likely the best table. Create a table with ra, dec, exposure time, and flux (and flux errors) from the public.chansngcat catalog for Chandra observations matched within 0.1 degree.

for tablename in heasarc_tables.keys():
    if "chansng" in tablename:
        print("Table {} has columns={}\n".format(
            tablename,
            sorted([k.name for k in heasarc_tables[tablename].columns ])))
Table chansngcat has columns=['"__row"', '"__x_ra_dec"', '"__y_ra_dec"', '"__z_ra_dec"', '"distance"', 'agn_flag', 'bii', 'class', 'dec', 'exposure', 'fit_chi_squared', 'fit_dof', 'flux', 'flux_lower', 'flux_upper', 'hardness_ratio_0', 'hardness_ratio_0_error', 'hardness_ratio_1', 'hardness_ratio_1_error', 'hardness_ratio_2', 'hardness_ratio_2_error', 'hubble_type', 'instrument', 'lii', 'log_blackhole_mass', 'log_blackhole_mass_lower', 'log_blackhole_mass_upper', 'log_l_cpt1', 'log_l_cpt2', 'log_l_halpha', 'log_l_halpha_flag', 'log_lx', 'log_lx_lower', 'log_lx_note', 'log_lx_upper', 'name', 'nh', 'nh_from_hr', 'nh_from_hr_lower', 'nh_from_hr_upper', 'nh_gal', 'nh_lower', 'nh_upper', 'nuclear_class', 'obsid', 'off_set', 'ra', 'ref_spectrum', 'sigma', 'sigma_error', 'source_number', 'spectral_index', 'spectral_index_lower', 'spectral_index_upper', 'spectral_model', 'spectral_norm_cpt1', 'spectral_norm_cpt2', 'temperature', 'temperature_lower', 'temperature_upper']
# Get the coordinate for NGC 1365
import astropy.coordinates as coord
pos=coord.SkyCoord.from_name("ngc1365")
# Construct a query that will get the ra, dec, exposure time, flux, and flux errors
#  from this catalog in the region around this source:
query="""SELECT ra, dec, exposure, flux, flux_lower, flux_upper FROM public.chansngcat as cat
    where contains(point('ICRS',cat.ra,cat.dec),circle('ICRS',{},{},0.1))=1
    and cat.exposure > 0 order by cat.exposure""".format(pos.ra.deg, pos.dec.deg)
#  Submit the query.  (See the CS_Catalog_queries.md for
#    information about these two search options.)
results=tap_services[0].service.run_async(query)
#results=tap_services[0].search(query)
#  Look at the results
results.to_table()
Table length=1
radecexposurefluxflux_lowerflux_upper
degdegserg/s/cm^2erg/s/cm^2erg/s/cm^2
float64float64float64float64float64float64
53.40192-36.14067155007.751e-127.1727e-128.2075e-12

Step 2: Make Images#

Create ultraviolet and X-ray images#

Hint: Start by checking what UV image services exist (e.g., GALEX?)

## Note that to browse the columns, use the .to_table() method
uv_services=vo.regsearch(servicetype='sia',keywords='galex', waveband='uv')
uv_services.to_table()['ivoid','short_name']
Table length=3
ivoidshort_name
objectobject
ivo://archive.stsci.edu/sia/galexGALEX
ivo://mast.stsci/siap/galex_atlasGALEX_Atlas
ivo://nasa.heasarc/skyview/galexGALEX

The keyword search for ‘galex’ returned a bunch of things that may have mentioned it, but let’s just use the ones that have GALEX as their short name:

uv_services.to_table()[
    np.array(['GALEX' in u.short_name for u in uv_services])
    ]['ivoid', 'short_name']
Table length=3
ivoidshort_name
objectobject
ivo://archive.stsci.edu/sia/galexGALEX
ivo://mast.stsci/siap/galex_atlasGALEX_Atlas
ivo://nasa.heasarc/skyview/galexGALEX

Though using the result as an Astropy Table makes it easier to look at the contents, to call the service itself, we cannot use the row of that table. You have to use the entry in the service result list itself. So use the table to browse, but select the list of services itself using the properties that have been defined as attributes such as short_name and ivoid:

galex_stsci=[s for s in uv_services if 'GALEX' in s.short_name and 'stsci' in s.ivoid][0]
galex_heasarc=[s for s in uv_services if 'GALEX' in s.short_name and 'heasarc' in s.ivoid][0]

Hint: Next create a UV image for the source

# Do an image search for NGC 1365 in the UV service found above
im_table_stsci=galex_stsci.search(pos=pos,size=0.1)
im_table_stsci.to_table()
Table length=809
productTypeimageFormatcontentLengthnamecollectioninsnamemetaReleasedataReleasetrgposRAtrgPosDecs_regionposition_naxesposition_naxisposition_scalecrpixcrvalcdmatrixcoordFrameprojectionposition_ctype1position_ctype2position_cunit1position_cunit2timBoundsSTCStime_bounds_cval1time_bounds_cval2time_bounds_centertimExposureenergy_bandpassNameenergy_bounds_cval1energy_bounds_cval2energy_bounds_centerenergy_unitspublisherDIDaccessURLcloud_access
objectobjectint32objectobjectobjectobjectobjectfloat64float64objectint32objectobjectobjectobjectobjectobjectstr3objectobjectobjectobjectobjectfloat64float64float64float64objectfloat64float64float64objectobjectobjectobject
scienceimage/fits12544983FORNAX_MOS06-xd-mcat.fits.gzGALEXGALEX5/11/2010 12:15:31 AM5/11/2010 12:15:31 AM53.0653359237686-36.3609134371405CIRCLE ICRS 53.06533592 -36.36091344 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.0653 -36.3609][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54106.382801 54117.28317154106.382800925954117.283171296354111.83298611113445.05NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?2555302543848636416https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-xd-mcat.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-xd-mcat.fits.gz"}}
AUXILIARYimage/fits22647591FORNAX_MOS06-nd-intbgsub.fits.gzGALEXGALEX5/11/2010 12:15:31 AM5/11/2010 12:15:31 AM53.0653359237686-36.3609134371405CIRCLE ICRS 53.06533592 -36.36091344 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.0653 -36.3609][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54106.382801 54117.28317154106.382800925954117.283171296354111.83298611113445.05NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?2555302543848636416https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-intbgsub.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-intbgsub.fits.gz"}}
AUXILIARYimage/fits43549FORNAX_MOS06-nd-flags.fits.gzGALEXGALEX5/11/2010 12:15:31 AM5/11/2010 12:15:31 AM53.0653359237686-36.3609134371405CIRCLE ICRS 53.06533592 -36.36091344 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.0653 -36.3609][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54106.382801 54117.28317154106.382800925954117.283171296354111.83298611113445.05NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?2555302543848636416https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-flags.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-flags.fits.gz"}}
AUXILIARYimage/fits24262FORNAX_MOS06-nd-flagstar.fits.gzGALEXGALEX5/11/2010 12:15:31 AM5/11/2010 12:15:31 AM53.0653359237686-36.3609134371405CIRCLE ICRS 53.06533592 -36.36091344 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.0653 -36.3609][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54106.382801 54117.28317154106.382800925954117.283171296354111.83298611113445.05NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?2555302543848636416https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-flagstar.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-flagstar.fits.gz"}}
THUMBNAILimage/jpeg10251FORNAX_MOS06-xd-int_2color_thumb.jpgGALEXGALEX5/11/2010 12:15:31 AM5/11/2010 12:15:31 AM53.0653359237686-36.3609134371405CIRCLE ICRS 53.06533592 -36.36091344 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.0653 -36.3609][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54106.382801 54117.28317154106.382800925954117.283171296354111.83298611113445.05NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?2555302543848636416https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/qa/FORNAX_MOS06-xd-int_2color_thumb.jpg{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/qa/FORNAX_MOS06-xd-int_2color_thumb.jpg"}}
INFOimage/fits14617FORNAX_MOS06-nd-cat_mch_rtastar.fits.gzGALEXGALEX5/11/2010 12:15:31 AM5/11/2010 12:15:31 AM53.0653359237686-36.3609134371405CIRCLE ICRS 53.06533592 -36.36091344 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.0653 -36.3609][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54106.382801 54117.28317154106.382800925954117.283171296354111.83298611113445.05NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?2555302543848636416https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-cat_mch_rtastar.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-cat_mch_rtastar.fits.gz"}}
PREVIEWimage/jpeg543324FORNAX_MOS06-xd-int_2color_medium_annot.jpgGALEXGALEX5/11/2010 12:15:31 AM5/11/2010 12:15:31 AM53.0653359237686-36.3609134371405CIRCLE ICRS 53.06533592 -36.36091344 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.0653 -36.3609][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54106.382801 54117.28317154106.382800925954117.283171296354111.83298611113445.05NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?2555302543848636416https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/qa/FORNAX_MOS06-xd-int_2color_medium_annot.jpg{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/qa/FORNAX_MOS06-xd-int_2color_medium_annot.jpg"}}
SCIENCEimage/fits17443052FORNAX_MOS06-nd-int.fits.gzGALEXGALEX5/11/2010 12:15:31 AM5/11/2010 12:15:31 AM53.0653359237686-36.3609134371405CIRCLE ICRS 53.06533592 -36.36091344 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.0653 -36.3609][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54106.382801 54117.28317154106.382800925954117.283171296354111.83298611113445.05NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?2555302543848636416https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-int.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-int.fits.gz"}}
AUXILIARYimage/fits5756688FORNAX_MOS06-nd-cnt.fits.gzGALEXGALEX5/11/2010 12:15:31 AM5/11/2010 12:15:31 AM53.0653359237686-36.3609134371405CIRCLE ICRS 53.06533592 -36.36091344 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.0653 -36.3609][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54106.382801 54117.28317154106.382800925954117.283171296354111.83298611113445.05NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?2555302543848636416https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-cnt.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/01-vsn/07090-FORNAX_MOS06/d/01-main/0001-img/07-try/FORNAX_MOS06-nd-cnt.fits.gz"}}
............................................................................................................
PREVIEWimage/jpeg134331AIS_423_0002_sg49-xd-int_2color_small.jpgGALEXGALEX6/16/2010 2:52:42 AM6/16/2010 2:52:42 AM53.9452301043047-36.1117650864775CIRCLE ICRS 53.94523010 -36.11176509 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9452 -36.1118][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54460.401030 54460.40222254460.401030092654460.402222222254460.4016261574103.0NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?6385798660088659968https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/00-visits/0002-img/07-try/qa/AIS_423_0002_sg49-xd-int_2color_small.jpg{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/00-visits/0002-img/07-try/qa/AIS_423_0002_sg49-xd-int_2color_small.jpg"}}
INFOimage/fits8737AIS_423_0002_sg49-asp.fits.gzGALEXGALEX6/16/2010 2:52:42 AM6/16/2010 2:52:42 AM53.9452301043047-36.1117650864775CIRCLE ICRS 53.94523010 -36.11176509 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9452 -36.1118][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54460.401030 54460.40222254460.401030092654460.402222222254460.4016261574103.0NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?6385798660088659968https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/00-visits/0002-img/07-try/AIS_423_0002_sg49-asp.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/00-visits/0002-img/07-try/AIS_423_0002_sg49-asp.fits.gz"}}
AUXILIARYimage/fits64456AIS_423_0002_sg49-nd-cat_mch_flagstar.fits.gzGALEXGALEX6/16/2010 2:52:42 AM6/16/2010 2:52:42 AM53.9452301043047-36.1117650864775CIRCLE ICRS 53.94523010 -36.11176509 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9452 -36.1118][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54460.401030 54460.40222254460.401030092654460.402222222254460.4016261574103.0NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?6385798660088659968https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/00-visits/0002-img/07-try/AIS_423_0002_sg49-nd-cat_mch_flagstar.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/00-visits/0002-img/07-try/AIS_423_0002_sg49-nd-cat_mch_flagstar.fits.gz"}}
AUXILIARYimage/fits25691AIS_423_0002_sg49-nd-flag_tbl.fits.gzGALEXGALEX6/16/2010 2:52:42 AM6/16/2010 2:52:42 AM53.9452301043047-36.1117650864775CIRCLE ICRS 53.94523010 -36.11176509 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9452 -36.1118][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54460.401030 54460.40222254460.401030092654460.402222222254460.4016261574103.0NUV1.693e-073.007e-072.35e-07metersivo://archive.stsci.edu/GALEX?6385798660088659968https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/00-visits/0002-img/07-try/AIS_423_0002_sg49-nd-flag_tbl.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/00-visits/0002-img/07-try/AIS_423_0002_sg49-nd-flag_tbl.fits.gz"}}
SCIENCEimage/fits1970004AIS_423_sg49-fd-int.fits.gzGALEXGALEX8/18/2010 1:25:11 AM8/18/2010 1:25:11 AM53.9552232357184-36.108680599578CIRCLE ICRS 53.95522324 -36.10868060 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9552 -36.1087][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54385.423877 54460.40215354385.423877314854460.402152777854422.9130150463200.0FUV1.34e-071.806e-071.573e-07metersivo://archive.stsci.edu/GALEX?6385798797494059008https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/AIS_423_sg49-fd-int.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/AIS_423_sg49-fd-int.fits.gz"}}
AUXILIARYimage/fits10548360AIS_423_sg49-fd-rrhr.fits.gzGALEXGALEX8/18/2010 1:25:11 AM8/18/2010 1:25:11 AM53.9552232357184-36.108680599578CIRCLE ICRS 53.95522324 -36.10868060 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9552 -36.1087][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54385.423877 54460.40215354385.423877314854460.402152777854422.9130150463200.0FUV1.34e-071.806e-071.573e-07metersivo://archive.stsci.edu/GALEX?6385798797494059008https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/AIS_423_sg49-fd-rrhr.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/AIS_423_sg49-fd-rrhr.fits.gz"}}
AUXILIARYimage/fits2797390AIS_423_sg49-fd-skybg.fits.gzGALEXGALEX8/18/2010 1:25:11 AM8/18/2010 1:25:11 AM53.9552232357184-36.108680599578CIRCLE ICRS 53.95522324 -36.10868060 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9552 -36.1087][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54385.423877 54460.40215354385.423877314854460.402152777854422.9130150463200.0FUV1.34e-071.806e-071.573e-07metersivo://archive.stsci.edu/GALEX?6385798797494059008https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/AIS_423_sg49-fd-skybg.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/AIS_423_sg49-fd-skybg.fits.gz"}}
AUXILIARYimage/fits14254446AIS_423_sg49-fd-wt.fits.gzGALEXGALEX8/18/2010 1:25:11 AM8/18/2010 1:25:11 AM53.9552232357184-36.108680599578CIRCLE ICRS 53.95522324 -36.10868060 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9552 -36.1087][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54385.423877 54460.40215354385.423877314854460.402152777854422.9130150463200.0FUV1.34e-071.806e-071.573e-07metersivo://archive.stsci.edu/GALEX?6385798797494059008https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/AIS_423_sg49-fd-wt.fits.gz{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/AIS_423_sg49-fd-wt.fits.gz"}}
THUMBNAILimage/jpeg9914AIS_423_sg49-xd-int_2color_thumb.jpgGALEXGALEX8/18/2010 1:25:11 AM8/18/2010 1:25:11 AM53.9552232357184-36.108680599578CIRCLE ICRS 53.95522324 -36.10868060 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9552 -36.1087][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54385.423877 54460.40215354385.423877314854460.402152777854422.9130150463200.0FUV1.34e-071.806e-071.573e-07metersivo://archive.stsci.edu/GALEX?6385798797494059008https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/qa/AIS_423_sg49-xd-int_2color_thumb.jpg{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/qa/AIS_423_sg49-xd-int_2color_thumb.jpg"}}
PREVIEWimage/jpeg576442AIS_423_sg49-xd-int_2color_medium_annot.jpgGALEXGALEX8/18/2010 1:25:11 AM8/18/2010 1:25:11 AM53.9552232357184-36.108680599578CIRCLE ICRS 53.95522324 -36.10868060 0.6252[3840 3840][-0.00041666667 0.00041666667][1920.5 1920.5][53.9552 -36.1087][-0.000416667 -0.0 -0.0 0.000416667]ICRSTANRA---TANDEC--TANdegdegRANGE 54385.423877 54460.40215354385.423877314854460.402152777854422.9130150463200.0FUV1.34e-071.806e-071.573e-07metersivo://archive.stsci.edu/GALEX?6385798797494059008https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:GALEX/url/data/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/qa/AIS_423_sg49-xd-int_2color_medium_annot.jpg{"aws": {"bucket_name":"stpubdata","region":"us-east-1","access":"open","key":"galex/GR6/pipe/02-vsn/50423-AIS_423/d/01-main/0001-img/07-try/qa/AIS_423_sg49-xd-int_2color_medium_annot.jpg"}}
#  Let's see what HEASARC offers, and this time limit it to FITS
#   this option doesn't currently work for STScI's service)
im_table_heasarc=galex_heasarc.search(pos=pos,size=0.1,format='image/fits')
im_table_heasarc.to_table()
Table length=2
SurveyRaDecDimSizeScaleFormatPixFlagsURLLogicalName
objectfloat64float64int32objectobjectobjectobjectobjectobject
galexnear53.40190833-36.140658332[300 300][-0.0003333333333333334 0.0003333333333333334]image/fitsFhttps://skyview.gsfc.nasa.gov/cgi-bin/images?position=53.40190833%2C-36.14065833&survey=galexnear&pixels=300%2C300&sampler=LI&size=0.10000000000000002%2C0.10000000000000002&projection=Tan&coordinates=J2000.0&requestID=skv1730925208063&return=FITS1
galexfar53.40190833-36.140658332[300 300][-0.0003333333333333334 0.0003333333333333334]image/fitsFhttps://skyview.gsfc.nasa.gov/cgi-bin/images?position=53.40190833%2C-36.14065833&survey=galexfar&pixels=300%2C300&sampler=LI&size=0.10000000000000002%2C0.10000000000000002&projection=Tan&coordinates=J2000.0&requestID=skv1730925208298&return=FITS2
## If you only run this once, you can do it in memory in one line:
##  This fetches the FITS as an astropy.io.fits object in memory
#dataobj=im_table_heasarc[0].getdataobj()
## But if you might run this notebook repeatedly with limited bandwidth,
##  download it once and cache it.
file_name = download_file(im_table_heasarc[0].getdataurl(), cache=True, timeout=600)
dataobj=fits.open(file_name)
print(type(dataobj))
<class 'astropy.io.fits.hdu.hdulist.HDUList'>
# Get the FITS file (which is index 0 for the NUV image or index=2 for the FUV image)
from pylab import figure, cm
from matplotlib.colors import LogNorm
plt.matshow(dataobj[0].data, origin='lower', cmap=cm.gray_r, norm=LogNorm(vmin=0.005, vmax=0.3))
<matplotlib.image.AxesImage at 0x7f2ac740ad10>
../../_images/f0f4b87910aa60dbf2edcdd589fb65738db47d0058245eab0dd6d8f83d23c631.png

Hint: Repeat steps for X-ray image. (Note: Ideally, we would find an image in the Chandra ‘cxc’ catalog)

x_services=vo.regsearch(servicetype='sia',keywords=['chandra'], waveband='x-ray')
print(x_services.to_table()['short_name','ivoid'])
 short_name                 ivoid                 
----------- --------------------------------------
        CDA         ivo://cxc.harvard.edu/cda.siap
        CSC         ivo://cxc.harvard.edu/csc.siap
      CSCR1       ivo://cxc.harvard.edu/cscr1.siap
        CSC     ivo://cxc.harvard.edu/cscr2.1.siap
      CSCR2       ivo://cxc.harvard.edu/cscr2.siap
    Chandra          ivo://nasa.heasarc/chanmaster
GOODSACISFB ivo://nasa.heasarc/skyview/goodsacisfb
## Do an image search for NGC 1365 in the X-ray CDA service found above
xim_table=x_services[0].search(pos=pos,size=0.2)
## Some of these are FITS and some JPEG.  Look at the columns:
print( xim_table.to_table().columns )
first_fits_image_row = [x for x in xim_table if 'image/fits' in x.format][0]
<TableColumns names=('name','instrument','date_obs','ra','dec','naxis','imgscale','imgfmt','accref','filesize','obsid')>
## Create an image from the first FITS file (index=1) by downloading:
## See above for options
#xhdu_list=first_fits_image_row.getdataobj()
file_name = download_file(first_fits_image_row.getdataurl(), cache=True, timeout=600)
xhdu_list=fits.open(file_name)


plt.imshow(xhdu_list[0].data, origin='lower', cmap='cool', norm=LogNorm(vmin=0.1, vmax=500.))
plt.xlim(460, 560)
plt.ylim(460, 560)
(460.0, 560.0)
../../_images/b3870cd8ca86ae93942d5aa6c90ad3354b46e7e2884a2f1974eb81f2fb0f4d2b.png

Step 3: Make a spectrum#

Find what Chandra spectral observations exist already for this source#

Hint: try searching for X-ray spectral data tables using the registry query

# Use the TAP protocol to list services that contain X-ray spectral data
xsp_services=vo.regsearch(servicetype='ssa',waveband='x-ray')
xsp_services.to_table()['short_name','ivoid','waveband']
Table length=7
short_nameivoidwaveband
objectobjectobject
Chandraivo://nasa.heasarc/chanmasterx-ray
HITOMASTERivo://nasa.heasarc/hitomasterx-ray
INTEGRAL/BSCivo://nasa.heasarc/intbscgamma-ray#x-ray
XRISMMASTRivo://nasa.heasarc/xrismmastrx-ray
RXTEivo://nasa.heasarc/xtemasterx-ray
NED_SEDivo://ned.ipac/sed_data_near_positionradio#millimeter#infrared#optical#uv#euv#x-ray#gamma-ray
HEAVENS @ ISDCivo://wfau.roe.ac.uk/heavens_at_isdc/light-curvesx-ray#gamma-ray

Hint 2: Take a look at what data exist for our candidate, NGC 1365.

spec_tables=xsp_services[0].search(pos=pos,radius=0.2,verbose=True)
spec_tables.to_table()
Table length=15
obsidstatusnameradectimedetectorgratingexposuretypepipublic_datedatalinkSSA_start_timeSSA_tmidSSA_stop_timeSSA_durationSSA_coord_obsSSA_raSSA_decSSA_fovSSA_titleSSA_referenceSSA_datalengthSSA_datamodelSSA_instrumentSSA_publisherSSA_formatSSA_wavelength_minSSA_wavelength_maxSSA_bandwidthSSA_bandpasscloud_access
degdegdsddddsdegdegdegdegmmmm
objectobjectobjectfloat64float64float64objectobjectfloat64objectobjectint32objectfloat64float64float64float64float64float64float64float64objectobjectobjectobjectobjectobjectobjectfloat64float64float64float64object
24788archivedNGC 136553.40192-36.1406659342.738ACIS-SHETG25080GTOCanizares597104639:chandra.obs.misc59342.737974537----25080.0--53.40192-36.140660.81acisf24788N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/8/24788/primary/acisf24788N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/8/24788/primary/acisf24788N001_pha2.fits.gz"}}
24737archivedNGC 136553.40192-36.1406659319.8031ACIS-SHETG20080GTOCanizares597104640:chandra.obs.misc59319.8030787037----20080.0--53.40192-36.140660.81acisf24737N002_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/7/24737/primary/acisf24737N002_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/7/24737/primary/acisf24737N002_pha2.fits.gz"}}
24787archivedNGC 136553.40192-36.1406659340.0616ACIS-SHETG39090GTOCanizares597104641:chandra.obs.misc59340.0615740741----39090.0--53.40192-36.140660.81acisf24787N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/7/24787/primary/acisf24787N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/7/24787/primary/acisf24787N001_pha2.fits.gz"}}
24789archivedNGC 136553.40192-36.1406659333.3037ACIS-SHETG21280GTOCanizares597104642:chandra.obs.misc59333.30375----21280.0--53.40192-36.140660.81acisf24789N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/9/24789/primary/acisf24789N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/9/24789/primary/acisf24789N001_pha2.fits.gz"}}
24790archivedNGC 136553.40192-36.1406659343.4834ACIS-SHETG18080GTOCanizares597104643:chandra.obs.misc59343.4834143519----18080.0--53.40192-36.140660.81acisf24790N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/0/24790/primary/acisf24790N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/0/24790/primary/acisf24790N001_pha2.fits.gz"}}
24791archivedNGC 136553.40192-36.1406659326.8302ACIS-SHETG26580GTOCanizares597104644:chandra.obs.misc59326.8301736111----26580.0--53.40192-36.140660.81acisf24791N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/1/24791/primary/acisf24791N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/1/24791/primary/acisf24791N001_pha2.fits.gz"}}
24792archivedNGC 136553.40192-36.1406659344.0923ACIS-SHETG17080GTOCanizares597104645:chandra.obs.misc59344.0923148148----17080.0--53.40192-36.140660.81acisf24792N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/2/24792/primary/acisf24792N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/2/24792/primary/acisf24792N001_pha2.fits.gz"}}
24793archivedNGC 136553.40192-36.1406659335.6602ACIS-SHETG17080GTOCanizares597104646:chandra.obs.misc59335.6602083333----17080.0--53.40192-36.140660.81acisf24793N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/3/24793/primary/acisf24793N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/3/24793/primary/acisf24793N001_pha2.fits.gz"}}
24794archivedNGC 136553.40192-36.1406659321.5437ACIS-SHETG38090GTOCanizares597104647:chandra.obs.misc59321.5437152778----38090.0--53.40192-36.140660.81acisf24794N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/4/24794/primary/acisf24794N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/4/24794/primary/acisf24794N001_pha2.fits.gz"}}
24795archivedNGC 136553.40192-36.1406659328.2974ACIS-SHETG27880GTOCanizares597104648:chandra.obs.misc59328.2974189815----27880.0--53.40192-36.140660.81acisf24795N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/5/24795/primary/acisf24795N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/5/24795/primary/acisf24795N001_pha2.fits.gz"}}
25015archivedNGC 136553.40192-36.1406659336.1988ACIS-SHETG17080GTOCanizares597104649:chandra.obs.misc59336.1987962963----17080.0--53.40192-36.140660.81acisf25015N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/5/25015/primary/acisf25015N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/5/25015/primary/acisf25015N001_pha2.fits.gz"}}
25024archivedNGC 136553.40192-36.1406659340.9376ACIS-SHETG14080GTOCanizares597104650:chandra.obs.misc59340.9376041667----14080.0--53.40192-36.140660.81acisf25024N002_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/4/25024/primary/acisf25024N002_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/4/25024/primary/acisf25024N002_pha2.fits.gz"}}
25036archivedNGC 136553.40192-36.1406659345.6677ACIS-SHETG18180GTOCanizares597104651:chandra.obs.misc59345.6677199074----18180.0--53.40192-36.140660.81acisf25036N001_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/6/25036/primary/acisf25036N001_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/6/25036/primary/acisf25036N001_pha2.fits.gz"}}
13920archivedNGC 136553.40167-36.1402856026.4065ACIS-SHETG90040GOReeves563984659:chandra.obs.misc56026.4065162037----90040.0--53.40167-36.140280.81acisf13920N002_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/0/13920/primary/acisf13920N002_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/0/13920/primary/acisf13920N002_pha2.fits.gz"}}
13921archivedNGC 136553.40167-36.1402856029.0272ACIS-SHETG110050GOReeves563984660:chandra.obs.misc56029.0271643518----110050.0--53.40167-36.140280.81acisf13921N002_pha2.fitshttps://heasarc.gsfc.nasa.gov/FTP/chandra/data/byobsid/1/13921/primary/acisf13921N002_pha2.fits.gz12Spectrum-1.0ACIS-SHEASARCapplication/fits1.2398e-106.1992e-096.07522e-093.16159e-09{"aws":{"bucket_name":"nasa-heasarc","region":"us-east-1","policy":"open","key":"chandra/data/byobsid/1/13921/primary/acisf13921N002_pha2.fits.gz"}}

Hint 3: Download the data to make a spectrum. Note: you might end here and use Xspec to plot and model the spectrum. Or … you can also try to take a quick look at the spectrum.

#  Get it and look at it:
#hdu_list=spec_tables[0].getdataobj()
file_name = download_file(spec_tables[0].getdataurl(), cache=True, timeout=600)
hdu_list=fits.open(file_name)

spectra=hdu_list[1].data
print(spectra.columns)
print(len(spectra))
ColDefs(
    name = 'SPEC_NUM'; format = '1I'; null = 0
    name = 'TG_M'; format = '1I'; null = 99
    name = 'TG_PART'; format = '1I'
    name = 'TG_SRCID'; format = '1I'; null = 0
    name = 'X'; format = '1E'; unit = 'pixel'
    name = 'Y'; format = '1E'; unit = 'pixel'
    name = 'CHANNEL'; format = '8192I'; null = 0
    name = 'COUNTS'; format = '8192I'; unit = 'count'; null = -1
    name = 'STAT_ERR'; format = '8192E'; unit = 'count'
    name = 'BACKGROUND_UP'; format = '8192I'; unit = 'count'; null = -1
    name = 'BACKGROUND_DOWN'; format = '8192I'; unit = 'count'; null = -1
    name = 'BIN_LO'; format = '8192D'; unit = 'angstrom'
    name = 'BIN_HI'; format = '8192D'; unit = 'angstrom'
)
12
## Or write it to disk
import os
if not os.path.isdir('downloads'):
    os.makedirs("downloads")
fname=spec_tables[0].make_dataset_filename()
#  Known issue where the suffix is incorrect:
fname=fname.replace('None','fits')
with open('downloads/{}'.format(fname),'wb') as outfile:
    outfile.write(spec_tables[0].getdataset().read())

Extension: Making a “quick look” spectrum. For our purposes, the 1st order of the HEG grating data would be sufficient.

j=1
for i in range(len(spectra)):
    matplotlib.rcParams['figure.figsize'] = (8, 3)
    if abs(spectra['TG_M'][i]) == 1 and (spectra['TG_PART'][i]) == 1:
        ax=plt.subplot(1,2,j)
        pha = plt.plot( spectra['CHANNEL'][i],spectra['COUNTS'][i])
        ax.set_yscale('log')
        if spectra['TG_PART'][i] == 1:
            instr='HEG'
        ax.set_title("{grating}{order:+d}".format(grating=instr, order=spectra['TG_M'][i]))
        plt.tight_layout()
        j=j+1
../../_images/139a86763631fcf3da9a9a0c1f998978d4539d704a2ebcaf41bb339bda4f073d.png

This can then be analyzed in your favorite spectral analysis tool, e.g., pyXspec. (For the winter 2018 AAS workshop, we demonstrated this in a notebook that you can consult for how to use pyXspec, but the pyXspec documentation will have more information.)

Congratulations! You have completed this notebook exercise.