Data reference

This page gives the columns and the units of the main readers of artistools, and the mistakes that are easy to make with them. The text comes from the artis-data skill for a large language model (LLM) agent (see “Use with an LLM agent” on the home page). Thus the instructions are for the agent, e.g. “give the number of cells that you used”. The test test_artis_data_skill_examples_run_on_the_test_model runs each Python example of the skill, thus each example of this page, on a test model.

Most columns use cgs units. Some columns give their unit at the end of the name, e.g. _Lsun or _kmps. Each section below gives the unit of each column, e.g. f_lambda is per Å and not per cm.

Estimators: the values of each cell at each time step

at.scan_estimators(modelpath, timestep=..., modelgridindex=..., join_modeldata=False) gives a LazyFrame with one row for each time step and cell. If you give timestep or modelgridindex, artistools reads less data and is faster. The main columns are:

  • Te (electron temperature, K), TR (radiation temperature, K), TJ (J temperature, K), and W (dilution factor);

  • nne (free electron density, cm^-3);

  • nnelement_<El>, nnion_<El>_<ion stage>, and nniso_<nuclide> (number densities, cm^-3);

  • heating_<process>, cooling_<process>, and deposition_<particle> (rates, erg/s/cm^3). A column with / in its name, e.g. heating_heating_dep/total_dep, is a ratio and not a rate.

To get a table of each column of a model with its units and a description, run artistools plotestimators --listvariables --print-data --quiet <modelpath>. join_modeldata=True adds these columns:

  • tmid_days (the mid time of the time step);

  • rho (density at that time, g/cm^3), volume (cm^3), and volume_prevtimestep (the volume at the time step before, cm^3);

  • mass_g (the mass of the cell);

  • init_<column> (a value of model.txt at the start time of the model).

Possible errors:

  • The estimators hold only the cells that contain matter. Thus the number of rows can be less than the number of cells in model.txt. Give the number of cells that you used.

  • ARTIS limits Te and the other temperatures to the range from MINTEMP to MAXTEMP. A temperature at a limit is not a physical value. Get the limits with at.misc.get_artis_option(modelpath, "MINTEMP"). It reads artisoptions.h in the model folder. If that file does not exist, it reads artis/artisoptions.h. Give the number of cells at each limit.

  • If a rate column of heating_, cooling_, or deposition_ has no value, the rate is 0. ARTIS writes no value for a rate of 0. Do not include a ratio column in a sum of the rates.

  • ARTIS writes the Monte Carlo deposition rate of time step n into the row of time step n + 1. It divides the rate by the volume of time step n. Thus the row of n + 1 gives the rate of time step n in erg/s/cm^3. For the rate of the cell in erg/s, multiply that value by volume_prevtimestep. The last time step has no Monte Carlo rate.

  • deposition_gamma always holds a Monte Carlo rate, and deposition_spfission always holds an analytic rate. An analytic rate is for the time step of its own row. The positrons, the electrons, and the alpha particles have an analytic rate if PARTICLE_THERMALISATION_SCHEME is INSTANTFULLDEPOSITION, or if INSTANT_PARTICLE_DEPOSITION is true in an older ARTIS. at.estimators.deposition.get_configured_analytic_channels(modelpath) gives these channels.

  • A statistic without a weight gives the same weight to a small outer cell and to a large inner cell. If the user asks for a typical value, also give a mean with the weight mass_g.

Example: the range of a column at a time.

import artistools as at
import polars as pl

modelpath = "."
column = "Te"
timestep = at.get_timestep_of_timedays(modelpath, 10)

dfcells = (
    at
    .scan_estimators(modelpath, timestep=timestep, join_modeldata=True)
    .select("modelgridindex", "tmid_days", "mass_g", column)
    .collect()
)
print(
    dfcells.select(
        pl.len().alias("cellcount"),
        pl.col("tmid_days").first(),
        pl.col(column).min().alias("min"),
        pl.col(column).quantile(0.05).alias("q05"),
        pl.col(column).median().alias("median"),
        pl.col(column).quantile(0.95).alias("q95"),
        pl.col(column).max().alias("max"),
        ((pl.col(column) * pl.col("mass_g")).sum() / pl.col("mass_g").sum()).alias("massweightedmean"),
    )
)
for limitname in ("MINTEMP", "MAXTEMP"):
    limit = at.misc.get_artis_option(modelpath, limitname)
    if limit is None:
        print(f"The artisoptions.h of the model gives no {limitname}.")
    else:
        atlimitcount = dfcells.filter(pl.col(column) == float(limit)).height
        print(f"{limitname} = {limit}: {atlimitcount} cells")

Ionisation

The estimators give the ionisation state of each element in each cell:

  • nnion_<El>_<ion stage> is the number density of an ion (cm^-3). The ion stage is a Roman numeral, e.g. IV in nnion_Fe_IV. The ion charge is the ion stage minus 1. at.decode_roman_numeral("IV") gives 4.

  • The ion fraction is nnion_<El>_<ion stage> / nnelement_<El>.

  • The mean charge of an element is the sum of the charge times the ion fraction, over the ions of the element.

  • gamma_R_<ion> (photoionisation, s^-1) and gamma_NT_<ion> (non-thermal ionisation, s^-1) are the rates of ionisation from that ion. Thus the top ion has no such column. Alpha_R_<ion> (cm^3/s) is the coefficient of recombination from that ion to the ion below it. Alpha_R*nne_<ion> (s^-1) is that coefficient times nne.

Possible errors:

  • ARTIS includes only the ions that compositiondata.txt gives. at.get_composition_data(modelpath) gives the columns Z, lowermost_ion_stage, and uppermost_ion_stage. ARTIS cannot ionise an element above its top ion. Thus a large fraction in the top ion shows that the true ionisation can be higher. A mean charge equal to the charge of the top ion is a lower limit and not a physical value. Give the number of cells where the top ion holds most of the element.

  • To get the ion fraction of a group of cells, divide the number of ions by the number of atoms of the element. Use the weight volume from join_modeldata=True. A mean of the ion fractions of the cells gives the same weight to a cell with few atoms and to a cell with many atoms.

  • An element with nnelement_<El> = 0 in a cell has no ion fraction there. Do not include such a cell.

Example: the ion fractions of Fe in all the cells, the mean charge of each cell, and the cells at the top ion.

import artistools as at
import polars as pl

modelpath = "."
element = "Fe"
timestep = at.get_timestep_of_timedays(modelpath, 10)

elementcol = f"nnelement_{element}"
lfcells = at.scan_estimators(modelpath, timestep=timestep, join_modeldata=True)
ioncols = [col for col in lfcells.collect_schema().names() if col.startswith(f"nnion_{element}_")]
ioncharges = {col: at.decode_roman_numeral(col.removeprefix(f"nnion_{element}_")) - 1 for col in ioncols}
topioncol = max(ioncharges, key=ioncharges.__getitem__)
dfcells = (
    lfcells
    .filter(pl.col(elementcol) > 0)
    .select("modelgridindex", "tmid_days", "volume", elementcol, *ioncols)
    .with_columns(
        meancharge=pl.sum_horizontal(charge * pl.col(col) for col, charge in ioncharges.items()) / pl.col(elementcol)
    )
    .collect()
)
print(
    dfcells.select([
        ((pl.col(col) * pl.col("volume")).sum() / (pl.col(elementcol) * pl.col("volume")).sum()).alias(
            col.removeprefix("nnion_")
        )
        for col in ioncols
    ])
)
print(
    dfcells.select(
        pl.len().alias("cellcount"),
        pl.col("tmid_days").first(),
        pl.col("meancharge").min().alias("min"),
        pl.col("meancharge").median().alias("median"),
        pl.col("meancharge").max().alias("max"),
    )
)

