astro.main.ReadNoise (version @(#)$Revision: 1.82 $)
index
/astro-wise/AWEHOME/AWBASE/astro/main/ReadNoise.py

read noise (req521) in ADU
 
The read noise measurement is a standard health check of the instrument.

 
Modules
       
datetime
math

 
Classes
       
astro.main.ProcessTarget.ProcessTarget(common.database.DBMeta.DBMixin, astro.main.OnTheFly.OnTheFly)
ReadNoise(common.database.DBMain.DBObject, astro.main.ProcessTarget.ProcessTarget)
common.database.DBMain.DBObject(__builtin__.object)
ReadNoise(common.database.DBMain.DBObject, astro.main.ProcessTarget.ProcessTarget)
ReadNoiseParameters

 
class ReadNoise(common.database.DBMain.DBObject, astro.main.ProcessTarget.ProcessTarget)
    Class for read noise objects.
 
The read-noise in ADU is rms/sqrt(2) of the difference between two
bias exposures. The read noise object can be created using:
 
>>> rn = ReadNoise()
>>> rn.raw_bias_frames = [RawBiasFrame(pathname='bias1.fits'),
                          RawBiasFrame(pathname='bias2.fits')]
>>> rn.make()
 
 
Method resolution order:
ReadNoise
common.database.DBMain.DBObject
astro.main.ProcessTarget.ProcessTarget
common.database.DBMeta.DBMixin
__builtin__.object
astro.main.OnTheFly.OnTheFly

Methods defined here:
__init__(self)
after_set_onthefly_dependencies(self, switches, advanced)
limit the number of raw bias frames to max 2
after_uptodate_object(self, dependencies_missing, dependencies_new, dependencies_obsolete)
For readnoise it does not matter if there are new RawBiasFrames
calculate_readnoise(self)
check_preconditions(self)
compare(self)
Verify the measured read_noise by comparing to the previous version
 
Requires:
    prev -- previous ReadNoise measurement
 
The following flag may be set:
    READNOISE_DIFFERENCE_TOO_HIGH -- Difference > process_params.MAXIMUM_READNOISE_DIFFERENCE
copy_attributes(self)
derive_timestamp(self)
Assign the default period for which the ReadNoise is valid.
 
The ReadNoise object is assumed to be valid for the night
following the day the observations were taken.
make(self)
Do a read_noise measurement
 
Requires:
    raw_bias_frames -- list of two RawBiasFrame objects (biases)
 
Parameters:
    process_params.REJECTION_THRESHOLD -- for bad pixels (sigma)
    process_params.MAXIMUM_ITERATIONS -- for estimating the statistics
 
Updates:
    read_noise -- The rms of the difference, divided by sqrt(2)
    mean_diff -- The mean difference between the biases
    median_diff -- The median of the difference betwen the biases
 
The read_noise is computed by subtracting the two raw bias images, and
dividing the standard deviation by sqrt(2). The descriptor value
read_noise will be set to the computed value.
 
The statistics of the difference between the raw biases is
computed iteratively. Bad pixels are rejected if they differ
more than process_params.REJECTION_THRESHOLD sigma from the median.
The maximum number of iteration is process_params.MAXIMUM_ITERATIONS
verify(self)
Verify the read noise measurement
 
The following flag may be set:
   BIAS_DIFFERENCE_TOO_HIGH -- Mean of the difference > self.process_params.MAXIMUM_BIAS_DIFFERENCE

Class methods defined here:
select_input_from_list(cls, raw_bias_frames) from common.database.DBMeta.DBObjectMeta
Select suitable input raw biases from a list of RawBiasFrames,
selecting only those biases for which:
   1) the raw biases are valid
   2) the time difference between successive observations is < 10 min
   3) the difference in their imstat.mean < MAXIMUM_BIAS_DIFFERENCE

Data descriptors defined here:
BIAS_DIFFERENCE_TOO_HIGH
READNOISE_DIFFERENCE_TOO_HIGH
READNOISE_TOO_HIGH
chip
Information about the chip [None]
creation_date
Date this object was created [None]
instrument
Information about the instrument [None]
is_valid
Manual/external flag to disqualify bad data (SuperFlag) [None]
mean_diff
The mean difference between biases [ADU]
median_diff
The median difference between biases [ADU]
object_id
The object identifier
 
