esasky.astroquery advanced use case

This notebook illustrates some more advanced usages of the ESASky implementation in astroquery

Author: Ivan Valtchanov

First you need to install astroquery and esasky.

Astroquery can be installed with pip install astroquery, the latest version should come with esasky. Alternatively, you can grab the latest astroquery with esasky from here.

The documentation for astroquery.esasky is available here.

In [1]:
#
# import some necessary packages
#
import matplotlib.pyplot as plt
from matplotlib.legend_handler import HandlerLine2D

%matplotlib inline

import sys  
reload(sys)  
sys.setdefaultencoding('utf8')

import numpy as np

from astropy.wcs import WCS
from astropy import visualization

from astroquery.esasky import ESASky

from astropy.convolution import convolve, Kernel, Gaussian2DKernel

Workflow

This is a simple workflow.

  1. Load an XMM-Newton EPIC image of a target of choice
  2. Smooth the image with a Gaussian with FWHM=5"
  3. Generate 10 contours
  4. Plot the original photon image in [0.2-7] keV (ESASky data) and overplot the contours
  5. Load a Herschel 250 µm image of the same target
  6. Plot the Herschel image and overplot the XMM smoothed image contours
  7. Overplot the the 3XMM point-source catalogue sources
  8. Overplot the Planck PSZ catalogue sources
In [2]:
# ESASky.list_maps()
# ESASky.list_catalogs()
maps = ESASky.query_object_maps('M51',["XMM-EPIC","HERSCHEL"])
print (maps)
In [3]:
print (maps["XMM-EPIC"].info)
maps["XMM-EPIC"]["observation_id","duration"].pprint()

We only need one of the 6 XMM-EPIC observation, let's take the longest one: 0303420101, it is with index 3.

In [4]:
# need to copy if you don't want to modify the original maps
nxmm = len(maps["XMM-EPIC"])
maps["XMM-EPIC"].remove_rows(np.delete(range(nxmm),3))
maps["XMM-EPIC"]["observation_id","duration"].pprint()

Now let's select the Herschel 250 µm map too, before we submit the download request to ESASky.

In [5]:
print (maps["HERSCHEL"].info)
maps["HERSCHEL"]["observation_id","filter","duration"].pprint()

Let's pick up SPIRE observation 1342188589, this is index 7.

In [6]:
nher = len(maps["HERSCHEL"])
maps["HERSCHEL"].remove_rows(np.delete(range(nher),7))
maps["HERSCHEL"]["observation_id","filter","duration"].pprint()

And we are ready to download the maps. They will be available in the memory but also saved to the deafult folder.

In [7]:
maps_data = ESASky.get_maps(maps)

Let's have a look at the maps_data

