API Reference#

The API reference guide contains detailed descriptions of the functions and classes of BowshockPy

bowshockpy.models#

This module contains the implementation of the momentum conserving bowshock model

class bowshockpy.models.BaseModel(distpc)

Bases: object

Parent Class of Models.

Parameters#

distpcfloat

Distance from the observer to the source in pc

stoyr(value)

Converts seconds to years

Parameters#

valuefloat

Seconds to convert to years

Returns#

float

Years

solMasskm2togcm2(value)

Converts solar masses/km**2 to g/cm**2

Parameters#

valuefloat

Solar masses per km^2 to convert to g/cm^2

Returns#

float

g/cm2

solMasskm3togcm3(value)

Converts solar masses/km**3 to g/cm**3

Parameters#

valuefloat

Solar masses per km^3 to convert to g/cm^3

Returns#

float

g/cm3

km2arcsec(value)

Converts km to arcsec

Parameters#

valuefloat

km to convert to arcsec

Returns#

float

g/cm3

class bowshockpy.models.BowshockModel(L0, zj, vj, va, v0, mass, distpc, rbf_obs=None, rbf_niters=1000)

Bases: BaseModel

Bowshock model for a negligible internal working surface radius.

Parameters#

L0float

Characteristic scale of the bowshock [km]

zjfloat

Distance between the source and the internal working surface [km]

vjfloat

Velocity of the internal working surface [km/s]

vafloat

Velocity of the ambient gas surrounding the jet [km/s]

v0float

Velocity at which the material is ejected sideways from the internal working surface [km/s]

massfloat

Total mass of the bowshock shell [Solar masses]

distpcfloat

Distance between the source and the observer [pc]

rbf_obs: float | None, optional

Final radius of the bowshock [km]. If None, the theoretical final radius is calculated.

rbf_niters: float, optional

Number of iterations to compute the final radius of the bowshock, used only if rbf_obs is None. Default is 1000

Attributes:#

L0float

Characteristic scale of the bowshock [km]

zjfloat

Distance between the source and the internal working surface [km]

vjfloat

Velocity of the internal working surface [km/s]

vafloat

Velocity of the ambient gas surrounding the jet [km/s]

v0float

Velocity at which the material is ejected sideways from the internal working surface [km/s]

massfloat

Total mass of the bowshock shell [Solar masses]

distpcfloat

Distance between the source and the observer [pc]

rbf_obs: float | None

Final radius of the bowshock [km]

rbf_niters: float

Number of iterations to compute the final radius of the bowshock

rbffloat

Final radius of the bowshock [km]

zbffloat

z coordinate at the final radius rbf [km]

tjfloat

Dynamical time defined as zj / vj [s].

tj_yrfloat

Dynamical time in yrs.

rhoafloat

Ambient density [Msun km^3]

rhoa_gcm3float

Ambient density [g cm^-3]

mp0float

Mass rate at which the jet material is ejected sideways from the internal working surface [Msun / s]

mp0_solmassyrfloat

Mass rate at which the jet material is ejected sideways from the internal working surface [Msun / yr]

mpamb_ffloat

Mass rate of ambient material is incorporated into the bowshock shell [Msun / s]

mpamb_f_solmassyrfloat

Mass rate of ambient material is incorporated into the bowshock shell [Msun / yr]

zj_arcsecfloat

Distance from the source to the internal working surface [arcsec]

L0_arcsecfloat

Bowshock characteristic scale [arcsec]

rbf_arcsecfloat

Final radius of the bowshock [arcsec]

zbf_arcsecfloat

z-coordinate at the final radius [arcsec]

References:#

[1] Tabone, B., Raga, A., Cabrit, S. & Pineau des Forêts, G. “Interaction between a pulsating jet and a surrounding disk wind. A hydrodynamical perspective.” Astron. Astrophys. 614, A119 (2018).

[2] Ostriker, E. C., Lee, C.-F., Stone, J. M. & Mundy, L. G. A Ballistic Bow Shock Model for Jet-driven Protostellar Outflow Shells. Astrophys. J. 557, 443–450 (2001).

[3] Blazquez-Calero, G., et al. (under rev.)

gamma()

Computes the gamma parameter, defined as gamma = (vj - va) / v0

Returns#

float

gamma parameter

rb(zb)

Bowshock radius for a given z coordinate of the bowshock

Parameters#

zbfloat

z coordinate of the bowshock [km]

Returns#

float

Bowshock radius at zb [km]

vr(zb)

Computes the transversal component of the velocity (along the r-axis, perpendicular to the symmetry axis of the bowshock)

Parameters#

zbfloat

z coordinate of the bowshock [km]

Returns#

float

Transversal component of the velocity [km/s]

vz(zb)

Computes the longitudinal component of the velocity (along z-axis, the symmetry axis of the bowshock)

Parameters#

zbfloat

z coordinate of the bowshock [km]

Returns#

float

Longitudinal component of the velocity [km/s]

vtot(zb)

Computes the total speed of the velocity

Parameters#

zbfloat

z coordinate of the bowshock [km]

Returns#

float

Speed of the bowshock at zb [km/s]

velangle(zb)

Computes the angle between the bowshock axis and the velocity

Parameters#

zbfloat

z coordinate of the bowshock [km]

Returns#

float

Angle between the bowshock axis and the velocity [radians]

tangent_angle(zb)

Computes the angle between the bowshock axis and the local tangent to the shell surface at the z-coordinate of the bowshock zb. The angle is measured with respect to the symmetry axis of the bowshock towards the negative z-coordinate, so the angle is <90.

Parameters#

zbfloat

z coordinate of the bowshock [km]

Returns#

float

Angle between the bowshock axis and the local tangent to the shell surface at the z-coordinate of the bowshock zb [radians]

tangent_angle_rb(rb)

Computes the angle between the bowshock axis and the local tangent to the shell surface at the z-coordinate of the bowshock zb

Parameters#

rbfloat

r coordinate of the bowshock [km]

Returns#

float

Angle between the bowshock axis and the local tangent to the shell surface at the z-coordinate of the bowshock zb [radians]

theta(zb)

Computes the polar angle of the position vector

Parameters#

zbfloat

z coordinate of the bowshock [km]

Returns#

float

Polar angle of the position vector in radians

rbf_0(rr)

This is the target function to minimize by rbf_calc() to find the theoretical final radius

Parameters#

rrfloat

r coordinate of the bowshock [km]

Returns#

float

Value to minimize (it will be zero when rr is the final radius of the bowshock)

rbf_calc(ns=None, use_minimize=True)

Computes numerically the bowshock final radius

Parameters#

use_minimizebool

If True, scipy.optimize.minimize_scalar is used. If False, rbf is computed by brute force

nsint

number of iteractions to compute rbf by brute force if use_minimize=False

Returns:#

float

Solution for the final radius of the bowshock [km]

zb_r(rr)

Bowshock z coordinate for a given radius of the bowshock

Parameters#

rrfloat

radius of the bowshock [km]

Returns#

float

z coordinate of the bowshock [km]

surfdens(zb)

Computes the surface density of the bowshock

Parameters#

zbfloat

z coordinate of the bowshock [km]

Returns#

float

surface density at zb [solmass/km^2]

dr_func(zb, dz)

Differential of r given a differential of z

Parameters#

zbfloat

z coordinate of the bowshock [km]

dzfloat

increment in z [km]

Returns#

float

differential of r [km]

dz_func(zb, dr)

Differential of r given a differential of z

Parameters#

zbfloat

z coordinate of the bowshock [km]

drfloat

increment in radius [km]

Returns#

float

differential of r [km]

dsurf_func(zb, dz, dphi)

Differential of surface given a differential in z and phi (azimuthal angle)

Parameters#

zbfloat

z coordinate of the bowshock [km]

dzfloat

increment in radius [km]

dphifloat

increment in azimuthal angle [radians]

Returns#

float

differential of surface [Msun/km^2]

dmass_func(zb, dz, dphi)

Differential of mass given a differential in z and phi (azimuthal angle)

Parameters#

zbfloat

z coordinate of the bowshock [km]

dzfloat

increment in radius [km]

dphifloat

increment in azimuthal angle [radians]

Returns#

float

differential of mass [Msun]

intmass_analytical(rbf)

Computes the total mass of the bowshock shell

Parameters#

rbffloat

final radius of the bowshock [km]

Returns#

float

Total mass of the shell [Msun]

intmass_numerical(r0, rbf, return_residual=False)

Computes numerically the total mass of the bowshock shell in a range of radius from r0 to rbf

Parameters#

r0float

initial radius of the bowshock [km]

rbffloat

final radius of the bowshock [km]

Returns#

float

Total mass of the shell [Msun]

rhoa_fromintmass_analytical(rb, massint)

Computes the ambient density given the integrated mass of the bowshock at rb

Parameters#

rbfloat

radius of the bowshock [km]

massintfloat

integrated mass of the bowshock shell up to rb [Msun]

Returns#

float

Density of the ambient [Msun/km^3]

rhoa_fromintmass_sigma_simple(R0, Rb, massint, return_residual=False)

Computes numerically the ambient density taken into account the integrated mass in a range of radii from R0 to Rb

Parameters#

R0float

initial radius of the bowshock [km]

Rbfloat

radius of the bowshock [km]

massintfloat

integrated mass of the bowshock shell from R0 to Rb [Msun]

Returns#

float

Density of the ambient [Msun/km^3]

mp0_calc(rhoa)

Computes the mass rate at which the jet material is ejected sideways from the internal working surface

Parameters#

rhoafloat

Ambient density

Returns#

float

Mass rate at which the jet material is ejected sideways from the internal working surface [Msun/s]

mpamb_f_calc(rhoa)

Computes the mass rate of ambient material incorporated into the bowshock shell

