Fit Data¶
-
class
eddington.fitting_data.FittingData(data: Union[collections.OrderedDict, Dict[str, <sphinx.ext.autodoc.importer._MockObject object at 0x7f36c2ccb1d0>]], x_column: Union[str, int, None] = None, xerr_column: Union[str, int, None] = None, y_column: Union[str, int, None] = None, yerr_column: Union[str, int, None] = None)¶ Fitting data class.
Constructor.
Parameters: - data (
dictorOrderedDictfromstrtonumpy.ndarray) – Dictionary from a column name to its values - x_column (
strornumpy.ndarray) – Indicates which column should be used as the x parameter - xerr_column (
strornumpy.ndarray) – Indicates which column should be used as the x error parameter - y_column (
strornumpy.ndarray) – Indicates which column should be used as the y parameter - yerr_column (
strornumpy.ndarray) – Indicates which column should be used as the y error parameter
-
all_columns¶ Columns list.
-
all_records¶ Get all records in data as a list.
-
column_data(column_header: str)¶ Get the data of a column.
Parameters: column_header (str) – The header name of the desired column. Returns: The data of the given column Return type: numpy.array
-
data¶ Data matrix.
-
is_selected(index)¶ Checks if a record is selected or not.
Parameters: index (int) – index of the desired record starting from 1. Returns: bool
-
length¶ Number of records.
-
classmethod
random(fit_func, x: Optional[<sphinx.ext.autodoc.importer._MockObject object at 0x7f36c2ccb790>] = None, a: Optional[<sphinx.ext.autodoc.importer._MockObject object at 0x7f36c2ccb890>] = None, xmin: float = -20.0, xmax: float = 20.0, min_coeff: float = -10.0, max_coeff: float = 10.0, xsigma: float = 0.5, ysigma: float = 0.5, measurements: int = 20)¶ Generate a random fit data.
Parameters: - fit_func (
FittingFunction) –FittingFunctionto evaluate with the fit data - x (
numpy.ndarray) – Optional. The input for the fitting algorithm. If not given, generated randomly. - a (
numpy.ndarray) – Optional. the actual parameters that should be returned by the fitting algorithm. If not given, generated randomly. - xmin (float) – Minimum value for x.
- xmax (float) – Maximum value for x.
- min_coeff (float) – Minimum value for a coefficient.
- max_coeff (float) – Maximum value for a coefficient.
- xsigma (int) – Standard deviation for x.
- ysigma (int) – Standard deviation for y.
- measurements (int) – Number of measurements
Returns: random
FittingData- fit_func (
-
classmethod
read_from_csv(filepath: Union[str, pathlib.Path], x_column: Union[str, int, None] = None, xerr_column: Union[str, int, None] = None, y_column: Union[str, int, None] = None, yerr_column: Union[str, int, None] = None)¶ Read
FittingDatafrom csv file.Parameters: - filepath – str or Path. Path to location of csv file
- x_column (
strornumpy.ndarray) – Indicates which column should be used as the x parameter - xerr_column (
strornumpy.ndarray) – Indicates which column should be used as the x error parameter - y_column (
strornumpy.ndarray) – Indicates which column should be used as the x parameter - yerr_column – Indicates which column should be used as the y error parameter
Returns: FittingDataread from the csv file.
-
classmethod
read_from_excel(filepath: Union[str, pathlib.Path], sheet: str, x_column: Union[str, int, None] = None, xerr_column: Union[str, int, None] = None, y_column: Union[str, int, None] = None, yerr_column: Union[str, int, None] = None)¶ Read
FittingDatafrom excel file.Parameters: - filepath – str or Path. Path to location of excel file
- sheet – str. The name of the sheet to extract the data from.
- x_column (
strornumpy.ndarray) – Indicates which column should be used as the x parameter - xerr_column (
strornumpy.ndarray) – Indicates which column should be used as the x error parameter - y_column (
strornumpy.ndarray) – Indicates which column should be used as the x parameter - yerr_column – Indicates which column should be used as the y error parameter
Returns: FittingDataread from the excel file.
-
classmethod
read_from_json(filepath: Union[str, pathlib.Path], x_column: Union[str, int, None] = None, xerr_column: Union[str, int, None] = None, y_column: Union[str, int, None] = None, yerr_column: Union[str, int, None] = None)¶ Read
FittingDatafrom json file.Parameters: - filepath – str or Path. Path to location of csv file
- x_column (
strornumpy.ndarray) – Indicates which column should be used as the x parameter - xerr_column (
strornumpy.ndarray) – Indicates which column should be used as the x error parameter - y_column (
strornumpy.ndarray) – Indicates which column should be used as the x parameter - yerr_column – Indicates which column should be used as the y error parameter
Returns: FittingDataread from the json file.
-
records¶ Get all selected records in data as a list.
-
records_indices¶ List of booleans indicating which records are selected.
-
residuals(fit_func, a: <sphinx.ext.autodoc.importer._MockObject object at 0x7f36c2ccb750>)¶ Creates residuals
FittingDataobjects.Parameters: - fit_func (
FittingFunction) –FittingFunctionto evaluate with the fit data - a (
numpy.ndarray) – the parameters of the given fitting function
Returns: residuals
FittingData- fit_func (
-
save_csv(output_directory: Union[str, pathlib.Path], name: str = 'fitting_data')¶ Save
FittingDatato csv file.Parameters: - output_directory (
Pathorstr) – Path to the directory for the new excel file to be saved. - name (str) – Optional. The name of the file, without the .csv suffix. “fitting_data” by default.
- output_directory (
-
save_excel(output_directory: Union[str, pathlib.Path], name: str = 'fitting_data', sheet: Optional[str] = None)¶ Save
FittingDatato xlsx file.Parameters: - output_directory (
Pathorstr) – Path to the directory for the new excel file to be saved. - name (str) – Optional. The name of the file, without the .xlsx suffix. “fitting_data” by default.
- sheet (str) – Optional. Name of the sheet that the data will be saved to.
- output_directory (
-
save_statistics_csv(output_directory: Union[str, pathlib.Path], name: Optional[str] = None)¶ Save the fitting data statistics to csv file.
Parameters: - output_directory (
Pathorstr) – Path to the directory for the new excel file to be saved. - name (str) – Optional. The name of the file, without the .csv suffix. “fitting_data” by default.
- output_directory (
-
save_statistics_excel(output_directory: Union[str, pathlib.Path], name: Optional[str] = None, sheet: Optional[str] = None)¶ Save the fitting data statistics to xlsx file.
Parameters: - output_directory (
Pathorstr) – Path to the directory for the new excel file to be saved. - name (str) – Optional. The name of the file, without the .xlsx suffix. “fitting_data_statistics” by default.
- sheet (str) – Optional. Name of the sheet that the data will be saved to.
- output_directory (
-
select_all_records()¶ Select all records to be used in fitting.
-
select_record(index: int)¶ Select a record to be used in fitting.
Parameters: index (int) – index of the desired record starting from 1.
-
set_cell(record_number, column_name, value)¶ Set new value to a cell.
Parameters: - record_number (int) – The number of the record to set, starting from 1
- column_name (str) – The column name
- value (float) – The new value to set for the cell
-
set_header(old, new)¶ Rename header.
Parameters: - old (str) – The old columns name
- new (str) – The new value to set for the header
-
statistics(column_name: str) → Optional[eddington.statistics.Statistics]¶ Get statistics of the values in a column.
Parameters: column_name (str) – The column name to get statistics of Returns: Statistics of the given column Return type: Statistics
-
unselect_all_records()¶ Unselect all records from being used in fitting.
-
unselect_record(index: int)¶ Unselect a record to be used in fitting.
Parameters: index (int) – index of the desired record starting from 1.
-
used_columns¶ Dictionary of columns in use.
-
x¶ X values.
-
x_column¶ Name of the x column.
-
xerr¶ X error values.
-
xerr_column¶ Name of the x error column.
-
y¶ Y values.
-
y_column¶ Name of the y column.
-
yerr¶ Y error values.
-
yerr_column¶ Name of the y error column.
- data (