astrocook.methods_text module#
The log of a session as the text of a methods section (phase 6-ter, PR 5c).
methods_text() writes what was done to a session as English text, to
paste in the methods section of a paper (decision 5 of phase 6-ter): an
opening paragraph, one paragraph per recipe of the log, a closing paragraph
on the fit and the atomic data, and the references.
A paragraph of a recipe is made of:
the reason given for the recipe (
LogEntry.reason, e.g. by an agent through the MCP server), as written;what the recipe did, from the key
methodsof the registry (a template of its parameters, or a function of them), with the menu of the recipe in parentheses (menus=Falseleaves it out), and the parameters the text does not quote that differ from their defaults;what the recipe changed, from the comparison of the state before and after it (
compare_sessions(), asRecipeResultdoes): the components added, removed and changed, the columns, the pixels; and the warnings the fit left on the components;the notes written at its state (
LogNote: notes and gaps declared, as written; the gaps seen by the MCP server are for the development and are left out).
The recipes undone are left out. The text is made from the log each time it
is asked for, never stored: a better wording reaches the sessions saved
before it. Nothing here names a recipe: a recipe added to the registry with
its methods is described with no code here, one without it with a
generic sentence.
- astrocook.methods_text.REFERENCES: Dict[str, Tuple[str, str]] = {'Astrocook': ('doi:10.5281/zenodo.1346736', 'Astrocook, Zenodo, doi:10.5281/zenodo.1346736'), 'BB19': ('Boisse & Bergeron 2019', 'Boisse P., Bergeron J. 2019, A&A 622, A140'), 'C26': ('Cupani et al. 2026', 'Cupani G. et al. 2026, Proc. SPIE 14155, 141551X, doi:10.1117/12.3101756'), 'K14': ('Kisielius et al. 2014', 'Kisielius R. et al. 2014, ApJ 780, 76'), 'K15': ('Kisielius et al. 2015', 'Kisielius R. et al. 2015, ApJ 804, 76'), 'M03': ('Morton 2003', 'Morton D. C. 2003, ApJS 149, 205'), 'PA04': ('Petitjean & Aracil 2004', 'Petitjean P., Aracil B. 2004, A&A 422, 523'), 'SciPy': ('Virtanen et al. 2020', 'Virtanen P. et al. 2020, Nature Methods 17, 261'), 'V1': ('the table of Astrocook 1, original source not recorded', None), 'V2': ('the table of Astrocook 2.0-2.1, original source not recorded', None), 'VPFIT': ('the atom.dat file of VPFIT; Carswell & Webb 2014', 'Carswell R. F., Webb J. K. 2014, Astrophysics Source Code Library, ascl:1408.015'), 'dynesty': ('Speagle 2020', 'Speagle J. S. 2020, MNRAS 493, 3132'), 'emcee': ('Foreman-Mackey et al. 2013', 'Foreman-Mackey D. et al. 2013, PASP 125, 306')}#
key -> (the citation in the text, the entry of the list of references). The keys of the atomic data are those of the table (
astrocook/data/atomic_data.ecsv, docs page Atomic Data); a test checks that every key of the table is here.- Type:
The works the texts cite
- astrocook.methods_text.SOFTWARE_REFERENCE = 'Astrocook'#
The key of the reference to Astrocook itself (its DOI), cited by every text; the algorithms are cited as C26 by the recipes that use them
- astrocook.methods_text.FIT_REFERENCE = 'SciPy'#
The key whose presence among the references of the recipes run says that Voigt profiles were fitted (the closing paragraph says how)
- astrocook.methods_text.COLUMN_NAMES: Dict[str, str | None] = {'abs_ids': None, 'abs_mask': 'the mask of the absorbed pixels', 'cont': 'the continuum', 'cont_pl': 'the power-law continuum (cont_pl)', 'dy': 'the error of the flux', 'fit_mask': None, 'model': 'the model', 'resol': None, 'x': 'the wavelengths', 'y': 'the flux'}#
not named (they follow from what the text says, e.g. the resolution of Set properties)
- Type:
How the text names the columns of the spectrum; None
- astrocook.methods_text.FLAG_NAMES: Dict[str, str] = {'b_at_lower_bound': 'b at the lower bound of the fit', 'b_at_upper_bound': 'b at the upper bound of the fit', 'logN_at_lower_bound': 'log N at the lower bound of the fit', 'logN_at_upper_bound': 'log N at the upper bound of the fit', 'nan_errors': 'no uncertainties (they could not be computed)', 'not_fitted': 'the values from before the fit (the fit of the group failed)', 'z_at_window': 'z at the edge of the window of the fit'}#
How the text names the flags the fit leaves on the components (
voigt_fitter.COMPONENT_FLAGS, andnot_fittedof Refit all)
- astrocook.methods_text.NOTES_LEFT_OUT = ('gap_seen',)#
The kinds of notes left out of the text
- astrocook.methods_text.fmt(value: Any) str[source]#
A value of a parameter as the text writes it:
5000.0as5000, a list as its items separated by commas.
- astrocook.methods_text.given(value: Any) bool[source]#
The value says something: not None, empty, ‘None’ or ‘_current_’.
- class astrocook.methods_text.MethodsValues(params: Dict[str, Any], menu: str = '')[source]#
Bases:
objectThe parameters of a log entry, as the
methodsof the registry read them:p['kappa']is the value as text (fmt()),p.raw('kappa')the value as logged,p.menuthe menu of the recipe in parentheses (with a space before it) or “”. The parameters read are remembered: the others that differ from their defaults are listed after the text.- used: set#
- astrocook.methods_text.REGION_WORDS = {'all_ly_forest': 'in the Lyman forest (from the Lyman limit to Lyman-alpha)', 'lya_forest': 'in the Lyman-alpha forest', 'red_side': 'redward of the Lyman-alpha emission'}#
The regions of the spectrum, as the parameters name them
- astrocook.methods_text.region_words(region: Any, before: str = ' ') str[source]#
`` redward of the Lyman-alpha emission`` for
'red_side'; “” for no region.
- astrocook.methods_text.fit_bounds(p: MethodsValues) str[source]#
b <= 50 km/s, log N <= 19 and the redshift free within +-20 km/s, from the parametersmax_b,max_logNandz_window_kmsthat the recipe has.
- astrocook.methods_text.mask_words(p: MethodsValues) str[source]#
The mask of the absorbed pixels that a recipe used (its parameter
mask, andmask_colif it has one).
- astrocook.methods_text.file_name(p: MethodsValues, name: str) str[source]#
The name of a file, without its folder (which may say who the user is, and means nothing to the reader).
- class astrocook.methods_text.MethodsParagraph(text: str, kind: str, recipe: str | None = None, entry: int | None = None)[source]#
Bases:
objectA paragraph of the text.
- text: str#
- kind: str#
opening,step(a recipe of the log),note(notes written before the first recipe) orclosing
- recipe: str | None = None#
The recipe of a step, as
category.name
- entry: int | None = None#
The index of the log entry of a step
- __init__(text: str, kind: str, recipe: str | None = None, entry: int | None = None) None#
- class astrocook.methods_text.MethodsText(paragraphs: Tuple[MethodsParagraph, ...], references: Tuple[str, ...])[source]#
Bases:
objectThe text of the methods of a session (
methods_text()).- paragraphs: Tuple[MethodsParagraph, ...]#
- references: Tuple[str, ...]#
The list of references, one entry each, sorted
- property text: str#
The paragraphs separated by blank lines, then the references.
- __init__(paragraphs: Tuple[MethodsParagraph, ...], references: Tuple[str, ...]) None#
- astrocook.methods_text.series_list(text: str) str[source]#
A list of series separated by commas (a parameter, e.g.
'CIV,SiIV,MgII') asC IV, Si IV and Mg II.
- astrocook.methods_text.series_name(series: str) str[source]#
A series as a paper writes it:
CIVasC IV,CIV_1548asC IV 1548,Ly_aasLy-alpha.
- astrocook.methods_text.changes_text(before, after) List[str][source]#
What changed from the state
beforetoafter, in sentences.
- astrocook.methods_text.atomic_data_sentence(state) Tuple[str | None, List[str]][source]#
Where the atomic data of the transitions of the components of
statecome from, and the keys of the works it cites. Only the transitions that fall in the spectrum are counted (all, if the x axis is not a wavelength).
- astrocook.methods_text.methods_text(source, *, menus: bool = True) MethodsText[source]#
The log of a session as the text of a methods section.
- Parameters:
source (SessionHistory or Session) – A history (the states and the log, as the GUI and the MCP server keep them), or a session alone: then only the log is known, not what each recipe changed.
menus (bool) – Name the menu of each recipe, in parentheses (for who reruns the analysis in the GUI; not for a paper).
- Returns:
The paragraphs and the references;
.text(orstr()) is the text.- Return type: