Use sloc.get_solspect() to load the solar reference. Pass wavelength nodes to interpolate.
Runs on bundled data only: no SPICE kernels, no downloads.
Default: TSIS-1 HSRS full extension, stored as 1 nm bin averages at 1 au.
Returns an Astropy QTable with physical units.
1. Load a spectrum
import pandas as pd
from astropy import units as u
from matplotlib import pyplot as plt
import skyloc as sloc
solar = sloc.get_solspect ()
solar[:5 ]
QTable length=5
wl flam dflam fnu ABmag
um W / (um m2) W / (um m2) MJy mag
float64 float64 float64 float64 float64
0.1155 0.017704958003898534 0.0026206546408502614 78.78402531777749 -10.84102979391448
0.1165 0.023327630981409598 0.0028674778604909075 105.60920768308202 -11.159188838733705
0.11750000000000001 0.07702100000874859 0.005257693374005611 354.702445973736 -12.474594835994
0.11850000000000001 0.031087354742679478 0.003070978209507302 145.61287166716878 -11.507933794675163
0.11950000000000001 0.04998586226664918 0.00394866492570145 238.1015901451787 -12.041840117269139
With no wavelength arguments, the getter returns:
the native samples,
all available source columns,
two derived columns (fnu, ABmag).
The default "tsis_full" result contains:
wl
Wavelength
µm
flam
Spectral irradiance per wavelength
W m⁻² µm⁻¹
dflam
Published absolute irradiance uncertainty
W m⁻² µm⁻¹
fnu
Spectral irradiance per frequency
MJy
ABmag
Monochromatic AB magnitude, using a 3631 Jy zero point
mag
ABmag is monochromatic. It is not a magnitude integrated through an instrument filter.
Zero irradiance gives zero fnu and infinite ABmag.
Source uncertainty and bandwidth
Finer TSIS (source="tsis") has both source uncertainty (dflam) and Gaussian bandwidth (bandwidth):
fine_native = sloc.get_solspect (source= "tsis" )
fine_native[["wl" , "flam" , "dflam" , "bandwidth" ]][:5 ]
QTable length=5
wl flam dflam bandwidth
um W / (um m2) W / (um m2) um
float64 float64 float64 float64
0.202 8.446091567984817 0.1097991844289936 0.0001
0.202025 8.469579491822719 0.11010452726623042 0.0001
0.20205 8.364807965966463 0.10874249710468574 0.0001
0.202075 8.250495407670735 0.10725644096964969 0.0001
0.2021 8.169301721141338 0.1062009177985601 0.0001
All available source columns load by default. To drop columns:
cols2drop=("dflam", "bandwidth") omits both.
cols2drop="bandwidth" keeps uncertainty, drops the width.
Known columns absent from a source are ignored, so one call works across references.
For dataset selection and provenance, see Solar reference .
Uncertainty propagation
Interpolation drops bandwidth and logs an INFO message from skyloc.solspect. The native Gaussian FWHM no longer describes the interpolated response.
For neighboring uncertainties \(\sigma_0\) , \(\sigma_1\) and interpolation weights \(1-t\) , \(t\) , the output variance is
\[
\sigma^2 = (1-t)^2\sigma_0^2 + t^2\sigma_1^2
+ 2t(1-t)\rho\sigma_0\sigma_1.
\]
The files contain no covariance. Assumption: dflam_rho=1.0 treats neighboring errors as fully correlated, giving an upper bound.
Choose the correlation:
dflam_rho=1.0 (default): fully correlated neighbors (upper bound).
dflam_rho=0: independent neighbors.
A scalar, or one correlation per source interval: another justified model.
Behavior:
Metadata records dflam_propagation="upper_bound" when all correlations are 1, otherwise "neighbor_correlation".
Exact source nodes keep their original uncertainty.
Excluded. Only the supplied marginal uncertainties propagate. The result leaves out:
wavelength errors,
interpolation model error,
output covariance.
Outputs that share source samples can be correlated even with dflam_rho=0. Reusing an interpolated table cannot reconstruct those correlations. No uncertainty columns are derived for fnu or ABmag.
Caution. Published TSIS uncertainty definitions vary by spectral region, including model comparisons in the infrared. They are not uniformly independent 1σ errors. See Coddington et al. (2023), §4.1 .
2. Choose and compare references
Load each reference explicitly when comparing results:
spectra = {
"tsis_full" : solar,
"tsis" : fine_native,
"astm" : sloc.get_solspect (source= "astm" ),
}
pd.DataFrame (
[
{
"source" : source,
"rows" : len (spectrum),
"minimum [µm]" : spectrum["wl" ][0 ].to_value(u.um),
"maximum [µm]" : spectrum["wl" ][- 1 ].to_value(u.um),
}
for source, spectrum in spectra.items()
]
)
0
tsis_full
199885
0.1155
199.999500
1
tsis
101120
0.2020
2.729975
2
astm
1697
0.1195
1000.000000
See Choose a reference for wavelength coverage, spectral resolution, and dataset differences.
Compare their native samples before choosing a grid for your analysis:
with plt.rc_context ({"font.size" : 10 , "axes.grid" : True , "grid.alpha" : 0.2 }):
fig, axes = plt.subplots (1 , 2 , figsize= (11 , 3.8 ), layout= "constrained" )
for source, spectrum in spectra.items():
wavelength = spectrum["wl" ].to_value(u.um)
irradiance = spectrum["flam" ].to_value(u.W / u.m** 2 / u.um)
overview = (wavelength >= 0.2 ) & (wavelength <= 10 )
detail = (wavelength >= 0.585 ) & (wavelength <= 0.595 )
axes[0 ].loglog(wavelength[overview], irradiance[overview], label= source)
axes[1 ].plot(
wavelength[detail] * 1000 ,
irradiance[detail],
marker= "." ,
markersize= 3 ,
linewidth= 1 ,
label= source,
)
axes[0 ].set (xlabel= "Wavelength [µm]" , ylabel= "Irradiance [W m⁻² µm⁻¹]" )
axes[1 ].set (xlabel= "Wavelength [nm]" , ylabel= "Irradiance [W m⁻² µm⁻¹]" )
axes[0 ].legend()
axes[1 ].legend()
plt.show ()
3. Interpolate, reuse, or select rows
Plain wavelength values are in micrometers. The getter loads the data for you:
QTable length=4
wl flam dflam fnu ABmag
um W / (um m2) W / (um m2) MJy mag
float64 float64 float64 float64 float64
0.6 1778.6334795961054 5.335900699719788 213583776.2318217 -26.923855029501027
1.0 730.7479096063955 2.192243817262351 243751265.28579834 -27.06730157459512
3.0 25.84130255916927 0.2228480516350833 77577576.36201888 -25.82427489640625
5.2 2.9409327616815526 0.04881879613094497 26525958.12662812 -24.65911207702044
To avoid re-reading the file, pass an existing table. Quantities in other length units are accepted:
QTable length=2
wl flam dflam fnu ABmag
um W / (um m2) W / (um m2) MJy mag
float64 float64 float64 float64 float64
0.6 1778.6334795961054 5.335900699719788 213583776.2318217 -26.923855029501027
1.0 730.7479096063955 2.192243817262351 243751265.28579834 -27.06730157459512
source and table are mutually exclusive.
Custom table requirements (validated strictly):
wl and flam: finite, unmasked, with physical units.
Wavelengths positive; irradiances nonnegative.
Interpolation also needs a nonempty, strictly increasing source grid.
dflam (if present): finite, unmasked, nonnegative, with compatible units.
bandwidth (if present): finite, unmasked, positive, with compatible units.
Present dflam and bandwidth columns are included automatically. Other columns in a custom table are copied on its native grid. Interpolation raises ValueError if those extra columns remain; drop them with cols2drop.
For a wavelength cut without interpolation, select existing rows:
cut = solar[(solar["wl" ] >= 0.6 * u.um) & (solar["wl" ] <= 5.2 * u.um)]
cut[:5 ]
QTable length=5
wl flam dflam fnu ABmag
um W / (um m2) W / (um m2) MJy mag
float64 float64 float64 float64 float64
0.6005 1769.3811465181757 5.30814379453659 212826996.3948663 -26.92000116752824
0.6015 1748.9500499978108 5.246850196272134 211070707.86511263 -26.911004294297722
0.6025 1724.9396075227955 5.174818914383649 208865780.87408787 -26.899602612722763
0.6035 1793.7370980703577 5.381211638450622 217917765.09490302 -26.945665968342535
0.6045 1781.2222616234917 5.343666765838861 217115096.38712186 -26.94165943208947
A row selection keeps the existing derived columns. For interpolation, pass the complete reference so both neighbors exist at the requested boundaries.
Queries outside the selected reference raise ValueError . For example, the finer TSIS product does not cover 5.2 µm:
'wl_knots must lie within source coverage.'
Interpolation rules:
Linear in flam; query order and duplicates are preserved.
Magnitudes are computed after interpolating irradiance.
It samples irradiance at points. It does not integrate a filter, conserve flux when rebinning, or recover sub-bin structure.
4. Control and refresh derived columns
The add_fnu and add_abmag flags are independent and both default to True. To get only wl and flam, disable both and omit extras:
physical = sloc.get_solspect (
[0.6 , 1.0 , 5.2 ], cols2drop= ("dflam" , "bandwidth" ), add_fnu= False , add_abmag= False
)
physical
QTable length=3
wl flam
um W / (um m2)
float64 float64
0.6 1778.6334795961054
1.0 730.7479096063955
5.2 2.9409327616815526
Add only AB magnitudes to that table in place:
QTable length=3
wl flam ABmag
um W / (um m2) mag
float64 float64 float64
0.6 1778.6334795961054 -26.923855029501027
1.0 730.7479096063955 -27.06730157459512
5.2 2.9409327616815526 -24.65911207702044
After editing wavelength or irradiance, refresh the derived columns. Work on a copy when you want to retain the original values:
edited = sampled.copy(copy_data= True )
edited["flam" ] *= 2
edited["dflam" ] *= 2 # The same exact scale factor applies to uncertainty.
sloc.solspect_addcols (edited)
pd.DataFrame (
{
"wavelength [µm]" : edited["wl" ].to_value(u.um),
"fnu ratio" : (edited["fnu" ] / sampled["fnu" ]).value,
"ABmag change" : (edited["ABmag" ] - sampled["ABmag" ]).to_value(u.mag),
}
)
0
0.6
2.0
-0.752575
1
1.0
2.0
-0.752575
2
3.0
2.0
-0.752575
3
5.2
2.0
-0.752575
Doubling irradiance doubles fnu and lowers ABmag by about 0.7526 mag.
solspect_addcols() :
returns None;
preserves other columns and metadata;
computes AB magnitudes from wl and flam, independent of any existing fnu;
leaves dflam and bandwidth unchanged. Update dflam yourself to match your edit.
Stale columns. A disabled flag leaves an existing column unchanged, so that column can go stale after an edit.
5. Check integration, memory, and provenance
For the full product’s original bins, sum each bin-average irradiance times its width. This applies to the native bins only, not to an arbitrarily interpolated table:
bin_width = solar.meta["bin_width_nm" ] * u.nm
integrated_irradiance = (solar["flam" ].sum () * bin_width).to(u.W / u.m** 2 )
integrated_irradiance
\(1361.4892 \; \mathrm{\frac{W}{m^{2}}}\)
The bundled snapshot gives about 1361.489 W m⁻². Skyloc preserves these values and applies no additional normalization.
All three references can coexist. Measure the retained numeric arrays:
pd.DataFrame (
[
{
"source" : source,
"numeric arrays [MiB]" : sum (
spectrum[column].value.nbytes for column in spectrum.colnames
)
/ 2 ** 20 ,
}
for source, spectrum in spectra.items()
]
)
0
tsis_full
7.625008
1
tsis
4.628906
2
astm
0.051788
Memory for the numeric arrays in all three tables:
About 12.31 MiB with all available extras.
About 9.24 MiB with cols2drop=("dflam", "bandwidth") for each source.
Excludes Python object overhead and temporary loading buffers.
Every getter result owns its data. There is no shared spectrum cache and no import-time data loading.
Dataset versions, original files, conversion details, and checksums are in Source records .