c ○ 2012. The American Astronomical Society. Version: Accepted Manuscript

We observed the extreme close-in hot Jupiter system WASP-12 with HST. Near-UV transits up to three times deeper than the optical transit of WASP-12b reveal extensive diffuse gas, extending well beyond the Roche lobe. The distribution of absorbing gas varies between visits. The deepest NUV transits are at wavelength ranges with strong photospheric absorption, implying the absorbing gas may have temperature and composition similar to the stellar photosphere. Our spectra reveal significantly enhanced absorption (greater than 3 \sigma below the median) at ~200 wavelengths on each of two HST visits; 65 of these wavelengths are consistent between the two visits, using a strict criterion for velocity matching which excludes matches with velocity shifts exceeding ~20 km/s. Excess transit depths are robustly detected throughout the inner wings of the MgII resonance lines independently on both HST visits. We detected absorption in FeII 2586A, the heaviest species yet detected in an exoplanet transit. The MgII line cores have zero flux, emission cores exhibited by every other observed star of similar age and spectral type are conspicuously absent. WASP-12 probably produces normal MgII profiles, but the inner portions of these strong resonance lines are likely affected by extrinsic absorption. The required Mg+ column is an order of magnitude greater than expected from the ISM, though we cannot completely dismiss that possibility. A more plausible source of absorption is gas lost by WASP-12b. We show that planetary mass loss can produce the required column. Our Visit 2 NUV light curves show evidence for a stellar flare. We show that some of the possible transit detections in resonance lines of rare elements may be due instead to non-resonant transitions in common species. We present optical observations and update the transit ephemeris.


Introduction
WASP-12 b is one of the most extreme of the hot Jupiter exoplanets: it orbits only one stellar diameter away from the photosphere of its late F type host star, and is thus one of the most irradiated planets known (Hebb et al. 2009). The brightest hot Jupiters, HD 189733 b and HD 209458 b, are known to be surrounded by extended clouds of absorbing gas which have been detected through observations of their transits in the far UV (FUV; Vidal-Madjar et al. 2003Ben-Jaffel 2007;Vidal-Madjar et al. 2008;Lecavelier Des Etangs et al 2010;Linsky et al. 2010;Lecavelier Des Etangs et al 2012). These FUV transits occult the patchy and time-variable chromospheric emission from the star (Haswell 2010): the FUV continuum from even the nearest transiting-planet host stars is faint (see e.g. Linsky et al. 2010) . The FUV transit light curve therefore depends on the locus the planet follows across this constantly changing irregular chromospheric emission distribution and also depends on the velocity range of the emission line adopted for analysis (Ben-Jaffel 2007;Vidal-Madjar et al. 2008).
Several mechanisms have been proposed to explain the extended absorbing gas. A hydrodynamic 'blow-off' of the planet's outer atmosphere caused by the intense irradiation was the first and most obvious . This model has been extensively discussed and refined, most recently by Guo (2011) and Desert (2011). Adams (2011) considers how these outflows might be influenced by the planetary magnetic field, while Lecavelier Des Lecavelier Des Etangs (2007) and Erkaev et al. (2007) consider the effect of the Roche equipotentials on the outflow. Li et al. (2010) suggested that for eccentric hot Jupiters, tidal disruption might drive mass loss orders of magnitude greater than that from irradiation-driven hydrodynamic outflow. This was motivated by the implications in the discovery paper that WASP-12 b had a significantly non-zero eccentricity (Hebb et al. 2009). The most recent measurements of the orbital eccentricity of WASP-12 b are, however, consistent with zero eccentricity (Lopez-Morales et al 2009;Husnoo et al 2011), so tidal disruption is not expected to play a significant role for WASP-12 b. It could nonetheless play an important role for hot Jupiters found to have non-zero eccentricity, for example due to perturbations by other planets in the system.
A third explanation proposes that the planet is surrounded by a cloud of energetic neutral atoms caused by interactions with the host star's stellar wind (Holmström et al. 2008;Ekenbäck et al. 2010). Tremblin & Chiang (2012) simulate these colliding winds reproducing the observed Lymanα transit profiles. Raiput & Safvan (2011) report the formation of energetic neutral atoms from ion-impact dissociation of water in the laboratory, and suggest this process may contribute to the absorbing gas in hot Jupiter exospheres. Lai et al (2010) considered mass loss via Roche lobe overflow in WASP-12, while others (e.g. Vidotto, Jardine & Helling 2010) suggest the absorbing gas may simply be entrained material from the stellar corona, in which case it provides an opportunity to measure the planetary magnetic field. Llama et al (2011) model the radiative transfer through compressed material behind the magnetospheric bow shock produced in this scenario.
Since WASP-12 b is such an extreme hot Jupiter it was an obvious target for observations to examine the properties of the extended absorbing gas around these systems. The UV spectral region contains many resonance lines of common elements, including Lyman α which provided the first detection of this phenomenon (Vidal-Madjar et al. 2003). These resonance lines provide a sensitive probe for the presence of absorbing gas. WASP-12's distance is 300 pc or more (Fossati et al. 2010b), and this means the predicted FUV emission would be extremely hard to detect.
Thus we chose to observe in the near UV (NUV) using the COS spectrograph on HST to cover the strong Mg II resonance lines and a host of other spectral lines from a rich variety of chemical elements. Our choice of the NUV spectral region has the additional benefit that our transit light curves are measured using the well-understood intensity distribution from the stellar photosphere, which is expected to remain constant with time. In the NUV we are also able to detect absorption from gas with any velocity: in the FUV, gas ceases to produce an observable effect once its velocity exceeds the velocity width of the stellar chromospheric line emission which is being absorbed.
Our observations comprised two visits, and we published a short paper on the results from the first visit in Fossati et al. (2010a, hereafter Paper 1). In Paper 1 we presented light curves revealing an exosphere which appears to overfill its Roche lobe and wavelength resolved data, identifying enhanced transit depths at the wavelengths of a number of resonance lines.
In this paper, we report on our full complement of HST/COS NUV observations of WASP-12 and on contemporaneous ground-based optical photometry. In §2 we describe our observations and data reduction. §3 gives our observational results and develops their interpretation. §4 critically examines the interpretation suggested by our observational results and presents calculations demonstrating their plausibility. While the conclusions of Paper 1 are not significantly changed by our re-examination with the benefit of more extensive data, the new data demands a more complex interpretation than our first analysis in Paper 1 suggested.

Observations and data reduction
We observed WASP-12 with HST/ COS; and from the ground with PIRATE (Holmes et al. 2011), Faulkes Telescope North, and the James Gregory Telescope. These observations are described in § §2.1, 2.2, 2.3 and 2.4 respectively.

