Class SedStats
source code
Environment with several tools to perform statistics on SED
photometry.
Then run several methods to set data, and models. e.g. (requires a
star_grid to be defined):
>>> sed = Sed.Sed('rscl')
>>> sedstats = SedStats.SedStats(star_name='rscl',path_code='codeSep2015')
>>> sedstats.setInstrument(sed=sed)
>>> sedstats.setModels(star_grid=star_grid)
>>> sedstats.setModelPhotometry()
Alternatively, you can take the SedStats object from a ComboCode
object given that STATISTICS=1 in the inputfile for CC. Then the above is
already done for you. Assuming the star_name is 'rscl':
>>> model = ComboCode.ComboCode('inputfile.dat')
>>> model.startSession()
>>> sedstats = model.sedstats['rscl']
Now you can go ahead and calculate chi^2 values and write them to a
file:
>>> chi2 = sedstats.calcChi2()
>>> sedstats.writeChi2('myfile.dat')
The writeChi2 method writes the latest chi2 calculation to a file with
given filename. Several options are available for selecting and sorting
photometry during the calculation, and sorting and adding extra columns
of model parameters when writing the results to a file. Check the
docstrings of each method for more information.
|
__init__(self,
star_name,
code=' MCMax ' ,
path_code=' codeSep2015 ' )
Initializing an instance of SedStats. |
source code
|
|
|
|
|
|
list
|
calcChi2(self,
ndf=0,
fns=None,
cwave=0.0,
phot_ivs=1,
sort=1,
chi2_method=' diff ' )
Calculate, save and return the chi^2 values for a given set of
models. |
source code
|
|
list(Star())
|
|
|
|
Inherited from cc.statistics.Statistics.Statistics :
doDataStats ,
setDataInfo ,
setModels
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
Inherited from object :
__class__
|
__init__(self,
star_name,
code=' MCMax ' ,
path_code=' codeSep2015 ' )
(Constructor)
| source code
|
Initializing an instance of SedStats.
- Parameters:
star_name (string) - Star name from Star.dat
code (string) - the code used for producing your output
(default: 'MCMax')
path_code (string) - Output folder in the code's home folder
(default: 'codeSep2015')
- Overrides:
object.__init__
|
Set and read the data objects for this statistics module.
The Sed object is made on the spot if sed is None. Extra arguments for
making the Sed can be passed through the method in kwargs.
- Parameters:
sed (Sed()) - The Sed object. In case of default, it is made on the spot for
given star with extra arguments kwargs if needed
(default: None)
- Overrides:
cc.statistics.Statistics.Statistics.setInstrument
|
Prepare the model photometry to be compared with the data.
Two kinds: The IvS photometry with proper photometric bands, and other
photometry to be compared with the interpolated model spectrum.
|
calcChi2(self,
ndf=0,
fns=None,
cwave=0.0,
phot_ivs=1,
sort=1,
chi2_method=' diff ' )
| source code
|
Calculate, save and return the chi^2 values for a given set of
models.
For now, only photometry (both with and without photometric bands
available, the latter being associated with the Photometric_IvS file) is
taken into account.
You can specify the number of degrees of freedom for the reduced chi^2
in case you are comparing models probing a grid across ndf different
parameters.
The method overrides previously calculated chi2 in the object. Write
the chi^2 to a file before running the method if you want to save the
values with self.writeChi2()
- Parameters:
ndf (int) - Number of degrees of freedom. Default in case of calculating for
one single model. Typically the number of variable grid
parameters in a grid calculation.
(default: 0)
fns (list(str)) - The photometric filenames to be included in the chi^2 calc
Default if all are to be included. Empty list if none are to be
included.
(default: None)
cwave (float) - A cut-off wavelength in micron used to calculate the chi^2 stat
for all photometry above or equal to the wavelength in micron.
Use a negative value to grab all wavelengths lower than cwave.
Default if no cut-off.
(default: 0.0)
phot_ivs (bool) - Include the Photometric_IvS photometry as well.
(default: 1)
sort (bool) - Sort the chi^2 values from lowest to highest.
(default: 1)
chi2_method (str) - Method for calculating chi^2. Can be diff or log (see BasicStats
for more information)
(default: 'diff')
- Returns: list
- The list of chi^2 values with the same length as the model grid
of valid MCMax models.
|
Return the star grid for which the chi^2 is calculated.
This grid may differ from the original ComboCode grid because the
local star_grid is filtered for unavailable MCMax models (either not
calculated or not loaded).
Each object in the star_grid is itself a dictionary that contains all
the parameters of the model.
- Parameters:
sort (bool) - Sort the star_grid according to the chi^2 values from lowest to
highest. Requires calcChi2 to be ran first.
(default: 1)
- Returns: list(Star())
- The star grid
|
Write the Chi^2 values to a file. Lists the model id in the first
column with the chi^2 value in the second.
The chi^2 values can be requested to be sorted.
Parameters from the Star() objects can be added as additional columns.
Given parameters must be valid.
- Parameters:
fn (str) - The output filename
sort (bool) - Sort the star_grid according to the chi^2 values from lowest to
highest. Requires calcChi2 to be ran first.
(default: 1)
parameters (list(str)) - The additional model parameters to be added as columns in the
file.
(default: [])
|