In [8]:
print (maps_data["HERSCHEL"])
print (maps_data["XMM-EPIC"])
In [9]:
xmm_hdu = maps_data["XMM-EPIC"][0]
xmm_hdu.info()
xmm_hdu[0].header
Out[9]:
SIMPLE  =                    T / file does conform to FITS standard             
BITPIX  =                   32 / number of bits per data pixel                  
NAXIS   =                    2 / number of data axes                            
NAXIS1  =                  648 / length of data axis 1                          
NAXIS2  =                  648 / length of data axis 2                          
EXTEND  =                    T / FITS dataset may contain extensions            
BUNIT   = 'Primary Array'      / Units of the image                             
XPROC0  = 'emosaic imagesets=''product/P0303420101M1S001IMAGE_8000.FIT product&'
CONTINUE  '/P0303420101M2S002IMAGE_8000.FIT product/P0303420101PNS003IMAGE_800&'
CONTINUE  '0.FIT'' exposuresets=expmap.ds withexposure=no mosaicedset=product/&'
CONTINUE  'P0303420101EPX000OIMAGE8000.FIT sampling=point forceuniformkwds=yes&'
CONTINUE  ' # (emosaic-1.16) [xmmsas_20121219_1645-12.0.1]'                     
XPROC1  = 'addattribute set=product/P0303420101EPX000OIMAGE8000.FIT attributen&'
CONTINUE  'ame=''INSTRUME BAND DATAMODE TELESCOP OBS_ID DATE-OBS DATE-END OBJE&'
CONTINUE  'CT OBSERVER'' attributetype=''string integer string string string s&'
CONTINUE  'tring string string string'' attributecomment='''' attributeunit=&'  
CONTINUE  ''''' realvalue='''' stringvalue=''EPIC IMAGING XMM 0303420101 2006-&'
CONTINUE  '05-20T06:31:43 2006-05-20T21:07:05 M51 "Dr Gulab Dewangan"'' intege&'
CONTINUE  'rvalue=8 booleanvalue='''' # (addattribute-2.2.6) [xmmsas_20121219_&'
CONTINUE  '1645-12.0.1]'                                                        
XPROC2  = 'addattribute set=product/P0303420101EPX000OIMAGE8000.FIT attributen&'
CONTINUE  'ame=''INSTRUME BAND DATAMODE TELESCOP OBS_ID DATE-OBS DATE-END OBJE&'
CONTINUE  'CT OBSERVER'' attributetype=''string integer string string string s&'
CONTINUE  'tring string string string'' attributecomment='''' attributeunit=&'  
CONTINUE  ''''' realvalue='''' stringvalue=''EPIC IMAGING XMM 0303420101 2006-&'
CONTINUE  '05-20T06:31:43 2006-05-20T21:07:05 M51 "Dr Gulab Dewangan"'' intege&'
CONTINUE  'rvalue=8 booleanvalue='''' # (addattribute-2.2.6) [xmmsas_20121219_&'
CONTINUE  '1645-12.0.1]'                                                        
XPROC3  = 'addattribute set=product/P0303420101EPX000OIMAGE8000.FIT attributen&'
CONTINUE  'ame=''SEQ_ID REVOLUT PROCDATE PROCREV PPSVERS SASVERS ODSVER ORIGIN&'
CONTINUE  ' ODFVER CONTENT'' attributetype=''string string string string strin&'
CONTINUE  'g string string string string string'' attributecomment=''"Pipeline&'
CONTINUE  ' sequence" "Satellite Revolution Number" "Processing date" "Process&'
CONTINUE  'ing revision" "PPS configuration" "SAS version used in pipeline pro&'
CONTINUE  'cessing" "ODS version" "Origin of FITS file" ODF_VERSION "Contents &'
CONTINUE  'of file"'' attributeunit='''' realvalue='''' stringvalue=''124006 1&'
CONTINUE  '180 2012-12-23T12:09:02 1 00000004_04_cat9.0_20121220.153800 xmmsas&'
CONTINUE  '_20121219_1645-12.0.1 16.911 Leicester/SSC 003 "EPIC OBSERVATION IM&'
CONTINUE  'AGE"'' integervalue='''' booleanvalue='''' # (addattribute-2.2.6) [&'
CONTINUE  'xmmsas_20121219_1645-12.0.1]'                                        
XPROC4  = 'addattribute set=product/P0303420101EPX000OIMAGE8000.FIT attributen&'
CONTINUE  'ame=''SEQ_ID REVOLUT PROCDATE PROCREV PPSVERS SASVERS ODSVER ORIGIN&'
CONTINUE  ' ODFVER CONTENT'' attributetype=''string string string string strin&'
CONTINUE  'g string string string string string'' attributecomment=''"Pipeline&'
CONTINUE  ' sequence" "Satellite Revolution Number" "Processing date" "Process&'
CONTINUE  'ing revision" "PPS configuration" "SAS version used in pipeline pro&'
CONTINUE  'cessing" "ODS version" "Origin of FITS file" ODF_VERSION "Contents &'
CONTINUE  'of file"'' attributeunit='''' realvalue='''' stringvalue=''124006 1&'
CONTINUE  '180 2012-12-23T12:09:02 1 00000004_04_cat9.0_20121220.153800 xmmsas&'
CONTINUE  '_20121219_1645-12.0.1 16.911 Leicester/SSC 003 "EPIC OBSERVATION IM&'
CONTINUE  'AGE"'' integervalue='''' booleanvalue='''' # (addattribute-2.2.6) [&'
CONTINUE  'xmmsas_20121219_1645-12.0.1]'                                        
XDAL0   = 'product/P0303420101EPX000OIMAGE8000.FIT 2012-12-24T05:10:29.000 Mod&'
CONTINUE  'ify addattribute (addattribute-2.2.6) [xmmsas_20121219_1645-12.0.1]&'
CONTINUE  ' High SAS_MEMORY_MODEL=high SAS_ROWS= SAS_ZERO_ROWS= SAS_COLUMN_WIS&'
CONTINUE  'E=      '                                                            
XDAL1   = 'product/P0303420101EPX000OIMAGE8000.FIT 2012-12-24T05:10:29.000 Mod&'
CONTINUE  'ify addattribute (addattribute-2.2.6) [xmmsas_20121219_1645-12.0.1]&'
CONTINUE  ' High SAS_MEMORY_MODEL=high SAS_ROWS= SAS_ZERO_ROWS= SAS_COLUMN_WIS&'
CONTINUE  'E=      '                                                            
XDAL2   = 'product/P0303420101EPX000OIMAGE8000.FIT 2012-12-23T14:20:10.000 Mod&'
CONTINUE  'ify addattribute (addattribute-2.2.6) [xmmsas_20121219_1645-12.0.1]&'
CONTINUE  ' High SAS_MEMORY_MODEL=high SAS_ROWS= SAS_ZERO_ROWS= SAS_COLUMN_WIS&'
CONTINUE  'E=      '                                                            
XDAL3   = 'product/P0303420101EPX000OIMAGE8000.FIT 2012-12-23T14:20:10.000 Mod&'
CONTINUE  'ify addattribute (addattribute-2.2.6) [xmmsas_20121219_1645-12.0.1]&'
CONTINUE  ' High SAS_MEMORY_MODEL=high SAS_ROWS= SAS_ZERO_ROWS= SAS_COLUMN_WIS&'
CONTINUE  'E=      '                                                            
XDAL4   = 'product/P0303420101EPX000OIMAGE8000.FIT 2012-12-23T14:20:08.000 Cre&'
CONTINUE  'ate emosaic (emosaic-1.16) [xmmsas_20121219_1645-12.0.1] High SAS_M&'
CONTINUE  'EMORY_MODEL=high SAS_ROWS= SAS_ZERO_ROWS= SAS_COLUMN_WISE='          
CREATOR = 'emosaic (emosaic-1.16) [xmmsas_20121219_1645-12.0.1]' / name of code 
DATE    = '2012-12-23T14:20:08.000' / creation date                             
LONGSTRN= 'OGIP 1.0'                                                            
EMSCF001= 'P0303420101M1S001IMAGE_8000.FIT' / Input Filename                    
EMSCF002= 'P0303420101M2S002IMAGE_8000.FIT' / Input Filename                    
EMSCF003= 'P0303420101PNS003IMAGE_8000.FIT' / Input Filename                    
EMSCI001= 'EMOS1   '           / Instrument                                     
EMSCI002= 'EMOS2   '           / Instrument                                     
EMSCI003= 'EPN     '           / Instrument                                     
EMSCE001= '36553.4000002444'   / Exposure (s)                                   
EMSCE002= '36683.400000155'    / Exposure (s)                                   
EMSCE003= '29980   '           / Exposure (s)                                   
EMSCD001= '??      '           / Duration (s)                                   
EMSCD002= '??      '           / Duration (s)                                   
EMSCD003= '54114   '           / Duration (s)                                   
EMSCA001= '0303420101'         / Obs Identifier                                 
EMSCA002= '0303420101'         / Obs Identifier                                 
EMSCA003= '0303420101'         / Obs Identifier                                 
EMSCB001= 'Dr Gulab Dewangan'  / Name of PI                                     
EMSCB002= 'Dr Gulab Dewangan'  / Name of PI                                     
EMSCB003= 'Dr Gulab Dewangan'  / Name of PI                                     
EMSCC001= 'M51     '           / Name of object                                 
EMSCC002= 'M51     '           / Name of object                                 
EMSCC003= 'M51     '           / Name of object                                 
EMSCG001= 'XMM     '           / Mission name                                   
EMSCG002= 'XMM     '           / Mission name                                   
EMSCG003= 'XMM     '           / Mission name                                   
EMSCH001= 'IMAGING '           / Instrmnt mode                                  
EMSCH002= 'IMAGING '           / Instrmnt mode                                  
EMSCH003= 'IMAGING '           / Instrmnt mode                                  
EMSCJ001= '2006-05-20T06:31:43' / Date obs made                                 
EMSCJ002= '2006-05-20T06:31:39' / Date obs made                                 
EMSCJ003= '2006-05-20T06:53:57' / Date obs made                                 
EMSCK001= '2006-05-20T21:07:05' / Date obs ended                                
EMSCK002= '2006-05-20T21:07:08' / Date obs ended                                
EMSCK003= '2006-05-20T21:25:06' / Date obs ended                                
EMSRP001= 2.02448583333333E+02 / [RA of s/c pointing]                           
EMSRP002= 2.02448583333333E+02 / [RA of s/c pointing]                           
EMSRP003= 2.02448583333333E+02 / [RA of s/c pointing]                           
EMSDP001= 4.71496944444444E+01 / [Dec of s/c pointing]                          
EMSDP002= 4.71496944444444E+01 / [Dec of s/c pointing]                          
EMSDP003= 4.71496944444444E+01 / [Dec of s/c pointing]                          
EMSAP001= 3.26572692871094E+02 / [Apos of s/c pointing]                         
EMSAP002= 3.26572692871094E+02 / [Apos of s/c pointing]                         
EMSAP003= 3.26572692871094E+02 / [Apos of s/c pointing]                         
INSTRUME= 'EPIC    '                                                            
BAND    =                    8                                                  
DATAMODE= 'IMAGING '                                                            
TELESCOP= 'XMM     '                                                            
OBS_ID  = '0303420101'                                                          
DATE-OBS= '2006-05-20T06:31:43'                                                 
DATE-END= '2006-05-20T21:07:05'                                                 
OBJECT  = 'M51     '                                                            
OBSERVER= 'Dr Gulab Dewangan'                                                   
SEQ_ID  = '124006  '           / Pipeline sequence                              
REVOLUT = '1180    '           / Satellite Revolution Number                    
PROCDATE= '2012-12-23T12:09:02' / Processing date                               
PROCREV = '1       '           / Processing revision                            
PPSVERS = '00000004_04_cat9.0_20121220.153800' / PPS configuration              
SASVERS = 'xmmsas_20121219_1645-12.0.1' / SAS version used in pipeline processin
ODSVER  = '16.911  '           / ODS version                                    
ORIGIN  = 'Leicester/SSC'      / Origin of FITS file                            
ODFVER  = '003     '           / ODF_VERSION                                    
CONTENT = 'EPIC OBSERVATION IMAGE' / Contents of file                           
HISTORY Created by emosaic (emosaic-1.16) [xmmsas_20121219_1645-12.0.1] at 2012-
HISTORY 12-23T14:20:08                                                          
HISTORY Modified by addattribute (addattribute-2.2.6) [xmmsas_20121219_1645-12.0
HISTORY .1] at 2012-12-23T14:20:10                                              
HISTORY Modified by addattribute (addattribute-2.2.6) [xmmsas_20121219_1645-12.0
HISTORY .1] at 2012-12-23T14:20:10                                              
HISTORY Modified by addattribute (addattribute-2.2.6) [xmmsas_20121219_1645-12.0
HISTORY .1] at 2012-12-24T05:10:29                                              
HISTORY Modified by addattribute (addattribute-2.2.6) [xmmsas_20121219_1645-12.0
HISTORY .1] at 2012-12-24T05:10:29                                              
XMMSEP  =                   11 / 11 primary image keywords follow               
CRPIX1  = 3.24506256109476E+02                                                  
CRPIX2  = 3.24506256109476E+02                                                  
CRVAL1  = 2.02448583333333E+02                                                  
CRVAL2  = 4.71496944444444E+01                                                  
CTYPE1  = 'RA---TAN'                                                            
CTYPE2  = 'DEC--TAN'                                                            
CUNIT1  = 'deg     '                                                            
CUNIT2  = 'deg     '                                                            
CROTA2  = 0.00000000000000E+00                                                  
CDELT1  = -1.11111111111111E-03                                                 
CDELT2  = 1.11111111111111E-03                                                  
In [10]:
her_hdu = maps_data["HERSCHEL"][0]["250"]
her_hdu.info()
her_hdu[0].header
Out[10]:
SIMPLE  =                    T / Java FITS: Tue Apr 19 23:09:38 CEST 2016       
BITPIX  =                   32                                                  
NAXIS   =                    0 / Dimensionality                                 
EXTEND  =                    T / May contain datasets                           
TIMESYS = 'UTC     '           / All dates are in UTC time                      
LONGSTRN= 'OGIP 1.0'           / The OGIP long string convention may be used.   
COMMENT This FITS file may contain long string keyword values that are          
COMMENT continued over multiple keywords.  This convention uses the  '&'        
COMMENT character at the end of a string which is then continued                
COMMENT on subsequent keywords whose name = 'CONTINUE'.                         
          ---------------Herschel FITS Data Generator---------------            
          This product is generated by Herschel software.                       