dfcomposition = at.get_composition_data(modelpath).filter(pl.col("Z") == at.get_atomic_number(element))
topstage = dfcomposition["uppermost_ion_stage"].item()
attopcount = dfcells.filter(pl.col(topioncol) > 0.5 * pl.col(elementcol)).height
topion = at.get_ionstring(at.get_atomic_number(element), topstage)
print(f"top ion: {topion}. It holds most of {element} in {attopcount} cells.")

artistools plotestimators --plot "Fe IV" "Fe V" ionpoptype=elpop --plot averageionisation Fe -t 10 <modelpath> plots the ion fractions and the mean charge against the velocity. Use it to check a result.

Ionisation processes

The estimators give two rates of ionisation for each ion except the top ion:

  • gamma_R_<ion> (s^-1) is the photoionisation rate of each ion of <ion>. ARTIS adds the rates of the levels that it can ionise, with a correction for stimulated recombination. The rate does not include collisional ionisation.

  • gamma_NT_<ion> (s^-1) is the non-thermal ionisation rate of each ion, from the fast electrons of the radioactive decays. ARTIS calculates it from the Spencer-Fano solution or from the work-function approximation. One non-thermal ionisation can remove more than one electron.

Possible errors:

  • ARTIS writes gamma_NT_ only if non-thermal ionisation is on. Without it, the model has no non-thermal ionisation.

  • The more important process can be different for each ion and for each region. Give the answer for each ion that holds much of the element, e.g. Fe II and Fe III. For a question about a region, select its cells, e.g. with vel_r_mid from join_modeldata=True.

Example: the ionisations per second by each process for each ion at a time.

import artistools as at
import polars as pl

modelpath = "."
timestep = at.get_timestep_of_timedays(modelpath, 50)
lfcells = at.scan_estimators(modelpath, timestep=timestep, join_modeldata=True)
columns = lfcells.collect_schema().names()
# the top ion has no ionisation rate, thus each rate column names the lower ion of the process
ions = sorted(
    {col.removeprefix("gamma_R_") for col in columns if col.startswith("gamma_R_")}
    & {col.removeprefix("gamma_NT_") for col in columns if col.startswith("gamma_NT_")}
)
if not ions:
    print("This model has no gamma_R or no gamma_NT columns. ARTIS writes gamma_NT only with non-thermal ionisation.")
else:
    # the ionisations per second in all the cells: the rate per ion times the ion density times the volume
    dftotals = lfcells.select(
        *(
            (pl.col(f"{process}_{ion}") * pl.col(f"nnion_{ion}") * pl.col("volume")).sum().alias(f"{process}_{ion}")
            for process in ("gamma_R", "gamma_NT")
            for ion in ions
        ),
        pl.col("tmid_days").first(),
    ).collect()
    dfions = pl.DataFrame({
        "ion": ions,
        "photoionisations_per_s": [dftotals[f"gamma_R_{ion}"].item() for ion in ions],
        "nonthermal_ionisations_per_s": [dftotals[f"gamma_NT_{ion}"].item() for ion in ions],
    }).with_columns(
        nonthermal_fraction=pl.col("nonthermal_ionisations_per_s")
        / (pl.col("photoionisations_per_s") + pl.col("nonthermal_ionisations_per_s"))
    )
    print(f"time step {timestep}, mid time {dftotals['tmid_days'].item():.1f} days")
    with pl.Config(tbl_rows=-1):
        print(dfions)

NLTE level populations

at.nltepops.read_nltepops(modelpath, timestep=..., modelgridindex=...) gives the level populations that ARTIS calculates out of local thermodynamic equilibrium (non-LTE, or NLTE). It gives a DataFrame with the columns timestep, modelgridindex, Z, ion_stage, level, n_LTE, and n_NLTE. n_NLTE is the number density of the level (cm^-3). n_LTE is a Boltzmann population relative to the NLTE population of the ground level. Thus n_NLTE / n_LTE is 1 at the ground level, and it gives the departure from a Boltzmann distribution inside the ion.