Parameters#

rhoafloat

Ambient density

Returns#

float

Mass rate of the ambient incorporated into the bowshock [Msun/s]

get_modelplot(modelname='none', nzs=200, figsize=(16, 3), narrows=10, v_arrow_ref=100, linespacing=0.08, textbox_widthratio=0.7, **kwargs)

Plot a figure including the main parameters of the bowshock model, its morphology and kinematics, and the distribution of the surface density

Parameters#

modelnamestr, optional

Name of the model to include in the plot

nzsint, optional

Number of points used to compute the model solutions

figsizetuple, optional

Tuple passed to matplotib.pyplot.figure to define the dimensions of the figure

narrowsint, optional

Number of arrows to show in order to indicate the velocity at each symmetrical half of the model.

v_arrow_reffloat, optional

Velocity in km/s to use as reference in the reference arrow

linespacingfloat, optional

Spacing between the text lines

textbox_widthratiofloat, optional

Width ratio of the text ax to pass to GridSpec

kwargsoptional

Keyword arguments into ~bowshockpy.plot.BowshockModelPlot

Returns#

modelplot~bowshockpy.plot.BowshockModelPlot class instance

An instance of a class BowshockModelPlot, which contains information on the figure and the model data

class bowshockpy.models.IWSModel(a, z0, zf, vf, vj, sigma_max, distpc)

Bases: BaseModel

Geometrical model of an internal working surface

Parameters#

afloat

Constant that controls the collimation of the paraboloid

z0float

z-coordinate (symmetry axis) of the apex of the paraboloid [km]

zffloat

z-coordinate (symmetry axis) of the edge of the paraboloid [km]

vjfloat

velocity of the jet (z-component of the velocity of the paraboloid at the apex) [km/s]

sigma_maxfloat

Maximum density at the apex

distpcfloat

Distance to the source from the observer in pc

References:#

[1] Tafalla M., Su Y.-N., Shang H., Johnstone D., Zhang Q., Santiago-García J., Lee C.-F., et al., 2017, A&A, 597, A119.

rb(zb)

Radius of the model for a given z coordinate

Parameters#

zbfloat

z-coordinate [km]

Returns#

float

Shell radius at zb [km]

v_tan(zb)

Computes the magnitude of the velocities tangent to the shell surface in the reference frame comoving with the jet

Parameters#

zbfloat

z-coordinate [km]

Returns#

float

Tangent velocity [km/s]

tangent_angle(zb)

Angle between the (z0-z) axis and the tangent to the shell surface

Parameters#

zbfloat

z-coordinate [km]

Returns#

float

Angle of the tangent to the shell surface [radians]

vz(zb)

Computes the longitudinal component of the velocity (along z-axis, the symmetry axis of the model)

Parameters#

zbfloat

z coordinate of the model [km]

Returns#

float

Longitudinal component of the velocity [km/s]

vr(zb)

Computes the radial component of the velocity (along r-axis, perpendicular symmetry axis of the model)

Parameters#

zbfloat

z-coordinate of the model [km]

Returns#

float

Transversal component of the velocity [km/s]

velangle(zb)

Computes the angle between the velocity vector and the z-axis (symmetry axis)

Parameters#

zbfloat

z-coordinate of the model [km]

Returns#

float

Angle between the velocity vector and the z-axis

vtot(zb)

Computes the total speed of the velocity

Parameters#

zbfloat

z-coordinate of the model [km]

Returns#

float

Speed of the model at zb [km/s]

zb_r(rr)

z-coordinate for a given radius of the model shell

Parameters#

rrfloat

radius of the model shell [km]

Returns#

float

z coordinate of the model shell [km]

surfdens(zb)

Surface density of the shell as a function of z-coordinate. The surface density follows a square-root law when r>rf/2, and is constant for r<=rf/2.

Parameters#

zbfloat

z-coordinate [km]

Returns#

float

Surface density of the shell at zb

dz_func(zb, dr)

Differential dz at zb

Parameters#

zbfloat

z-coordinate [km]

drfloat

Differential or radius [km]

Returns#

float

Differential of z [km]

dsurf_func(zb, dz, dphi)

Differential of surface given a differential in z and phi

Parameters#

zbfloat

z coordinate [km]

dzfloat

Differential of z [km]

dphiphi

Differential of azimuthal angle [radians]

Returns#

float

Differential surface density

dmass_func(zb, dz, dphi)

Differential of mass given a differential in z and phi

Parameters#

zbfloat

z coordinate [km]

dzfloat

Differential of z [km]

dphiphi

Differential of azimuthal angle [radians]

Returns#

float

Differential of mass [Msun]

bowshockpy.modelproj#

This module contains the class that projects the bowshock model morphology and kinematics

class bowshockpy.modelproj.ObsModel(model, i_deg, pa_deg=0, vsys=0)

Bases: BaseModel

Computes the projected morphology and kinematics of a BowshockModel model

Parameters#

modelclass instance

instance of BowshockModel model to get the attributes

i_degfloat

Inclination angle between the bowshock axis and the line-of-sight [degrees]

pa_degfloat, optional

Position angle, default 0 [degrees]

vsysfloat, optional

Systemic velocity of the source, default 0 [km/s]

vzp(zb, phi)

Calculates the line-of-sight velocity for a point of the bowshock shell with (zb, phi)

Parameters#

zbfloat

z coordinate of the bowshock [km]

phifloat

azimuthal angle [radians]

Returns#

float

Line-of-sight velocity [km/s]

xp(zb, phi)

Calculates the xp coordinate for a point of the bowshock shell with (zb, phi)

Parameters#

zbfloat

z coordinate of the bowshock [km]

phifloat

azimuthal angle [radians]

Returns#

float

xp coordinate in the plane-of-sky [km]

yp(zb, phi)

Calculates the yp coordinate for a point of the bowshock shell with (zb, phi)

Parameters#

zbfloat

z coordinate of the bowshock [km]

phifloat

azimuthal angle [radians]

Returns#

float

yp coordinate in the plane-of-sky [km]

zp(zb, phi)

Calculates the xp coordinate for a point of the bowshock shell with (zb, phi)

Parameters#

zbfloat

z coordinate of the bowshock [km]

phifloat

azimuthal angle [radians]

Returns#

float

zp coordinate, along the line-of-sight direction [km]

get_obsmodelplot(modelname='none', nzs=150, nphis=150, figsize=(12, 6), linespacing=0.09, textbox_widthratio=0.8, cmap='turbo', minpointsize=0.1, maxpointsize=10, **kwargs)

Plot a figure including the main parameters of the bowshock model, its morphology and kinematics, and the distribution of the surface density

Parameters#

modelnamestr, optional

Name of the model to include in the plot

nzsint, optional

Number of z coordinates used to compute the model solutions

nphisint, optional

Number of phi coordinates used to compute the model solutions

figsize: tuple, optional

Tuple passed to matplotib.pyplot.figure to define the dimensions of the figure

linespacingfloat, optional

Spacing between the text lines

textbox_widthratiofloat, optional

Width ratio of the text ax to pass to GridSpec

cmapstr, optional

Colormap label

minpointsizefloat, optional

Minsize of the points to plot

maxpointsizefloat, optional

Minsize of the points to plot

kwargsoptional

Keyword arguments into ~bowshockpy.plot.BowshockObsModelPlot

Returns#

modelplot~bowshockpy.plot.BowshockObsModelPlot class instance

An instance of a class BowshockModelPlot, which contains information on the figure and the model data

bowshockpy.cubemass#

This module contains the tools that allows to compute the masses in a spectral cube of a bowshock model

class bowshockpy.cubemass.MassCube(obsmodel, nphis, xpmax, vch0, vchf=None, chanwidth=None, nzs=200, nc=50, nxs=200, nys=200, refpix=[0, 0], cic=True, vt='2xchannel', tolfactor_vt=None, massdiff_tol=0.1, verbose=True)

Bases: ObsModel

Computes the spectral cube of the bowshock model

Parameters#

obsmodelclass instance

Instance of ObsModel

nphisint

Number of azimuthal angles phi to calculate the bowshock solution

xpmaxfloat

Physical size of the channel maps along the x axis [arcsec]

vch0float

Central velocity of the first channel map [km/s]

vchffloat | None

Central velocity of the last channel map [km/s]. If a float is provided, chanwidth input argument should be None, since chanwidth would be computed internally. If vchf is None, you should provide instead the channel width using chanwidth argument. Default is None.

chanwidthfloat | None

Channel width of the spectral cube [km/s]. If a float is provided, vchf input argument should be None, since vchf would be computed internally. If chanwidth>0 then vch0<vchf, if chanwidth<0 then vch0>vchf. If None, you should provide instead the central velocity of the last channel map using vchf argument. Default is None.

nzsint, optional

Number of points used to compute the model solutions

ncint, optional

Number of spectral channel maps

nxsint, optional

Number of pixels in the right ascension axis.

nysint, optional

Number of pixels in the declination axis.

refpixlist | None, optional

Pixel coordinates (zero-based) of the source, i.e., the origin from which the distances are measured. The first index is the R.A. axis, the second is the Dec. axis [[int, int] or None]

cicbolean, optional

Set to True to perform Cloud in Cell interpolation [1].

vtfloat | str, optional

Thermal+turbulent line-of-sight velocity dispersion [km/s]. If thermal+turbulent line-of-sight velocity dispersion is smaller than the instrumental spectral resolution, vt should be the spectral resolution. It can be also set to an integer times the channel width using a string (e.g., “2xchannel”)

tolfactor_vtfloat, optional

