SourceModel¶
- class sofia_redux.scan.source_models.source_model.SourceModel(info, reduction=None)[source]¶
Bases:
ABC
Initialize a source model.
The source model is an abstract class used to represent the source for a given reduction, and operate on its contents.
- Parameters:
- infosofia_redux.scan.info.info.Info
The Info object which should belong to this source model.
- reductionsofia_redux.scan.reduction.reduction.Reduction, optional
The reduction for which this source model should be applied.
Attributes Summary
Return the flags specific to channels.
Return the configuration for the source model.
Return the sample exclusion flags.
Return the flags specific to integration frames.
Return the logging ID.
Return the number of scans in the source model.
Return attributes that should be referenced during a copy.
Return the signal mode flag.
Methods Summary
add_integration
(integration)Add an integration to the source model.
add_integration_time
(time)Add integration time to the source model.
add_model
(source_model[, weight])Add a source model increment onto this model.
add_model_data
(source_model[, weight])Add an increment source model data onto the current model.
add_process_brief
(message)Add a message to the process brief.
add_scan_hdus_to
(hdul)Add each scan HDU to an HDUL
assign_reduction
(reduction)Assign a reduction to the source model.
assign_scans
(scans)Assign scans to the source model.
check_pixel_count
(integration)Check if an integration has enough mapping pixels to generate a map.
Clear all memory references prior to deletion.
Clear the contents of the source model.
Remove all process brief information.
Remove all available models from the recycler.
copy
([with_contents])Return a copy of the source model.
Return the number of points in the model.
create_from
(scans[, assign_scans])Initialize model from scans.
edit_header
(header)Update a header with model information.
Return the header for an ASCII output file.
Return the average resolution.
Return the blanking level from the configuration.
Return the source name with bad characters replaced with '_'.
get_clean_local_copy
([full])Get an unprocessed copy of the source model.
Return the clipping level from the configuration.
Return a descriptive name for the source model.
Get the parallel process executor for source processing.
Return the first scan in the source model scans.
Return the kelvin unit.
Return the native unit for the source model
Get the number of parallel operations for the source model.
Return the point size of the source model.
get_recycled_clean_local_copy
([full])Return a clean local copy of a source model.
Return the reference (x, y) coordinate.
Return the source name for the source model.
Return the source size of the source model.
get_table_entry
(name)Return the parameter value for a given name.
get_unit
()Return the source model unit.
has_option
(option)Return whether the configuration option is configured.
Return whether source model issues may be related to scanning problems.
is_valid
()Return whether the source model is valid or not.
Initiate a new source model generation.
Sets the number of parallel operations for the source to 1 (serial).
parallel_safe_sync_integration
(args, ...)Synchronize a single integration.
parse_header
(header)Parse and apply a FITS header.
post_process_scan
(scan)Apply post processing steps to a scan.
process
()Process the source model.
process_scan
(scan)Process a scan.
recycle
()Add this source model to the list of available recycled source models.
renew
()Renew the source model.
Reset the source processing.
set_base
()Set the base data for the source model.
set_executor
(executor)Set the parallel process executor for source processing.
set_info
(info)Set the primary Info object for the source model.
set_parallel
(threads)Set the number of parallel operations for the source model.
set_recycler_capacity
(size)Set the number of available models in the recycler.
source_option
(option_name)Return the name of the option in configuration specific to the source.
Return a message suggestion corrections to an invalid map.
Write log messages with source reduction suggestions.
sync
()Removes the source model from the frame data and dependents.
Synchronize all integrations with the source model.
sync_integration
(integration[, signal_mode])Sync an integration.
Generate log messages related to small numbers of pixels in the map.
write
(path)Write the source to file.
Attributes Documentation
- channel_flagspace¶
Return the flags specific to channels.
- Returns:
- Flags
- configuration¶
Return the configuration for the source model.
- Returns:
- Configuration
- exclude_samples¶
Return the sample exclusion flags.
- Returns:
- enum.Enum
- frame_flagspace¶
Return the flags specific to integration frames.
- Returns:
- Flags
- logging_id¶
Return the logging ID.
- Returns:
- str
- n_scans¶
Return the number of scans in the source model.
- Returns:
- int
- recycler = None¶
- referenced_attributes¶
Return attributes that should be referenced during a copy.
For the basic source model, the reduction and any scans will be copied as references to the original.
- Returns:
- set (str)
- signal_mode¶
Return the signal mode flag.
- Returns:
- enum
Methods Documentation
- abstract add_integration(integration)[source]¶
Add an integration to the source model.
- Parameters:
- integrationIntegration
- Returns:
- None
- add_integration_time(time)[source]¶
Add integration time to the source model.
- Parameters:
- timeastropy.units.Quantity
The time to add.
- Returns:
- None
- add_model(source_model, weight=1.0)[source]¶
Add a source model increment onto this model.
- Parameters:
- source_modelSourceModel
Another model to increment this model by.
- weightfloat, optional
The weight of the increment source model.
- Returns:
- None
- abstract add_model_data(source_model, weight=1.0)[source]¶
Add an increment source model data onto the current model.
- Parameters:
- source_modelSourceModel
The source model increment.
- weightfloat, optional
The weight of the source model increment.
- Returns:
- None
- add_process_brief(message)[source]¶
Add a message to the process brief.
- Parameters:
- messagestr
- Returns:
- None
- add_scan_hdus_to(hdul)[source]¶
Add each scan HDU to an HDUL
- Parameters:
- hdulastropy.io.fits.HDUList
The FITS HDU list.
- Returns:
- None
- assign_reduction(reduction)[source]¶
Assign a reduction to the source model.
This method assigns the reduction to this source model, and the source model to the reduction and also sets the info object to be equivalent to the reduction info. Any scans will be replaced by the reduction scans. The reduction configuration will also be updated by any conditionals activated by the source name present in this source model.
- Parameters:
- reductionReduction
- Returns:
- None
- assign_scans(scans)[source]¶
Assign scans to the source model.
- Parameters:
- scanslist (Scan)
A list of scans that should be assigned to THIS source model.
- Returns:
- None
- static check_pixel_count(integration)[source]¶
Check if an integration has enough mapping pixels to generate a map.
Checks are performed depending on whether the following configuration keywords are present for the integration:
- mappingpixels: The number of integration mapping pixels must be greater than this value. - mappingfraction: The ratio of mapping pixels to observing pixels must be greater than or equal to this fraction.
- classmethod clear_recycler()[source]¶
Remove all available models from the recycler.
NOTE: This needs to be done with parallel queues rather than lists.
- Returns:
- None
- copy(with_contents=True)[source]¶
Return a copy of the source model.
- Parameters:
- with_contentsbool, optional
If
True
, return a true copy of the source model. Otherwise, just return a basic version with the necessary meta data.
- Returns:
- SourceModel
- create_from(scans, assign_scans=True)[source]¶
Initialize model from scans.
Sets the model scans to those provided, and the source model for each scan as this. All integration gains are normalized to the first scan. If the first scan is non-sidereal, the system will be forced to an equatorial frame.
- Parameters:
- scanslist (Scan)
A list of scans from which to create the model.
- assign_scansbool, optional
If
True
, assign the scans to this source model. Otherwise, there will be no hard link between the scans and source model.
- Returns:
- None
- edit_header(header)[source]¶
Update a header with model information.
- Parameters:
- headerastropy.fits.header.Header
The FITS header to update.
- Returns:
- None
- get_ascii_header()[source]¶
Return the header for an ASCII output file.
- Returns:
- headerstr
A line space delimited header.
- get_average_resolution()[source]¶
Return the average resolution.
The average resolution is given by:
r = sqrt(sum(wg^2 * integration_resolution^2) / sum(wg^2))
where the sum occurs over all integrations in all scans, w is the weight of the scan belonging to each integration, and g is the gain factor for each integration. If the denominator is zero, then the resolution returned by the source model instrument info is returned instead.
- Returns:
- astropy.units.Quantity
The average resolution.
- get_canonical_source_name()[source]¶
Return the source name with bad characters replaced with ‘_’.
- Returns:
- str
- get_clean_local_copy(full=False)[source]¶
Get an unprocessed copy of the source model.
- Parameters:
- fullbool, optional
If True, copy additional parameters for stand-alone reductions that would otherwise be referenced. Not used for the basic SourceModel.
- Returns:
- SourceModel
- get_executor()[source]¶
Get the parallel process executor for source processing.
The executor is not currently used for anything - this is a placeholder.
- Returns:
- None
- get_native_unit()[source]¶
Return the native unit for the source model
- Returns:
- astropy.units.Quantity
- get_parallel()[source]¶
Get the number of parallel operations for the source model.
- Returns:
- threadsint
- get_recycled_clean_local_copy(full=False)[source]¶
Return a clean local copy of a source model.
If the recycler is active and contains free models, one of those will be returned. Otherwise, one will be generated using
SourceModel.get_clean_local_copy()
.- Parameters:
- fullbool, optional
If True, copy additional parameters for stand-alone reductions that would otherwise be referenced.
- Returns:
- SourceModel
- get_table_entry(name)[source]¶
Return the parameter value for a given name.
- Parameters:
- namestr
- Returns:
- value
- has_option(option)[source]¶
Return whether the configuration option is configured.
In order to be considered “configured”, the option must exist and also have a value.
- Parameters:
- optionstr
- Returns:
- configuredbool
- is_scanning_problem_only()[source]¶
Return whether source model issues may be related to scanning problems.
- Returns:
- speed_problembool
True
if scanning problems are only related to scanning speed.
- no_parallel()[source]¶
Sets the number of parallel operations for the source to 1 (serial).
Not implemented for the basic SourceModel.
- Returns:
- None
- classmethod parallel_safe_sync_integration(args, integration_number)[source]¶
Synchronize a single integration.
This function is safe for use with
multiprocessing.multitask()
.- Parameters:
- args2-tuple
The source pickle filename (str), and a list of integration pickle filenames (list (str)).
- integration_numberint
The index of the integration pickle file to sync.
- Returns:
- integration_filestr
The integration pickle file that was synchronized. The original file is unpickled, synced, and then pickled to the same location.
- parse_header(header)[source]¶
Parse and apply a FITS header.
Completely creates a new Channels instance with a blank info, but updated with the FITS header.
- Parameters:
- headerastropy.fits.Header
- Returns:
- None
- post_process_scan(scan)[source]¶
Apply post processing steps to a scan.
- Parameters:
- scanScan
- Returns:
- None
- recycle()[source]¶
Add this source model to the list of available recycled source models.
- Returns:
- None
- renew()[source]¶
Renew the source model.
Renewing the source model consists of resetting the processing and clearing all content.
- Returns:
- None
- set_executor(executor)[source]¶
Set the parallel process executor for source processing.
The executor is not currently used for anything - this is a placeholder.
- Parameters:
- executorobject
- Returns:
- None
- set_info(info)[source]¶
Set the primary Info object for the source model.
This sets the provided
info
as the primary Info object containing the configuration and reduction information for the source model. The source model will also take ownership of theinfo
.- Parameters:
- infosofia_redux.info.info.Info
- Returns:
- None
- set_parallel(threads)[source]¶
Set the number of parallel operations for the source model.
- Parameters:
- threadsint
- Returns:
- None
- classmethod set_recycler_capacity(size)[source]¶
Set the number of available models in the recycler.
- Parameters:
- sizeint
- Returns:
- None
- static source_option(option_name)[source]¶
Return the name of the option in configuration specific to the source.
- Parameters:
- option_namestr
Name of the option.
- Returns:
- str
- static suggest_make_valid()[source]¶
Return a message suggestion corrections to an invalid map.
- Returns:
- messagestr
- sync_all_integrations()[source]¶
Synchronize all integrations with the source model.
Sync (subtract the source model) from all integrations in all scans used to generate the source model. If parallel processing is enabled, this will be done in parallel using the available_reduction_jobs * parallel_tasks jobs.
- Returns:
- None
- abstract sync_integration(integration, signal_mode=None)[source]¶
Sync an integration.
- Parameters:
- integrationIntegration
- signal_modeFrameFlagTypes
The signal mode flag, indicating which signal should be used to extract the frame source gains. Typically, TOTAL_POWER.
- Returns:
- None