HCSS____=                    5 / HCSS Fits Product Version                      
          -------------- Herschel Structure Data--------------------            
          Following fields are private to the structure of the                  
          Java object this HDU is representing.                                 
CLASS___= 'herschel.ia.dataset.image.SimpleImage' / java representation         
INFO____= 'Final zero-level corrected extended calibrated map'                  
          -------------- Herschel Parameter Data--------------------            
          All actual parameter names are converted to FITS compliant            
          conventions. Note that the HIERARCH comments contain the              
          appropriate key mapping                                               
TELESCOP= 'Herschel Space Observatory' / Name of telescope                      
INSTRUME= 'SPIRE   '           / Instrument attached to this product            
CREATOR = 'SPG v14.1.0'        / Generator of this product                      
OBJECT  = 'ngc5194 '           / Target name                                    
OBSERVER= 'cwilso01'           / Observer name                                  
PROPOSAL= 'KPGT_cwilso01_1'    / Proposal name                                  
OBS_ID  =           1342188589 / [] Observation identifier                      
ODNUMBER=                  226 / [] Operational day number                      
DATE    = '2016-04-19T21:34:51.326000' / Creation date of this product          
DATE-OBS= '2009-12-26T12:22:14.141888' / Start date of this product             
DATE_OBS= '2009-12-26T12:22:14.141888' / Start date of this product             
DATE-END= '2009-12-26T12:47:00.835092' / End date of this product               
AOT     = 'Photometer'         / AOT Identifier                                 
AOR     = 'SPhoto-m51'         / AOR Label as entered in HSpot                  
CUSMODE = 'SpirePhotoLargeScan' / CUS observation mode                          
INSTMODE= 'POF5    '           / Instrument Mode                                
OBS_MODE= 'Large Map'          / Observation mode name                          
POINTMOD= 'Cross_scan'         / Pointing mode                                  
MODELNAM= 'FLIGHT  '           / Model name attached to this product            
FORMATV = '1.0     '           / Version of product format                      
MISSIONC= 'MC_HPhase3_P39ASTR_S43ASTR_RP' / Mission configuration               
EQUINOX =               2000.0 / [] Equinox of celestial coordinate system      
RADESYS = 'ICRS    '           / Coordinate reference frame for the RA and DEC  
RA      =    202.4674659945885 / [deg] Actual Right Ascension of pointing       
RA_NOM  =   202.46962499999998 / [deg] Requested Right Ascension of pointing    
DEC     =   47.190760748608966 / [deg] Actual Declination of pointing           
DEC_NOM =   47.195166666666665 / [deg] Requested Declination of pointing        
POSANGLE=   118.41590402715985 / [deg] Position Angle of pointing               
PMRA    =                  0.0 / [arcsec/year] Target's proper motion RA (arc&  
COMMENT sec/yr) as given by the observer                                        
PMDEC   =                  0.0 / [arcsec/year] Target's proper motion Dec (ar&  
COMMENT csec/yr) as given by the observer                                       
ORIGIN  = 'Herschel Science Centre' / Site that created the product             
TYPE    = 'PXMP    '           / Product Type Identification                    
DESC    = 'Final zero-level corrected extended calibrated map&'                 
CONTINUE  '' / &                                                                
COMMENT Name of this product                                                    
CALVERS = 'spire_cal_14_3'     / Calibration version                            
LEVEL   = '20      '           / The level of the product                       
SCANDIR = 'scanab  '           / nominal, orthogonal or scanab                  
NSCANNOM=                    4 / [] Number of scanlines in nominal direction    
NSCANORT=                    4 / [] Number of scanlines in orthogonal directi&  
COMMENT on                                                                      
SCANSPD = 'nominal '           / Speed of scan                                  
SCANVEL =                 30.0 / [arcsec/s] Constant speed of the spacecraft &  
COMMENT during scanline                                                         
CRPIX1  =                213.0 / [] WCS: Reference pixel position axis 1, uni&  
COMMENT t=Scalar                                                                
CRPIX2  =                220.0 / [] WCS: Reference pixel position axis 2, uni&  
COMMENT t=Scalar                                                                
DETECTOR= 'PSW     '           / Name of bolometer array                        
SIGUNIT = 'MJy/sr  '           / Unit of the signal                             
QINVSAMP=                  0.0 / [] Fraction of NaN or infinite samples         
QINVCORD=                  0.0 / [] Fraction of NaN or infinite coordinates     
NDTSAMPS=              3620971 / [] Number of data samples propogated in the &  
COMMENT creation of this Tod                                                    
META_0  =                    0 / [] First TOD sample index included in the map  
META_1  =              3620970 / [] Last TOD sample index included in the map   
CRVAL1  =    202.4674659945885 / [] WCS: First coordinate of reference pixel    
CRVAL2  =   47.190760748608966 / [] WCS: Second coordinate of reference pixel   
CDELT1  =   -0.001666666666667 / [] WCS: Pixel scale axis 1, unit=Angle         
CDELT2  =    0.001666666666667 / [] WCS: Pixel scale axis 2, unit=Angle         
CTYPE1  = 'RA---TAN'           / WCS: Projection type axis 1, default="LINEAR"  
CTYPE2  = 'DEC--TAN'           / WCS: Projection type axis 2, default="LINEAR"  
CROTA2  =                  0.0 / [] The Rotation angle                          
META_2  =                  422 / []                                             
META_3  =                  445 / []                                             
WAVELNTH=                250.0 / [micrometer] The reference wavelength at whi&  
COMMENT ch the image is taken                                                   
META_4  = 'DX11d_map_545_smooth_8arcmin.fits' / HFI 545 GHz file used           
META_5  = 'DX11d_map_857_smooth_8arcmin.fits' / HFI 857 GHz file used           
META_6  = '5       '           / HFI-SPIRE colour correction version used       
META_7  =   1.8588205934941149 / [MJy sr-1] Offset added to SPIRE image as ob&  
COMMENT tained from cross-calibration with Planck                               
META_8  =    0.711226583692533 / [MJy sr-1] Standard deviation of difference &  
COMMENT map between HFI and SPIRE maps as obtained from cross-calibration with &
COMMENT Planck                                                                  
HIERARCH  key.TELESCOP='telescope'                                              
HIERARCH  key.INSTRUME='instrument'                                             
HIERARCH  key.CREATOR='creator'                                                 
HIERARCH  key.OBJECT='object'                                                   
HIERARCH  key.OBSERVER='observer'                                               
HIERARCH  key.PROPOSAL='proposal'                                               
HIERARCH  key.OBS_ID='obsid'                                                    
HIERARCH  key.ODNUMBER='odNumber'                                               
HIERARCH  key.DATE='creationDate'                                               
HIERARCH  key.DATE-OBS='startDate'                                              
HIERARCH  key.DATE-END='endDate'                                                
HIERARCH  key.AOT='aot'                                                         
HIERARCH  key.AOR='aorLabel'                                                    
HIERARCH  key.CUSMODE='cusMode'                                                 
HIERARCH  key.INSTMODE='instMode'                                               
HIERARCH  key.OBS_MODE='obsMode'                                                
HIERARCH  key.POINTMOD='pointingMode'                                           
HIERARCH  key.MODELNAM='modelName'                                              
HIERARCH  key.FORMATV='formatVersion'                                           
HIERARCH  key.MISSIONC='missionConfig'                                          
HIERARCH  key.EQUINOX='equinox'                                                 
HIERARCH  key.RADESYS='raDeSys'                                                 
HIERARCH  key.RA='ra'                                                           
HIERARCH  key.RA_NOM='raNominal'                                                
HIERARCH  key.DEC='dec'                                                         
HIERARCH  key.DEC_NOM='decNominal'                                              
HIERARCH  key.POSANGLE='posAngle'                                               
HIERARCH  key.PMRA='pmRA'                                                       
HIERARCH  key.PMDEC='pmDEC'                                                     
HIERARCH  key.ORIGIN='origin'                                                   
HIERARCH  key.TYPE='type'                                                       
HIERARCH  key.DESC='description'                                                
HIERARCH  key.CALVERS='calVersion'                                              
HIERARCH  key.LEVEL='level'                                                     
HIERARCH  key.SCANDIR='scanDirection'                                           
HIERARCH  key.NSCANNOM='numScanLinesNom'                                        
HIERARCH  key.NSCANORT='numScanLinesOrth'                                       
HIERARCH  key.SCANSPD='scanSpeed'                                               
HIERARCH  key.SCANVEL='scanVelocity'                                            
HIERARCH  key.CRPIX1='crpix1'                                                   
HIERARCH  key.CRPIX2='crpix2'                                                   
HIERARCH  key.DETECTOR='arrayName'                                              
HIERARCH  key.SIGUNIT='unit'                                                    
HIERARCH  key.QINVSAMP='ratioInvalidSamplesInTimeline'                          
HIERARCH  key.QINVCORD='ratioInvalidCoordsInTimeline'                           
HIERARCH  key.NDTSAMPS='nDataSamples'                                           
HIERARCH  key.META_0='firstSample'                                              
HIERARCH  key.META_1='lastSample'                                               
HIERARCH  key.CRVAL1='crval1'                                                   
HIERARCH  key.CRVAL2='crval2'                                                   
HIERARCH  key.CDELT1='cdelt1'                                                   
HIERARCH  key.CDELT2='cdelt2'                                                   
HIERARCH  key.CTYPE1='ctype1'                                                   
HIERARCH  key.CTYPE2='ctype2'                                                   
HIERARCH  key.CROTA2='crota2'                                                   
HIERARCH  key.META_2='naxis1'                                                   
HIERARCH  key.META_3='naxis2'                                                   
HIERARCH  key.WAVELNTH='wavelength'                                             
HIERARCH  key.META_4='hfi545'                                                   
HIERARCH  key.META_5='hfi857'                                                   
HIERARCH  key.META_6='hfiColor'                                                 
HIERARCH  key.META_7='zPointOffset'                                             
HIERARCH  key.META_8='zPointStDev'                                              
          -----------------Dataset Children-------------------------            
          Below you will find all HDU locations that are children of            
          this composite dataset.                                               