The masses corresponding to a channel map are spread along the cube in the velocity axis following a Gaussian distribution, being vt parameter the standard deviation of the Gaussian. tolfactor_vt parameter truncates the Gaussian distribution at vt * tolfactor_vt in order to make the computation substantially faster. A low tolfactor_vt can result in a warning reporting an underestimation of the total mass of the model.

massdiff_tolfloat, optional

Percentage tolerance of the difference between the input and total output mass of the model due to numerical errors.

verbosebolean, optional

Set True to verbose messages about the computation

kwargsoptional

Keyword arguments into ~bowshockpy.plot.plot_channel

Attributes:#

nrsint

Number of model points to which the solution has been computed.

rsnumpy.ndarray

Array of the radii of the model.

drfloat

Increment of radii between the points, which is constant.

zsnumpy.ndarray

Array of the z-coordinates of the model.

dzsnumpy.ndarray

Increment of z-coordinates between the points.

phisnumpy.ndarray

Array of the azimuthal angles of the model.

dphifloat

Increment in azimuthal angle of the points of the model.

vsnumpy.ndarray

Array with the velocities of the points of the model.

velchansnumpy.ndarray

Array with the line-of-sight velocities of the channels of the spectral cube.

cubenumpy.ndarray

Spectral cube of the masses of the bowshock model.

cube_samplingnumpy.ndarray

Cube where the values are the number of model points used to sample each pixel at each channel.

References:#

[1] Fehske, H., Schneider, R., & Weiße, A. (2008), Computational Many-Particle Physics, Vol. 739 (Springer), doi: 10.1007/978-3-540-74686-7.

makecube(fromcube=None)

Makes the spectral cube of the model

Parameters#

fromcubenumpy.ndarray, optional

Cube that will be populated with the model data. If None, and empty cube will be considered.

plot_channel(chan, vmax=None, vmin=None, cmap='inferno', interpolation='bilinear', savefig=None, return_fig_axs=False)

Plots a channel map of a cube

Parameters#

chanint

Channel map to plot

vmaxfloat, optional

Maximum value of the colormap. If None (default), the maximum value of the channel is chosen.

vminfloat, optional

Minimum value of the colormap. If None (default), the minimum value of the channel is chosen.

cmapstr, optional

Label of the colormap, by default “inferno”.

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

savefigstr, optional String of the full path to save the figure. If

None, no figure is saved. By default, None.

return_fig_axsbool, optional

If True, returns the figure, axes of the channel map, and the axes the colorbar. If False, does not return anything.

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs=True.

plot_channels(savefig=None, return_fig_axs=False, **kwargs)

Plots several channel map of a spectral cube.

Parameters#

ncolint, optional

Number of columns in the figure, by default 4

nrowint, optional

Number of rows of the figure, by default 4

figsizetuple, optional

Size of the figure. If None, an optimal size will be computed. By default None.

wspacefloat, optional

Width space between the channel plots, by default 0.05

hspacefloat, optional

Height space between the cannel plots, by default 0.0

vmaxfloat, optional

Maximum value of the colormap. If None (default), the maximum value of the channel is chosen.

vcenter_type_, optional

_description_, by default None

vminfloat, optional

Minimum value of the colormap. If None (default), the minimum value of the channel is chosen.

cmapstr, optional

Label of the colormap, by default “inferno”.

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

unitsstr, optional

Units of the values of the cube, by default “Mass [Msun]”

xmajor_locatorfloat, optional

Major locator in x-axis, by default 1

xminor_locatorfloat, optional

Minor locator in x-axis, by default 0.2

ymajor_locatorfloat, optional

Major locator in y-axis, by default 1

yminor_locatorfloat, optional

Minor locator in y-axis, by default 0.2

refpixlist, optional

Pixel of reference, by default [0,0]

savefigstr, optional String of the full path to save the figure. If

None, no figure is saved. By default, None.

bowshockpy.cubeproc#

This module contains the tools that allows to compute the column densities, opacities, and intensities of the bowshock model spectral cubes

class bowshockpy.cubeproc.CubeProcessing(modelcubes, modelname='none', J=3, nu=<Quantity 345.7959899 GHz>, abund=8.5e-05, meanmolmass=2.8, mu=<Quantity 0.112 D>, Tex=<Quantity 100. K>, Tbg=<Quantity 2.7 K>, tau_custom_function=None, Inu_custom_function=None, coordcube='offset', ra_source_deg=None, dec_source_deg=None, bmin=None, bmaj=None, pabeam=0, papv=0.0, sigma_beforeconv=None, maxcube2noise=None, verbose=True, **kwargs)

Bases: MassCube

Process a MassCube instance

Parameters#

modelcubesclass instance

Instance of MassCube

modelnamestr, optional

Name of the folder in /models where the outputs will be saved

Jint, optional

Upper level of the rotational transition (e.g. 3 for transition “3-2”)

nufloat | astropy.units.Quantity, optional

Frequency of the transition. If float, the units of nu should be GHz

abundfloat, optional

Abundance relative to the molecular hydrogen

meanmolmassfloat, optional

Mean mass per H molecule.

mufloat | astropy.unit.Quantity, optional

Permanent dipole moment of the molecule. If float, the units of mu should be Debye.

Texfloat | astropy.unit.Quantity, optional

Excitation temperature. If float, the units of Tex should be Kelvin.

Tbgfloat | astropy.unit.Quantity, optional

Excitation temperature. If float, the units of Tex should be Kelvin.

tau_custom_functioncallable, optional

By default, BowshockPy will compute the opacities from a rotational transition of a linear molecule (neglecting vibrational excited states and centrifugal distortion of the molecule). You can provide a custom function to compute the opacities from the column densities per velocity bin. This function should accept only the column densities per velocity bin, and return the opacities.

Inu_custom_functioncallable, optional

Custom function to compute the intensities from the opacities

coordcubestr, optional

Set to “sky” if you would like to set the cube headers in sky coordinates, or “offset” if you prefer them in offsets relative to the origin (the source).

ra_source_degfloat, optional

Source right ascension [deg]

dec_source_degfloat, optional

Source declination [deg]

bminfloat | None, optional

Beam minor axis [arcsec]

bmajfloat | None, optional

Beam major axis [arcsec]

pabeamfloat

Beam position angle [degrees]

papvfloat

Position angle used to calculate the PV [degrees]

sigma_beforeconvfloat

Standard deviation of the noise of the map, before convolution. Set to None if maxcube2noise is used.

maxcube2noisefloat

Standard deviation of the noise of the map, before convolution, relative to the maximum pixel in the cube. The actual noise will be computed after convolving. This parameter would not be used if sigma_beforeconve is not None.

verbosebolean, optional

Set True to verbose messages about the computation

kwargsoptional

Keyword arguments into ~bowshockpy.plot.plot_channel

Attributes#

cubesdict

Dictionary of the processed cubes. Keys are abbreviations of the quantity of the cube and the operations performed to it

refpixsdict

Dictionary of the reference pixel of the cubes. Keys are abbreviations of the quantity of the cube and the operations performed to it

hdrsdict

Dictionary of the headers astropy.io.fits.header.Header of each cube. The headers are generated when savecube method is used.

areapix_cmfloat

Area of a pixel in cm.

x_FWHMfloat | None

Full width half maximum of the Gaussian beam for the x direction [pixel]

y_FWHMfloat | None

Full width half maximum of the Gaussian beam for the y direction [pixel]

beamareafloat | None

Area of the beam [pixel^2]

beamarea_srastropy.units.Quantity | None

Area of the beam in stereoradians. If no beam is provided, beamarea_sr will be None, and all the intensities will be expressed in Jy/arcsec^2

listmompvslist

List of cubes to which the moments and the position velocity diagrams are going to performed when the method self.momentsandpv_and_params_all is called

combine_cubes(modelcubes)

Combines (sums) a list of cubes

Parameters#

modelcubeslist

List of cubes to combine

calc_Ntot()

Computes the total (molecular hydrogen + heavier components) column densities of the model cube

calc_Nmol()

Computes the emitting molecule column densities of the model cube

calc_tau()

Computes the opacities of the model cube

calc_I()

Calculates the intensity [Jy/beam] of the model cube.

add_source(ck='m', value=None)

Adds a source to the cube in the reference pixel

Parameters#

ckstr, optional

Key of the cube to add the source

valuefloat, optional

Pixel value of the source. If None, the maximum of the cube will be considered

add_noise(ck='m')

Adds Gaussian noise to the cube.

Parameters#

ckstr, optional

Key of the cube to rotate

convolve(ck='m')

Convolves the cube with the defined Gaussian kernel (self.bmaj, self.bmin, self.pabeam)

Parameters#

ckstr, optional

Key of the cube to convolve

calc(userdic)

Computes the quantities and the operations to the cubes.

Parameters#

userdicdict

Dictionary indicating the desired output spectral cubes and the operations performed over them. The keys of the dictionary are strings indicating the quantities of the desired cubes. These are the available quantities of the spectral cubes:

  • “mass”: Total mass of molecular hydrogen in solar mass.

  • “mol_column_density”: Column density of the emitting molecule in cm-2.

  • “intensity”: Intensity in Jy/beam.

  • “tau”: Opacities.

The values of the dictionary are lists of strings indicating the operations to be performed over the cube. These are the available operations:

  • “add_source”: Add a point source at the reference pixel.

  • “add_noise”: Add Gaussian noise, defined by maxcube2noise parameter.

  • “convolve”: Convolve with a Gaussian defined by the parameters bmaj, bmin, and pabeam.

  • “moments_and_pv”: Computes the moments 0, 1, and 2, the maximum intensity and the PV-diagram.

The operations will be performed folowing the order of the strings in the list (from left to right). The list can be left empty if no operations are desired.

Example:#