HST/COS observations
COS is a slitless spectrograph which we used to obtain R∼20 000 NUV spectroscopy. COS maximises the spectroscopic sensitivity of HST in the UV; a full instrument description and on-orbit performance characteristics can be found in Osterman et al. (2011) and Green et al. (2012).
Our HST observations are summarised in Table 1. Visits 1 and 2 each comprised five consecutive HST orbits and were executed on 2009 September 24/25 and 2010 March 28 respectively. A first analysis and brief discussion of Visit 1 was given in Paper 1. For Visit 1 we used the NUV G285M grating at the 2676 Å setting, which provides non-contiguous spectra over three wavelength ranges; see Table 1. For Visit 2 we used the 2695 Å setting of the same grating which gives a slight shift to the red as detailed in Table 1. Our set-up for the two visits was otherwise identical, with spectral resolution of R ∼20 000, without the use of offset FP-POS positions. We obtained simultaneous lamp spectra during science exposures using "FLASH = YES".
The settings for Visit 1 optimized coverage of the region around the core of the strong Mg II UV resonance lines; for Visit 2 we chose to cover the Fe II resonance line at λ2586 Å while maximising the overlap in wavelength between the two sets of observations. Obtaining a homogeneous data-set may have had advantages, as we are photon starved, and the behavior of the WASP-12 system appears different on the two visits. The wavelength shift means that only a subset of our spectral coverage can be combined to make light curves which can be straightforwardly interpreted. In § §3.6 and 4.1, however, we use the Fe II resonance line to disentangle a complicated story, and it is decisive in one of the major interpretative questions of this paper.
In each visit the exposure time was 2334 s in the first HST orbit and about 3000 s per subsequent HST orbit. We designed the timings of the two visits so they interleave to give full phase coverage of the transit with out of transit (OOT) coverage before ingress and after egress.
Our observations were obtained in TIME-TAG observing mode, in which individual photon events are recorded at a resolution of 32 ms, but our effective time-resolution is much poorer due to the faintness of the target. The count rates summed over wavelength are ∼ 10 count s −1 ; ∼ 28 count s −1 ; and ∼ 13 count s −1 respectively for the NUVA, NUVB, and NUVC ranges (see Table 1 for definitions). The data were reduced using the calibration files provided by STScI; these were updated following Paper 1, so we re-reduced all the HST data using the updated calibration files for the present paper. We downloaded data from MAST 1 adopting CALCOS V.2.11b 2 for calibration. The COS data comprise exposures of the science target with corresponding lamp spectra displaced in the spatial direction. The effects of the new reduction on the data presented in Paper 1 are shown at the end of this section.
The reduced Visit 2 data as downloaded from the MAST archive suffered from a problem in the extraction of the science spectra and in the determination of the background level. We characterised the location of the science spectra by fitting Gaussians to the profile in the spatial direction. The center of the extraction box for the NUVA region, as defined in the extraction reference file, is about 5 pixels from the central peak of the science spectrum. Similarly, the center of one of the two extraction boxes used by CALCOS to compute the background level is misplaced so that a portion of the science spectrum falls into the background extraction box. To solve this problem, we compared the position of the central pixel of each of the NUVA, NUVB and NUVC spectra as given in the reference file for different settings of the same grating. The prescribed central pixel differs for different settings, but NUVA, NUVB and NUVC are always at the same relative positions, except for the 2695 Å setting. For this reason we simply corrected the extraction box for the NUVA and background region by adopting the same shift as for the NUVB and NUVC regions, we then re-ran CALCOS and the extraction succeeded. Figure 1 shows the flux-calibrated grand sum spectra obtained in Visit 1 and Visit 2 in comparison with synthetic fluxes, as discussed in §3.2. The mean fluxes are 9 ± 1%, 7 ± 1% and 3.5 ± 1.0% lower in Visit 2 for NUVA, NUVB, and NUVC respectively. This is largely attributable to the declining throughput , but also due to the varying mean obscuration of the WASP-12 stellar flux by the planet and diffuse gas. We will discuss a likely third contributor to varying fluxes in §3.6.
In our time-series analysis we used the count rates obtained after background subtraction, rather than the flux calibrated spectra. The high quality flat-field and the relatively low background of the NUV channel mean the uncertainties are dominated by Poisson statistics. The resulting signal to noise ratio (SNR) in our extracted NUVB spectra is ∼8 per pixel for each 3000 sec exposure. This is consistent with the expected photon counting noise, and propagates to a fractional uncertainty of ∼ 0.007 when a 3000 s exposure is averaged. Figure 2 shows our Visit 1 light curves. These were produced by summing across wavelength for each of NUVA, NUVB and NUVC to produce a photometric point for each HST orbit. Fig. 2 compares the results from Paper 1 with those from our revised calibration. The first and last data points for both reductions are set to unity with the normalisation procedure applied in Paper 1; all the remaining points are within 1σ of their previous positions. For all three wavelength regions, the normalisation lines (see Paper 1) are slightly improved (flatter) with the new calibration files.
The normalisation applied does not significantly affect the shape of the observed NUV transit, as no point moves by as much as 1σ.
The NUVA point immediately preceding optical ingress and the NUVA and NUVC points at mid-transit have been moved down almost 1σ relative to the reduction presented in Paper 1.
The refined reduction therefore strengthens the case (made in Paper 1) for an early ingress and an extended asymmetric cloud of absorbing gas: the NUVA and NUVC transit depths are now ∼ 4σ below the depth of the optical transit. When we consider the data from both visits together, however, these conclusions become more complicated, as discussed in §3.3.

PIRATE optical photometry
In conjunction with our first HST visit we undertook a program of optical photometry with The Open University's remotely operable optical telescope, PIRATE (Holmes et al. 2011). The goal of these observations was to verify or, if necessary, update the WASP-12 b orbital ephemeris.
The PIRATE observations are logged in Table 2. We used the R filter on all 7 nights, and either 120s, 60s, or 45s exposures. The dead time between exposures is 15s, resulting in a cadence of 135s, 75s, or 60s. We captured one ingress, four egresses, and on two nights OOT coverage only. The control computer's real-time clock was synchronized every hour with a USNO time server, typically requiring 11-13s correction each time. Light curve precision was 2.5-2.8 mmag, which we achieved through an iterative comparison-ensemble procedure (Holmes et al. 2011).
The light curve of one egress is published in Holmes et al. (2011, their Fig. 7), and we present our phase-folded optical light curve in Sect. 3.1 below.

Faulkes Telescope North optical photometry
The Spectral camera on the 2m Faulkes Telescope North, Hawai'i, was used to observe  (Irwin & Lewis 2001). The software has been compared with SExtractor and found to be very similar in the completeness, astrometry and photometry tests. We adopted an 8 pixel radius aperture to match the typical seeing for the night (FWHM ∼ 8 ′′ ). Differential photometry was generated from the instrumental magnitudes using the combined flux of 7 nearby stars of similar brightness to WASP-12.

The Orbital Ephemeris
The elapsed time between the WASP-12 b discovery paper photometry (Hebb et al. 2009) and our two HST visits was 18 months and two years respectively. Since we anticipated the interpretation of our NUV time-series data could be critically dependent on the WASP-12 orbital ephemeris, we re-examined it. We took our PIRATE, FTN and JGT data, the Liverpool Telescope Z band from Hebb et al. (2009) Figure 1 shows the grand total flux calibrated spectra for our two HST visits. The Visit 2 spectral coverage is redwards of the Visit 1 coverage, and the two ranges overlap for about half of the total coverage. As noted in §2.1 the Visit 2 spectra have slightly lower fluxes, largely due to  without the phase-offsets applied.

NUV Spectroscopic coverage
the (uncalibrated) decline in COS throughput. Both spectra are RV-corrected to the WASP-12 rest frame by line profile fitting to the two spectra, thus determining an empirical wavelength offset between the two visits. This correction was applied before generating Figure 1 and subsequent figures.
Figure 1 also shows the stellar continuum level (dashed line). There is prodigious stellar photospheric absorption in WASP-12's atmosphere throughout; no point in our NUV spectra is consistent with unabsorbed continuum. Figure 1 shows synthetic fluxes calculated using the LLmodels stellar model atmosphere code (Shulyak et al. 2004), assuming the fundamental parameters, metallicity and detailed abundance pattern given by Fossati et al. (2010b). LLmodels assumes Local Thermodynamical Equilibrium (LTE) for all calculations, adopts a plane-parallel geometry, and uses direct sampling of the line opacity allowing the computation of model atmospheres with individualised (not scaled to solar) abundance patterns. We used the VALD database (Piskunov et al. 1995;Kupka et al. 1999;Ryabchikova et al. 1999) for the atomic line parameters. The resolution applied to the synthetic fluxes matches that of COS, but we did not model the peculiar line spread function (LSF) of HST 3 . The differences between the synthetic and observed spectra are predominantly caused by the HST LSF.
All three regions are affected throughout by many blended photospheric absorption lines.
We observe no unabsorbed stellar continuum. The NUVA region is strongly absorbed by many overlapping lines, with lines of MgI and FeI predominating; the NUVB region for both visits is closest to the continuum; while the NUVC region is dominated by absorption in the broad wings of the strong Mg II doublet at 2795.5 Å and 2802.7 Å.

NUV Transit Light Curve
In Paper 1 we observed an NUV transit which was significantly deeper than the optical transit, and which began with an early ingress compared to the optical ephemeris. These conclusions from our Visit 1 data alone are strengthened by the re-reduction described in §2.1. We quantify this by fitting the simplest possible transit model, assuming a circular occulting disc transiting a uniform brightness (no limb-darkening) star. We fix all the parameters of this model to the values demanded by WASP-12 b's optical transit except for two free parameters: R/R * ≥ R P /R * , and ∆φ, describing the radius and phase offset of the NUV occulting disc compared to the transit of the optically opaque planet with R = R P and ∆φ = 0 across the star of radius R * . The normalisation of the data to the model is also a free parameter. We report our model fitting in Table 4, using the reduced-χ 2 statistic, χ 2 ν , which is the appropriate statistic for assessing the goodness of fit. For completeness we also report the number of degrees of freedom, i.e. the number of parameters including normalisation, minus the number of fitted data points. The results for Visit 1 shown in  Table 4 are consistent with Paper 1: for NUVA, NUVB, and NUVC the best-fit transits are early by 43 min, 29 min, and 26 min respectively. As Table 4 shows, the best-fit radii for the occulting disc are significantly enhanced compared to that of the optically opaque planet (R P /R * = 0.1119, Chan et al 2011) with an enhancement in radius of 70%, i.e. almost a factor of three in area, for the NUVA and NUVC bands. The NUVA and NUVC bands provide extremely sensitive probes for the presence of low density gas at temperatures of several thousand degrees because these bands contain ∼ 10 3 overlapping spectral lines. We discuss the spectral information in detail in §3.4 below. We do not imagine that the low density gas we have detected surrounding and preceding WASP-12 b actually presents a circular cross-section to us during its transit; this was the simplest model we could imagine, and we have few data points to fit. As the upper panels in Fig. 5 show, with two free parameters (three including normalisation) the model is already able to produce an improbably good fit to the data, and this suggests that our error bars (derived from photon-counting statistics) are not under-estimated. grids from fitting model transits to our Visit 1 NUV data. We model circular opaque discs transiting a uniform brightness stellar disc. By allowing the normalisation of the model light curves to vary we find the best-fit transit for each value of phase and radius ratio without making any assumptions about which of the empirical points represent out of transit coverage. All three light curves are best fit by transits which occur early, and the best fit models in all cases correspond to discs much larger than that of the optical planet: R P /R * = 0.1119, which is the smallest value of Visit 2 was timed to provide coverage of the orbital phases missing due to Earth-occultation in our Visit 1 data. The two visits provide well-sampled coverage between −0.17 < φ orb < 0.12.
Unfortunately the Visit 2 data defy straightforward interpretation. The lower panels of Fig. 5 show the Visit 2 data along with the best-fit simple transit models to the three NUV bands. As the corresponding entries in Table 4 show, none of these fits are formally acceptable, with χ 2 ν significantly above 1 in all cases. The NUVB band produces the best fit transit for Visit 2, but this fit essentially reproduces the transit of the optically opaque planet (dotted line in Fig. 5), with points before and after the transit deviating significantly from the model. The best-fit NUVB model is slightly late compared to the optical transit because the Visit 2 point which samples optical ingress is higher than the optical transit would predict. The Visit 2 NUVA and NUVC light curves strongly resemble each other. Throughout, the point-to-point deviations in the two light curves appear similar. In both cases the Visit 2 data is strongly absorbed before optical first contact, with the point sampling optical ingress lying above the out of transit level, while the Visit 1 data appears more strongly absorbed between optical second and third contacts. The best-fitting model for the Visit 2 NUVA and NUVC light curves is a transit which occurs so early that it fails to overlap the optical transit. This is clearly unphysical: the planet is surely opaque to NUV light.
These fits result from the anomalously high third data point (arising from the third HST orbit) in the Visit 2 NUVA and NUVC light curves: in both cases the exposure spanning the optical ingress is the 2nd-highest in the light curve. Our simple model requires a strict relationship between the depth and duration of the fitted transit. Since the 'orbit 3 point' is high, the model places it above the out-of-transit level and as the pre-optical-ingress NUVA and NUVC data points are both lower than the fitted out of transit level, the best-fit transit model places the entire transit early.
The aberrantly high Visit 2 orbit 3 data point in the NUVA and NUVC light curves thus defies the simple explanation we developed from Visit 1. We can think of three plausible explanations for this: (i) these are noisy data and this simply happens to be a point with a positive deviation; (ii) there was a short-lived stellar flare during Visit 2 orbit 3; (iii) the gas which absorbs before Visit 1 we obtain good fits which reveal an NUV transit deeper than the optical transit, and an early ingress. Visit 2 is less clear-cut: the 3rd data point in all three bands is high compared to the models fitting Visit 1, particularly for NUVA and NUVC. For these two bands the best fit model places this anomalously high point after egress so the 'best-fit' transit does not overlap the optical transit (dotted line).
first contact is clumpy, and there was a clear window to the star during Visit 2 orbit 3. Vidotto, Jardine & Helling (2011)'s bow shock model can produce such a 'window' configuration. The same pattern independently appearing in both the NUVA and NUVC light curves makes the first explanation far less likely than it would otherwise be, and our fits to the Visit 1 light curve suggest our error estimations are ample. We will discuss the stellar flare hypothesis in § §3.6 and 4.1, and the window hypothesis in §4.1.
The Visit 2 data with the aberrant 3rd-orbit data masked out produces the fits shown in Fig 6 and Table 4 (entries for visit '2NF'). The NUVB fit now has a slightly deeper transit which occurs earlier because the fit has placed the orbit 4 point to span the beginning of egress. This fit, and the adjustments to it we might make if we relax our arbitrary assumption that the extended gas presents a circular cross-section, is consistent with the interpretation we made in Paper 1. The NUVA and NUVC 'best' fits are comical. Because the orbit 1, 2, and 4 points in both cases lie so far below the orbit 5 point, the relationship between transit depth and duration favors fits in which the transit depth is much deeper than any data point. A more sensible interpretation would be that the absorbing gas is extended along the orbital plane and presents a significantly non-circular cross-section, so the duration is longer than that of the models while the depth is shallower.
The fits we have performed separately on the two individual visits suggest that the configuration of the absorbing gas changed between the two visits. Indeed Vidotto, Jardine & Helling (2011) interpret this variability. Nonetheless for completeness we now proceed to examine the data from the two visits together. Fig. 7 interleaves the two visits using only the photons detected within the overlapping wavelength regions of the RV-corrected spectra. It is immediately apparent that the Visit 1 data (black circles) lies above the Visit 2 data (red triangles). We attribute this to the known declining throughput of the COS/G285M configuration (Osten et al 2011). We corrected for this by boosting the Visit 2 count-rates by 5.52% using an estimate from , but the rate of sensitivity decline is not precisely known for our instrument configurations. The 'corrected' Visit 2 data are shown as blue squares.
The background level differed between the two visits, with roughly twice as many background counts during Visit 2. The temporal behaviour of the background also differed, with a gradual increase in background during Visit 1 contrasting with a decrease in background during Visit 2.
We corrected for background, so this should not affect our light curves. The corrected Visit 2 data appear to match well at phases following the transit for NUVA and NUVC, but the corrected NUVB light curve from Visit 2 appears systematically lower than the Visit 1 light curve. The Visit 2 orbit 3 point remains aberrant in NUVC, but restricting the wavelength coverage to only the overlapping region has dramatically lowered the NUVA orbit 3 point. We will return to discuss the reasons for this in §4.1.
Our NUV light curves, particularly the NUVA and NUVC bands, suggest that in Visit 2 perhaps the absorbing gas obscured the stellar disc at phases as early as φ orb = 0.83, in which case Visit 2 contains no genuine pre-transit data. Fig. 8 shows the light curves produced using all the data (i.e. not just the overlapping wavelength regions), arbitrarily setting the last point in each visit to (an out-of-transit level of) 1.0. The NUVB light curve now looks perfectly consistent with the interpretation we made in Paper 1: the transit is deeper than the optical transit and appears to be preceded by absorption occurring before optical ingress. The NUVA and NUVC light curves also look reasonably consistent with this interpretation, with much more significant pre-ingress absorption occurring in Visit 2.
We performed simple transit fits (as described above) to the combined data from the overlapping wavelength regions in the two visits, allowing the normalisation of each visit to vary independently. These fits thus have four free parameters in total: R, ∆φ, and two independent normalisation values. Fig 9 shows the best fitting models, along with the data after applying the best fit normalisations. As Table 4 Figure 1.
the three fits in Fig. 9 are formally acceptable. Nonetheless, the NUVA and NUVB fits are broadly consistent with our interpretation in Paper 1. The best-fit transit is significantly deeper than the optical transit and the light curves show signs of absorption from diffuse gas before optical ingress. The NUVC band produces formally the worst fit, and the first half of the light curve shows enormous scatter between the sets of points from the two visits. The best fit model transit is late compared to the optical transit: a fit which moved the ingress to after the anomalously high Visit 2 orbit 3 point has been preferred. Figure 10 shows the best fits to the interleaved data without the Visit 2 orbit 3 point. These fits (entries for Visits '1,2NF') are all broadly consistent with our Paper 1 conclusions. For the NUVB and NUVC bands, the best χ 2 ν is better than the fits shown in Fig. 9.
In both NUVA and NUVC, as Figure 1 shows, the wavelength ranges covered only by the Visit 1 data are strongly absorbed by the stellar photosphere, while the wavelength ranges covered only by the Visit 2 data are significantly less strongly absorbed. If the diffuse absorbing gas has broadly the same ionic composition (i.e. abundance mix and temperature) as the stellar photosphere, this would predict a deeper transit in Visit 1 NUVA and NUVC than in Visit 2 NUVA and NUVC. This is exactly what Fig. 5 and Table 4 show. Figure 1 shows that the NUVB spectral region, for both visits, is the closest to the stellar continuum: there is relatively little photospheric absorption, and we might similarly expect relatively little absorption from the extended cloud of diffuse gas. Of course, without knowing the composition and physical conditions of this gas, it is impossible to assert this is definitely true, but it is the simplest assumption one could make a priori. Our NUVB data suggests a deeper transit than that of the optical light curve, but of the three spectral regions it is the closest to the optical curve. Note the NUVB data have the smallest uncertainties because, being relatively unabsorbed, we detect most photons from the star in NUVB.
Each (version of the) NUVB light curve (Figs. 5,6,7,8,9 and 10) shows indications of an The best-fit NUVC transit occurs late, but the first half of the interleaved lightcurve has extremely high scatter so this fit should clearly not be taken at face value. Symbols as in Fig. 5. early ingress in NUVB. Our NUVA and NUVC light curves are also broadly consistent with this, except for the anomalous count rates observed in Visit 2 orbit 3. This aberrant point appears in both NUVA and NUVC when we considered the entire wavelength range (Figs. 5 and 8) but only in NUVC when we extract light curves from the overlapping wavelength ranges (Figs. 7 and 9).
The Visit 2 orbit 3 NUVA point shifts downwards by 4σ when we restrict the wavelength range.
We think this is significant and will return to discuss the implications of this piece of evidence in §4.1.
In summary, the NUV light curves are broadly consistent with our principal conclusions in Paper 1. The transit is deeper than in the optical, and is preceded by an early ingress, though the point for the third orbit in Visit 2 deviates from this description when some wavelength regions are considered. There is clearly NUV absorption occurring before optical first contact.

