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

channel_flagspace

Return the flags specific to channels.

configuration

Return the configuration for the source model.

exclude_samples

Return the sample exclusion flags.

frame_flagspace

Return the flags specific to integration frames.

logging_id

Return the logging ID.

n_scans

Return the number of scans in the source model.

recycler

referenced_attributes

Return attributes that should be referenced during a copy.

signal_mode

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()

Clear all memory references prior to deletion.

clear_content()

Clear the contents of the source model.

clear_process_brief()

Remove all process brief information.

clear_recycler()

Remove all available models from the recycler.

copy([with_contents])

Return a copy of the source model.

count_points()

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.

get_ascii_header()

Return the header for an ASCII output file.

get_average_resolution()

Return the average resolution.

get_blanking_level()

Return the blanking level from the configuration.

get_canonical_source_name()

Return the source name with bad characters replaced with '_'.

get_clean_local_copy([full])

Get an unprocessed copy of the source model.

get_clipping_level()

Return the clipping level from the configuration.

get_default_core_name()

Return a descriptive name for the source model.

get_executor()

Get the parallel process executor for source processing.

get_first_scan()

Return the first scan in the source model scans.

get_kelvin_unit()

Return the kelvin unit.

get_native_unit()

Return the native unit for the source model

get_parallel()

Get the number of parallel operations for the source model.

get_point_size()

Return the point size of the source model.

get_recycled_clean_local_copy([full])

Return a clean local copy of a source model.

get_reference()

Return the reference (x, y) coordinate.

get_source_name()

Return the source name for the source model.

get_source_size()

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.

is_scanning_problem_only()

Return whether source model issues may be related to scanning problems.

is_valid()

Return whether the source model is valid or not.

next_generation()

Initiate a new source model generation.

no_parallel()

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_processing()

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.

suggest_make_valid()

Return a message suggestion corrections to an invalid map.

suggestions()

Write log messages with source reduction suggestions.

sync()

Removes the source model from the frame data and dependents.

sync_all_integrations()

Synchronize all integrations with the source model.

sync_integration(integration[, signal_mode])

Sync an integration.

troubleshoot_few_pixels()

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.
Parameters:
integrationIntegration

The integration to check.

Returns:
validbool

True if the integration has enough pixels, and False otherwise.

clear_all_memory()[source]

Clear all memory references prior to deletion.

Returns:
None
abstract clear_content()[source]

Clear the contents of the source model.

Returns:
None
clear_process_brief()[source]

Remove all process brief information.

Returns:
None
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
abstract count_points()[source]

Return the number of points in the model.

Returns:
int
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_blanking_level()[source]

Return the blanking level from the configuration.

Returns:
float
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_clipping_level()[source]

Return the clipping level from the configuration.

Returns:
float
get_default_core_name()[source]

Return a descriptive name for the source model.

Returns:
str
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_first_scan()[source]

Return the first scan in the source model scans.

Returns:
Scan
get_kelvin_unit()[source]

Return the kelvin unit.

Returns:
units.Quantity
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_point_size()[source]

Return the point size of the source model.

Returns:
units.Quantity
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
abstract get_reference()[source]

Return the reference (x, y) coordinate.

Returns:
2-tuple
abstract get_source_name()[source]

Return the source name for the source model.

Returns:
str
get_source_size()[source]

Return the source size of the source model.

Returns:
units.Quantity
get_table_entry(name)[source]

Return the parameter value for a given name.

Parameters:
namestr
Returns:
value
abstract get_unit()[source]

Return the source model unit.

Returns:
astropy.units.Quantity
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.

abstract is_valid()[source]

Return whether the source model is valid or not.

Returns:
bool
next_generation()[source]

Initiate a new source model generation.

Returns:
None
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
abstract process()[source]

Process the source model.

Returns:
None
abstract process_scan(scan)[source]

Process 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
reset_processing()[source]

Reset the source processing.

Returns:
None
abstract set_base()[source]

Set the base data for the source model.

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 the info.

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
suggestions()[source]

Write log messages with source reduction suggestions.

Returns:
None
sync()[source]

Removes the source model from the frame data and dependents.

Returns:
None
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
troubleshoot_few_pixels()[source]

Generate log messages related to small numbers of pixels in the map.

Returns:
scanning_problem_onlybool

True if the problem relates to scanning speeds; False if there are other issues in play.

abstract write(path)[source]

Write the source to file.

Parameters:
pathstr

The file path to write to.

Returns:
None