>>> cp = CubeProcessing(...)
>>> outcubes = {
>>>    "intensity": ["add_noise", "convolve", "moments_and_pv"],
>>>    "opacity": [],
>>>    "mol_column_density": ["convolve"],
>>>    "mass": [],
>>> }
>>> cp.calc(outcubes)

will save 4 spectral cubes in fits format. The first one are the intensities with Gaussian noise added, it will be convolved, and the moments and PV-diagrams will be computed; the second cube will be the opacity; the third will be the mol_column_density, which will be convolved; and the forth cube will be the masses. The first spectral cube will be named I_nc.fits, the second tau.fits, the third Nmol_c.fits, and the fourth m.fits.

savecube(ck, fitsname=None)

Saves the cube in fits format

Parameters#

ckstr

Key of the cube to convolve

fitsnamestr

Relative path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}.fits. If the path does not exist, it will be created.

savecubes(cks=None)

Saves the cubes specified by userdic

Parameters#

ckslist

List of keys of the cube to save. Default is None. If None, all calculated cubes will be saved.

plot_channel(ck, chan, vmax=None, vmin=None, cmap='inferno', savefig=None, add_beam=False, return_fig_axs=False)

Plots a channel map of a cube

Parameters#

ckstr

Key of the cube to plot (see keys of self.cubes dictionary)

chanint

Channel map to plot

vmaxfloat, optional

Maximum value of the colormap. If None (default), the maximum value of the channel is chosen.

vminfloat, optional

Minimum value of the colormap. If None (default), the minimum value of the channel is chosen.

cmapstr, optional

Label of the colormap, by default “inferno”.

savefigstr, optional String of the full path to save the figure. If

None, no figure is saved. By default, None.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

return_fig_axsbool, optional

If True, returns a tuple of the ax of the channel map and the colorbar. If False, does not return anything.

Returns#

(fig, ax, cbax)tuple of matplotlib.axes.Axes Axes of the channel map

and the colorbar, only returns if return_fig_axs=True.

plot_channels(ck, savefig=None, add_beam=False, return_fig_axs=False, **kwargs)

Plots several channel map of a spectral cube.

Parameters#

ckstr

Key of the cube to plot (see keys of self.cubes dictionary)

ncolint, optional

Number of columns in the figure, by default 4

nrowint, optional

Number of rows of the figure, by default 4

figsizetuple, optional

Size of the figure. If None, an optimal size will be computed. By default None.

wspacefloat, optional

Width space between the channel plots, by default 0.05

hspacefloat, optional

Height space between the cannel plots, by default 0.0

vmaxfloat, optional

Maximum value of the colormap. If None (default), the maximum value of the channel is chosen.

vcenter_type_, optional

_description_, by default None

vminfloat, optional

Minimum value of the colormap. If None (default), the minimum value of the channel is chosen.

cmapstr, optional

Label of the colormap, by default “inferno”.

unitsstr, optional

Units of the values of the cube, by default “Mass [Msun]”

xmajor_locatorfloat, optional

Major locator in x-axis, by default 1

xminor_locatorfloat, optional

Minor locator in x-axis, by default 0.2

ymajor_locatorfloat, optional

Major locator in y-axis, by default 1

yminor_locatorfloat, optional

Minor locator in y-axis, by default 0.2

refpixlist, optional

Pixel of reference, by default [0,0]

savefigstr, optional String of the full path to save the figure. If

None, no figure is saved. By default, None.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

return_fig_axsbool, optional

If True, returns the figure, axes of the channel map, and the axes the colorbar. If False, does not return anything.

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs=True.

pvalongz(ck, halfwidth=0, savefits=False, fitsname=None)

Performs the position velocity diagram along the self.papv direction

Parameters#

ckstr

Key of the cube to perform the PV-diagram.

halfwidthint, optional

Number of pixels around xpv that will be taking into account to compute the PV-diagram.

savefitsboolean

If True, save the PV-diagram in fits format.

fitsnamestr

Full path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_pv.fits. If the path does not exist, it will be created.

Returns#

pvimagenumpy.ndarray

Position velocity diagram

sumint(ck, chan_range=None, savefits=False, fitsname=None)

Computes the image of the summation of pixels of the cube along the velocity axis

Parameters#

ckstr

Key of the cube to perfomr the PV-diagram.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

savefitsboolean

If True, save the PV-diagram in fits format.

fitsnamestr

Full path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_sumint.fits. If the path does not exist, it will be created.

Returns#

sumintnumpy.ndarray

Image of the summation of the pixels of the cube along the velocty axis

mom0(ck, chan_range=None, savefits=False, fitsname=None)

Computes the 0th order moment along the velocity axis

Parameters#

ckstr

Key of the cube to perfomr the PV-diagram.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

savefitsboolean

If True, save the PV-diagram in fits format.

fitsnamestr

Full path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_mom0.fits. If the path does not exist, it will be created.

Returns#

mom0numpy.ndarray

Moment 0 image of the cube

mom1(ck, chan_range=None, clipping=0, savefits=False, fitsname=None)

Computes the 1th order moment along the velocity axis

Parameters#

ckstr

Key of the cube to perfomr the PV-diagram.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

clippingfloat, optional

Pixels with values smaller than the one given by clipping parameter will be masked with 0 values.

savefitsboolean, optional

If True, save the PV-diagram in fits format.

fitsnamestr

Full path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_mom1.fits. If the path does not exist, it will be created.

Returns#

mom1numpy.ndarray

Moment 1 image of the cube

mom2(ck, chan_range=None, clipping=0, savefits=False, fitsname=None)

Computes the 2th order moment along the velocity axis

Parameters#

ckstr

Key of the cube to perfomr the PV-diagram.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

clippingfloat, optional

Pixels with values smaller than the one given by clipping parameter will be masked with 0 values.

savefitsboolean, optional

If True, save the PV-diagram in fits format.

fitsnamestr, optional

Full path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_mom2.fits. If the path does not exist, it will be created.

Returns#

mom2numpy.ndarray

Moment 2 image of the cube

maxintens(ck, chan_range=None, clipping=0, savefits=False, fitsname=None)

Computes the maximum value of the cube along the velocity axis

Parameters#

ckstr

Key of the cube to perfomr the moment.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

clippingfloat, optional

Pixels with values smaller than the one given by clipping parameter will be masked with 0 values.

savefitsboolean, optional

If True, save the moment in fits format.

fitsnamestr, optional

Full path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_maxintens.fits. If the path does not exist, it will be created.

Returns#

maxintensnumpy.ndarray

Maximum value of the pixels of the cubes along the velocity axis

plotpv(ck, halfwidth, ax=None, cbax=None, savefits=False, fitsname=None, savefig=None, return_fig_axs_im=False, **kwargs)

Plots the position velocity diagram.

Parameters#

ckstr

Key of the cube to which the PV-diagram will be computed.

halfwidthint, optional

Number of pixels around xpv that will be taking into account to compute the PV-diagram.

axmatplotlib.axes.Axes, optional The matplotlib.axes.Axes` instance

in which the position velodity diagram is drawn. If None, it will create one. By default, None

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn. If None, it will create one. By default, None

savefitsbool

If True, the position velocity diagram will be saved in fits format

fitsnamestr

Relative path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_pv.fits. If the path does not exist, it will be created.

savefigstr, optional

String of the full path to save the figure. If None, no figure is saved. By default, None.

return_fig_axs_imbool, optional

If True, returns the figure, axes of the channel map, the axes the colorbar, and the image. If False, does not return anything.

kwargsoptional

Keyword arguments into ~bowshockpy.plot.plotpv

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs_im=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs_im=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs_im=True.

pvimagenumpy.ndarray

Position velocity diagram

plotsumint(ck, chan_range=None, ax=None, cbax=None, add_beam=False, savefits=False, fitsname=False, savefig=None, return_fig_axs_im=False, **kwargs)

Plots the sum of the pixels of the cubes along the velocity axis.

Parameters#

ckstr

Key of the cube to which the moment will be computed.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

axmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes` instance in which the position velodity diagram is drawn. If None, it will create one. By default, None

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn. If None, it will create one. By default, None

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

savefitsbool

If True, the moment will be saved in fits format

fitsnamestr

Relative path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_sumint.fits. If the path does not exist, it will be created.

savefigstr, optional

String of the full path to save the figure. If None, no figure is saved. By default, None.

return_fig_axs_imbool, optional

If True, returns the figure, axes of the channel map, the axes the colorbar, and the image. If False, does not return anything.

kwargsoptional

Keyword arguments into ~bowshockpy.plot.plotsumint

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs_im=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs_im=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs_im=True.

sumintnumpy.ndarray

Sum of all the pixels along the velocity axis.

plotmom0(ck, chan_range=None, ax=None, cbax=None, add_beam=False, savefits=False, fitsname=None, savefig=None, return_fig_axs_im=False, **kwargs)

Plots the moment 0 (integrated intensity).

Parameters#

ckstr

Key of the cube to which the moment will be computed.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

axmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes` instance in which the position velodity diagram is drawn. If None, it will create one. By default, None

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn. If None, it will create one. By default, None

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

savefitsbool

If True, the moment will be saved in fits format

fitsnamestr

Relative path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_mom0.fits. If the path does not exist, it will be created.

savefigstr, optional

String of the full path to save the figure. If None, no figure is saved. By default, None.

return_fig_axs_imbool, optional

If True, returns the figure, axes of the channel map, the axes the colorbar, and the image. If False, does not return anything.

kwargsoptional

Keyword arguments into ~bowshockpy.plot.plotmom0

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs_im=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs_im=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs_im=True.

mom0numpy.ndarray

Integrated intensity

plotmom1(ck, chan_range=None, mom1clipping=0, ax=None, cbax=None, add_beam=False, savefits=False, fitsname=None, savefig=None, return_fig_axs_im=False, **kwargs)

Plots the moment 1 (Intensity weighted mean velocity field).

Parameters#

ckstr

Key of the cube to which the moment will be computed.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

mom1clippingfloat

Clipping to in order to compute the moment 1. Pixels with values smaller than the one given by clipping parameter will be masked with 0 values.

axmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes` instance in which the position velodity diagram is drawn. If None, it will create one. By default, None

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn. If None, it will create one. By default, None

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