Possible errors:

  • Only a model that wrote the files nlte_*.out has these data. artistools needs minutes to read a large model. Thus give a time step and the cells.

  • A row with level = -1 is a superlevel. It holds the levels above the highest NLTE level of its ion, up to the last level that ARTIS keeps. The top ion has only its ground level.

  • The sum of n_NLTE over the levels of an ion can be different from nnion_. Use nnion_ for the ion fraction.

Model data: the cells of model.txt

at.scan_modeldata(modelpath, get_elemabundances=False) gives a tuple. The first item is a LazyFrame with one row for each cell. The second item is a dict of the model parameters. Each value of model.txt is at the start time of the model, t_model_init_days. The columns are:

  • inputcellid and modelgridindex (the index of the cell in the estimators);

  • rho (3D and 2D, g/cm^3) or logrho (1D, the log10 of the density);

  • the position columns, which change with the coordinates of the model:

    • vel_r_max_kmps (1D spherical, km/s);

    • pos_rcyl_mid and pos_z_mid (2D cylindrical, the mid-point of the cell, cm);

    • pos_x_min, pos_y_min, and pos_z_min (3D Cartesian, the corner of the cell, cm);

    • no position column (2D spherical and 3D spherical). The parameters hold the edges of the cells, see below;

  • X_<nuclide> (the mass fractions of the radioactive nuclides, e.g. X_Ni56) and X_Fegroup;

  • X_<El> (the mass fractions of the elements). Give get_elemabundances=True to read these columns. They come from abundances.txt, or from the columns of a model.txt of format version 2 (see below).

at.add_derived_cols_to_modeldata(dfmodel, modelmeta=modelmeta) calculates more columns from these values. Examples are rho and logrho for each number of dimensions, mass_g, volume, and the velocities, e.g. vel_r_mid (cm/s) and vel_r_mid_on_c. Call it before you filter the rows. A 1D cell takes its inner velocity from the row before it.

The main parameters are t_model_init_days, vmax_cmps (cm/s), dimensions, npts_model (the number of cells), and coordinates. The value of coordinates is spherical1d, cylindrical2d, cartesian3d, spherical2d, or spherical3d. Use coordinates to select the code for a model. Each of the values 2 and 3 of dimensions has two possible values of coordinates.

The parameter formatversion is 1 or 2. A model.txt of format version 2 starts with the line format_version 2. Its header gives the cell edges of each axis, and its cell ids (inputcellid) start at 0. Such a model has no abundances.txt: the mass fraction of an element is the sum of its nuclide columns and of its column X_<element>_otherstable, and scan_modeldata(..., get_elemabundances=True) gives that sum. For such a file, the parameters also hold the lists of the edges, e.g. vel_r_edges_kmps or vel_x_edges_kmps. The columns of a 1D, a 2D cylindrical, or a 3D Cartesian model are the same for the two versions.

A version 2 model also has no Ye.txt, because the column Ye of model.txt gives the electron fraction. The columns X_Fegroup, X_Ni56, X_Co56, X_Fe52, and X_Cr48 are optional in a version 2 file. scan_modeldata gives such a column with the value 0 if the file does not have it, because sn3d uses 0 for an absent column.

A model with the coordinates spherical2d or spherical3d has version 2 only. Its parameters are vel_r_edges_kmps, costheta_edges, and, for spherical3d, phi_edges_radians. Each list holds the edges of the cells on one axis. costheta_edges holds the cosine of the polar angle theta from the +z axis, from -1 to 1, and the azimuthal angle is phi = atan2(y, x). The index of a cell is i_r + n_r * (i_costheta + n_costheta * i_phi). For such a model, add_derived_cols_to_modeldata gives these columns:

  • vel_r_min, vel_r_mid, and vel_r_max;

  • costheta_min and costheta_max;

  • phi_min_radians and phi_max_radians (spherical3d only);

  • the velocity of the mid-point of the cell: vel_rcyl_mid and vel_z_mid, and for spherical3d also vel_x_mid and vel_y_mid.