The wavelength resolved transit
The enhanced transit depths seen in Figs. 4, 5, 6, 8, 9 and 10 result from summing over the ∼ 40Å covered in each of our NUVA, NUVB and NUVC spectra (or the ∼ 30Å of overlapping wavelength coverage for the last two figures listed). The enhancement of the NUV transit depth compared to the optical transit depth is due to absorption in the diffuse gas surrounding the planet.
This absorption is caused by bound-bound transitions in atomic and ionic species. A priori we do not know which species are present in this gas, but we do know that there are thousands of overlapping spectral lines within the wavelength ranges we have observed. Since we have time-series spectral data, we can examine the transit at any spectral resolution greater than or equal to that of the data. In Paper 1 we presented evidence for detections of enhanced transit depths in Mg II and other lines of neutral and ionised metals. With the addition of Visit 2 we have extended our wavelength coverage, our temporal coverage, and increased the SNR of the overlapping wavelength region, so we examined our Visit 1 and Visit 2 data afresh for evidence of enhanced transit depths at particular wavelengths.            We used the methods of Paper 1 to detect wavelengths with significantly over-deep transits.
In Paper 1, we used the average of orbits 1 and 5 for the out of transit (OOT) spectrum, and orbit 3 for the in transit (IN) spectrum. As Fig. 2 and Fig. 5 demonstrates, there is no reason to change this, so we used the same portions of data (re-reduced as detailed in Section 2.1). Visit 2 shows no clear pre-ingress OOT data, so in this case we used orbit 5 for the OOT spectrum, and orbit 4 for the IN spectrum. Consequently the propagated error estimate for our Visit 2 OOT spectrum is larger that that for the Visit 1 OOT spectrum. the spectral resolution, and the magnitude of WASP-12 b's orbital velocity. The blue line is the synthetic stellar spectrum, normalised to the continuum level, with a resolution of R = 10, 000, adopted to simulate the HST LSF. We do not use the synthetic stellar spectrum in our analysis.
Wavelengths of a few absorbing species are identified, with a small asterix after the ion identification for resonance lines.
For each visit, we define the ratio spectrum, and OOT is the out of transit flux, to measure the transit depth at wavelength λ i . We examine d i to determine wavelengths λ i with statistically significant excess transit depths. These are the wavelengths where the diffuse gas absorbs. These individual contributions combine to produce the excess depth in the light curves examined in §3.3. We report the wavelengths of these points in Table 5 and in Fig. 11. In Table 5 we use two different criteria to assess anomalously low points, i.e. those deviating by 3σ, as we did in Paper 1. The first of these examines the ratio spectrum against the error estimate we obtain from the propagated (Poisson-dominated) errors in the reduction. We label this error estimate as σd i | prop , and report in Table 5 wavelengths where the ratio spectrum is 3σd i | prop or more below the median value of the ratio. These wavelengths are also indicated in Fig. 11. The second assessment uses the RMS scatter, σ d i | exp , within the ratio spectrum itself in the criterion. As Fig. 3 of Paper 1 showed, the σ d i | exp criterion is more likely to pick out points where the signal in the observed stellar spectrum is low.
Our ratio spectra have a total of just under 3100 points, so if the noise is Gaussian-distributed we expect ∼ 9 distinct points in each to deviate by more than 3σd i | prop . As Table 5 shows, we find many more deviating points than this. In every case the points which deviate by more than 3σd i | prop are deviations below the median of the ratio spectrum, indicating extra absorption compared to the median. Where there are positive deviations, these are accompanied by large values of σd i | prop due to the low flux, and hence low SNR of the WASP-12 spectrum at that wavelength. Consequently, none of these positive deviations are 3σd i | prop . We would expect, nonetheless, to find a small number (∼ 4 ± 2) of positive deviations due to white noise, but we do not. Possibly our propagated errors are slightly over-estimated. This leads us to conclude we have detected statistically significant excess absorption at ∼ 200 distinct wavelengths in each visit from the gas around WASP-12.
As noted in §3.3 the NUVA and NUVC spectral regions are more strongly absorbed within the stellar photosphere than is NUVB. In §3.3 we showed that the transit is deeper in wavelength regions where the photospheric absorption is strong. These wavelength regions contain overlapping spectral lines which produce strong photospheric absorption of the underlying stellar continuum. To the extent that the extended diffuse gas cloud has similar abundances and temperature as the stellar photosphere, it too will produce strong absorption in these wavelength regions. Fig. 11 supports this: it is immediately obvious that there are far more wavelengths exhibiting enhanced transit depths in NUVA and NUVC than there are in NUVB. It is also clear that the wavelengths exhibiting excess transit depths generally occur where the emergent stellar flux is low. This shows our rule of thumb works well: the photospheric absorption within a wavelength range is a good predictor of the likely diffuse absorption. Fig. 11 shows that our identified wavelengths in NUVC from the two distinct visits are largely associated with absorption in the wings of the Mg II resonance lines. This is clearly and unambiguously detected in both visits, and at so many distinct wavelength-pixels that the median value of the ratio spectrum must be lowered by them. Away from the cores of Mg II at ∼ 2788 − 2789Å, ∼ 2811 − 2812Å and ∼ 2815Å there is a suggestion of a consistent wavelength shift between the Visit 2 (upper) and Visit 1 (lower) detections, with the Visit 1 transits being redshifted by ∼ 0.5 − 1Å (∼ 50-100 km s −1 ). This shift is much greater than our spectral resolution, but less than the magnitude of the planet's orbital velocity (230 km s −1 ), which is the natural velocity scale for motions of material orbiting the star. The NUVA and NUVB identified wavelengths show less consistency between the two visits, except for wavelengths consistent with resonance lines which are picked out in both visits.
The next step is to attempt to identify the spectral lines causing these enhanced transit depths. In Paper I we arbitrarily restricted our line identifications to resonance lines, and the consistently detected wavelengths in Fig. 11 show this was a sensible first step. Nonetheless, strong non-resonance lines of abundant elements may be more prominent than the resonance lines of rare elements. We attempted to assess this with a procedure which accounts for the stellar abundances derived for WASP-12 (Fossati et al. 2010b); the velocity shift required to match the rest wavelength of the line to the observed deviation; the excitation potential of the line; and the g f value of the line. We introduce three simple functions: P a , P ∆λ , and P χ , (each defined below) to estimate the effects of the first three of these factors on the likelihood of a particular identification being correct.
We wish to estimate the probability that an observed 3σ deviation at wavelength λ, arises from absorption by spectral line i of element el which has rest wavelength λ i . We consider a wavelength range λ i ± ∆λ and adopt ∆λ = 3 Å in our analysis to recover the full range of deviating points we identified in the broad wings of the Mg II lines in Paper 1 (see Fig. 3 therein.) This corresponds to a velocity shift slightly greater than the magnitude of the orbital velocity of WASP-12 b, but our procedure favours the smallest possible value of wavelength/velocity shift.
The wavelength shift required to match the observed point to rest wavelength is accounted for in the factor P ∆λ ; the excitation potential, χ i , of the lower level in the factor P χ ; and the abundance in the factor P a . We define these probability factors by where N el is the abundance of the element considered, and Z is the 'metal' abundance. Each gives a value of unity for the most favorable value of the quantity concerned; P a is unity if the proposed gas composition comprises only H, He and the element under consideration. P ∆λ was designed to have a weak dependence on the shift |λ i − λ| as we expect the gas to have non-zero velocity w.r.t.
the stellar rest-frame. P χ is proportional to the expected population in the lower level, and P a is proportional to the number of absorbing atoms/ions. P ∆λ , P χ and P a are multiplied together and further multiplied by the gf value of the line under consideration to give our estimated overall probability measure, P i , that the deviation is associated with the specified spectral line, i. P i in Eq.3 is thus not normalised to 1.
We then use this framework to assess the likely contribution to the measured deviation of all known spectral lines within ∆λ. P i estimates the likely relative contribution of each of these lines to the detected absorption; summing over all lines estimates the total absorbing capacity, P tot . The fraction of this due to any given spectral line is our proxy for the likelihood, L i that this is the correct line identification.
This framework indicates, with some physical justification for our estimates, how the likely line identification depends on the assumed temperature and abundance pattern. Our factor to account for a decreasing likelyhood as the shift from the line's rest wavelength increases is arbitrary, but adequate, given the complex COS LSF, the unknown velocity distribution in the absorbing gas, and the SNR of our data. The temperature dependence is only indicative: we have not used the Saha equation to determine the ionic balance. Figure 12 shows examples of applying this procedure to a selection of four points detected as having enhanced transit depths at significance of 3σ or more in Visit 1. Similarly Figure 13 shows a selection of line ID assessments from the Visit 2 data.
In Fig. 12   during Visit 1 remains unassailable under this more careful scrutiny. Visit 2 provides independent data, and as the lower left hand panel of Fig. 13 demonstrates, it shows the Visit 2 detection of an enhanced transit depth at 2795.307 Å can be confidently attributed to Mg II. Note the wavelength solutions produced by the simultaneous arc lamp spectra differ for the two visits, so we cannot compare pixels with identical wavelength sampling without rebinning. Rebinning is undesirable because adjacent pixels are then no longer independent.
Not all deviating points could be unambiguously associated with absorption by a single ionic species: the lower left panel of Fig. 12 Table 5 gives the full list of wavelengths where we detected enhanced transit depths. We used a relative shift of 0.2Å as our measure of wavelength consistency, this is approximately the value of the formal resolution plus the dispersion (the wavelength solution and hence the pixelation of the ratio spectra differs between the two spectra). It is far less than the magnitude of WASP-12 b's orbital velocity, so as the motions in the gas are probably time-dependent, we are imposing a very strict criterion for consistency between the two visits. Where enhanced transit depths are detected within 0.2Å of each other in both visits, these are listed in bold in Table 5. We have two independent measurements of the ratio spectrum, one from each visit, so enhanced depths which are detected at consistent wavelengths in both are unlikely to be due to noise. We would expect a match for any wavelength pixel picked out in Visit 1 to occur due to gaussian-distributed noise in 2.7% of cases. In NUVA (NUVB, NUVC) 53% (28%, 70%) of Visit 1 detections using the 3σd i | prop statistic are matched by the same statistic in Visit 2.
A definitive assignment of identifications to these many wavelengths exhibiting enhanced transit depths requires more certain knowledge of the properties of the diffuse gas than we currently have. We can, however, examine how changing our assumptions affects our line identifications. Fig. 14 examines how the identification of the absorber at 2672.018Å depends on the assumed abundance distribution. In Paper 1, by including only resonance lines in our analysis, we excluded many plausible spectral lines from our consideration. This led us to identify enhanced absorption at wavelengths around 2680 Å with V II (see Table 2 of Paper 1). Fig. 14 shows a more careful examination of the line identification of one of these points. The black open circles show our likelihood estimates for an abundance pattern which matches our current best estimate of that of the WASP-12 stellar photosphere (Fossati et al. 2010b). With this abundance pattern, vanadium is too rare to make a dominant contribution to the absorption; instead we are led to conclude that Fe I and Ti I are more likely than V II. Iron is generally rather abundant, and in common with many other iron-peak elements including vanadium, has a complex electronic structure, leading to a large number of blended iron lines, particularly in the NUV. If, on the other hand, we were to assume that vanadium is abundant in WASP-12 b's exosphere and we arbitrarily increased the vanadium abundance to match that of iron in WASP-12's photosphere, we would introduce a significant change to our assessment of the line identification. The open red triangles in Fig. 14 show the results we obtain if we adopt this assumption. In this case, we identify V II and V I as the species most likely to be responsible for the enhanced transit depth. It is worth noting that VO has been widely discussed as a possible constituent of the stratospheres of hot Jupiter exoplanets (e.g. Desert et al. 2008;Speigel et al. 2010;Fortney et al. 2010) and it is possible that the gases lost from the upper atmosphere of a hot Jupiter could have enhanced vanadium abundances. dependence of the ionisation balance in our assessments.
Figs. 14 and 15 show that our line identifications depend on the assumptions we make. This is generally true in astrophysics, but in more mature fields, we have a sound basis for confidently adopting likely assumptions. For example we have a very good understanding of the physical conditions prevailing in stellar atmospheres, and much high SNR ratio data has been used to hone models such as the one we plotted in Figs. 1 and 11. The study of hot Jupiter exospheres is not so well-developed.
To temperature of T eff = 6250 ± 100 K, in agreement with Hebb et al. (2009) but with tighter uncertainties. Generally, stars of this T eff and age are expected to exhibit activity, and emission cores in the MgII resonance lines are one clear observable consequence of this. As Figure 16 demonstrates, however, MgII emission cores are conspicuously absent in WASP-12.
To produce Figure 16 we normalised the spectra of WASP-12 and two stars of the same age and T eff to match the flux in the far wings of the Mg II lines (the regions used in the normalisation are further from the line cores than the edges of Fig. 16). These two stars, HD 102634 and HD 107213, are plotted in red and green in Fig. 16  were a slowly-rotating sub-giant, Mg II emission cores would be expected (Ayres 2010). Even very inactive Sun-like stars have significant chromospheric spectra with prominent Mg II emission powered by acoustic shock heating and local dynamo action which converts hydrodynamic turbulence into magnetic flux.
Our interpretation of Fig. 16 is that the inner parts of WASP-12's Mg II lines are absorbed by gas beyond the stellar chromosphere, with sufficient column density to completely obliterate the expected emission reversals, and to perhaps also depress the line wings just outside the cores.
Because the star is distant, one possibility is interstellar absorption. As we demonstrate below, however, the necessary Mg + column density is quite substantial, and is implausible unless the ISM in that direction is unusual. Another possibility, which we favor, is that the absorption is local to the WASP-12 system.
Gas immediately surrounding WASP-12 b cannot account for the absorption we have just described. The planet itself covers only a small fraction of the stellar disc: to completely remove the predicted Mg II chromospheric emission would require a much more spatially extended distribution of absorbing material, blanketing the entire stellar disc. We propose, in fact, that Jupiter atmosphere type, but our hypothesis suggests an alternative/additional explanation. Many of these systems could be shrouded in diffuse gas which absorbs any emission cores produced by stellar activity.
Chromospheric activity is strongly correlated with stellar age and rotational velocity.
WASP-12's rotational velocity is unknown, but the transit of WASP-12 b is accompanied by an undetected Rossiter-McLaughlin (RM) effect (Husnoo et al. 2011), so either the rotational velocity is low or the orbital angular momentum of WASP-12 b is misaligned with the stellar rotation axis (see e.g. Haswell 2010, for explanation). If the chromospheric activity is low, as expected for a middle-aged slowly rotating dwarf, a stellar flare is a very unlikely explanation for the high flux in orbit 3 of our Visit 2 light curves. We must then conclude either our data are intrinsically noisy beyond the assigned photometric error, or that we are viewing WASP-12 through diffuse gas at all observed orbital phases, and there happened to be a relatively clear view to the stellar surface during orbit 3 of Visit 2. This latter possibility might be produced by a bow shock in a very extended planetary magnetosphere (Vidotto, Jardine & Helling 2011).
3.6. Resonance Line Absorption in WASP-12 and the ISM Figure 17 shows our Visit 2 WASP-12 spectrum compared to HST/STIS data on α Cen from the archive. The STIS data have been convolved with the COS NUV LSF and scaled by the multiplicative factor 4 × 10 −5 . Both spectra have been smoothed for display purposes. The flux axis is logarithmic to emphasize the deep absorption in the cores of strong lines. The photometric error is per resolution element, and the flux densities have been truncated at the 1 σ error level.
As in Fig. 16, the spectra have been normalised to agree in the far wings of the Mg II absorption.
Generally stellar Mg II line profiles scale so that normalising in the far wings produces good agreement in the inner wings for stars of the same luminosity class (Ayres 2010), but as we saw in Fig. 16, WASP-12's inner wings are depressed relative to other main sequence stars. The Mg II resonance line cores in WASP-12 have total absorption, which is perhaps blue-shifted by ∼ 20 km s −1 .
In the NUVA region of Fig. 17, WASP-12 exhibits similar total absorption in the core of the Fe II resonance line at λ2586 Å where α Cen's absorption is shallower by over a factor of 10.
Appearing slightly less strong is WASP-12's Mn II resonance line at λ2577 Å.  These absorption features in the WASP-12 stellar spectrum are too deep to have their origin in the photosphere itself. Our favoured interpretation is that the absorption arises in gas within the WASP-12 system, but we now examine the plausibility of the alternative explanation that the absorption might arise in the ISM. Figure 18 shows the central part of the observed α Cen A Mg II k-line profile. The solid red line shows the absorption we expect from the ISM along the very short pathlength (1.3 pc) to the star, using the Mg II column density of 5 × 10 12 cm −2 reported by Linsky & Wood (1996). The absorption profile was calculated using a temperature of 7000 K and a turbulent velocity of 1.5 km/s, typical values for the local warm cloud in which α Cen A and the Sun are embedded. The calculated absorption fits the narrow slightly redshifted absorption dip in the extreme core of the line, noting that the broader "absorption" between the twin peaks of the profile is a central reversal of chromospheric origin (see Linsky & Wood 1996). The blue curve indicates the attenuation predicted for a plausible N(Mg + ) in the line of sight to WASP-12: 2 × 10 16 cm −2 . We arrived at this estimate assuming E(B − V) ∼ 0.2 magnitudes for WASP-12 (based on a nominal 0.6 magnitudes kpc −1 of reddening for an average Galactic sightline and the ∼ 350 pc estimated distance of WASP-12), which yields a hydrogen column density of ∼ 1.2 × 10 21 from the standard Milky Way reddening law (e.g., Savage & Mathis 1979). If we then assume that roughly half the magnesium is in the form of Mg + -about what is deduced from the α Cen A sightline, albeit perhaps not typical -then we obtain: N(Mg + ) ∼ 2 × 10 16 cm −2 .
Applying the corresponding absorption profile to the α Cen A Mg II k line results in the dashed blue curve, which still preserves substantial core emission.
The green line in Fig. 16 depicts the absorption profile for a Mg II column density a factor of 10 greater than the interstellar estimate above, i.e. N(Mg + ) = 2 × 10 17 cm −2 . Here broad damping wings have developed, strongly suppressing the emission core, and even affecting the inner wings of the k line. While the predicted profile is not an exact match to that of WASP-12 (cf., Fig. 14), it does demonstrate the plausibility of the absorption mechanism, albeit requiring a very substantial column of Mg + . The required column is excessive enough, in fact, to make an interstellar origin seem much less plausible than a more local source, especially given the existence of the hot Jupiter and the possibility of strong atmospheric stripping. We examine this possibility in more detail later ( §4.2, below).