DSETS___=                    4 / Number of datasets                             
DS_0    =                    1 / HDU of Child Dataset                           
DS_1    =                    2 / HDU of Child Dataset                           
DS_2    =                    3 / HDU of Child Dataset                           
DS_3    =                    4 / HDU of Child Dataset                           

Now we have the maps loaded in the session and we can start with some of the points in the workflow.

  1. Smooth the XMM-EPIC map with a Gaussian with FWHM=5"
In [11]:
# need to create the Gaussian kernel, it needs the st.dev. in pixels, so we need ot get the WCS of the image first
wcs = WCS(xmm_hdu[0].header)
pix = wcs.wcs.cdelt[1]*3600.0 # pixel size in arcsec
fwhm = 15/pix
conv = np.sqrt(8.0*np.log(2.0))
stdev = fwhm/conv
gauss = Gaussian2DKernel(stddev=stdev)
xmm_sm5 = convolve(xmm_hdu[0].data,gauss)
In [12]:
fig = plt.figure(figsize=(10,10),dpi=100)
pp = 98.0 # colour cut percentage
ax = fig.add_subplot(121,projection=wcs)
ax.set_title("XMM raw")
img_scaled = visualization.scale_image(xmm_hdu[0].data,percent=pp)
ax.imshow(img_scaled,cmap=plt.cm.gray,origin='lower',interpolation='nearest')
ay = fig.add_subplot(122,projection=wcs)
ay.set_title("XMM smoothed and contour")
img_scaled2 = visualization.scale_image(xmm_sm5,percent=pp)
ay.imshow(img_scaled2,cmap=plt.cm.gray,origin='lower',interpolation='nearest')
#print (np.min(xmm_sm5),np.max(xmm_sm5))
# now plot the contours
ay.contour(xmm_sm5, transform=ay.get_transform(WCS(xmm_hdu[0].header)), 
           levels=np.linspace(3,100,20),colors='yellow')