A cylindrical2d, spherical2d, or spherical3d model of version 2 can have the parameter mirror_plane with the value z=0. Its file then holds the cells with z >= 0, and each cell also fills its mirror cell with z <= 0. Thus volume and mass_g are two times the values of the half cell. The cell of a position with z < 0 is the cell of its mirror position.

Possible errors:

  • A cell with rho = 0 is empty. It has no estimators. Do not include it in a statistic of the cells that contain matter.

  • The density at a time t is rho * (t_model_init_days / t) ** 3, because the ejecta expand homologously. scan_estimators with join_modeldata=True gives this density as rho at each time step.

Example: the total mass and the mass of Ni56.

import artistools as at
import polars as pl
from artistools.constants import Msun_to_g

modelpath = "."
dfmodel, modelmeta = at.scan_modeldata(modelpath)
dfmodel = at.add_derived_cols_to_modeldata(dfmodel, modelmeta=modelmeta)
print(
    dfmodel.select(
        (pl.col("rho") > 0).sum().alias("cellswithmatter"),
        (pl.col("mass_g").sum() / Msun_to_g).alias("mass_msun"),
        ((pl.col("mass_g") * pl.col("X_Ni56")).sum() / Msun_to_g).alias("mass_Ni56_msun"),
    ).collect()
)
print("t_model_init_days:", modelmeta["t_model_init_days"], "dimensions:", modelmeta["dimensions"])

Deposition: the energy that the ejecta absorb

at.scan_deposition(modelpath) reads deposition.out. It gives a LazyFrame with one row for each time step. The LazyFrame always has the columns timestep and tmid_days. The other columns come from the header of the file, and they change with the version of ARTIS. Examples are:

  • total_dep_Lsun, gammadep_Lsun, positrondep_Lsun, elecdep_Lsun, and alphadep_Lsun (the deposition rate of each type of particle, in solar luminosities);

  • eps_gamma_Lsun, eps_elec_Lsun, and eps_alpha_Lsun (the rate at which the decays release energy, in solar luminosities). A name with _ana gives the analytic value;

  • eps_erg/s/g and Qdot_ana_erg/s/g (the specific rates, erg/s/g).

Possible errors:

  • The deposition rates are in solar luminosities and not in erg/s. Multiply by Lsun_to_erg_per_s from artistools.constants.

  • deposition.out gives the sum over the ejecta. For the deposition rate of each cell, use the deposition_ columns of the estimators. A deposition_ column with a Monte Carlo rate holds the rate of the time step before its row. See “Estimators”.

Example: the deposition at a time, and the fraction of the gamma-ray energy that the ejecta absorb.

import artistools as at
import polars as pl
from artistools.constants import Lsun_to_erg_per_s

modelpath = "."
timestep = at.get_timestep_of_timedays(modelpath, 10)
dfdep = at.scan_deposition(modelpath).filter(pl.col("timestep") == timestep).collect()
print(
    dfdep.select(
        "timestep",
        "tmid_days",
        (pl.col("total_dep_Lsun") * Lsun_to_erg_per_s).alias("total_dep_erg/s"),
        (pl.col("gammadep_Lsun") / pl.col("eps_gamma_Lsun")).alias("gamma_deposition_fraction"),
    )
)

Light curves

at.lightcurve.find_lightcurve_file(modelpath) gives the path of light_curve.out. Give gamma=True for gamma_light_curve.out, or directionresolved=True for light_curve_res.out. at.lightcurve.scan_lightcurve(path) reads the file. Give the same directionresolved value to both functions. The result is a dict with one LazyFrame for each direction bin, with these columns:

  • time_days (the mid time of the time step);

  • luminosity_erg/s and luminosity_Lsun (the bolometric luminosity in the observer frame);

  • luminosity_cmf_erg/s and luminosity_cmf_Lsun (the luminosity in the comoving frame);

  • mag (the absolute bolometric magnitude).

at.lightcurve.scan_lightcurve_from_packets(modelpath, escape_type="TYPE_RPKT", timedaysmin=..., timedaysmax=...) makes the light curve from the packets files. Use it for a time range or a type of packet that the light curve files do not give. It is slower than scan_lightcurve.