The object identifier is an attribute shared by all persistent
instances. It is the prime key, by which object identity is established
observing_block
Information about the observing block [None]
process_params
Processing parameters [None]
process_status
A flag indicating the processing status [None]
quality_flags
Automatic/internal quality flag [None]
raw_bias_frames
The RawBiasFrames used to do the measurement [None]
read_noise
The read noise measurement [ADU]
template
Information about the template [None]
timestamp_end
End of valid period [None]
timestamp_start
Start of valid period [None]

Data and other attributes defined here:
PROCESS_TIME = 10
mandatory_dependencies = (('raw_bias_frames', 2),)
prev = None

Methods inherited from common.database.DBMain.DBObject:
__del__(self)
Destructor for the DBObject
 
This destructor is called by the garbage collector for the transient
part of the DBObject. When it is called it calls the gc_transient()
method of the DBProxy implementation. The implementation of the
gc_transient() method can then decide what to do with the persistent
counterpart.
E.g. the database can be synchronized with its transient counterpart.
Another possibility is that the gc_transient() implementation checks
whether any attributes of a read-only object have changed since an
object was fetched from the database. If there are differences an
exception can be raised.
__reduce__(self)
Method necessary to create picklable objects
 
This mehod return a tuple containg a function object used for
unpickling and a picklable state tuple, to be used as argument
to the unpickle function. If necessary this object is registered
in the pickle cache
as_dict(self, seqnr=1, dependency_name='', dictionary={}, allow_lazy_typed_list=False)
Method much like the info method, but returns a dictionary.
 
Dictionary looks like:
  {'<classname>.<property1_name>.<property2_name>': value,
   '<classname>.<property2_name>.<property3_name>': value}
 
Problem: infinite loops for cold/flat dependencies. It seems a maximum
recursion depth limits the problem.
commit(self)
Commits object including objects that are referenced and have been changed.
 
If this object refers to other persistent object a commit() ensures that
 
1. ALL changes to the object and referred objects are made persistent.
2. NONE of the changed object and referred objects are made persistent.
Under normal circumstances only the first thing should ever happen.
If the second case occurs it is almost certainly because of some bug in
the routine that implements the DBProxy interface.
get_creator(self)
Returns the name of the user who created this object.
get_persistent(self)
get_project(self)
Returns the name of the project to which this object belongs.
info(self, level=0, doc=False, _indent=0, _printclass=True)
Print the values of all persistent properties of the object.
 
level       : level of introspection
doc         : display docstrings for attributes
_indent     : internal parameter used for formatting
_printclass : internal parameter used for formatting
inverse_objects(self, max_results=100)
Iterate through and return all objects that use the current object
max_results     The maximum number of objects returned per query
inverse_query(self)
go through all inverse properties to see if this object is used
persists(self)
Returns whether an object is already made persistent or transient.
recommit(self)
Commits changes to an object, without following links.

Class methods inherited from common.database.DBMain.DBObject:
get_inverse_properties(cls, props=None) from common.database.DBMeta.DBObjectMeta
return all inverse properties 
that are all the properties that point to this class

Data descriptors inherited from common.database.DBMain.DBObject:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from common.database.DBMain.DBObject:
__metaclass__ = <class 'common.database.DBMeta.DBObjectMeta'>
This is the metaclass for persistent classes
 
Provides:
  __new__ -- manages class construction
  __call__ -- manages object instantiation
database = <common.database.DBOracle.DBProxy instance at 0xfb1a28>
pickle_id = None

Methods inherited from astro.main.ProcessTarget.ProcessTarget:
check_mandatory_dependencies(self)
check if all the mandatory dependencies are set
check_observing_blocks(self, childs)
check if all childs have the same observing_block
check_templates(self, childs)
check if all childs have the same template
get_dependencies(self)
Return a list of names of attributes that are required for make()
get_qcflags_set(self)
Return a list of names of flags that have been set.
get_qcflags_set_dict(self)
Return a dictionary of flags that have been set.  The key is the
name, the value is a tuple of (index, docstring).
inspect(self)
Quality Control -- visual inspection
 
Visual inspection of the data remains a powerful tool in
quality control. The inspect() method provides the mechanism
to record the results of visual inspection for posterity.
is_compared(self)
Return true if the object has been compared
is_inspected(self)
Return true if the object has been inspected
is_made(self)
Return true if the object has been made
is_ok(self)
Return true if no quality control flags have been set.
is_verified(self)
Return true if the object has been verified
set_compared(self)
Set the process status to indicate that the object has been
compared.
set_inspected(self)
Set the process status to indicate that the object has been
inspected.
set_made(self)
Set the process tatus to indicate that the object has been made
set_process_parameters_from_dict(self, pars={})
pars is a dictionary of the type e.g.:
{'BiasFrame.process_params.SIGMA_CLIP':8}
set_user_config(self, user_config_dict)
Store the user specified configuration (as produced e.g. by the
util.Pars tool) in a transient attribute.
set_verified(self)
Set the process status to indicate that the object has been
verified.