Discussion and Conclusions
The conclusions we reached in Paper 1 more or less stand in the light of our Visit 2 data and our interpretation of the entire COS/NUV dataset. As §3 shows, the Visit 2 data did not neatly fill in the phase-folded NUV light curves we produced from Visit 1. Instead, a rather more complex reinterpretation was required. Our principle conclusions in Paper 1 (from Visit 1 data alone) were that the NUV transit depth is deeper than the optical, that this is due to absorption in metal atoms/ions within WASP-12 b's exosphere, and that this exospheric gas was spatially distributed such that an early ingress occurs. To make sense of our combined NUV light curves, we needed to adopt two further hypotheses: (i) the absorbing gas is (at least sometimes) even more spatially extended than we inferred from Visit 1; (ii) a short-lived stellar flare occurred during Visit 2 orbit 3 or Visit 2 orbit 3 had a line of sight through a relatively low density window in the absorbing gas.
In Section 3 we presented several lines of indirect evidence in favour of the hypothesis that WASP-12 has some chromospheric activity, despite the resounding lack of observed emission cores in the Mg II and Ca II lines. We now examine our data to see if it contains direct evidence in favor of this hypothesis over the alternative low density window hypothesis.

A stellar flare during Visit 2 orbit 3?
We have attributed the high NUV fluxes during Visit 2 orbit 3 to a stellar flare. To check this interpretation, Fig. 19 shows a direct comparison of the NUV spectra from orbit 3 of Visit 2 with orbit 3 of Visit 1. The two spectra are plotted with the pipeline calibration, no normalisation was applied to account for the declining throughput. These spectra are clearly noisier that those shown in earlier figures as they comprise only about a fifth of the exposure time on each visit.
The two spectra broadly agree, but there is a hint in the Visit 2 spectrum of a small emission component redwards of the center of each of the Mg II line cores. This is not an unassailable detection. The appearance of these two small bumps is very similar to the remnant line core emission on the red side of the line profile in Figure 18  profile and rendered undetectable at any individual pixel in the spectrum. When we sum over wavelength to produce light curves, however, the signal becomes apparent above the noise.
Since the flux from the stellar photosphere in the Fe II λ2586 Å line is low (Fig. 17), whether or not this line is included within the wavelength coverage should make little difference to the light curve in the low density window hypothesis. We therefore interpret the 4σ movement of Visit 2 orbit 3 NUVA point between Fig. 7 and Fig. 8, i.e. between data including and excluding this line as evidence in favour of the stellar flare hypothesis over the low density window hypothesis. Only when we include features which we expect to show a significant flux increase during a stellar flare do we see the NUV flux in Visit 2 orbit 3 lying significantly above the other data. Several aspects of our data thus suggest we caught a stellar flare which occurred during the ingress of the optical transit in Visit 2.

