Querying ALMA archive for OrionKL pointings and plotting them on a 2MASS image
from astroquery.alma import Alma
from astroquery.skyview import SkyView
import string
from astropy import units as u
from astropy import coordinates
import pylab as pl
import aplpy
Retrieve OrionKL 2MASS K-band image:
orionkl_coords = coordinates.SkyCoord.from_name('Orion KL')
orionkl_images = SkyView.get_images(position='Orion KL', survey=['2MASS-K'], pixels=500)
orionkl_images
FITS files must be read as binaries; error is likely.
[[<astropy.io.fits.hdu.image.PrimaryHDU at 0x11f811a50>]]
Retrieve ALMA archive information including private data and non-science fields:
orionkl = Alma.query_region(coordinate=orionkl_coords, radius=4*u.arcmin, public=False, science=False)
orionkl
Project code | Source name | RA | Dec | Band | Frequency resolution | Integration | Release date | Frequency support | Velocity resolution | Pol products | Observation date | PI name | PWV | Member ous id | Asdm uid | Project title | Project type | Scan intent |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | kHz | s | GHz | m / s | mm | ||||||||||||
string128 | string2048 | float64 | float64 | int32 | float64 | float64 | object | string21600 | float64 | string512 | object | string2048 | float32 | string256 | string256 | string2048 | string128 | string2048 |
2011.0.00199.S | Orion H2O maser outburst | 83.808854166666663 | -5.3768016666666663 | 6 | 31250.0 | 10.677 | 2013-06-14 | [240.01..241.99GHz,31250.00kHz, XX YY] U [242.01..243.99GHz,31250.00kHz, XX YY] U [256.01..257.99GHz,31250.00kHz, XX YY] U [258.01..259.99GHz,31250.00kHz, XX YY] | 37474.05724998501 | XX YY | 2012-04-08 20:19:27 | Hirota, Tomoya | 2.9074531 | uid://A002/X303d22/X4c | uid://A002/X3ca066/X114 | Bursting Water Maser Feature in Orion KL | S | TARGET |
2011.0.00199.S | Orion H2O maser outburst | 83.808854166666663 | -5.3768016666666663 | 7 | 244.140625 | 27.931000000000001 | 2013-12-03 | [320.98..321.45GHz,244.14kHz, XX YY] U [322.12..322.59GHz,244.14kHz, XX YY] U [334.43..334.90GHz,244.14kHz, XX YY] U [335.98..336.45GHz,244.14kHz, XX YY] | 222.79811202502449 | XX YY | 2012-10-21 10:14:20 | Hirota, Tomoya | 0.49233711 | uid://A002/X303d22/X5a | uid://A002/X518d2b/Xb3a | Bursting Water Maser Feature in Orion KL | S | TARGET |
2011.0.00199.S | Orion H2O maser outburst | 83.808854166666663 | -5.3768016666666663 | 7 | 244.140625 | 32.107999999999997 | 2013-12-03 | [320.98..321.45GHz,244.14kHz, XX YY] U [322.12..322.59GHz,244.14kHz, XX YY] U [334.43..334.90GHz,244.14kHz, XX YY] U [335.98..336.45GHz,244.14kHz, XX YY] | 222.79811202502449 | XX YY | 2012-07-16 11:07:23 | Hirota, Tomoya | 0.66106993 | uid://A002/X303d22/X5a | uid://A002/X460fc9/Xa91 | Bursting Water Maser Feature in Orion KL | S | TARGET |
2011.0.00199.S | Orion H2O maser outburst | 83.808854166666663 | -5.3768016666666663 | 7 | 244.140625 | 32.716999999999999 | 2013-12-03 | [320.98..321.45GHz,244.14kHz, XX YY] U [322.12..322.59GHz,244.14kHz, XX YY] U [334.43..334.90GHz,244.14kHz, XX YY] U [335.98..336.45GHz,244.14kHz, XX YY] | 222.79811202502449 | XX YY | 2012-08-25 10:30:47 | Hirota, Tomoya | 0.73374134 | uid://A002/X303d22/X5a | uid://A002/X4afc39/Xa3a | Bursting Water Maser Feature in Orion KL | S | TARGET |
2011.0.00028.S | OrionField1-1 | 83.817916666666648 | -5.3895555555555559 | 7 | 976.5625 | 32.654000000000003 | 2014-01-03 | [342.36..344.24GHz,976.56kHz, XX YY] U [344.24..346.11GHz,976.56kHz, XX YY] U [354.28..356.16GHz,976.56kHz, XX YY] U [355.79..357.67GHz,976.56kHz, XX YY] | 835.99889987775487 | XX YY | 2012-10-24 05:23:07 | Mann, Rita | 0.72024173 | uid://A002/X327408/X205 | uid://A002/X51ee7e/X1c2 | The Effect of Extreme Environment on Protoplanetary Disks in Orion | S | TARGET |
2011.0.00028.S | OrionField1-1 | 83.817916666666648 | -5.3895555555555559 | 7 | 976.5625 | 32.664000000000001 | 2014-01-03 | [342.36..344.24GHz,976.56kHz, XX YY] U [344.24..346.11GHz,976.56kHz, XX YY] U [354.28..356.16GHz,976.56kHz, XX YY] U [355.79..357.67GHz,976.56kHz, XX YY] | 835.99889987775487 | XX YY | 2012-10-24 08:48:42 | Mann, Rita | 0.70387971 | uid://A002/X327408/X205 | uid://A002/X51ee7e/X4dd | The Effect of Extreme Environment on Protoplanetary Disks in Orion | S | TARGET |
2011.0.00028.S | OrionField1-1 | 83.817916666666648 | -5.3895555555555559 | 7 | 976.5625 | 32.694000000000003 | 2014-01-03 | [342.36..344.24GHz,976.56kHz, XX YY] U [344.24..346.11GHz,976.56kHz, XX YY] U [354.28..356.16GHz,976.56kHz, XX YY] U [355.79..357.67GHz,976.56kHz, XX YY] | 835.99889987775487 | XX YY | 2012-10-24 07:14:43 | Mann, Rita | 0.73464209 | uid://A002/X327408/X205 | uid://A002/X51ee7e/X35f | The Effect of Extreme Environment on Protoplanetary Disks in Orion | S | TARGET |
2011.0.00028.S | OrionField1-1 | 83.817916666666648 | -5.3895555555555559 | 7 | 976.5625 | 32.707000000000001 | 2014-01-03 | [342.36..344.24GHz,976.56kHz, XX YY] U [344.24..346.11GHz,976.56kHz, XX YY] U [354.28..356.16GHz,976.56kHz, XX YY] U [355.79..357.67GHz,976.56kHz, XX YY] | 835.99889987775487 | XX YY | 2012-10-24 03:47:01 | Mann, Rita | 0.70661682 | uid://A002/X327408/X205 | uid://A002/X51ee7e/X44 | The Effect of Extreme Environment on Protoplanetary Disks in Orion | S | TARGET |
2011.0.00028.S | OrionField1-1 | 83.817916666666648 | -5.3895555555555559 | 7 | 976.5625 | 32.744999999999997 | 2014-01-03 | [342.36..344.24GHz,976.56kHz, XX YY] U [344.24..346.11GHz,976.56kHz, XX YY] U [354.28..356.16GHz,976.56kHz, XX YY] U [355.79..357.67GHz,976.56kHz, XX YY] | 835.99889987775487 | XX YY | 2012-10-24 10:30:52 | Mann, Rita | 0.71500158 | uid://A002/X327408/X205 | uid://A002/X51ee7e/X67a | The Effect of Extreme Environment on Protoplanetary Disks in Orion | S | TARGET |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2012.1.00352.S | Orion_Bar | 83.835833333333326 | -5.4222222222222216 | 7 | 976.5625 | 2226.3829999999998 | [345.40..346.39GHz,488.28kHz, XX YY] U [356.22..357.22GHz,488.28kHz, XX YY] U [357.29..358.29GHz,488.28kHz, XX YY] | 410.93402462306449 | XX YY | 2014-10-07 09:28:44 | Goicoechea, Javier | 1.3864298 | uid://A001/X144/X21 | uid://A002/X8f1c7c/X1528 | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET WVR | |
2012.1.00352.S | Orion_Bar | 83.835833333333326 | -5.4222222222222216 | 7 | 976.5625 | 2226.652 | [345.40..346.40GHz,488.28kHz, XX YY] U [356.22..357.22GHz,488.28kHz, XX YY] U [357.29..358.29GHz,488.28kHz, XX YY] | 410.93362488666679 | XX YY | 2014-10-05 09:41:58 | Goicoechea, Javier | 0.28458548 | uid://A001/X144/X21 | uid://A002/X8ec83d/Xbaa | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET WVR | |
2012.1.00352.S | Orion_Bar | 83.835833333333326 | -5.4222222222222216 | 7 | 976.5625 | 2227.9760000000001 | [345.40..346.40GHz,488.28kHz, XX YY] U [356.22..357.22GHz,488.28kHz, XX YY] U [357.29..358.29GHz,488.28kHz, XX YY] | 410.93170820116194 | XX YY | 2014-09-10 10:11:13 | Goicoechea, Javier | 0.44827378 | uid://A001/X144/X21 | uid://A002/X8b7acb/X355 | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET WVR | |
2012.1.00352.S | Orion_Bar | 83.835833333333326 | -5.4222222222222216 | 7 | 976.5625 | 2228.877 | [345.40..346.40GHz,488.28kHz, XX YY] U [356.22..357.22GHz,488.28kHz, XX YY] U [357.29..358.29GHz,488.28kHz, XX YY] | 410.93386189627125 | XX YY | 2014-10-07 08:27:54 | Goicoechea, Javier | 1.3269638 | uid://A001/X144/X21 | uid://A002/X8f1c7c/X1269 | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET WVR | |
2012.1.00352.S | Orion_Bar | 83.835833333333326 | -5.4222222222222216 | 7 | 976.5625 | 2230.4259999999999 | [345.40..346.39GHz,488.28kHz, XX YY] U [356.22..357.22GHz,488.28kHz, XX YY] U [357.29..358.29GHz,488.28kHz, XX YY] | 410.93415100721489 | XX YY | 2014-10-08 08:55:11 | Goicoechea, Javier | 0.62932658 | uid://A001/X144/X21 | uid://A002/X8f3a3d/X16f0 | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET WVR | |
2012.1.00352.S | Orion_Bar | 83.83667697797128 | -5.4157652111971943 | 7 | 976.5625 | 37.659999999999997 | [345.34..346.34GHz,488.28kHz, XX YY] U [356.21..357.21GHz,488.28kHz, XX YY] U [357.24..358.24GHz,488.28kHz, XX YY] | 410.9394076007394 | XX YY | 2014-04-08 23:24:29 | Goicoechea, Javier | -- | uid://A002/X6dddc4/X6c | uid://A002/X7ea111/X22d | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET | |
2012.1.00352.S | Orion_Bar | 83.837432914740404 | -5.4262469396865551 | 7 | 976.5625 | 37.659999999999997 | [345.34..346.34GHz,488.28kHz, XX YY] U [356.21..357.21GHz,488.28kHz, XX YY] U [357.24..358.24GHz,488.28kHz, XX YY] | 410.9394076007394 | XX YY | 2014-04-08 23:24:29 | Goicoechea, Javier | -- | uid://A002/X6dddc4/X6c | uid://A002/X7ea111/X22d | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET | |
2012.1.00352.S | Orion_Bar | 83.838465543570635 | -5.4224103607838883 | 7 | 976.5625 | 37.659999999999997 | [345.34..346.34GHz,488.28kHz, XX YY] U [356.21..357.21GHz,488.28kHz, XX YY] U [357.24..358.24GHz,488.28kHz, XX YY] | 410.9394076007394 | XX YY | 2014-04-08 23:24:29 | Goicoechea, Javier | -- | uid://A002/X6dddc4/X6c | uid://A002/X7ea111/X22d | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET | |
2012.1.00352.S | Orion_Bar | 83.83949817240088 | -5.4185737818812232 | 7 | 976.5625 | 37.659999999999997 | [345.34..346.34GHz,488.28kHz, XX YY] U [356.21..357.21GHz,488.28kHz, XX YY] U [357.24..358.24GHz,488.28kHz, XX YY] | 410.9394076007394 | XX YY | 2014-04-08 23:24:29 | Goicoechea, Javier | -- | uid://A002/X6dddc4/X6c | uid://A002/X7ea111/X22d | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET | |
2012.1.00352.S | Orion_Bar | 83.842319366830452 | -5.4213823525652201 | 7 | 976.5625 | 37.659999999999997 | [345.34..346.34GHz,488.28kHz, XX YY] U [356.21..357.21GHz,488.28kHz, XX YY] U [357.24..358.24GHz,488.28kHz, XX YY] | 410.9394076007394 | XX YY | 2014-04-08 23:24:29 | Goicoechea, Javier | -- | uid://A002/X6dddc4/X6c | uid://A002/X7ea111/X22d | The fundamental structure of molecular cloud edges: from clumps to photoevaporation | S | TARGET |
Parse components of the ALMA data. Specifically, find the frequency support - the frequency range covered - and convert that into a central frequency for beam radius estimation.
def parse_frequency_support(frequency_support_str):
supports = frequency_support_str.split("U")
freq_ranges = [(float(sup.strip('[] ').split("..")[0]),
float(sup.strip('[] ').split("..")[1].split(',')[0].strip(string.letters)))
*u.Unit(sup.strip('[] ').split("..")[1].split(',')[0].strip(string.punctuation+string.digits))
for sup in supports]
return u.Quantity(freq_ranges)
def approximate_primary_beam_sizes(frequency_support_str):
freq_ranges = parse_frequency_support(frequency_support_str)
beam_sizes = [(1.22*fr.mean().to(u.m, u.spectral())/(12*u.m)).to(u.arcsec,
u.dimensionless_angles())
for fr in freq_ranges]
return u.Quantity(beam_sizes)
primary_beam_radii = [approximate_primary_beam_sizes(row['Frequency support']) for row in orionkl]
Compute primary beam parameters for the public and private components of the data for plotting below.
bands = np.unique(orionkl['Band'])
print "The bands used include: "
print bands
band_colors_priv = dict(zip(bands, ('red','darkred','orange','brown','maroon')))
band_colors_pub = dict(zip(bands, ('blue','cyan','green','turquoise','teal')))
The bands used include: Band ---- 3 4 6 7 9
private_circle_parameters = {band: [(row['RA'],row['Dec'],np.mean(rad).to(u.deg).value)
for row,rad in zip(orionkl, primary_beam_radii)
if row['Release date']!='' and row['Band']==band]
for band in bands}
public_circle_parameters = {band: [(row['RA'],row['Dec'],np.mean(rad).to(u.deg).value)
for row,rad in zip(orionkl, primary_beam_radii)
if row['Release date']=='' and row['Band']==band]
for band in bands}
unique_private_circle_parameters = {band: np.array(list(set(private_circle_parameters[band])))
for band in bands}
unique_public_circle_parameters = {band: np.array(list(set(public_circle_parameters[band])))
for band in bands}
for band in bands:
print "BAND {0}".format(band)
privrows = sum((orionkl['Band']==band) & (orionkl['Release date'] != ''))
pubrows = sum((orionkl['Band']==band) & (orionkl['Release date'] == ''))
print "PUBLIC: Number of rows: {0}. Unique pointings: {1}".format(pubrows, len(unique_public_circle_parameters[band]))
print "PRIVATE: Number of rows: {0}. Unique pointings: {1}".format(privrows, len(unique_private_circle_parameters[band]))
BAND 3 PUBLIC: Number of rows: 2. Unique pointings: 1 PRIVATE: Number of rows: 1. Unique pointings: 1 BAND 4 PUBLIC: Number of rows: 0. Unique pointings: 0 PRIVATE: Number of rows: 2. Unique pointings: 2 BAND 6 PUBLIC: Number of rows: 388. Unique pointings: 388 PRIVATE: Number of rows: 262. Unique pointings: 155 BAND 7 PUBLIC: Number of rows: 25. Unique pointings: 14 PRIVATE: Number of rows: 190. Unique pointings: 151 BAND 9 PUBLIC: Number of rows: 0. Unique pointings: 0 PRIVATE: Number of rows: 21. Unique pointings: 17
Show all of the private observation pointings that have been acquired
fig = aplpy.FITSFigure(orionkl_images[0])
fig.show_grayscale(stretch='arcsinh')
for band in bands:
if unique_private_circle_parameters[band].any():
fig.show_circles(unique_private_circle_parameters[band][:,0],
unique_private_circle_parameters[band][:,1],
unique_private_circle_parameters[band][:,2],
color=band_colors_priv[band], alpha=0.2)
INFO:astropy:Auto-setting vmin to 2.393e+02 INFO:astropy:Auto-setting vmax to 3.155e+03
INFO: Auto-setting vmin to 2.393e+02 [aplpy.core] INFO: Auto-setting vmax to 3.155e+03 [aplpy.core]
In principle, all of the pointings shown below should be downloadable from the archive:
fig = aplpy.FITSFigure(orionkl_images[0])
fig.show_grayscale(stretch='arcsinh')
for band in bands:
if unique_public_circle_parameters[band].any():
fig.show_circles(unique_public_circle_parameters[band][:,0],
unique_public_circle_parameters[band][:,1],
unique_public_circle_parameters[band][:,2],
color=band_colors_pub[band], alpha=0.2)
INFO:astropy:Auto-setting vmin to 2.393e+02 INFO:astropy:Auto-setting vmax to 3.155e+03
INFO: Auto-setting vmin to 2.393e+02 [aplpy.core] INFO: Auto-setting vmax to 3.155e+03 [aplpy.core]
Use pyregion to write the observed regions to disk. Pyregion has a very awkward API; there is (in principle) work in progress to improve that situation but for now one must do all this extra work.
import pyregion
from pyregion.parser_helper import Shape
prv_regions = {band: pyregion.ShapeList([Shape('circle',[x,y,r]) for x,y,r in private_circle_parameters[band]])
for band in bands}
pub_regions = {band: pyregion.ShapeList([Shape('circle',[x,y,r]) for x,y,r in public_circle_parameters[band]])
for band in bands}
for band in bands:
circle_pars = np.vstack([x for x in (private_circle_parameters[band],
public_circle_parameters[band]) if any(x)])
for r,(x,y,c) in zip(prv_regions[band]+pub_regions[band],
circle_pars):
r.coord_format = 'fk5'
r.coord_list = [x,y,c]
r.attr = ([], {'color': 'green', 'dash': '0 ', 'dashlist': '8 3 ', 'delete': '1 ', 'edit': '1 ',
'fixed': '0 ', 'font': '"helvetica 10 normal roman"', 'highlite': '1 ',
'include': '1 ', 'move': '1 ', 'select': '1 ', 'source': '1', 'text': '',
'width': '1 '})
if prv_regions[band]:
prv_regions[band].write('OrionKL_observed_regions_band{0}_private_March2015.reg'.format(band))
if pub_regions[band]:
pub_regions[band].write('OrionKL_observed_regions_band{0}_public_March2015.reg'.format(band))
from astropy.io import fits
prv_mask = {band: fits.PrimaryHDU(prv_regions[band].get_mask(orionkl_images[0][0]).astype('int'),
header=orionkl_images[0][0].header) for band in bands
if prv_regions[band]}
pub_mask = {band: fits.PrimaryHDU(pub_regions[band].get_mask(orionkl_images[0][0]).astype('int'),
header=orionkl_images[0][0].header) for band in bands
if pub_regions[band]}
for band in pub_mask:
pub_mask[band].writeto('public_orionkl_band{0}_almaobs_mask.fits'.format(band), clobber=True)
for band in prv_mask:
prv_mask[band].writeto('private_orionkl_band{0}_almaobs_mask.fits'.format(band), clobber=True)
fig = aplpy.FITSFigure(orionkl_images[0])
fig.show_grayscale(stretch='arcsinh')
for band in bands:
if band in prv_mask:
fig.show_contour(prv_mask[band], levels=[0.5,1], colors=[band_colors_priv[band]]*2)
if band in pub_mask:
fig.show_contour(pub_mask[band], levels=[0.5,1], colors=[band_colors_pub[band]]*2)
INFO:astropy:Auto-setting vmin to 2.393e+02 INFO:astropy:Auto-setting vmax to 3.155e+03
INFO: Auto-setting vmin to 2.393e+02 [aplpy.core] INFO: Auto-setting vmax to 3.155e+03 [aplpy.core]
Now we create a 'hit mask' showing the relative depth of each observed field in each band
hit_mask_public = {band: np.zeros_like(orionkl_images[0][0].data) for band in pub_mask}
hit_mask_private = {band: np.zeros_like(orionkl_images[0][0].data) for band in prv_mask}
from astropy import wcs
mywcs = wcs.WCS(orionkl_images[0][0].header)
for band in bands:
for row,rad in zip(orionkl, primary_beam_radii):
shape = Shape('circle', (row['RA'], row['Dec'],np.mean(rad).to(u.deg).value))
shape.coord_format = 'fk5'
shape.coord_list = (row['RA'], row['Dec'],np.mean(rad).to(u.deg).value)
shape.attr = ([], {'color': 'green', 'dash': '0 ', 'dashlist': '8 3 ', 'delete': '1 ', 'edit': '1 ',
'fixed': '0 ', 'font': '"helvetica 10 normal roman"', 'highlite': '1 ',
'include': '1 ', 'move': '1 ', 'select': '1 ', 'source': '1', 'text': '',
'width': '1 '})
if row['Release date']=='' and row['Band']==band and band in prv_mask:
(xlo,xhi,ylo,yhi),mask = pyregion_subset(shape, hit_mask_private[band], mywcs)
hit_mask_private[band][ylo:yhi,xlo:xhi] += row['Integration']*mask
if row['Release date']!='' and row['Band']==band and band in pub_mask:
(xlo,xhi,ylo,yhi),mask = pyregion_subset(shape, hit_mask_public[band], mywcs)
hit_mask_public[band][ylo:yhi,xlo:xhi] += row['Integration']*mask
fig = aplpy.FITSFigure(orionkl_images[0])
fig.show_grayscale(stretch='arcsinh')
for band in bands:
if band in pub_mask:
fig.show_contour(fits.PrimaryHDU(data=hit_mask_public[band], header=orionkl_images[0][0].header),
levels=np.logspace(0,5,base=2, num=6), colors=[band_colors_pub[band]]*6)
if band in prv_mask:
fig.show_contour(fits.PrimaryHDU(data=hit_mask_private[band], header=orionkl_images[0][0].header),
levels=np.logspace(0,5,base=2, num=6), colors=[band_colors_priv[band]]*6)
INFO:astropy:Auto-setting vmin to 2.393e+02 INFO:astropy:Auto-setting vmax to 3.155e+03
INFO: Auto-setting vmin to 2.393e+02 [aplpy.core] INFO: Auto-setting vmax to 3.155e+03 [aplpy.core]
from astropy import wcs
import pyregion
from astropy import log
def pyregion_subset(region, data, mywcs):
"""
Return a subset of an image (`data`) given a region.
"""
shapelist = pyregion.ShapeList([region])
if shapelist[0].coord_format not in ('physical','image'):
# Requires astropy >0.4...
# pixel_regions = shapelist.as_imagecoord(self.wcs.celestial.to_header())
# convert the regions to image (pixel) coordinates
celhdr = mywcs.sub([wcs.WCSSUB_CELESTIAL]).to_header()
pixel_regions = shapelist.as_imagecoord(celhdr)
else:
# For this to work, we'd need to change the reference pixel after cropping.
# Alternatively, we can just make the full-sized mask... todo....
raise NotImplementedError("Can't use non-celestial coordinates with regions.")
pixel_regions = shapelist
# This is a hack to use mpl to determine the outer bounds of the regions
# (but it's a legit hack - pyregion needs a major internal refactor
# before we can approach this any other way, I think -AG)
mpl_objs = pixel_regions.get_mpl_patches_texts()[0]
# Find the minimal enclosing box containing all of the regions
# (this will speed up the mask creation below)
extent = mpl_objs[0].get_extents()
xlo, ylo = extent.min
xhi, yhi = extent.max
all_extents = [obj.get_extents() for obj in mpl_objs]
for ext in all_extents:
xlo = xlo if xlo < ext.min[0] else ext.min[0]
ylo = ylo if ylo < ext.min[1] else ext.min[1]
xhi = xhi if xhi > ext.max[0] else ext.max[0]
yhi = yhi if yhi > ext.max[1] else ext.max[1]
log.debug("Region boundaries: ")
log.debug("xlo={xlo}, ylo={ylo}, xhi={xhi}, yhi={yhi}".format(xlo=xlo,
ylo=ylo,
xhi=xhi,
yhi=yhi))
subwcs = mywcs[ylo:yhi, xlo:xhi]
subhdr = subwcs.sub([wcs.WCSSUB_CELESTIAL]).to_header()
subdata = data[ylo:yhi, xlo:xhi]
mask = shapelist.get_mask(header=subhdr,
shape=subdata.shape)
log.debug("Shapes: data={0}, subdata={2}, mask={1}".format(data.shape, mask.shape, subdata.shape))
return (xlo,xhi,ylo,yhi),mask