Plot the atlas¶
This module holds specialized plotting function for YSOVAR data.
This module hold some plotting functions for YSOVAR data, i.e. lightcurves and color-color or color-magnitude diagrams. All the plotting is done with matplotlib.
Module level variables¶
There are several module level variables, that define defaults for plots.
Default offset of x-axis for lightcurve plots:
YSOVAR.plot.mjdoffset = 55000
List of all formats for output for those routines that make e.g. the lightcurve plot for each source. This has to be a list even if it contains only one element. List multiple formats to obtain each image in each format:
YSOVAR.plot.filetype = ['.eps']
This routine can connect to the internet and download thumbnail images from the YSOVAR database. To do so, you need to set the username and password for the YSOVAR database:
YSOVAR.plots.YSOVAR_USERNAME = 'username'
YSOVAR.plots.YSOVAR_PASSWORD = 'password'
Plotting functions¶
The most important purpose of this module is to provide functions that can
generate a big atlas, which holds some key diagnostic plots (e.g. the
lightcurve, color-mag diagram) for every star in a YSOVAR.atlas.YSOVAR_atlas
object. However, some of the functions are also useful for stand-alone plots.
Functions that generate multiple plots often start with make
and have
a plural name (e.g. YSOVAR.plot.make_lc_plots()
). These function then
call a function that makes the individual plot (and sometimes that is broken
down again into one function that sets up the figure and the axis and a
second one that executes the actual plot command), see
YSOVAR.plot.plot_lc()
and YSOVAR.plot.lc_plot()
.
Use those functions to plot individual lightcurves e.g. for a paper.
-
YSOVAR.plot.
cmd_plot
(atlas, mergedlc, redvec=None, verbose=True)¶ Parameters: atlas : ysovar_atlas.YSOVAR_atlas with one row only
mergedlc : np.ndarray
contains
't'
as time for merged lightcurves and'm36'
and'm45'
as magnitues for lightcurvesredvec : float
slope of reddening vector in the CMD. If
None
use default.
-
YSOVAR.plot.
extraplots_1
()¶ some random plots I was interested in; may or may not be relevant to others. Read the code if you want to know more about this function.
-
YSOVAR.plot.
extraplots_2
(data, infos, outroot_overview)¶ some more random plots I was interested in; may or may not be relevant to others.
Read the code if you want to know more about this function.
-
YSOVAR.plot.
fancyplot
(x, y, outroot, filename, colors, ind, xlabel, ylabel, marker, xlog=False, ylog=False, legendtext='', legendpos='upper right')¶
-
YSOVAR.plot.
get_stamps
(data, outroot, verbose=True)¶ Retrieve stamp images from the YSOVAR2 database
The database requires a login. To get past that set the following variables before calling this routine: - YSOVAR.plot.YSOVAR_USERNAME - YSOVAR.plot.YSOVAR_PASSWORD
Parameters: data : ysovar_atlas.YSOVAR_atlas
needs to contain a column called YSOVAR2_id
outroot : string
directory where the downloaded files will end up
-
YSOVAR.plot.
lc_plot
(catalog, xlim=None, twinx=True)¶ plot one or two lcs for a single object
Parameters: catalog : single row from YSOVAR.atlas.YSOVAR_atlas
contains ‘t1’ and / or ‘t2’ as time for lightcurves and ‘m1’ and / or ‘m2’ as magnitues for lightcurves
xlim : None or list
None auto scales the x-axis list of [x0, x1] scales the xaxis form x1 to x2 list of lists [[x00,x01], [x10, x11], ...] splits in multiple panels and each [x0, x1] pair gives the limits for one panel.
twinx : boolean
if true make seperate y axes for IRAC1 and IRAC2 if both are present
-
YSOVAR.plot.
make_cmd_plots
(atlas, outroot, verbose=True)¶ plot cmds into files for all objects in atlas
Parameters: atlas :
YSOVAR_atlas
contains dict with
't36'
and / or't45'
as time for lightcurves and'm36'
and / or'm45'
as magnitues for lightcurves
-
YSOVAR.plot.
make_info_plots
(infos, outroot, bands=['36', '45'], bandlabels=['[3.6]', '[4.5]'])¶
-
YSOVAR.plot.
make_latexfile
(atlas, outroot, name, ind=None, plotwidth='0.45\\textwidth', output_figs=[['_lc', '_color'], ['_ls', '_sed'], ['_lc_phased', '_color_phased'], ['_stamp', '_lcpoly']], output_cols={'simbad_MAIN_ID': 'ID Simbad', 'YSOVAR2_id': 'ID in YSOVAR 2 database', 'median_36': 'median [3.6]', 'mad_45': 'medium abs dev [4.5]', 'mad_36': 'medium abs dev [3.6]', 'stddev_36': 'stddev [3.6]', 'IRclass': 'Rob class', 'stetson_36_45': 'Stetson [3.6] vs. [4.5]', 'stddev_45': 'stddev [4.5]', 'median_45': 'median [4.5]', 'simbad_SP_TYPE': 'Simbad Sp type'}, pdflatex=True)¶ make output LeTeX file that produces an atlas
This procedure actually checks the directory outroot and only includes Figures in the LaTeX document that are present there. For some stars (e.g. if they only have one lightcurve) certain plots may never be produced, so this strategy will ensure that the LaTeX document compiles in any case. It also means that files, that are not present because you forgot to produce them, will not be present.
Parameters: atlas : ysovar_atlas.YSOVAR_atlas
This is the atlas with the data to be plotted
outroot : string
path to directory where all figures are found. The LeTeX file will be written in the same directory.
name : string
filename of the atlas file (without the .tex)
ind : index array
Only objects in this index array will be included in the LaTeX file. Use None to output the entire atlas.
plotwidth : string
width of the plots in LeTeX notation. It is the users responsibility to ensure that the plots chosen with output_figs fit on the page.
output_figs : list of lists
List of file extensions of plots to be included. Filenames will be of format i + fileextension. This is a list of lists in the form:
`[[fig1_row1, fig2_row1, fig3_row1], [fig1_row2, ...]]`
Each row in the figure grid can have a different number of figures, but it is the users responsibility to choose plotwidth so that they all fit on a page.
output_cols : dictionary
Select columns in the table to print out below the figures. Format is {‘colname’: ‘label’}, where label is what will appear in the LaTeX document.
pdflatex : bool
if True check for files that pdflatex uses (jpg, png, pdf), otherwise for fiels LaTeX uses (ps, eps).
-
YSOVAR.plot.
make_lc_cmd_plots
(atlas, outroot, lc_xlim=None, lc_twinx=False)¶ plot CMDs and lightcurves
See
make_lc_plots()
andmake_cmd_plots()
for documentation.Parameters: atlas :
YSOVAR_atlas
contains dict with
't36'
and / or't45'
as time for lightcurves and'm36'
and / or'm45'
as magnitues for lightcurves
-
YSOVAR.plot.
make_lc_plots
(atlas, outroot, verbose=True, xlim=None, twinx=False, ind=None, filedescription='_lc')¶ plot lightcurves into files for all objects in atlas
Parameters: atlas : ysovar_atlas.YSOVAR_atlas
contains dict with ‘t36’ and / or ‘t45’ as time for lightcurves and ‘m36’ and / or ‘m45’ as magnitues for lightcurves
verbose : boolean
if true print progress in processing
xlim : None or list
None auto scales the x-axis list of [x0, x1] scales the xaxis form x1 to x2 list of lists [[x00,x01], [x10, x11], ...] splits in multiple panels and each [x0, x1] pais gives teh limits for one panel.
twinx : boolean
if true make separate y axes for IRAC1 and IRAC2 if both are present
ind : list of integers
index numbers of elements, only for those elements a lightcurve is created. If None, make lightcurve for all sources.
filedescription : string
Output files are named
YSOVAR2_id + filedescription + extension
. The extension(s) is specified inYSOVAR.plots.filetype
. Use thefiledescription
parameters if this method is called more than once per star.
-
YSOVAR.plot.
make_ls_plots
(atlas, outroot, maxper, oversamp, maxfreq, verbose=True)¶ calculates & plots Lomb-Scargle periodogram for each source
Parameters: atlas :
YSOVAR.atlas.YSOVAR_atlas
input atlas, which includes lightcurves
outroot : string
data path for saving resulting files
maxper : float
maximum period to be used for periodogram
oversamp : integer
oversampling factor
maxfreq : float
maximum frequency to be used for periodogram
verbose : bool
Show progress as output?
-
YSOVAR.plot.
make_phased_lc_cmd_plots
(atlas, outroot, bands=['36', '45'], marker=['o', '+'], lw=[0, 1], colorphase=True, lc_name='_lc_phased')¶ plots phased lightcurves and CMDs for all sources
Parameters: atlas :
YSOVAR_atlas
input atlas, which includes lightcurves
outroot : string
data path for saving resulting files
bands : list of strings
band identifiers
marker : list of valid matplotlib markers (e.g. string)
marker for each band
lw : list of floats
linewidth for each band
lc_name : string
filenames for phased lightcurve plots
colorphase : bool
If true, entries in the lightcurves will be color coded by phase, if not, by time (to see if there are e.g. phase shifts over time).
-
YSOVAR.plot.
make_plot_skyview
(outroot, infos)¶ only for IRAS 20050: plots positions of identified YSOs over all detected sources This code is specific to the cluster IRAS 20050+2720 and should not be used for other regions.
-
YSOVAR.plot.
make_reddeningvector_for_plot
(x1, x2, y1, y2)¶
-
YSOVAR.plot.
make_sed_plots
(infos, outroot, title='SED (data from Guenther+ 2012)', sed_bands={})¶ Plot SEDs for all objects in
infos
Parameters: infos :
YSOVAR_atlas
orastropy.table.Table
This input table holds the magnitudes in different bands that form the points of the SED.
outroot : string
path to an output directory where the plots are saved. Individual files will automatically named according to the YSOVAR id number.
title : string
Title for each plot. Can be an empty string.
sed_bands : dictionary
This dictionary specifies which bands are to be plotted in the SED. See
YSOVAR.atlas.get_sed()
for a description of the format forsed_bands
.
-
YSOVAR.plot.
make_slope_plot
(infos, outroot)¶
-
YSOVAR.plot.
multisave
(fig, filename)¶
-
YSOVAR.plot.
plot_lc
(ax, data, mergedlc)¶ plot lc in a given axes container
Parameters: data : dictionary
contains ‘t36’ and / or ‘t45’ as time for lightcurves and ‘m36’ and / or ‘m45’ as magnitues for lightcurves
-
YSOVAR.plot.
plot_polys
(atlas, outroot, verbose=True)¶ plot lightcurves into files for all objects in data
Parameters: atlas :
YSOVAR_atlas
each ls in the atlas contains
't36'
and / or't45'
as time for lightcurves and'm36'
and / or'm45'
as magnitues for lightcurvesoutroot : string
data path for saving resulting files
verbose : boolean
if true print progress in processing
-
YSOVAR.plot.
setup_lcplot_axes
(data, xlim, twinx=True, fig=None)¶ set up axis containers for one or two lcs for a single object.
This function checks the xlim and divides the space in the figure so that the xaxis has the same scale in each subplot.
Parameters: data : dict
This lightcurve is inspected for the number of bands present
xlim : None or list
None auto scales the x-axis list of [x0, x1] scales the xaxis form x1 to x2 list of lists [[x00,x01], [x10, x11], ...] splits in multiple panels and each [x0, x1] pair gives the limits for one panel.
twinx : boolean
if true make seperate y axes for IRAC1 and IRAC2 if both are present
fig: matplotlib figure instance or ``None`` :
If
None
, it creates a figure with the matplotlib defaults. Pass in a figure instance to customize e.g. the figure size.Returns: fig : matplotlib figure instance
axes : list of matplotlib axes instances
This list holds the default axes (axis labels at the left and bottom).
taxes : list of matplotlib axes instances
This list holds the twin axes (labels on bottom and right).