The column density of Mg II
In Section 3.6 we showed that a high column density of Mg II between us and the stellar chromosphere can absorb WASP-12's Mg II emission cores, assuming the intrinsic emission is similar to that of α Cen. Here we consider whether the value we deduced, N(Mg + ) ∼ 2 ×10 17 cm −2 , can be plausibly attributed to mass loss from the planet WASP-12 b. Since this extremely close-in planet is the most obviously unusual characteristic of the star, it seems likely that the anomalous Mg II line profiles are ultimately caused by the planet.
Various mechanisms have been proposed for mass loss from WASP-12 b and similar planets.
There are several variants of the 'blow-off' hypothesis, which assumes hydrodynamic outflow driven by energy input from irradiation by the host star. Tidal heating can drive planetary envelope expansion and consequent Roche lobe overflow (Li et al 2010). For the early eccentricity estimates of WASP-12 b, for example, this mechanism was predicted to cause a mass loss rate of 10 −7 M J yr −1 (ibid).
Mass lost from the planet will carry specific angular momentum from the planet's orbit, and will thus tend to be confined to the orbital plane. To absorb chromospheric emission from the entire visible disc of the star, the material must extend about one stellar radius above and below the orbital plane. To derive an upper limit on the absorbing column density due to mass lost from the planet, therefore, we begin with the geometry shown in Fig. 20. Gas is present within a squat cylinder of radius ∆R and height 2R * , centered on the star and aligned with the orbital plane.
The mean density,ρ within the cylinder is whereṁ is the mass loss rate and ∆t is the time over which mass has been lost. The equality arises when all mass lost from the planet is confined to the cylinder we require to be populated. This is obviously an upper limit as some mass will accrete on to the star or diffuse in the vertical direction out of our line of sight to the star.
The column density of particles is where the integral is carried out along our line of sight (LOS), µ is the mean molecular weight of the gas and v = ∆R/∆t is the velocity with which the gas moves outwards from the orbit of the planet. We have used the mean density and implicitly assumed that the velocity is approximately constant for outflow over the distance ∆R. The integral is effectively performed over the distance ∆R which contributes appreciably to the column density. This avoids addressing our ignorance of the functions ρ(l) and v(l). The approximations are sufficient for an order of magnitude estimate, particularly since our empirical estimate of v will ensure our approximation is weighted to the appropriate part of the velocity field. If the fraction of the total number density in the form of Mg II is f , then To obtain N(Mg + ), we adopt the mass loss rate predicted by evaporation processes, for example Ehrenreich and Desert (2011) giveṁ ∼ 3 × 10 7 kg s −1 for WASP-12 b. We take f ≈ 10 −5 , which is based on a number fraction of 10 −4 for Mg in the solar elemental abundance mix, and a (conservative) assumption that one in 10 magnesium nuclei is in the Mg II ionic state; R * = 1.1 × 10 9 m (Chan et al 2011); we assume a mean molecular weight of µ = m p = 1.7 × 10 −27 kg which will be correct to within a factor of a few for material predominately composed of hydrogen. We can estimate v from our data: the absorption appears to be blue-shifted by roughly 0.25Å (Fig. 17, 5th panel from the top), implying v ∼ 2.5 × 10 4 m s −1 Using these values in Eqn. 7 we obtain N(Mg + ) ≤ 4 × 10 21 cm −2 . The required column density is below this crude upper limit by a factor of ∼ 2 × 10 4 . Obviously, some material will move inwards and be captured by the star, and some will spread in the vertical direction beyond the cylinder we require to be filled with gas, but we have a comfortable factor to allow for this and other losses of Mg II.

