View source: R/speclib_download.R
speclib_download | R Documentation |
Simple interface to show all the currently available ProSpect SSPs, and download them as needed.
speclib_download(URL = "https://tinyurl.com/prospect-speclib/", ...)
speclib_FITSload(file, Labels = list(Zlab = "Metallicity",
Agelab = "Time since ZAM / Yrs", Wavelab = "Wavelength / Ang",
Lumlab = "Lsun / Ang (for 1 Msun SF)", LumAgelab = "Lsun / Ang (for 1 Msun/Yr SFR)"),
check = FALSE)
speclib_check(speclib, structure = TRUE, coverage = TRUE, Labels = list(
Zlab = "Metallicity", Agelab = "Time since ZAM / Yrs", Wavelab = "Wavelength / Ang",
Lumlab = "Lsun / Ang (for 1 Msun SF)", LumAgelab = "Lsun / Ang (for 1 Msun/Yr SFR)"))
URL |
Character scalar; location of the ProSpect SSP libraries. This should not need to be altered by the user. |
... |
Other arguments to pass to |
file |
Character scalar; full path and name of target FITS spectral library to load. |
Labels |
List; list of plot labels (probably no reason to alter this from the default). These will either be created as written, or checked. |
check |
Logical; should checks be run on the spectral library being returned? Uses |
speclib |
List; spectral library to pass through |
structure |
Logical; should the structure of speclib be checked. If TRUE, results are printed to screen. |
coverage |
Logical; should the coverage (Z, Age, Wave) of speclib be checked? If TRUE, results are printed to screen. |
This interface has proven necessary in order to provide flexible SSPs without making the core package too big. We have also had issue with the package getting close to the file size limit of GitHub. In future all additional SSP will be provided through this mechanism.
Internally a ProSpect
compatible format (e.g. as seen for BC03
/ EMILES
/ BPASS
, as output by speclib_FITSload
, and as verified with speclib_check
) looks like a list containing:
Z: Numeric vector of available template metallicities (ascending order).
Age: Numeric vector of available template ages in Yrs (ascending order).
AgeBins: Numeric vector of available template age bin limits in Yrs (ascending order, must be 1 longer than "Age" vector to cover lower and upper limits).
AgeWeights: Numeric vector of available template age weights (bin sizes) in Yrs (same length as "Age").
Wave: Numeric vector of spectral wavelength in Angstroms (ascending order).
Labels: List of the labels required for plotting (see BC03
).
Zspec: List containing the spectra in units Lsun / Ang (for 1 Msun SF). The list must correspond to the 'Z' vector metallicities. Each list item is a numeric matrix of spectra with Nrow equal to the number of age bins (corresponding with 'Age') and Ncol the number of wavelength element (corresponding with 'Wave').
Zevo: List containing the mean evolutionary tracks of the SSPs (as determined by the route isochrones). The list must correspond to the 'Z' vector metallicities. Each list item is a data.frame with columns 'SMstar' (fraction of mass in luminous stars) 'SMgas' (fraction of mass in gas) 'SMtot' (fraction of total mass, always 1 in practice) 'SFR' (star formation rate, always 0 in practice) 'SMrem' (fraction of mass in stellar remnants, e.g. black holes etc). Nrow should be equal to the number of age bins (corresponding with 'Age').
For FITS loading, the required format is a multi-extension FITS file containing (and named via EXTNAME):
Z: Numeric vector of available template metallicities (ascending order). The length of this vector is N_Z (as referred to below).
Age: Numeric vector of available template ages in Yrs (ascending order).
AgeBins: Numeric vector of available template age bin limits in Yrs (ascending order, must be 1 longer than "Age" vector to cover lower and upper limits).
AgeWeights: Numeric vector of available template age weights (bin sizes) in Yrs (same length as "Age").
Wave: Numeric vector of spectral wavelength in Angstroms (ascending order).
Zspec[1:N_Z]: Extensions containing the spectra in units Lsun / Ang (for 1 Msun SF). Each numbered extension must correspond to the 'Z' vector metallicities. Each extension is a numeric matrix of spectra with Nrow equal to the number of age bins (corresponding with 'Age') and Ncol the number of wavelength element (corresponding with 'Wave').
Zevo[1:N_Z]: Extensions containing the mean evolutionary tracks of the SSPs (as determined by the route isochrones). The extension must correspond to the 'Z' vector metallicities. Each extension is a data.frame with columns 'SMstar' (fraction of mass in luminous stars) 'SMgas' (fraction of mass in gas) 'SMtot' (fraction of total mass, always 1 in practice) 'SFR' (star formation rate, always 0 in practice) 'SMrem' (fraction of mass in stellar remnants, e.g. black holes etc). Nrow should be equal to the number of age bins (corresponding with 'Age').
Note the "Labels" component of the structure is missing in the FITS version of the spectral library. This is created when processing it with speclib_FITSload
.
The extensions and ordering of the target FITS file should look similar to the included BC03lr example used in the Examples below (e.g. note the extension names and the overall ordering):
Ext | Name | Class | Dim | Size.MB |
1 | Z | numeric | 6 | 0.0001 |
2 | Age | numeric | 221 | 0.0017 |
3 | AgeBins | numeric | 221 | 0.0017 |
4 | AgeWeights | numeric | 221 | 0.0017 |
5 | Wave | numeric | 1221 | 0.0094 |
6 | Zspec1 | matrix | 221 x 1221 | 2.0589 |
7 | Zspec2 | matrix | 221 x 1221 | 2.0589 |
8 | Zspec3 | matrix | 221 x 1221 | 2.0589 |
9 | Zspec4 | matrix | 221 x 1221 | 2.0589 |
10 | Zspec5 | matrix | 221 x 1221 | 2.0589 |
11 | Zspec6 | matrix | 221 x 1221 | 2.0589 |
12 | Zevo1 | data.frame | 221 x 5 | 0.0096 |
13 | Zevo2 | data.frame | 221 x 5 | 0.0096 |
14 | Zevo3 | data.frame | 221 x 5 | 0.0096 |
15 | Zevo4 | data.frame | 221 x 5 | 0.0096 |
16 | Zevo5 | data.frame | 221 x 5 | 0.0096 |
17 | Zevo6 | data.frame | 221 x 5 | 0.0096 |
speclib_download
If stellpop = 'avail' then the contents of avail.txt will be displayed (using the default method). Otherwise, the target SSP rda/FITS file is downloaded and the destination path (+ filename) is returned.
speclib_FITSload
Returns the target SSP in ProSpect
compatible format. Note this needs to be assigned to a larget object, i.e. newlib = speclib_FITSload('newlib.fits')
.
speclib_check
Returns invisibily TRUE (all checks pass) or FALSE (some checks fail). Also prints the results of various checks to screen.
Aaron Robotham
ProSpectSED
## Not run:
# Just check what is there:
speclib_download()
# This is roughly what loading an additional SSP library will look like:
speclib_download(stellpop='XSL_PC_Kr', destpath='~/Downloads/')
load('~/Downloads/XSL_PC_Kr.rda')
temp = ProSpectSED(speclib=XSL_PC_Kr)
plot(temp)
# Check an SSP:
data(BC03lr)
speclib_check(BC03lr)
# Check the FITS version of the library:
BC03lr_file = system.file('BC03lr.fits', package="ProSpectData")
BC03lr_test = speclib_FITSload(BC03lr_file)
#The differences should be very small (parts in 1e-5 - 1e-8):
all.equal(BC03lr, BC03lr_test)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.