savefitsbool

If True, the moment will be saved in fits format.

fitsnamestr

Relative path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_mom1.fits. If the path does not exist, it will be created.

savefigstr, optional

String of the full path to save the figure. If None, no figure is saved. By default, None.

return_fig_axs_imbool, optional

If True, returns the figure, axes of the channel map, the axes the colorbar, and the image. If False, does not return anything.

kwargsoptional

Keyword arguments into ~bowshockpy.plot.plotmom1

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs_im=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs_im=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs_im=True.

mom1numpy.ndarray

Intensity weighted velocity field.

plotmom2(ck, chan_range=None, mom2clipping=0, ax=None, cbax=None, add_beam=False, savefits=False, fitsname=None, savefig=None, return_fig_axs_im=False, **kwargs)

Plots the moment 2 (velocity dispersion).

Parameters#

ckstr

Key of the cube to which the moment will be computed.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

mom2clippingfloat

Clipping to in order to compute the moment 2. Pixels with values smaller than the one given by clipping parameter will be masked with 0 values.

axmatplotlib.axes.Axes, optional The matplotlib.axes.Axes` instance

in which the position velodity diagram is drawn. If None, it will create one. By default, None

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn. If None, it will create one. By default, None

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

savefitsbool

If True, the moment will be saved in fits format

fitsnamestr

Relative path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_mom2.fits. If the path does not exist, it will be created.

savefigstr, optional

String of the full path to save the figure. If None, no figure is saved. By default, None.

return_fig_axs_imbool, optional

If True, returns the figure, axes of the channel map, the axes the colorbar, and the image. If False, does not return anything.

kwargsoptional

Keyword arguments into ~bowshockpy.plot.plotmom2

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs_im=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs_im=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs_im=True.

mom2numpy.ndarray

Velocity dispersion

plotmaxintens(ck, chan_range=None, ax=None, cbax=None, add_beam=False, savefits=False, fitsname=None, savefig=None, return_fig_axs_im=False, **kwargs)

Plots the moment 8 (peak intensity).

Parameters#

ckstr

Key of the cube to which the moment diagram will be computed.

chan_rangelist, optional

Two element list with the last and first channels used to compute the moment. If None, the whole cube will be considered.

axmatplotlib.axes.Axes, optional The matplotlib.axes.Axes` instance

in which the position velodity diagram is drawn. If None, it will create one. By default, None

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn. If None, it will create one. By default, None

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

savefitsbool

If True, the moments and the position velocity diagram will be saved in fits format

fitsnamestr

Relative path name of the fits file. If None, it will be saved as models/{self.modelname}/fits/{ck}_maxintens.fits. If the path does not exist, it will be created.

savefigstr, optional

String of the full path to save the figure. If None, no figure is saved. By default, None.

return_fig_axs_imbool, optional

If True, returns the figure, axes of the channel map, the axes the colorbar, and the image. If False, does not return anything.

kwargsoptional

Keyword arguments into ~bowshockpy.plot.plotmaxintens

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs_im=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs_im=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs_im=True.

maxintensnumpy.ndarray

Peak intensity

momentsandpv_and_params(ck, savefits=False, saveplot=False, mom1clipping=0, mom2clipping=0, verbose=True, chan_range=None, halfwidth_pv=0, add_beam=False, mom0values={'vcenter': None, 'vmax': None, 'vmin': None}, mom1values={'vcenter': None, 'vmax': None, 'vmin': None}, mom2values={'vcenter': None, 'vmax': None, 'vmin': None}, maxintensvalues={'vcenter': None, 'vmax': None, 'vmin': None}, pvvalues={'vcenter': None, 'vmax': None, 'vmin': None}, custom_showtext=None)

Computes the moments and position velocity diagram including also the main parameters of the model listed in the first ax

Parameters#

ckstr

Key of the cube to which the moments and the position velocity diagram will be computed.

savefitsbool

If True, the moments and the position velocity diagram will be saved in fits format

saveplotbool

If True, a plot of the moments and position velocity diagrams will be saved

mom1clippingfloat

Clipping to in order to compute the moment 1. Pixels with values smaller than the one given by clipping parameter will be masked with 0 values.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

mom2clippingfloat

Clipping to in order to compute the moment 2. Pixels with values smaller than the one given by clipping parameter will be masked with 0 values.

maxintensclippingfloat

Clipping to in order to compute the maximum value of the pixels along the velocity axis. Pixels with values smaller than the one given by clipping parameter will be masked with 0 values.

mom0valuesdict or None

Dictionary with the maximum, central, and minimum value to show in the plot of the moment 0. If the dictionary value is None for vmax, vcenter, or vmin, then the maximum, central, or the minimum value of the moment image will be considered, respectively. Example: mom0values = {“vmax”: None, “vcenter”: None, “vmin”: 0,}.

mom1valuesdict or None

Dictionary with the maximum, central, and minimum value to show in the plot of the moment 1. If the dictionary value is None for vmax, vcenter, or vmin, then the maximum, central, or the minimum value of the moment image will be considered, respectively. Example: mom1values = {“vmax”: None, “vcenter”: None, “vmin”: 0,}.

mom2valuesdict or None

Dictionary with the maximum, central, and minimum value to show in the plot of the moment 2. If the dictionary value is None for vmax, vcenter, or vmin, then the maximum, central, or the minimum value of the moment image will be considered, respectively. Example: mom1values = {“vmax”: None, “vcenter”: None, “vmin”: 0,}.

maxintensvaluesdict or None

Dictionary with the maximum, central, and minimum value to show in the plot of the maximum value along the velocity axis. If the dictionary value is None for vmax, vcenter, or vmin, then the maximum, central, or the minimum value of the moment image will be considered, respectively. Example: maxintensvalues = {“vmax”: None, “vcenter”: None, “vmin”: None,}.

momentsandpv_and_params_all(**kwargs)

Computes all the moments and pv to the cubes listed in self.listmompvs, including a list of values of the main parameters of the model in the first ax

kwargsoptional

Keyword arguments into ~bowshockpy.cubeproc.CubeProcessing.momentsandpv_and_params

bowshockpy.radtrans#

This module contains the general equations that allows to compute the column densities and opacities, and to perform the radiative transfer

bowshockpy.radtrans.column_density_tot(m, area, meanmolmass)

Computes the total (H2 + heavier components) column density given the mass and the projected area

Parameters#

mfloat | astropy.units.Quantity

Mass. If float, units should be Solar Masses.

areafloat | astropy.units.Quantity

Projected area. If float, the area should be in cm**2.

meanmolmassfloat

Mean molecular mass per hydrogen molecule

Returns#

astropy.units.Quantity

Total column density (H2 + heavier components)

bowshockpy.radtrans.column_density_mol(Ntot, abund)

Computes the column density of a molecule given its abundance with respect to the H2

Parameters#

Ntotfloat | astropy.units.Quantity

Total column density (H2 + heavier components). If float, the column density should be given in particles per cm**2

abundfloat

Abundance relative to molecular hydrogen

Returns#

astropy.units.Quantity

Column density of the molecule

bowshockpy.radtrans.Qpart(Tex, Ei, gi, Ei_args=(), gi_args=(), tol=1e-15)

Computes the partition function.

Parameters#

Texfloat | astropy.units.quntity

Excitation temperature. If float, it should be in Kelvin

Eicallable

Function Ei(i, *Ei_args) to compute the energy at level i

gicallable

Function gi(i, *gi_args) to compute the degeneracy at level i

Ei_argstuple, optional

Extra arguments passed to Ei function

gi_argstuple, optional

Extra arguments passed to gi

tolfloat, optional

Tolerance at which the summation is stopped, by default 10**(-15)

Returns#

float

Partition function

bowshockpy.radtrans.column_density_mol_i(Nmol, Tex, i, Ei, gi, Ei_args=(), gi_args=())

Computes the column density of a molecule at energy level i.

Parameters#

Nmolfloat | astropy.units.Quantity

Column density of the emitting molecule. If float, should be in cm**(-2)

Texfloat | astropy.units.Quantity

Excitation temperature. If float, should be in Kelvin.

Eicallable

Function Ei(i, *Ei_args) to compute the energy at level i

gicallable

Function gi(i, *gi_args) to compute the degeneracy at level i

Ei_argstuple, optional

Extra arguments passed to Ei function

gi_argstuple, optional

Extra arguments passed to gi

Returns#

astropy.units.Quantity

Column density of the molecule at energy level i

bowshockpy.radtrans.A_ul(nu, mu_ul)

Calculates the spontaneous emission coeffitient for the u -> l level transition

Parameters#

nufloat | astropy.units.Quantity

Frequency of the transition. If float, it should be in GHz.

mu_ulfloat | astropy.units.Quantity

Dipole moment matrix element u,l. If float, it should be in Debye.

bowshockpy.radtrans.tau_func(dNmoldv, nu, Tex, i, Ei, gi, mu_ul, Ei_args=(), gi_args=())

Computes the opacity as a function of the column density per channel width

Parameters#

dNmoldvfloat | astropy.units.Quantity

Column density per velocity bin. If float, it should be given in cm**(-2) * s * km**(-1)

nufloat | astropy.units.Quantity

Frequency. If float, it should be in GHz.

Texastropy.units.Quantity

Excitation temperature. If float, it should be in Kelvin.

iint

