ScatterPPV#
- class mufasa.visualization.scatter_3D.ScatterPPV(parafile, fittype, vrange=None, verr_thres=5, meta_model=None)[source]#
Bases:
objectA class to plot the fitted parameters in 3D scatter plots. Most of the data is stored in a pandas DataFrame.
- Parameters:
parafile (str) – Path to the .fits file containing the MUFASA generated parameter maps.
fittype (str) – The name of the fit model, e.g., “nh3_multi_v” or “n2hp_multi_v”.
vrange (tuple of float, optional) – Velocity range to clip the data (in km/s). Data outside this range is excluded. Default is None.
verr_thres (float, optional) – Velocity error threshold (in km/s) to filter out data with higher errors. Data with a velocity error greater than this threshold is excluded. Default is 5.
Examples
Initialize the ScatterPPV object and plot the position-position-velocity (PPV) scatter plot:
>>> sc = scatter_3D.ScatterPPV("path/to/fname.fits", fittype="nh3_multi_v") >>> sc.plot_ppv(savename='monR2.html', vel_scale=0.5)
- add_peakI()[source]#
Calculate and add a peak intensity value for each model point in the DataFrame.
- Parameters:
nu (float, optional) – Reference frequency (in GHz) to estimate the peak intensity. If not provided, defaults to the rest_freq attribute.
- Return type:
None
- add_wcs_del(ra_ref=None, dec_ref=None, unit='arcmin')[source]#
Calculate relative RA & Dec coordinates and add them to the DataFrame as columns.
- Parameters:
ra_ref (float, optional) – Reference RA value to calculate relative RA. If not provided, uses the minimum RA in the data.
dec_ref (float, optional) – Reference Dec value to calculate relative Dec. If not provided, uses the minimum Dec in the data.
unit ({'arcmin', 'arcsec'}, optional) – Units for delta RA & Dec. Use ‘arcmin’ to plot in arcminutes or ‘arcsec’ for arcseconds. Default is ‘arcmin’.
- Return type:
None
- plot_ppv(label_key='peakT', vel_scale=0.8, xyunit='arcmin', savename=None, **kwargs)[source]#
Plot the fitted model in position-position-velocity (PPV) space as a 3D scatter plot.
Points in the PPV plot are colored based on a specified key (e.g., intensity values) from the DataFrame. The velocity axis can be scaled relative to the spatial axes, and units for the x and y axes can be customized.
- Parameters:
label_key (str, default='peakT') – Column name in the DataFrame used for coloring data points. For example, ‘peakT’ for peak intensity or clustering labels.
vel_scale (float, default=0.8) – Scaling factor for the velocity axis (z-axis) relative to the spatial axes. The x-axis is normalized to 1.
xyunit ({'arcmin', 'pix'}, default='arcmin') – Units for the x and y coordinates: - ‘arcmin’: Plot relative RA and Dec in arcminutes. - ‘pix’: Plot coordinates in pixels.
savename (str, default=None) – File path to save the generated plot as an HTML file. If None, the plot is not saved.
**kwargs (dict) –
Additional keyword arguments passed to the scatter_3D_df function. Useful options include:
- auto_open_htmlbool, default=True
If True, automatically open the saved HTML file in a browser.
- mask_dfpandas.Series or None, default=None
Boolean mask to filter the DataFrame before plotting.
kwargs (dict) – Additional options for customizing the scatter plot, such as color mapping and opacity scaling.
- Returns:
fig – A 3D scatter plot figure representing the PPV data.
- Return type:
plotly.graph_objs.Figure
Notes
If label_key is “peakT”, default color mapping (“magma_r”) and opacity ranges are applied automatically.
The velocity axis range is derived from the 1st and 99th percentiles of the “vlsr” column, with additional padding.
Color scaling uses the 1st and 99th percentiles of the column specified by label_key.
Examples
>>> model.plot_ppv(label_key='peakT', vel_scale=0.9, xyunit='pix', savename='ppv_plot.html') >>> model.plot_ppv(label_key='cluster_label', auto_open_html=False, mask_df=mask)
See also
scatter_3D_dfFunction used internally for generating the scatter plot.