Exospheric Gas or Coronal Gas?
WASP-12 b is only about one stellar diameter from the stellar surface, so this planet is orbiting within the star's corona. This raises the possibility that absorption we observed around WASP-12b may be attributable to entrained or bow-shocked coronal gas, rather than from mass lost from the planet (e.g. Vidotto, Jardine & Helling 2010 Fig. 21 shows the cross-section of the critical equipotential surface is not much larger than that of the planet itself. We have detected transit depths in the NUVA and NUVC spectra regions which are up to a factor of 3 deeper than the optical transit (see Figs. 5 and 9). As the optical depth of the absorbing gas will vary with both wavelength and position, it is clear that we require the projection of the spatial distribution of the absorbing gas on the plane of the sky to exceed that of the Roche lobe by a factor of more than a few. Our observations thus show that the absorbing gas far overfills the planet's Roche lobe.
This is consistent with our Visit 2 data, which suggest absorption is occurring at phase 0.83 (see Fig. 8), i.e. the absorbing gas extends ∼ 20% of the way around the orbit. Fig. 21 also shows the deviation from spherical of WASP-12 b. The fluid planet will fill the equipotential surface corresponding to the area occulted in the optical transit. The y-z cross-section of this equipotential surface deviates slightly from circular as a result of the centripetal force, with the x-y and x-z cross-sections each being noticeably distorted by the combination of the tidal distortion due to the stellar gravity and the centripetal force. The volume of the planet is consequently ∼ 20% greater than that of a sphere producing the same optical transit depth.