Level

mu_ulfloat | astropy.units.Quantity

Dipole moment matrix element i, i-1. If float should be in Debye.

Eicallable

Function Ei(i, *Ei_args) to compute the energy at level i

gicallable

Function gi(i, *gi_args) to compute the degeneracy at level i

Ei_argstuple, optional

Extra arguments passed to Ei function

gi_argstuple, optional

Extra arguments passed to gi

Returns#

float

Opacity

bowshockpy.radtrans.exp_hnkt(nu, T)

Computes exp(h nu / k_B/T)

Parameters#

nufloat | astropy.units.Quantity

Frequency. If float, it should be in GHz

Tfloat | astropy.units.Quantity

Temperature. If float, should be in Kelvin

Returns#

float

exp(h nu / k_B/T)

bowshockpy.radtrans.Bnu_func(nu, T)

Computes the spectral radiance or specific intensity of a Planckian (energy per unit of area, time, frequency, and solid angle)

Parameters#

nufloat | astropy.units.Quantity

Frequency. If float, it should be in GHz.

Tfloat | astropy.units.Quantity

Temperature. If float, it should be in Kelvin.

Returns#

Bnuastropy.units.Quantity

Spectral radiance in u.Jy / u.sr

bowshockpy.radtrans.Inu_func(tau, nu, Tex, Tbg)

Computes the intensity through the radiative transfer equation.

Parameters#

taufloat

Opacity.

nufloat | astropy.units.Quantity

Frequency of the transition. If float, it should be in GHz

Texfloat | astropy.units.quntity

Excitation temperature. If float, it should be in Kelvin.

Tbg: float | astropy.units.Quantity

Background temperature. If float, it should be in Kelvin

Returns#

astropy.units.Quantity

Intensity (energy per unit of area, time, frequency and solid angle)

bowshockpy.rotlinearmol#

This module contains the implementation of the model of a rotational transition of a linear molecule. The assumptions are: Local Thermodynamical Equilibrium, negligible population of vibrational excited states, negligible centrifugal distortions

bowshockpy.rotlinearmol.gJ(J)

Degeneracy of the level J at which the measurement was made. For a linear molecule, g = 2J + 1

Parameters#

Jint

Rotational level

Returns#

int

Degeneracy of the level J

bowshockpy.rotlinearmol.B0J(J, nu)

Rigid rotor rotation constant, being nu the frequency for the transition J-> J-1. For high J an aditional term is needed

Parameters#

Jint

Rotational level

nufloat | astropy.units.Quantity

Frequency of the transition. If float, it should be in GHz

Returns#

float

Rigid rotor rotation constant.

bowshockpy.rotlinearmol.EJ(J, B0)

Energy state of a rigid rotor, neglecting centrifugal distortions

Parameters#

Jint

Rotational level

B0float | astropy.units.Quantity

Rotation constant. If float, it should be in GHz

Returns#

astropy.units.Quantity

Energy state of a rotator

bowshockpy.rotlinearmol.muJ_Jm1(J, mu)

Computes the dipole moment matrix element squared for rotational transition J->J-1

Parameters#

Jint

Rotational level

mufloat | astropy.units.Quantity

Permanent dipole moment of the molecule. If float, it should be in Debye

bowshockpy.rotlinearmol.tau_linearmol(dNmoldv, J, nu, Tex, mu)

Computes the opacity as a function of the column density per channel width for a rotational transition of a linear molecule

Parameters#

dNmoldvfloat | astropy.units.Quantity

Column density per velocity bin dv. If float, it should be in s / km / cm**2

Jint

Rotational level

nufloat | astropy.units.Quantity

Frequency. If float, it should be in GHz.

Texfloat | astropy.units.Quantity

Excitation temperature. If float, it should be in Kelvin

mufloat | astropy.units.Quantity

Permanent dipole moment of the molecule. If float, it should be in Debye

Returns#

float

Opacity

bowshockpy.moments#

This module contains the functions that perform the statistical moments to the spectral cubes

bowshockpy.moments.sumint(cube, chan_range)

Sums all pixels of a cube along the 0 axis.

Parameters#

cubenumpy.ndarray

Input 3 dimensional array.

chan_rangelist

Two element list with the last and first channels used to compute the summation.

Returns#

sumint_imnp.ndarray

2 dimensional array

bowshockpy.moments.mom0(cube, chan_vels, chan_range)

Computes the moment of order 0 of a cube along the 0 axis.

Parameters#

cubenumpy.ndarray

Input 3 dimensional array.

chan_vels: list or numpy.ndarray

1-dimensional array of the velocity corresponding to the channels.

chan_rangelist

Two element list with the last and first channels used to compute the moment.

Return:#

mom0_imnumpy.ndarray

Moment of order 0

References:#

https://www.aoc.nrao.edu/~kgolap/casa_trunk_docs/CasaRef/image.moments.html

bowshockpy.moments.summixvi(cube, chan_vels, chan_range, exp=1)

Computes the summation: sum (m_i * v_i)**exp

Parameters#

cubenumpy.array

Input 3 dimensional array

chan_velslist or numpy.array

1-dimensional array of the velocity corresponding to the channels.

chan_rangelist

Two element list with the last and first channels used to compute the moment.

expint, optional

Exponent, by default 1

Returns#

_type_

_description_

bowshockpy.moments.mom1(cube, chan_vels, chan_range)

Computes the moment of order 1 (intensity weighted mean velocity field) of a cube along the 0 axis.

Parameters#

cubenumpy.ndarray

Input 3 dimensional array.

chan_vels: list or numpy.ndarray

1-dimensional array of the velocity corresponding to the channels.

chan_rangelist

Two element list with the last and first channels used to compute the moment.

Return:#

mom1_imnumpy.ndarray

Moment of 1 order

References:#

https://www.aoc.nrao.edu/~kgolap/casa_trunk_docs/CasaRef/image.moments.html

But note that the equation for the moment 1 is wrong in this reference (units should be km/s, and not an adimensional value). The moment1 is the intensity intensity weighted mean velocity = Sigma m_i v_i/Sigma m_i

bowshockpy.moments.mom2(cube, chan_vels, chan_range)

Computes the moment 2 (the intensity weighted dispersion) of a cube along the 0 axis

Parameters#

cubenumpy.ndarray

Input 3 dimensional array.

chan_vels: list or numpy.ndarray

1-dimensional array of the velocity corresponding to the channels.

chan_rangelist

Two element list with the last and first channels used to compute moment.

Return:#

dispnumpy.ndarray

Moment of 2 order

References:#

https://www.aoc.nrao.edu/~kgolap/casa_trunk_docs/CasaRef/image.moments.html

But note that the equation for the moment 2 is wrong in this reference (units should be km/s, no sqrt(km/s)). The moment2 is intensity weighted dispersion = [Sigma m_i v^2_i/Sigma m_i]**(1/2)

bowshockpy.moments.maxintens(cube, chan_range)

Computes the moment the maximum value of a cube along the along the 0 axis

Parameters#

cubenumpy.ndarray

Input 3 dimensional array

chan_rangelist

Two element list with the last and first channels used to compute the moment

Return:#

maxintens_imnumpy.ndarray

Moment 8 (maximum value along the 0 axis)

References:#

https://www.aoc.nrao.edu/~kgolap/casa_trunk_docs/CasaRef/image.moments.html

bowshockpy.moments.pv(cube, xpv, halfwidth, axis=1)

Computes the Position-Velocity diagram of a cube

Parameters#

cubenumpy.ndarray

Input 3 dimensional array.

xpvint

Pixel along which the PV-diagram is computed.

halfwidthint

Number of pixels around xpv that will be taking into account to compute the PV-diagram.

Return:#

pv_imnumpy.ndarray

PV-diagram.

bowshockpy.plots#

This module contains the tools to plot the bowshock model, the spectral cubes, moments maps and position-velocity diagrams

class bowshockpy.plots.BowshockModelPlot(bsm, modelname='none', nzs=200, figsize=(16, 3), narrows=10, v_arrow_ref=100, linespacing=0.08, textbox_widthratio=0.7, gs_wspace=0.2, gs_hspace=0.4)

Bases: object

Figure including the main parameters of the bowshock model, its morphology and kinematics, and the distribution of the surface density

Parameters:#

bsm~bowshockpy.models.BowshockModel class instance

Instance of the model to plot

modelnamestr, optional

Name of the model to include in the plot

nzsint, optional

Number of points used to compute the model solutions

figsizetuple, optional

Tuple passed to matplotib.pyplot.figure to define the dimensions of the figure

narrowsint, optional

Number of arrows to show in order to indicate the velocity at each symmetrical half of the model.

v_arrow_reffloat, optional

Velocity in km/s to use as reference in the reference arrow

linespacingfloat, optional

Spacing between the text lines

textbox_widthratiofloat, optional

Width ratio of the text ax to pass to GridSpec

gs_wspacefloat, optional

wspace passed to GridSpec

gs_hspacefloat, optional

hspace passed to GridSpec

Attributes:#

nzsint

Number of points used to compute the model solutions

zsnumpy.ndarray

Array of the z-coordinates of the model.

dzsnumpy.ndarray

Increment of z-coordinates between the points.

rsnumpy.ndarray

Array with the radii of the model at each z-coordinate [km].

thetasnumpy.ndarray

Array of the polar angle of the position vector at each point of the model [radians].

vsnumpy.ndarray

Array of the total velocity for each point of the model [km/s].

vrsnumpy.ndarray

Array of the radial component of the velocity at each point of the model [km/s].

vzsnumpy.ndarray

Array of the z-coordinate component of the velocity at each point of the model [km/s].

surfdenssnumpy.ndarray

Array of the surfance density of the shell at each z-coordinate [Msun km-2]