Class methods inherited from astro.main.ProcessTarget.ProcessTarget:
get_qcflags(cls) from common.database.DBMeta.DBObjectMeta
Return a list of attribute names of QCflag() objects.
is_cal(cls) from common.database.DBMeta.DBObjectMeta
Test for being cal, derived raw classes should set _IS_CAL to 1
is_config(cls) from common.database.DBMeta.DBObjectMeta
Test for being config, derived raw classes should set _IS_CONFIG
to 1
is_raw(cls) from common.database.DBMeta.DBObjectMeta
Test for being raw, derived raw classes should set _IS_RAW to 1
is_science(cls) from common.database.DBMeta.DBObjectMeta
Test for being science, derived raw classes should set _IS_SCIENCE
to 1
is_seq(cls) from common.database.DBMeta.DBObjectMeta
Test for being seq, derived raw classes should set _IS_SEQ to 1
is_support(cls) from common.database.DBMeta.DBObjectMeta
Test for being config, derived raw classes should set _IS_SUPPORT
to 1
select(cls, **searchterms) from common.database.DBMeta.DBObjectMeta
Class method to select RawFrames, Calfiles and ReducedScienceFrames
from the database.
 
Syntax example:
 
q = RawScienceFrame.select(instrument='WFI', filter='#842',
    chip='ccd50', time_from='2000-01-02 04:45:46',
    time_to='2000-01-02 05:03:00')
 
Possible search terms:
----------------------
check_quality  - (Default 1) Exclude invalidated data (quality_flags!=0)
check_validity - (Default 1) Exclude invalidated data (is_valid=0)
chip        - select of the same CCD ('ccd50', 'ccd51', etc.)
date        - select of the same date (i.e. date at the start of
              observing night, in yyyy-mm-dd format)
exptime     - select frames with similar exposure time
              (EXPTIME-0.8sec to EXPTIME+0.8 sec)
extension   - select (raw) frames for a certain extension of its
              RawFitsData object
filename    - select a frame(!) by its filename
filter      - select of the same filter ('#842', '#843', etc.)
instrument  - select of the same instrument ('WFI', 'WFC', 'OCAM')
object      - select for OBJECT header keyword, uses "like"
              functionality, which allows wildcards "*" and "?"
time_from   - precise form of date, in yyyy-mm-dd hh:mm:ss format
time_to     - required when using time_from
select_for_raw(cls, raw, overscan=None, check_quality=1, check_validity=1) from common.database.DBMeta.DBObjectMeta
Class method to select the most recent valid calfile for the
provided raw frame from the database.
select_for_reduced(cls, reduced, overscan=None, check_quality=1, check_validity=1) from common.database.DBMeta.DBObjectMeta
Synonym for the select_for_raw method; the implementation should
be identical.

Data and other attributes inherited from astro.main.ProcessTarget.ProcessTarget:
STATUS_COMPARE = 2
STATUS_INSPECT = 3
STATUS_MAKE = 0
STATUS_VERIFY = 1

Class methods inherited from common.database.DBMeta.DBMixin:
get_persistent_attributes(cls) from common.database.DBMeta.DBObjectMeta
return a list of persistent attributes

Methods inherited from astro.main.OnTheFly.OnTheFly:
Flagged(self)
Check if any flag is set
return 1 for flag is set
return 0 no flag
after_do_make(self, switches=None)
extra make statements, this method can be overridden by OnTheFly classes to
implement extra make statements which will be executed after the make of self
check_for_mandatory(self, dep_str, dep_new)
check if dependency is mandatory and present
dep_str is the name of the attribute, dep_new is the (attribute) object
get_onthefly_dependencies(self, advanced=None)
Method retrieves a list of all dependencies used for
on-the-fly processing
Return: [dependency, dependency class, dependency name]
uptodate(self, date_time=None, template=None, switches=None, advanced=None)
This method checks if the object is up-to-date, for the given datetime.
OnTheFly_uptodate class has the functionality for checking uptodate

