SkySurveyMixin

class whampy.SkySurveyMixin[source]

Bases: object

Mixin class with convenience functions for WHAM data

Methods Summary

bettermoment([order, vmin, vmax, ...])

compute moment maps using bettermoments (quadratic fitting approach; Teague & Foreman-Mackey 2018)

click_map([fig, image_ax, spec_ax, ...])

Interactive plotting of WHAM data to plot spectra when clicking on map

get_SkyCoord(**kwargs)

returns SkyCoord object of coordinates for pointings in Table

get_equivalent_width([intensity, ...])

Estimate emission line equivalent width

get_quadratic_centroid([data_column, ...])

Use quadratic centroid method to find centroid and errors data_column: str, optional, must be keyword name of data column to use velocity_column: 'str', optional, must be keyword name of velocity column to use vmin: number, u.Quantity, optional, must be keyword min velocity to consider vmax: number, u.Quantity, optional, must be keyword max velocity to consider smooth: str, optional, must be keyword smoothing method to use if None, doesn't smooth window_len: number, optional, must be keyword size of smoothing window variance_column: str, optional, must be keyword name of variacne column to use uncertainty: 'number', list-like, optional, must be keyword if provided, uses this instead of variance column provided

get_scale_height_data(**kwargs)

Return data needed for scale height analysis

get_spectral_slab(vmin, vmax)

returns survey with velocity window cut down

get_spectrum(coordinate[, index])

returns single WHAM pointing closest to provided coordinate

get_spiral_slice(**kwargs)

Returns SkySurvey object isolated to velocity ranges corresponding to specified spiral arm

intensity_map([fig, ax, lrange, brange, ...])

plots the intensity map using WHAM beams as scatter plots

moment([order, vmin, vmax, return_sigma, ...])

compute moment maps

stack_spectra_bootstrap(**kwargs)

Stack all spectra in provided SkySurvey Table

Methods Documentation

bettermoment(order=None, vmin=None, vmax=None, return_sigma=False, masked=False, ratio=False, window_length=5, rms='auto', return_Fnu=False, traditional=False)[source]

compute moment maps using bettermoments (quadratic fitting approach; Teague & Foreman-Mackey 2018)

Parameters:
order: ‘number’, optional, must be keyword

moment order to return, default = 0

vmin: ‘number’ or ‘Quantuty’, optional, must be keyword

min Velocity, default units of km/s

vmax: ‘number’ or ‘Quantity’, optional, must be keyword

max Velocity, default units of km/s

return_sigma: ‘bool’, optional, must be keyword

if True, will also return one-sigma gaussian error estimate

masked: `bool`, optional, must be keyword

if True, used masked velocity axis

ratio: `bool`, optional, must be keyword

if True, assumes computnig for a line ratio

filter_width: `int`, must be keyword

window_length passed to savgol_filter, must be >2

rms: `str, number`, optional must be keyword

if “auto”, estimates rms from data, or uses provided value

return_Fnu: `bool`, optional, must be keyword

if True, also returns Fnu and dFnu for first moment

traditional: `bool`, optional, must be keyword

if True, uses traditional moments for first and second order

click_map(fig=None, image_ax=None, spec_ax=None, projection=None, spectra_kwargs={}, over_data=None, average_beam=False, radius=None, over_spectra_kwargs={}, over_spec_ax=None, share_yaxis=False, no_image=False, **kwargs)[source]

Interactive plotting of WHAM data to plot spectra when clicking on map

Parameters:
fig: ‘plt.figure’, optional, must be keyword

if provided, will create axes on the figure provided