Out[12]:
<matplotlib.contour.QuadContourSet at 0x114364890>

Now, let's show the Herschel 250 µm image.

In [13]:
fig = plt.figure(figsize=(10,10),dpi=100)
pp = 98.0 # colour cut percentage
wcs_h = WCS(her_hdu['image'].header)
ax = fig.add_subplot(111,projection=wcs_h)
ax.set_title("Herschel SPIRE 250 µm")
img_scaled = visualization.scale_image(her_hdu['image'].data,percent=pp)
ax.imshow(img_scaled,cmap=plt.cm.gray,origin='lower',interpolation='nearest')
cs = ax.contour(xmm_sm5, transform=ax.get_transform(wcs), 
           levels=np.linspace(3,50,10),colors='yellow', label="XMM [0.2-7] keV")
plt.xlabel = 'RA'
plt.ylabel = 'Dec'
ax.legend([q for q in cs.collections],["XMM EPIC"])
Out[13]:
<matplotlib.legend.Legend at 0x11a5d06d0>
In [14]:
cats = ESASky.query_region_catalogs('M51','10 arcmin')
print (cats)
In [15]:
catx= cats['PLANCK-PCCS2-HFI']
catx.info
# select only the 857 GHz sources
ix857 = np.where(catx['frequency'] == 857)[0]
src857 = catx[ix857]
src857
Out[15]:
<Table masked=True length=4>
namera [1]dec [1]frequency [1]detflux [1]detflux_err [1]extended [1]highest_reliability_cat [1]
objectfloat64float64int32float64float64int32int32
PCCS2 857 G104.80+68.56202.48658716847.181795866585746454.07382.1489199
PCCS2 857 G104.89+68.46202.50614268847.29270496698578509.699148.8071199
PCCS2 857 G104.70+68.45202.60703218147.26945873828572487.3816144.50739199
PCCS2 857 G104.65+68.65202.50746619147.07815467838571935.9907154.44075199

Now let's combine everything into a final figure.

In [16]:
fig = plt.figure(figsize=(10,10),dpi=100)
pp = 95.0 # colour cut percentage
wcs_h = WCS(her_hdu['image'].header)
ax = fig.add_subplot(111,projection=wcs_h)
ax.set_title("Herschel SPIRE 250 µm")
img_scaled = visualization.scale_image(her_hdu['image'].data,percent=pp)
ax.imshow(img_scaled,cmap=plt.cm.gray,origin='lower',interpolation='nearest')
cs = ax.contour(xmm_sm5, transform=ax.get_transform(wcs), 
           levels=np.linspace(6,50,10),colors='yellow', label="XMM [0.2-7] keV")
p1 = ax.scatter(src857['ra'],src857['dec'],transform=ax.get_transform('world'), \
        s=300, edgecolor='red', facecolor='none', label='Planck PCCS2-HFI')
plt.xlabel = 'RA'
plt.ylabel = 'Dec'
ax.legend([[q for q in cs.collections][0],p1],["XMM EPIC","Planck PCCS2-HFI857"])
Out[16]:
<matplotlib.legend.Legend at 0x11a5d0850>