galmoss.Parameter package
Submodules
galmoss.Parameter.basic module
- class galmoss.Parameter.basic.Parameters(parameters: ndarray | torch.Tensor | float | Series, value_range: Tuple[float, float] | None = (None, None), step_length: float = 0.015, M0: float | None = None, pix_scale: float | None = None, angle: bool = False, fit: bool = True, log: bool = False, dim: str = '1d')
Bases:
ParamsRepo- best_value_append(batched_mapped_best_value: torch.tensor)
Append the best fitted values for each batch of galaxies after the completion of each batch fitting process.
- Parameters:
batched_mapped_best_value – The best fitted value for each batch of galaxies.
- calculate_uncertainty(proj_uc)
This function is for calculating the final uncertainty of parameters. Inside function “cm_uncertainty”, we get the projected uncertianty `self.uncertainty`of parameters, so we need the error propagation equation to expand.
- Parameters:
proj_uc – The projected uncertianty of parameters
- inv_from_mapping_uc(data)
Return the total uncertainty in the original input domain, with shape (param_length, dim_length), in numpy.array.
- mapping(parameter: torch.tensor, value_range: Tuple[float, float], *args, **kwargs)
Returns the mapped parameter and value range. If log=True, this function returns the log of the mapped values.
- Parameters:
parameter – The parameter value in the original input domain.
value_range – Constrains the fitting range, with values in the original input domain.
kwargs (*args &) – Additional arguments, can only be M0, pix_scale, or angle. M0 is the magnitude zero point for magnitude parameters. pix_scale is the conversion factor between arcseconds and pixels, applicable only to scale-related parameters like eff_r. angle indicates if the parameter is angle-related.
- update_best_val(index: torch.tensor | bool | None = None)
Update the best value during the optimization process. Not every iteration in the optimization process results in a better outcome with a lower chi-square. Therefore, updates are made only in iterations that successfully reduce the chi-square, guided by the given index.
- Parameters:
index – Specifies the position in the best value matrix to be refreshed. If None, refreshes the entire matrix.
- update_updating_val(value: torch.tensor)
Returns the mapped parameter and value range. If log=True, this function returns the log of the mapped values.
- Parameters:
parameter – The parameter value in the original input domain.
value_range – Constrains the fitting range, with values in the original input domain.
*args&**kwargs – Additional arguments, can only be M0, pix_scale, or angle. M0 is the magnitude zero point for magnitude parameters. pix_scale is the conversion factor between arcseconds and pixels, applicable only to scale-related parameters like eff_r. angle indicates if the parameter is angle-related.
- class galmoss.Parameter.basic.ParamsRepo
Bases:
object- property batched_broadcasted_mapped_best_val
Return the best value in each sub-fitting batch, mapped to the profile equation domain (e.g., mag’ = mag - M0, eff_r’ = eff_r / pix_scale), and broadcasted for calculations. This is typically used to generate the model image in the result image saving process.
This attribute can also be accessed via param.value(“best_model”).
- property batched_broadcasted_updating_val
Return the updating value in each sub-fitting batch, mapped to the profile equation domain (e.g., mag’ = mag - M0, eff_r’ = eff_r / pix_scale), and broadcasted for calculations. This is typically used to generate the model image during the fitting process.
This attribute can also be accessed via param.value(“updating_model”).
- property total_best_value
Return the total best value in the original input domain, with shape (param_length, dim_length), in numpy.array.
- property total_best_value_numpy
Return the total best value in the original input domain, with shape (param_length, dim_length), in numpy.array. This is typically used to save the fitted values for variable parameters.
- property total_broadcasted_mapped_inital_val
Return the total initial value, mapped to the profile equation domain (e.g., mag’ = mag - M0, eff_r’ = eff_r / pix_scale), and broadcasted for calculations. The data is loaded on the CPU by default, but can be changed to other devices using the ‘device’ argument. This is typically used to generate the initial model image for a quick review.
This attribute can also be accessed by param.value(“initial_model”).
- property total_bsp_uncertainty
Return the total uncertainty in the original input domain, with shape (param_length, dim_length), in torch.Tensor.
- property total_initial_value_numpy
Return the total initial value in the original input domain, with shape (param_length, dim_length). This is typically used to save the fitted parameter values for fixed parameters, as they only have an initial value.
- property total_mapped_best_val_cpu
Return the total best value, mapped to the profile equation domain (e.g., mag’ = mag - M0, eff_r’ = eff_r / pix_scale), and broadcasted for calculations. This is typically used to generate the model image during the fitting uncertainty estimation process using co-variance matrix.
This attribute can also be accessed by param.value(“load_best_in_jacobian”).
- property total_mapped_ini_value
Return the total initial value in the normalized domain. This is typically for loading into the optim_list that will later be loaded into optimizer in the fitting process.
This attribute can also be accessed by param.value(“load_initial_in_optim_list”).
- property total_normalized_best_val_cpu
Return the total best value in the normalized domain. This is typically for loading into the optim_list that will later be loaded into optimizer in the bootstrapping process.
This attribute can also be accessed by param.value(“load_best_in_optim_list”).
- property total_normalized_ini_value
Return the total initial value in the normalized domain. This is typically for loading into the optim_list that will later be loaded into optimizer in the fitting process.
This attribute can also be accessed by param.value(“load_initial_in_optim_list”).
- property total_uncertainty_numpy
Return the total uncertainty value in the original input domain, with shape (param_length, dim_length). This is typically used to save the fitting uncertainty for variable parameters.
- value(mode: str = 'updating_model') torch.tensor
Return the value guided by the ‘mode’ argument.
- Parameters:
mode – The string representing which value to choose from self.value_dict.
galmoss.Parameter.decorater module
- galmoss.Parameter.decorater.inv_from_log(func)
- Workflow of parameters in galmoss:
- Original domain
–> to_mapped –>
- mapped domain
–> to_logged –>
- logged domain
–> to_normalized –>
normalized domain and be load into optimizer
The inv-workflow follows the same logic.
Checks whether need to transform input values from logged to mapped domain follows the attribute log. If log is True, which means the value in the func has already transformed into logarithmic domain before, so the transition will be effective. Otherwise, return input values.
- galmoss.Parameter.decorater.inv_from_mapping(func)
- Workflow of parameters in galmoss:
- Original domain
–> to_mapped –>
- mapped domain
–> to_logged –>
- logged domain
–> to_normalized –>
normalized domain and be load into optimizer
The inv-workflow follows the same logic.
Checks whether need to transform input values from mapped to original domain follows the attribute M0, pix_scale and angle. If M0 and pix_scale is not None or angle is True, which means the value in the func has already transformed into mapped domain before, so the transition will be effective. Otherwise, return input values.
- galmoss.Parameter.decorater.inv_from_mapping_uncertainty(func)
- Workflow of parameters in galmoss:
- Original domain
–> to_mapped –>
- mapped domain
–> to_logged –>
- logged domain
–> to_normalized –>
normalized domain and be load into optimizer
The inv-workflow follows the same logic.
Checks whether need to transform input values from mapped to original domain follows the attribute M0, pix_scale and angle. If M0 and pix_scale is not None or angle is True, which means the value in the func has already transformed into mapped domain before, so the transition will be effective. Otherwise, return input values.
- galmoss.Parameter.decorater.inv_from_normalization(func)
- Workflow of parameters in galmoss:
- Original domain
–> to_mapped –>
- mapped domain
–> to_logged –>
- logged domain
–> to_normalized –>
normalized domain and be load into optimizer
The inv-workflow follows the same logic.
Checks whether need to transform input values from normlization to logged domain follows the attribute value_range. If value_range is not None, which means the value in the func has already transformed into (-1, 1) domain before, so the transition will be effective. Otherwise, return input values.
- galmoss.Parameter.decorater.redim(func)
To transit input values into torch.tensor, and resize to (param_length, param_dim). param_length equals the number of total galaxies.
- galmoss.Parameter.decorater.to_log(func)
- Workflow of parameters in galmoss:
- Original domain
–> to_mapped –>
- mapped domain
–> to_logged –>
- logged domain
–> to_normalized –>
normalized domain and be load into optimizer
The inv-workflow follows the same logic.
Checks whether need to transform input values to logged domain follows the attribute log. If log is True, the transition will be effective. Otherwise, return input values.
- galmoss.Parameter.decorater.to_mapping_log_with_value_range(func)
- Workflow of parameters in galmoss:
- Original domain
–> to_mapped –>
- mapped domain
–> to_logged –>
- logged domain
–> to_normalized –>
normalized domain and be load into optimizer
The inv-workflow follows the same logic.
Checks whether need to transform input values from original to mapped and then to logged domain.
- galmoss.Parameter.decorater.to_normalization(func)
- Workflow of parameters in galmoss:
- Original domain
–> to_mapped –>
- mapped domain
–> to_logged –>
- logged domain
–> to_normalized –>
normalized domain and be load into optimizer
The inv-workflow follows the same logic.
Checks whether need to normalize input values into (-1, 1) noramlized domain follows the attribute value_range. If value_range is not None, which means the value has constrains during the fitting pocess, so the transition will be effective. Otherwise, return input values.
- galmoss.Parameter.decorater.transiform_eff_degrees(degrees)
To map the degrees out of the value range into the effective value inside the value range (-180~180).
- Parameters:
degrees – The degrees, that may have values out of the value range.
- Return type:
The degrees all inside the value range.