image_ax: ‘plt.figure.axes’ or ‘cartopy.axes`, optional, must be keyword

if provided, will plot image/map on these axes can provide ax as a cartpy projection that contains different map projections

spec_ax: ‘plt.figure.axes’, optional, must be keyword

if provided, will plot spectra on these axes

projection: ‘ccrs.projection’

if provided, will be passed to creating a map with specified cartopy projection

spectra_kwargs: ‘dict’, optional, must be keyword

kwargs passed to plot command for spectra

over_data: ‘SkySurvey’ or ‘str’ or ‘spectral_cube.SpectralCube’, optional, must be keyword

Extra data to over plot spectra from if SkySurvey, assumed to be WHAM observations, perhaps at another wavelength if ‘str’, assumed to be a 3D FITS Data cube filename to be loaded as SpectralCube if ‘SpectralCube’, defaults to extracting closest spectra to click

average_beam: ‘bool’, optional, must be keyword

if True, instead over plots average spectrum from over_data within nearest WHAM beam

radius: ‘Quantity’ or ‘number’, optional, must be keyword

beam radius to average beam over if avreage_beam is True default is 0.5 degrees (WHAM beam)

over_spectra_kwargs: ‘dict’, optional, must be keyword

kwargs passed to plot command for over_spectra

over_spec_ax: ‘plt.figure.axes’, optional, must be keyword

if provided, will plot over_spectra on these axes

share_yaxis: ‘bool’, optional, must be keyword

if True, over_spectra shares same y_axis as spectra if False, over_spec_ax has a unique y_axis if over_spec_ax is provided, share_yaxis is not used

no_image: ‘bool’, optional, must be keyword

if True, does not plot a WHAM intensity map Can instead plot any image using WCS axes or default coordinate axes and click to plot spectra below it

**kwargs: ‘dict’, must be keywords

passed to SkySurvey.intensity_map

get_SkyCoord(**kwargs)[source]

returns SkyCoord object of coordinates for pointings in Table

Parameters:
**kwargs:

passed to SkyCoord

get_equivalent_width(intensity=None, intensity_error=None, continuum=None, continuum_error=None, return_sigma=True)[source]

Estimate emission line equivalent width

Parameters:
continuum: `u.Quantity`, optional, must be keyword

Continuum value or values to use

continuum_error: `u.Quantity`, optional, must be keyword

Continuum error value or values to use

intensity: ‘u.Quantity’, optional, must be keyword

Intensity values to use

get_quadratic_centroid(data_column=None, velocity_column=None, vmin=None, vmax=None, smooth='hanning', window_len=11, variance_column=None, uncertainty=None)[source]

Use quadratic centroid method to find centroid and errors data_column: str, optional, must be keyword

name of data column to use

velocity_column: ‘str’, optional, must be keyword

name of velocity column to use

vmin: number, u.Quantity, optional, must be keyword

min velocity to consider

vmax: number, u.Quantity, optional, must be keyword

max velocity to consider

smooth: str, optional, must be keyword

smoothing method to use if None, doesn’t smooth

window_len: number, optional, must be keyword

size of smoothing window

variance_column: str, optional, must be keyword

name of variacne column to use

uncertainty: ‘number’, list-like, optional, must be keyword

if provided, uses this instead of variance column provided

get_scale_height_data(**kwargs)[source]

Return data needed for scale height analysis

Parameters:
data: `skySurvey`

WHAM skySurvey object of full sky (requires track keyword), or spiral arm section

track: `str`, optional, must be keyword

if provided, will apply skySurvey.get_spiral_slice for provided track if None, will check for track as an attribute of data

deredden: `bool`, `dustmap`, optional, must be keyword

if True, will apply dereddening using 3D dustmaps of Marshall et al. (2006) or can input a dustmap to query from using the dustmaps package default to dustmaps.marshall.MarshallQuery Warning: Currently only supports Marshall Dustmap

return_pandas_dataframe: `bool`, optional, must be keyword

if True, returns pandas dataframe with subset of data specific to scale height analysis

**kwargs: `dict`

keywords passed to data.get_spiral_slice if track is provided

get_spectral_slab(vmin, vmax)[source]

returns survey with velocity window cut down

Parameters:
vmin: `number`, `u.Quantity`

Min velocity

vmax: `number`, `u.Quantity`

Max velocity

get_spectrum(coordinate, index=False)[source]

returns single WHAM pointing closest to provided coordinate

Parameters:
coordinate: ‘SkyCoord’ or ‘list’

SkyCoord or [lon,lat] list assumes Galactic Coordinates and u.deg

index: ‘bool’, optional, must be keyword

if True, returns the index of the closest coordinate

get_spiral_slice(**kwargs)[source]

Returns SkySurvey object isolated to velocity ranges corresponding to specified spiral arm

Parameters:
track: ‘np.ndarray’, ‘str’, optional, must be keyword

if ‘numpy array’, lbv_RBD track data if ‘str’, name of spiral arm from Reid et al. (2016)

filename: ‘str’, optional, must be keyword

filename of track file to read in using whampy.lbvTracks.get_lbv_track

brange: ‘list’, ‘u.Quantity’

min,max latitude to restrict data to Default of +/- 40 deg

lrange: ‘list’, ‘u.Quantity’

min,max longitude to restrict data to Default of full track extent

interpolate: ‘bool’, optional, must be keyword

if True, interpolates velocity to coordinate of pointings if False, … do nothing … for now

Future: slices have velocities set by track

wrap_at_180: `bool`, optional, must be keyword

if True, wraps longitude angles at 180d use if mapping accross Galactic Center

vel_width: `number`, `u.Quantity`, optional, must be keyword

velocity width to isolate in km/s

intensity_map(fig=None, ax=None, lrange=None, brange=None, vel_range=None, s_factor=1.0, colorbar=False, cbar_kwargs={}, return_sc=False, smooth=False, smooth_res=None, wrap_at='180d', ratio=False, **kwargs)[source]

plots the intensity map using WHAM beams as scatter plots

Parameters:
fig: ‘plt.figure’, optional, must be keyword

if provided, will create axes on the figure provided

ax: ‘plt.figure.axes’ or ‘cartopy.axes`, optional, must be keyword