Class methods inherited from astro.main.OnTheFly.OnTheFly:
exist(cls, date_time=None, chip=None, filter=None, object_id=None, parent=None, parent_attr=None, template=None, extra=[], advanced=None, switches=None) from common.database.DBMeta.DBObjectMeta
for the given parameters and class return the most
recent object(s), or None
get_onthefly(cls, date_time=None, filter=None, chip=None, object_id=None, advanced=None, switches=None, template=None, parent=None, parent_attr=None) from common.database.DBMeta.DBObjectMeta
For the given parameters and class get the object,
if the object does not exist -> make it.
This is done recursively for all dependencies.
 
The object can only be made if there are raws

 
class ReadNoiseParameters(common.database.DBMain.DBObject)
    The parameters used in ReadNoise processing and verification.
 
 
Method resolution order:
ReadNoiseParameters
common.database.DBMain.DBObject
__builtin__.object

Data descriptors defined here:
MAXIMUM_BIAS_DIFFERENCE
QC: Maximum difference between biases [ADU]
MAXIMUM_ITERATIONS
The maximum number of iterations [None]
MAXIMUM_READNOISE
QC: The maximum value for read_noise [ADU]
MAXIMUM_READNOISE_DIFFERENCE
QC: Maximum difference between measuremets [ADU]
REJECTION_THRESHOLD
The threshold rejecting outlying pixels [None]
SOURCE_CODE_VERSION
The version of the source code [None]
object_id
The object identifier
 
The object identifier is an attribute shared by all persistent
instances. It is the prime key, by which object identity is established

Methods inherited from common.database.DBMain.DBObject:
__del__(self)
Destructor for the DBObject
 
This destructor is called by the garbage collector for the transient
part of the DBObject. When it is called it calls the gc_transient()
method of the DBProxy implementation. The implementation of the
gc_transient() method can then decide what to do with the persistent
counterpart.
E.g. the database can be synchronized with its transient counterpart.
Another possibility is that the gc_transient() implementation checks
whether any attributes of a read-only object have changed since an
object was fetched from the database. If there are differences an
exception can be raised.
__reduce__(self)
Method necessary to create picklable objects
 
This mehod return a tuple containg a function object used for
unpickling and a picklable state tuple, to be used as argument
to the unpickle function. If necessary this object is registered
in the pickle cache
as_dict(self, seqnr=1, dependency_name='', dictionary={}, allow_lazy_typed_list=False)
Method much like the info method, but returns a dictionary.
 
Dictionary looks like:
  {'<classname>.<property1_name>.<property2_name>': value,
   '<classname>.<property2_name>.<property3_name>': value}
 
Problem: infinite loops for cold/flat dependencies. It seems a maximum
recursion depth limits the problem.
commit(self)
Commits object including objects that are referenced and have been changed.
 
If this object refers to other persistent object a commit() ensures that
 
1. ALL changes to the object and referred objects are made persistent.
2. NONE of the changed object and referred objects are made persistent.
Under normal circumstances only the first thing should ever happen.
If the second case occurs it is almost certainly because of some bug in
the routine that implements the DBProxy interface.
get_creator(self)
Returns the name of the user who created this object.
get_persistent(self)
get_project(self)
Returns the name of the project to which this object belongs.
info(self, level=0, doc=False, _indent=0, _printclass=True)
Print the values of all persistent properties of the object.
 
level       : level of introspection
doc         : display docstrings for attributes
_indent     : internal parameter used for formatting
_printclass : internal parameter used for formatting
inverse_objects(self, max_results=100)
Iterate through and return all objects that use the current object
max_results     The maximum number of objects returned per query
inverse_query(self)
go through all inverse properties to see if this object is used
persists(self)
Returns whether an object is already made persistent or transient.
recommit(self)
Commits changes to an object, without following links.

Class methods inherited from common.database.DBMain.DBObject:
get_inverse_properties(cls, props=None) from common.database.DBMeta.DBObjectMeta
return all inverse properties 
that are all the properties that point to this class

Data descriptors inherited from common.database.DBMain.DBObject:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from common.database.DBMain.DBObject:
__metaclass__ = <class 'common.database.DBMeta.DBObjectMeta'>
This is the metaclass for persistent classes
 
Provides:
  __new__ -- manages class construction
  __call__ -- manages object instantiation
database = <common.database.DBOracle.DBProxy instance at 0xfb1a28>
pickle_id = None

 
Data
        __version__ = '@(#)$Revision: 1.82 $'