NUV versus FUV
As we discussed in the introduction, most of the observations of diffuse gas around hot Jupiter exoplanets have been carried out in the FUV, with our WASP-12 program being the single published exception. Our observations are clearly limited by the SNR of the data, but it must be remembered that WASP-12 is 4 magnitudes fainter than either HD 209458 b or HD 189733 b, the two objects where FUV transit observations exist. Even with the 4 magnitudes advantage, conclusions from the FUV transit data can be compromised by the fact that the FUV stellar emission is patchy and variable in time and/or severely limited by poor SNR. To demonstrate how FUV observations can be irrevocably compromised by these issues, we present a brief case study using FUV COS data. The target, HD 189733 b, is a hot Jupiter transiting a bright nearby early K-star, and has been widely and informatively studied. Observations covered orbital phases from -0.074 to 0.051 (adopting the orbital parameters of Knutson et al. 2007). The data were obtained from the Multi-Mission Archive at STScI (MAST) and calibrated one-dimensional spectra were coadded with the custom IDL procedures described by Danforth et al. (2010). The coadded spectrum is displayed in Fig. 22. The SNR per resolution element is > 50 in the chromospheric CII 1334, 1335 A lines.
As COS is a slitless spectrograph, geocoronal emission complicates observations at discrete wavelengths (most notably H I Lyα, 1216 Å, and the O I multiplet at 1304 Å). However, the high sensitivity and low instrumental background allow high-SNR observations in emission lines of several other chromospheric and transition region ions, including C III λ1175, Si III λ1206, N V λ1240, C II λ1335, and Si IV λ1400. Unfortunately the very processes powering these emission lines (e.g., Ayres & France 2010) also limit the capability of far-UV transit studies.
Light curves of the bright chromospheric emission lines from the spectrum in Fig. 22 were created from the calibrated two-dimensional data by exploiting the TIME-TAG capability (France If we assume that exposures taken on the fourth spacecraft orbit represent the in-transit spectrum, we can compare the coadded, one-dimensional in-transit and out-of-transit spectra. Integrating the total flux over airglow-free wavelength intervals, ∆λ = [1150 -1210 Å, 1220 -1270 Å, 1308 -1425 Å], we find a in-transit/out-of-transit flux ratio of 1.000 ± 0.017. These Like the FUV observations of HD 189733, our Visit 2 NUV light curve of WASP-12 was also complicated by stellar activity, but we were able to isolate and ameliorate its effect (c.f. the NUVA lightcurve in Fig. 9). The NUV can provide more robust information on absorption by diffuse gas than the FUV. The COS/FUV observations of HD 209458 b (Linsky et al. 2010) have exquisitely high SNR; NUV observations of this planet would clearly reveal much information about the composition and velocity structure of its exosphere.

Summary
1. We observed WASP-12 in the NUV, a spectral region which proves to be an extremely sensitive probe for the presence of absorbing gas.
2. We have detected asymmetric absorbing material in the WASP-12 system which is more extensive than the Roche lobe of WASP-12 b.
3. The stellar photospheric absorption appears to be a fairly good predictor of the wavelengthdependence of the excess absorption, indicating the extended gas may be similar in composition and ionisation state to the WASP-12 photosphere. The NUVB spectral region, which has the least photospheric absorption and is devoid of strong resonance lines yields the most straight-forward light curve. This gives us confidence in our interpretation.
4. In HST Visit 1 we detected enhanced absorption during and before the optical transit.
5. In HST Visit 2 our NUV light curve appeared to be below the out-of-transit flux level for all the pre-ingress coverage, despite this extending to earlier phases than that of Visit 1. Thus the spatial distribution of the absorbing gas appears to vary.
6. The cores of the Mg II and Fe II resonance lines are very dark throughout our coverage.
WASP-12 would be completely unique amongst all stars of similar age and spectral type if this lack of observed Mg II chromospheric emission reversals was intrinsic to the star. We attribute it instead to absorption occurring in gas between us and WASP-12. The required column density is at least ∼ 2 × 10 17 cm −2 . This value is about a factor of 10 greater than a plausible estimate of the interstellar column density, but is consistent with gas loss from WASP-12 b via photo-evaporation. Nevertheless, the ISM explanation cannot be dismissed completely, since there is substantial "cosmic variance" in ISM properties, and the WASP-12 sightline might just be unusually opaque in Mg II.
7. The lack of Mg II chromospheric emission cores from the star could be explained by absorbing gas not confined to the region immediately surrounding the planet. Absorbing gas would need to occupy the lines-of-sight to at least the mid-latitude regions of the stellar disc at all orbital phases. We show that an outflow of some fraction of the mass loss expected from WASP-12 b can plausibly provide this obscuration, though we have not proved the gas will necessarily fulfill the geometric requirements.
8. In HST Visit 2 the NUV flux was near its maximum value at optical ingress. Such a fast change in flux is a signature of a stellar flare, although such an event would be very rare on a low-activity star like WASP-12. Nevertheless, there are (albeit very noisy) hints in the Mg II line profile of some chromospheric emission at this time.
9. FUV transit observations can be far more affected by stellar activity than our NUV observations were. In the NUV we have the opportunity to isolate the effects of activity by excluding spectral lines which are strongly affected.

Concluding remarks
Given its spectral type and probable age, we have suggested that WASP-12 should have a normal level of chromospheric activity, despite the lack of observed emission cores in the Mg II resonance lines. This hypothesis in principle could be tested by obtaining far-UV (FUV) spectra, which should show the normal complement of chromospheric (e.g., O I 1305 Å triplet; C II 1335 Å multiplet) and higher-temperature features (e.g., C IV 1550 Å doublet). However, the great distance of WASP-12 (at least 300 pc, Fossati et al. 2010b) would imply line peak flux densities below 10 −16 erg cm −2 s −1 Å −1 (scaling from the FUV spectrum of α Cen A), which even with the high sensitivity G140L grating of COS would require an exposure of ∼ 25 ks to reach a secure S/N∼ 10, or nearly 10 HST orbits. Even worse, the estimated interstellar reddening of further lengthening the necessary COS or STIS exposures to beyond the realm of practicality.
Furthermore, this does not even account for the additional absorption deduced from the WASP-12 Mg II lines, which -if truly interstellar and accompanied by the normal dust-to-gas ratiowould completely extinguish the FUV radiation. Similarly, and again scaling from α Cen A, WASP-12 would be predicted to be a 0.02 counts ks −1 coronal X-ray source in the Chandra imagers, which is about a factor of two below the average cosmic background rate. In that background-limited regime, it would require at least 1 Ms of exposure to achieve a minimal 3 σ detection, again completely impractical.
We need to look at more close-in exoplanets using this highly informative NUV wavelength region. Most known hot Jupiters are less distant than WASP-12, and consequently will offer higher NUV fluxes and thus better signal to noise. Our conclusions throughout this paper are limited by the noise level in our data.
Many related studies have been performed in the FUV. The FUV does provide access to higher ionization state lines that can be good proxies for activity and suffer less confusion with the lower-ionization ISM (CIII, NV, SiIV). Additionally, the CIII FUV multiplet is not a resonant transition, its lower level lies about 6.5 eV above the ground state, therefore this line is effectively never seen in the diffuse ISM. Despite this, as    . The light curves were created from the two-dimensional COS data files, with the total number of counts in given line (defined by an [x,y] location on the COS detector) integrated in 120s intervals. Error bars are taken to be the square-root of the number of counts in a given time bin. We note that the variability on minute to hour timescales exceeds the photon noise and can be the limiting factor for transit studies of chromospherically active, low-mass stars. The dashed lines denote the end of an individual COS exposure.