if provided, will plot on these axes can provide ax as a cartpy projection that contains different map projections

lrange: ‘list’, optional, must be keyword

provides longitude range to plot

brange: ‘list’, optional, must be keyword

provides latitude range to plot

vel_range: ‘list’ or ‘Quantity’, optional, must be keyword

velocity range to integrate data over

s_factor: ‘number’, optional, must be keyword

multiplied by supplied default s value to set size of WHAM beams

colorbar: ‘bool’, optional, must be keyword

if True, plots colorbar

cbar_kwargs: ‘dict’, optional, must be keyword

dictionary of kwargs to pass to colorbar

return_sc: ‘bool’, optional, must be keyword

if True, returns ax.scatter object before figure

smooth: `bool`, optional, must be keyword

if True, smooths map using griddata and plots using pcolormesh

smooth_res: `number`, optional, must be keyword

pixel width in units of degrees

wrap_at: ‘str’, optional, must be keyword - either “180d” or “360d”

sets value to wrap longitude degree values to Defaults to “180d”

ratio: `bool`, optional, must be keyword

if True treated as a line ratio

**kwarrgs: `dict`

passed to scatter plot

moment(order=None, vmin=None, vmax=None, return_sigma=False, masked=False, ratio=False)[source]

compute moment maps

Parameters:
order: ‘number’, optional, must be keyword

moment order to return, default = 0

vmin: ‘number’ or ‘Quantuty’, optional, must be keyword

min Velocity, default units of km/s

vmax: ‘number’ or ‘Quantity’, optional, must be keyword

max Velocity, default units of km/s

return_sigma: ‘bool’, optional, must be keyword

if True, will also return one-sigma gaussian error estimate

masked: `bool`, optional, must be keyword

if True, used masked velocity axis

ratio: `bool`, optional, must be keyword

if True, assumes computnig for a line ratio

stack_spectra_bootstrap(**kwargs)[source]

Stack all spectra in provided SkySurvey Table

Parameters:
survey: ‘whampy.skySurvey’

input skySurvey

data_column: ‘str’, optional, must be keyword

Name of data column, default of “DATA”

variance_column: ‘str’, optional, must be keyword

Name od variance column, defaut of “VARIANCE”

velocity: ‘np.array, list’, optional, must be keyword

velocity to interpolate data to for stacking defaults to np.round of first row “VELOCITY”

no_interp: ‘bool’, optional, must be keyword

if True, skips interpolating data to same velocity assumes it is already regularly gridded to given velocity

n_boot: ‘int’, optional, must be keyword

number of bootstrap samples for each spectrum to stack default of 1000

ci: ‘number’, optional, must be keyword

Size of confidence interval to return as errors

estimator: ‘callable’, optional, must be keyword

estimator method to use, defaults to numpy.mean must take axis keyword

set_name: ‘str’, optional, must be keyword

if provided, sets “NAME” column to this in returned stack