Getting Started#
Welcome to Astrocook V2! This guide will walk you through the basics of the interface: loading data, exploring your spectra, and managing your analysis sessions.
1. Loading a Spectrum#
Let’s begin by loading some data. Astrocook supports various formats, including standard FITS files and its own archive formats (.acs, .acs2). A .csv file written by File > Export to ASCII… is read back with its columns and units (see below); any other .csv file is read as three columns, by position: wavelength (nm), flux and its error, with or without a line of names on top, and further columns are ignored. A text table with other separators (spaces, tabs) is read by the names of its columns, from a line on top, also commented (# x xmin xmax y dy; the names lam, F, dF and wave, flux, err are understood too), the further columns kept; without names, by position as a .csv file.
Note
The unit of the flux. A spectrum gets a physical unit of the flux only when the file says it: the BUNIT or TUNIT keyword of a FITS file (e.g. erg cm**(-2) s**(-1) angstrom**(-1) in an ESO X-Shooter product, unless its FLUXCAL is UNCALIBRATED), the units of an exported CSV file, or the archives. Otherwise the flux is in arbitrary units, the unit arb_flux of Astrocook: the plot says “arbitrary units”, the iso-magnitude grid is not drawn, and Convert Y axis refuses to convert it. If you know the unit, declare it with Edit > Set Properties… (the field yunit, e.g. 1e-17 erg/(Angstrom s cm^2)): the values are not changed. Flux > Calibrate from Magnitudes gives the flux a physical unit by calibrating it. The archives of Astrocook 1 and the archives whose flux has no unit open in arbitrary units; an archive with a unit keeps it.
Note
The telluric transmission. A spectrum may carry a model of the telluric absorption, the transmission (1 where there is none), in the column telluric: the fits normalize the flux by the continuum times this column, unless the flux is already corrected (Edit > Set Properties…, the field telluric_corrected). It comes from the file: the Molecfit model (mtrans of the TELLURIC_DATA extension) of an ESO X-Shooter product, whose flux is taken as already corrected; the TELLURIC column of a PypeIt telluric model; the trans_molecfit or mtrans column of a text table with the columns of a spectrum (e.g. wave flux error trans_molecfit). A model made elsewhere, such as a Molecfit fit, is brought into a spectrum with File > Import Model… (see External Models). The column called telluric_model (in the archives saved before 2.8.0) is renamed telluric when a spectrum is opened; the boolean telluric column of the archives of Astrocook 1 (the mask of the telluric bands) becomes telluric_mask. The telluric_corr of an ESPRESSO S2D file is kept as it is, outside the normalization.
Launch Astrocook. The window opens with the size and position you left it with, and shows the welcome screen, with the buttons Open Session… and Open Recent (a drop-down menu of the files you opened last).
Click Open Session…, or select File > Open Session… in the menu bar (or press
Ctrl+O/Cmd+O). File > Open Recent lists the files opened last; you can also drop files on the window.Select your spectrum file. You can select multiple files at once if you want to load several observations simultaneously: they are loaded in the background, with a window that shows the progress and can cancel the files not yet opened; the status bar then says how many were opened, and the files that could not be opened are listed together.
Once loaded, the interface will come alive. The central area displays your spectrum, while two sidebars provide control over your data and visualization.
3. Customizing the View (Right Sidebar)#
Click the cog icon at the top right of the plot to open the Plot Controls panel (click it again to close it). Here you can tweak how the data is displayed without altering the data itself.
The panel floats over the plot, so that opening it does not change the aspect of the spectrum. To cover as little as possible, it is only as tall as its contents, and it fades out while the mouse is on the plot: you can see the effect of a change through it. It comes back as soon as the mouse returns to it. Its sections (Plot Elements, View Controls, Axis Limits, Redshift Cursor, Edit Continuum) open and close with a click on their title, and Astrocook remembers which ones you left open.
Plot Elements#
You can show or hide specific layers of the plot. Next to each one, a short sample of the line shows how it is drawn: these samples are the legend of the plot, which has none of its own. The auxiliary column chosen in Auxiliary column has its sample inside the menu, and each other session shown (see below) next to its name in the list of the sessions.
1-sigma error: Shows or hides the error of the flux (grey).
Show error as line: Checked by default: the error array (\(dy\)) is drawn as a line of its own, useful for inspecting the noise structure in high-resolution spectra. Unchecked, the error is drawn as a band around the flux.
Normalization: Hides the continuum level (dashed black line).
Absorption model: Hides the Voigt profile fits (solid green line).
Systems: Hides the tick marks of the fitted components at the bottom of the plot, in two rows: HI (red) below, metals (grey) above.
Auxiliary column: Select an additional data column (e.g.,
abs_mask,running_std) to overlay on the plot.Strong emission lines only: Shows only the major emission lines (e.g., Lyα, C IV), named in spectroscopic notation; unchecked, all the lines of the atomic data, fainter.
Note
This requires defining the emission redshift first (see Setting Session Properties).
Show iso-magnitude grid: Overlays curves of constant AB magnitude.
Note
This requires flux calibration (see Flux Calibration).
Axis Controls#
Units: You can switch the X-axis display between
nm,Angstrom, andmicronon the fly.Normalize F: Plots the flux relative to the continuum (showing \(f = F / F_\mathrm{cont}\)) (this control becomes active only when a
contcolumn is present).Show S/N: Plots the signal-to-noise ratio instead of flux.
Error column: When showing the S/N, you can select which column to use as the noise estimate (default is
dF).
Logarithmic \(\lambda\): Switches the X-axis to a logarithmic scale.
Logarithmic F: Switches the Y-axis to a logarithmic scale, e.g. to see the continuum and the emission lines over several orders of magnitude, or the iso-magnitude grid as straight lines. Pixels with \(F \le 0\) (saturated absorption, noise) are drawn at the bottom of the plot. In the normalized view the axis starts from 0.01, so saturated lines are shown down to 1% of the continuum. A non-positive F Min is not applied while the scale is logarithmic.
Axis Limits#
You can manually set the precise bounds of the plot view. Enter values for \(\lambda\) Min/Max and F Min/Max and press Enter to apply them. These boxes automatically update when you zoom or pan interactively.
The Redshift Cursor#
This is a handy tool for quick visual inspection.
In the Redshift Cursor section, enter a transition name (e.g.,
Ly_a,CIV,MgII) and a redshiftz.Check the Show cursor box.
Vertical dashed lines will appear on the plot indicating where that transition should be found, with their redshift written at the top of the first one. The cursor follows the mouse over the plot; you can also type the
zvalue to place it.
Interactive Setting: You can Right-click directly on the plot background to open a context menu. Select Set Emission Redshift to z=… to instantly update the session’s \(z_{em}\) based on the cursor’s current position.
Note
If the Zoom or Pan tools are active in the toolbar, the right-click shortcut is overridden. In this case, hold Ctrl (or Cmd on Mac) while right-clicking to access the context menu.
Dark Mode and Plot Colours#
By default Astrocook follows the light or dark appearance of your system (on macOS, System Settings > Appearance), and switches with it while it is open. View > Appearance chooses Light or Dark for Astrocook alone, or System to follow the system again; the choice is remembered. The plots stay white in both, like the figures of a paper, so that the colours of the lines are always the same.
View > Plot Colours chooses the colours of the plots, in the main window and in the System Inspector, also remembered. Standard draws the spectrum in blue and the model in green. Colour-blind Safe uses the palette of Okabe and Ito: the spectrum in dark grey, the model in blue, the residuals and the ticks of the HI components in vermilion, a component at a bound of the fit in reddish purple; the selection stays amber. Its colours stay apart for every common type of colour blindness, while in the standard colours the model, the selected component and the residuals of the System Inspector look alike to a deuteranope.
The Continuum Editor#
Located at the bottom of the sidebar, this panel allows you to interactively refine the continuum shape using spline knots. See the Interactive Manual Editing in the Continuum Fitting tutorial for a detailed guide on using the slider, spacing box, and editing tools.
5. Exporting and Importing Data#
Astrocook allows you to easily exchange data with external tools (like spreadsheet managers, Topcat, or custom Python scripts) using standard CSV files.
Export to ASCII#
To save your current data in a human-readable format, go to File > Export to ASCII…. A dialog will appear allowing you to select exactly what to export:
Spectrum (spec): Saves the wavelength (
lam), its pixel edges (lammin,lammax), the flux (F), its error (dF), the continuum (cont) and any other column of the spectrum into a_spec.csvfile. The wavelength is always written; the other columns can be chosen one by one.System List (systems): Saves your identified absorption lines (including Redshift, Column Density, Doppler Parameter, etc.) into a
_systems.csvfile.
The _spec.csv file is in ECSV, the CSV format of astropy: a header of lines starting with # gives the unit of each column and the emission redshift, then come the names of the columns and the values, separated by commas. Opened again in Astrocook (File > Open Session…), it gives back the columns, their units and \(z_\mathrm{em}\); astropy reads it with Table.read(path, format="ascii.ecsv"), pandas with pandas.read_csv(path, comment="#"). The files written by earlier versions (columns x, y, dy, …, no units) are read by the names of their columns, with the flux in arbitrary units.
You can choose to export entire structures or pick individual columns. The suggested filename will automatically adjust based on your selection, and Astrocook will warn you if you are about to overwrite existing files. An item that is neither a column nor spec or systems (e.g. cont before a continuum is estimated) is skipped, and a warning in the log names it.
Export Log as Text#
File > Export Log as Text… writes the session log as the text of a methods section, in English, ready to paste in a paper: a first paragraph on the spectrum and the version of Astrocook, then one paragraph per recipe (the reason given for it, if any, e.g. by an AI agent; what it did, with its parameters and the works it relies on; what it changed, e.g. the components added and the largest changes of a refit; the notes written at that point), then the Voigt fit and the sources of the atomic data of the transitions fitted (see Atomic Data), and the references. The recipes undone are left out. Each recipe is followed by its menu in parentheses, to rerun it in the GUI; uncheck Name the menus of the recipes for a paper. Copy puts the text in the clipboard, Save… writes it to a text file. The text is a draft to edit: it says what was done, not why it is right.
For a session just opened from an archive, the log says which recipes were run and with which parameters, but not what each one changed: the text says so for those steps.
Import from ASCII#
If you have manipulated your exported _spec.csv data externally, you can bring it back into Astrocook by going to File > Import from ASCII….
Astrocook will match the column headers in your CSV to the columns in the active session and overwrite them; the names of the GUI (
F,dF, …) and those of the data (y,dy, …) are both understood. The wavelength (lam,lammin,lammax, orx,xmin,xmax) is not imported: the grid of the spectrum is kept. A column with a unit in the file keeps it; a flux or an error in a unit different from that of the session is refused.Safety first: The imported file must have the exact same number of rows (pixels) as your current spectrum, and its wavelength, if it has one, must be that of the spectrum (within a tenth of a pixel): a table on another grid is refused (to bring a model onto the grid of the spectrum, use File > Import Model…, see External Models). The log names the columns of the spectrum that the file replaced. Because this operates through the recipe pipeline, the import is fully undoable via the Log Scripter or
Ctrl+Z(Cmd+Z).
6. The Dialog of a Recipe#
Every entry of the menus Edit, Flux, Continuum and Absorbers that ends in ... opens the dialog of a recipe, titled with the label of the entry (Absorbers > Auto-detect Doublets… opens Recipe: Auto-detect Doublets). The dialog describes the recipe and its parameters; the Help button opens the page of this documentation that explains it (the section of the tutorial for the recipe, e.g. Masking Data for Mask by Expression). The session log and the text of the methods (File > Export Log as Text…) name the recipe by the same label.
7. When Something Goes Wrong#
A recipe that cannot run says why: in the status bar, in a dialog, and in the log written to the terminal (or to the window of the long recipes). A recipe that gives a result but has something to say about it (a parameter at a bound, a step done with its defaults) lists its warnings at the end.
An error that Astrocook does not expect is a bug. It is shown in an Unexpected Error dialog with the message; Show Details… opens the traceback, which you can copy and attach to an issue on GitHub. Astrocook goes on after it, but the action that failed was not completed.
What’s Next?#
Now that you are comfortable with the interface, you are ready to manipulate your data. Check out the Editing Data tutorial to learn how to clean up your spectra.