surfdenss_gcm2numpy.ndarray

Array of the surfance density of the shell at each z-coordinate [g cm-2]

axsdict

Dictionary of matplotlib.axes.Axes in the figure

cbaxsdict

Dictionary of matplotlib.axes.Axes of the colorbars in the figure

plot(custom_showtext=None, min_plotvel=None, max_plotvel=None, min_plotdens=None, max_plotdens=None, normdens='log')

Plots the 2D bowshock model

savefig(figname=None, **kwargs)

Saves the plot of the bowhsock model.

Parameters#

fignamestr, optional

Full path name of the figure. If None, the the full path name will be models/{self.modelname}/bowshock_model.pdf. If the folder tree does not exist, it will be created.

kwargsoptional

Keyword arguments into ~matplotlib.pyplot.savefig

class bowshockpy.plots.BowshockObsModelPlot(bsmobs, modelname='none', nzs=150, nphis=150, figsize=(12, 6), linespacing=0.09, textbox_widthratio=0.8, cmap='turbo', minpointsize=0.1, maxpointsize=10, x_obs_arrow=0.98, y_obs_arrow=0.95)

Bases: object

Figure including the main parameters of the bowshock model, its projected morphology, kinematics, and a PV diagram along the symmetry axis with the distribution of the surface density in color code.

Parameters:#

bsm~bowshockpy.models.BowshockModel class instance

Instance of the model to plot

modelnamestr, optional

Name of the model to include in the plot

nzsint, optional

Number of z coordinates used to compute the model solutions

nphisint, optional

Number of phi coordinates used to compute the model solutions

figsize: tuple, optional

Tuple passed to matplotib.pyplot.figure to define the dimensions of the figure

linespacingfloat, optional

Spacing between the text lines

textbox_widthratiofloat, optional

Width ratio of the text ax to pass to GridSpec

cmapstr, optional

Colormap label

minpointsizefloat, optional

Minsize of the points to plot

maxpointsizefloat, optional

Minsize of the points to plot

x_obs_arrowfloat, optional

x-axis coordinate of the reference observer arrow

y_obs_arrowfloat, optional

y-axis coordinate of the reference observer arrow

Attributes:#

nrsint

Number of r coordinates used to compute the model solutions

zsnumpy.ndarray

Array of the z-coordinates of the model.

dzsnumpy.ndarray

Increment of z-coordinates between the points.

rsnumpy.ndarray

Array with the radii of the model at each z-coordinate [km].

thetasnumpy.ndarray

Array of the polar angle of the position vector at each point of the model [radians].

vsnumpy.ndarray

Array of the total velocity for each point of the model [km/s].

vrsnumpy.ndarray

Array of the radial component of the velocity at each point of the model [km/s].

vzsnumpy.ndarray

Array of the z-coordinate component of the velocity at each point of the model [km/s].

surfdenssnumpy.ndarray

Array of the surfance density of the shell at each z-coordinate [Msun km-2]

surfdenss_gcm2numpy.ndarray

Array of the surfance density of the shell at each z-coordinate [g cm-2]

axsdict

Dictionary of matplotlib.axes.Axes in the figure

cbaxsdict

Dictionary of matplotlib.axes.Axes of the colorbars in the figure

plot(custom_showtext=None)

Plots the 2D bowshock model

savefig(figname=None, **kwargs)

Saves the plot of the bowhsock model.

Parameters#

fignamestr, optional

Full path name of the figure. If None, the the full path name will be models/{self.modelname}/bowshock_projected.pdf. If the folder tree does not exist, it will be created.

kwargsoptional

Keyword arguments into ~matplotlib.pyplot.savefig

bowshockpy.plots.plot_channel(cube, chan, arcsecpix, velchans, vmax=None, vmin=None, cmap='inferno', interpolation='bilinear', units='Mass [Msun]', refpix=None, markorigin=True, add_beam=False, bmin=None, bmaj=None, pabeam=None, return_fig_axs=False)

Plots a channel map of a spectral cube

Parameters#

cubenumpy.ndarray()

Spectral cube from which the channel is plotted

chanint

Index of the channel to plot

arcsecpixfloat

Arcseconds per pixel

velchanslist or numpy.ndarray()

Array with the velocities of each channel

vmaxfloat, optional

Maximum value of the colormap. If None (default), the maximum value of the channel is chosen.

vminfloat, optional

Minimum value of the colormap. If None (default), the minimum value of the channel is chosen.

cmapstr, optional

Label of the colormap, by default “inferno”.

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

unitsstr, optional

Units of the values of the cube, by default “Mass [Msun]”

refpixlist, optional

Pixel of reference, by default [0,0]

markoriginboolean, optional

If True, a marker will be plot at [0,0]. Default True.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

bminfloat, optional

Beam minor axis [arcsec]

bmajfloat, optional

Beam major axis [arcsec]

pabeamfloat

Beam position angle [degrees]

return_fig_axsbool, optional

If True, returns the figure, axes of the channel map, and the axes the colorbar. If False, does not return anything.

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs=True.

bowshockpy.plots.plot_channels(cube, arcsecpix, velchans, ncol=4, nrow=4, figsize=None, wspace=0.05, hspace=0.0, vmax=None, vcenter=None, vmin=None, cmap='inferno', interpolation='bilinear', units='Mass [Msun]', xmajor_locator=1, xminor_locator=0.2, ymajor_locator=1, yminor_locator=0.2, refpix=None, markorigin=True, add_beam=False, bmin=None, bmaj=None, pabeam=None, return_fig_axs=False)

Plots several channel map of a spectral cube.

Parameters#

cubenumpy.ndarray()

Spectral cube from which the channel is plotted

arcsecpixfloat

Arcseconds per pixel

velchanslist or numpy.ndarray()

Array with the velocities of each channel

ncolint, optional

Number of columns in the figure, by default 4

nrowint, optional

Number of rows of the figure, by default 4

figsizetuple, optional

Size of the figure. If None, an optimal size will be computed. By default None.

wspacefloat, optional

Width space between the channel plots, by default 0.05

hspacefloat, optional

Height space between the cannel plots, by default 0.0

vmaxfloat, optional

Maximum value of the colormap. If None (default), the maximum value of the channel is chosen.

vcenterfloat, optional

Center value of the colormap. If None (default), the middle vale will be chosen.

vminfloat, optional

Minimum value of the colormap. If None (default), the minimum value of the channel is chosen.

cmapstr, optional

Label of the colormap, by default “inferno”.

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

unitsstr, optional

Units of the values of the cube, by default “Mass [Msun]”

xmajor_locatorfloat, optional

Major locator in x-axis, by default 1

xminor_locatorfloat, optional

Minor locator in x-axis, by default 0.2

ymajor_locatorfloat, optional

Major locator in y-axis, by default 1

yminor_locatorfloat, optional

Minor locator in y-axis, by default 0.2

refpixlist, optional

Pixel of reference, by default [0,0]

markoriginboolean, optional

If True, a marker will be plot at [0,0]. Default True.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

bminfloat, optional

Beam minor axis [arcsec]

bmajfloat, optional

Beam major axis [arcsec]

pabeamfloat

Beam position angle [degrees]

return_fig_axsbool, optional

If True, returns the figure, axes of the channel map, and the axes the colorbar. If False, does not return anything.

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs=True.

bowshockpy.plots.plotpv(pvimage, rangex, chan_vels, ax=None, cbax=None, vmax=None, vcenter=None, vmin=None, cmap='nipy_spectral', interpolation='bilinear', cbarlabel='Intensity [Jy/beam]', return_fig_axs=False)

Plots the Position-Velocity diagram

Parameters#

pvimagenumpy.ndarray

Position velocity diagram to plot.

rangexlist or numpy.ndarray

2 element list or numpy.ndarray corresponding to the physical coordinates of the boundaries of the image in the spatial direction.

chan_velslist or numpy.ndarray

list or numpy.ndarray with the velocities corresponding to the channels

axmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes` instance in which the position velodity diagram is drawn.

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn.

vmaxfloat, optional

Maximum value of the colorbar

vcenterfloat, optional

Center value of the colorbar

vminfloat, optional

Minimum value of the colorbar

cmapstr, optional

Label of the colorbar

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

cbarlabelstr, optional

String with information on the quantity represented in the Position Velocity diagram

return_fig_axsbool, optional

If True, returns the figure, axes of the channel map, and the axes the colorbar. If False, does not return anything.

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs=True.

bowshockpy.plots.plotsumint(sumint, ax=None, cbax=None, extent=None, vmax=None, vcenter=None, vmin=None, cmap='inferno', interpolation='bilinear', cbarlabel='Intensity', add_beam=False, bmin=None, bmaj=None, pabeam=None, markorigin=True, return_fig_axs=False)

Plots the sumation of all the pixels along the velocity axis

Parameters#

sumintnumpy.ndarray

Image of the sumation of all the pixels along the velocty axis.

axmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the position velodity diagram is drawn.

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn.

extentlist

Physical coordinates of the boundaries of the image.

vmaxfloat, optional

Maximum value of the colorbar

vcenterfloat, optional

Center value of the colorbar

vminfloat, optional

Minimum value of the colorbar

cmapstr, optional

Label of the colorbar

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

cbarlabelstr, optional

String with information on the quantity represented in the plot

markoriginboolean, optional

If True, a marker will be plot at [0,0]. Default True.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

bminfloat, optional

Beam minor axis [arcsec]

bmajfloat, optional

Beam major axis [arcsec]

pabeamfloat

Beam position angle [degrees]

return_fig_axsbool, optional

If True, returns the figure, axes of the channel map, and the axes the colorbar. If False, does not return anything.

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs=True.

bowshockpy.plots.plotmom0(mom0, ax=None, cbax=None, extent=None, vmax=None, vcenter=None, vmin=None, cmap='inferno', interpolation='bilinear', cbarlabel='Moment 0 [Jy/beam km/s]', add_beam=False, bmin=None, bmaj=None, pabeam=None, markorigin=True, return_fig_axs=False)

Plots the moment 0

Parameters#

mom0numpy.ndarray

Image of the moment 0.

axmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the position velodity diagram is drawn.

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn.

extentlist

Physical coordinates of the boundaries of the image.

vmaxfloat, optional

Maximum value of the colorbar

vcenterfloat, optional

Center value of the colorbar

vminfloat, optional

Minimum value of the colorbar

cmapstr, optional

Label of the colorbar

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

cbarlabelstr, optional

String with information on the quantity represented in the plot

markoriginboolean, optional

If True, a marker will be plot at [0,0]. Default True.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

bminfloat, optional

Beam minor axis [arcsec]

bmajfloat, optional

Beam major axis [arcsec]

pabeamfloat

Beam position angle [degrees]

return_fig_axsbool, optional

If True, returns the figure, axes of the channel map, and the axes the colorbar. If False, does not return anything.

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs=True.

bowshockpy.plots.plotmom1(mom1, ax=None, cbax=None, extent=None, vmin=None, vmax=None, vcenter=None, extend_cbar='max', bg='black', cmap_ref='jet_r', interpolation='bilinear', cbarlabel='Moment 1 [km/s]', add_beam=False, bmin=None, bmaj=None, pabeam=None, markorigin=True, return_fig_axs_velcmap=False)

Plots the moment 1

Parameters#

mom1numpy.ndarray

Image of the moment 1.

axmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the position velodity diagram is drawn.

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn.

extentlist

Physical coordinates of the boundaries of the image.

vmaxfloat, optional

Maximum value of the colorbar

vcenterfloat, optional

Center value of the colorbar

vminfloat, optional

Minimum value of the colorbar

extend_cbarstr,

Extremum to extend the colorbar: “max” or “min”

bgstr

Color of the background image.

cmap_refstr, optional

Label of the colorbar used for reference.

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

cbarlabelstr, optional

String with information on the quantity represented in the plot

markoriginboolean, optional

If True, a marker will be plot at [0,0]. Default True.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

bminfloat, optional

Beam minor axis [arcsec]

bmajfloat, optional

Beam major axis [arcsec]

pabeamfloat

Beam position angle [degrees]

return_fig_axs_velcmapbool, optional

If True, returns the figure, axes of the channel map, the axes the colorbar, and the colormap created to plot the moment 1. If False, does not return anything.

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs_velcmap=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs_velcmap=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs_velcmap=True.

velcmapmatplotlib.colors.ListedColormap

Colormap created to plot the moment 1

bowshockpy.plots.plotmom2(mom2, ax=None, cbax=None, extent=None, vmin=None, vmax=None, vcenter=None, extend_cbar='max', bg='black', cmap_ref='jet_r', cbarlabel='Moment 2 [km/s]', interpolation=None, add_beam=False, bmin=None, bmaj=None, pabeam=None, markorigin=True, return_fig_axs_velcmap=False)

Plots the moment 2

Parameters#

mom2numpy.ndarray

Image of the moment 2.

axmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the position velodity diagram is drawn.

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn.

extentlist

Physical coordinates of the boundaries of the image.

vmaxfloat, optional

Maximum value of the colorbar

vcenterfloat, optional

Center value of the colorbar

vminfloat, optional

Minimum value of the colorbar

extend_cbarstr,

Extremum to extend the colorbar: “max” or “min”

bgstr

Color of the background image.

cmap_refstr, optional

Label of the colorbar used for reference.

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

cbarlabelstr, optional

String with information on the quantity represented in the plot

markoriginboolean, optional

If True, a marker will be plot at [0,0]. Default True.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

bminfloat, optional

Beam minor axis [arcsec]

bmajfloat, optional

Beam major axis [arcsec]

pabeamfloat

Beam position angle [degrees]

return_fig_axs_velcmapbool, optional

If True, returns the figure, axes of the channel map, the axes the colorbar, and the colormap created to plot the moment 2. If False, does not return anything.

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs_velcmap=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs_velcmap=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs_velcmap=True.

velcmapmatplotlib.colors.ListedColormap

Colormap created to plot the moment 2

bowshockpy.plots.plotmaxintens(maxintens, ax=None, cbax=None, extent=None, vmax=None, vcenter=None, vmin=None, cmap='inferno', interpolation='bilinear', cbarlabel='Moment 8', add_beam=False, bmin=None, bmaj=None, pabeam=None, markorigin=True, return_fig_axs=False)

Plots the maximum value of the pixels along the velocity axis

Parameters#

maxintensnumpy.ndarray

Image of the maximum pixel along the velocty axis.

axmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the position velodity diagram is drawn.

cbaxmatplotlib.axes.Axes, optional

The matplotlib.axes.Axes instance in which the color bar is drawn.

extentlist

Physical coordinates of the boundaries of the image.

vmaxfloat, optional

Maximum value of the colorbar

vcenterfloat, optional

Center value of the colorbar

vminfloat, optional

Minimum value of the colorbar

cmapstr, optional

Label of the colorbar

interpolationstr, optional

Interpolation to pass to matplotlib.pyplot.imshow

cbarlabelstr, optional

String with information on the quantity represented in the plot

markoriginboolean, optional

If True, a marker will be plot at [0,0]. Default True.

add_beambolean, optional

If True, plots a ellipse of the beam size in the left bottom corner.

bminfloat, optional

Beam minor axis [arcsec]

bmajfloat, optional

Beam major axis [arcsec]

pabeamfloat

Beam position angle [degrees]

Returns:#

figmatplotlib.figure.Figure

Figure instance, only return_fig_axs=True

axmatplotlib.axes.Axes

Axes of the channel map, only return_fig_axs=True

cbaxtuple of matplotlib.axes.Axes

Axes of the channel map and the colorbar, only returns if return_fig_axs=True.

bowshockpy.utils#

This module contains the definition of useful tools used in the rest of BowshockPy modules

bowshockpy.utils.formatwarning(message, category, filename, lineno, line)

Custom format of warning compatible with the progress bar

exception bowshockpy.utils.UserError

Bases: Warning

Warning category to interrupt the program

bowshockpy.utils.print_example(example)

Prints one of the available examples of input file to run bowshockpy.

Parameters:#

nexamplestr or int
Number of the example to print. There are 4 examples:
  • Example 1: A redshfted bowshock

  • Example 2: A blueshifted bowshock

  • Example 3: A side-on bowshock

  • Example 4: Several bowshocks in one cube

  • Example 5: Custom computation of opacities and intensities

bowshockpy.utils.list2str(a, precision=2)

Converts a list to a str

Parameters#

alist

List to convert as string

precisionint

Number of decimals to display

bowshockpy.utils.progressbar_bowshock(iteration, total, timelapsed, intervaltime, decimals=1, length=100, fill='─', printend='\r')

Bowshock-like progress bar

Parameters#

iterationint

Current iteraction

totalint

Total iteractions

timelapsedfloat

Current time elapsed

intervaltimefloat

Duration of an iteraction

decimalsint

Number of decimals to show

lengthfloat

Length of the progress bar

fillstr

String to define the filled part of the progress bar

printendstr

End of the progress bar

bowshockpy.utils.make_folder(foldername)

Makes a folder of the model

Parameters#

foldernamestr

Name of the folder of the model

bowshockpy.utils.mb_sa_gaussian_f(maja, mina)

Computes the solid angle of a Gaussian main beam

Parameters:#

majaastropy.units.Quantity

Beam major axis (FWHM)

minaastropy.units.Quantity

Beam minor axis (FWHM)

Returns:#

omega_mastropy.units.sr

Beam solid angle in stereoradians

bowshockpy.utils.gaussconvolve(data, x_FWHM, y_FWHM, pa, return_kernel=False)

Convolves data with a Gaussian kernel

Parameters:#

datanumpy.ndarray

Data to convolve

x_FWHMfloat

Full width half maximum of the Gaussian kernel for the x direction

y_FWHMfloat

Full width half maximum of the Gaussian kernel for the y direction

pafloat

Position angle in degrees

return_kerneloptional, bool

Whether to return the kernel or not

Returns:#

data_convnumpy.ndarray

Convolved data

kernelnumpy.ndarray

Image of the Gaussian kernel. Is returned only if return_kernel = True

bowshockpy.utils.get_color(vel_range, vel, cmap, norm='linear', customnorm=None)

Gets the color that corresponds in a colormap linearly interpolated taking into account the values at the limits.

Parameters:#

vel_rangelist

List with 2 elements defining the range of values to be represented by the colors

velfloat

Value to get the corresponding color from

cmapstr

Colormap label

normoptional, str

Set “linear” for a linear scale, “log” for log scale.

customnormoptional, str

Custom norm from matplotlib.colors

class bowshockpy.utils.VarsInParamFile(params)

Bases: object

This class takes as attributes the keys and values of a dictionary

Parameters#

paramsdict

Input dictionary

bowshockpy.utils.allequal(inputlist)

Checks if all elements of a list or a np.array are equal

Parameters#

inputlistlist

List object to check that all its elements are equal

Returns#

boolean

True if all elements are equal, False if they are not

bowshockpy.utils.make_astropy_units(quantity, astropy_unit)

Transform to astropy.units.Quantity unless it is already an astropy.units.Quantity

Parameters:#

quantityfloat | astropy.units.Quantity

Value to transform to astropy.units.Quantity

astropy_unitastropy.units.Quantity

Unit

Returns:#

astropy.units.Quantity

Input quantity as an astropy.units.Quantity type