Possible errors:

  • The luminosity is 0 at the early time steps, before packets escape. The magnitude of such a row is inf.

  • The light curve of a direction bin has more Monte Carlo noise than the average over all directions.

  • The light curve has values only for the time steps of the model. The true peak can be outside the time range of the model in these cases:

    • the maximum of the observer-frame luminosity is in the first two or the last two time steps;

    • the first time step is almost as bright as the maximum;

    • the maximum of the comoving-frame luminosity is in the last two time steps, thus the light curve still rises at the end.

    Give this warning with the answer.

  • In the last time steps, the luminosity in the observer frame falls, e.g. to 0, but the luminosity in the comoving frame does not. The observer-frame time of a packet includes the travel time of the light across the ejecta. Thus the last time steps do not get the packets that escape after the last time step of the model. Do not report this fall as the decline of the light curve.

Example: the time and the luminosity of the peak, the rows near it, and a test of the edges of the time range.

import polars as pl

import artistools as at

modelpath = "."
lcpath = at.lightcurve.find_lightcurve_file(modelpath)
dflc = at.lightcurve.scan_lightcurve(lcpath)[-1].collect().with_row_index("row")
print(lcpath)
# a NaN or an infinite value is not a luminosity, thus each peak takes only the finite rows. "row" keeps the row number
dffinite = dflc.filter(pl.col("time_days").is_finite() & pl.col("luminosity_erg/s").is_finite())
dfcmffinite = dflc.filter(pl.col("time_days").is_finite() & pl.col("luminosity_cmf_erg/s").is_finite())
print(f"{dffinite.height} of {dflc.height} rows have a finite time and luminosity")
peakrow = dffinite["row"][dffinite["luminosity_erg/s"].arg_max()]
cmfpeakrow = dfcmffinite["row"][dfcmffinite["luminosity_cmf_erg/s"].arg_max()]
print(dflc.slice(max(peakrow - 2, 0), 5).select("row", "time_days", "luminosity_erg/s", "luminosity_cmf_erg/s", "mag"))
peakluminosity = dflc["luminosity_erg/s"][peakrow]
firstluminosity = dffinite["luminosity_erg/s"][0]
if peakrow < dffinite["row"][0] + 2 or peakrow > dffinite["row"][-1] - 2:
    print("The maximum is at an edge of the time range, thus the true peak can be outside the range.")
# the observer-frame luminosity falls at the end, thus only the comoving frame shows a curve that still rises
elif cmfpeakrow > dfcmffinite["row"][-1] - 2:
    print("The comoving-frame luminosity has its maximum at the end, thus the true peak can be after the time range.")
elif firstluminosity > 0.9 * peakluminosity:
    print(
        f"The first luminosity is {firstluminosity / peakluminosity:.0%} of the maximum. The true peak can be earlier."
    )

Spectra

at.spectra.scan_spectra(Path(modelpath), timestepmin, timestepmax, directionbins=[-1]) reads spec.out. It gives a dict with one LazyFrame for each direction bin. Each spectrum is the mean over the time steps from timestepmin to timestepmax, with the width of each time step as the weight. The columns are:

  • lambda_angstroms (Å), the wavelength of the bin;

  • f_lambda (erg/s/cm^2/Å), the flux per unit wavelength at a distance of 1 Mpc;

  • nu (Hz), the frequency of the bin;

  • f_nu (erg/s/cm^2/Hz), the flux per unit frequency at a distance of 1 Mpc.

The flux is at a distance of 1 Mpc. Give gamma=True for the gamma-ray spectrum. Give only the direction bins that you need. For a bin of 0 or more, artistools reads the large file spec_res.out.

at.spectra.scan_spectra_from_packets(modelpath, timelowdays, timehighdays, directionbins=[-1]) makes the spectrum from the packets files for a time range in days. It is slower than scan_spectra. Each row of a spectrum from packets is a bin. It has the columns of scan_spectra and these columns:

  • delta_lambda (Å) and delta_nu (Hz), the width of the bin in wavelength and in frequency;

  • packetcount, the number of packets in the bin;

  • with relnoise=True, relnoise, the relative Monte Carlo noise sqrt(sum(e^2)) / sum(e) of the packet energies e in the bin.

lambda_angstroms and nu are the centres of the bin. Each centre is the mean of the two edges of the bin, thus nu is not c / lambda_angstroms. f_lambda * delta_lambda and f_nu * delta_nu both give the flux of the bin.

Possible errors:

  • scan_spectra takes time steps and not days. Change a range of days to time steps with at.misc.get_time_range(modelpath, timemin=..., timemax=...). It keeps the time steps whose mid time is in the range, as artistools plotspectra --timedays does. For a range after the end of the model, it gives the time step -1.

  • A maximum in a range of wavelengths can be at an edge of that range. Compare it with the maximum of the full spectrum.

  • Multiply the flux by 4 * math.pi * megaparsec_to_cm**2 to get a luminosity density. Integrate it over the wavelength or the frequency to get a luminosity. megaparsec_to_cm is in artistools.constants.

  • Integrate with the trapezoidal rule, e.g. np.trapezoid, as artistools does. A sum of the flux times the width of each interval takes only one end of each interval. Each row of a spectrum from packets is a bin with the width delta_lambda. For such a spectrum, sum f_lambda times delta_lambda, as artistools does.

Example: the mean spectrum from 10 to 12 days, the wavelength of its maximum in the range from 3000 to 10000 Å, and its luminosity.

import math
from pathlib import Path

import artistools as at
import numpy as np
import polars as pl
from artistools.constants import megaparsec_to_cm

modelpath = "."
timestepmin, timestepmax, daysmin, daysmax = at.misc.get_time_range(modelpath, timemin=10, timemax=12)
dfspec = at.spectra.scan_spectra(Path(modelpath), timestepmin, timestepmax, directionbins=[-1])[-1].collect()
print(f"time steps {timestepmin} to {timestepmax}, {daysmin:.2f} to {daysmax:.2f} days")
print(dfspec.filter(pl.col("lambda_angstroms").is_between(3000, 10000)).top_k(1, by="f_lambda"))
lambdapeak = dfspec.top_k(1, by="f_lambda")["lambda_angstroms"].item()
if not 3000 <= lambdapeak <= 10000:
    print(f"The maximum of the full spectrum is at {lambdapeak:.0f} Å, outside the range from 3000 to 10000 Å.")
dfbyfrequency = dfspec.sort("nu")
flux = float(np.trapezoid(dfbyfrequency["f_nu"].to_numpy(), x=dfbyfrequency["nu"].to_numpy()))
luminosity = flux * 4 * math.pi * megaparsec_to_cm**2
print(f"luminosity in the spectrum: {luminosity:.3e} erg/s")

Other data

  • at.packets.scan_packets(modelpath) gives (number of ranks that it read, LazyFrame of the packets). artistools divides a sum of the packet energies by that number, e.g. for a luminosity. Do the same. Before it returns, the first call writes a parquet cache for each batch of 100 packets files. On a large model this takes many minutes. To prevent a slow step:

    • get the columns with at.packets.get_packets_column_names(modelpath), which writes no cache;

    • give maxpacketfiles=100 to read only the packets files of the first 100 ranks;

    • select the columns and filter the rows before .collect().

    artistools cache make <modelpath> writes the caches of the packets and of most other data at one time, and artistools cache list gives them. It does not convert the NLTE populations.

    get_packets_column_names gives the columns of the packets files. The LazyFrame does not have some of these columns, and it adds other columns, e.g. t_arrive_d and dirbin.

  • at.get_inputparams(modelpath) gives a dict of the parameters of input.txt.

  • For a different reader, read the section “Use from Python” of the artistools README: https://github.com/artis-mcrt/artistools#use-from-python