The andata.Reader is initialized with the filename list part
of the data interval then the time range part of the data interval is
used as an arguments to andata.Reader.select_time_range().
This class gives a convenient way to search and filter data acquisitions
as well as time ranges of data within acquisitions. Search results
constitute a list of files within an acquisition as well as a time range for
the data within these files. Convenient methods are provided for loading
the precise time range of constituting a search result.
This is intended to make the most common types of searches of CHIME data as
convenient as possible. However for very complex searches, it may be
necessary to resort to the lower level interface.
Searching the index
There are four ways that a search can be modified which may be combined in
any way.
You can restrict the types of acquisition that are under
consideration, using methods whose names begin with only_.
In this way, one can consider only, say, housekeeping acquisitions.
The second is to adjust the total time range under consideration.
This is achieved by assigning to time_range or calling
methods beginning with set_time_range_. The total time range affects
acquisitions under consideration as well as the data time ranges within
the acquisitions. Subsequent changes to the total time range under
consideration may only become more restrictive.
The data index may also be filtered by acquisition using methods whose
names begin with filter_acqs. Again subsequent filtering are always
combined to become more restrictive. The attribute acqs
lists the acquisitions currently included in the search for convenience
when searching interactively.
Time intervals within acquisitions are added using methods with names
beginning with include_. Time intervals are defined in the
time_intervals attribute, and are inclusive (you can
add as many as you want).
Finally, upon calling :meth:get_results or :meth:get_results_acq,
one can pass an arbitrary condition on individual files, thereby
returning only a subset of files from each acquisition.
Getting results
Results of the search can be retrieved using methods whose names begin with
get_results An individual search result is constituted of a list of file
names and a time interval within these files. These can easily loaded into
memory using helper functions (see BaseDataInterval and
DataIntervalList).
Parameters:
acqs (list of chimedb.data_index.ArchiveAcq objects) – Acquisitions to initially include in data search. Default is to search
all acquisitions.
node_spoof (dictionary) – Normally, the DB will be queried to find which nodes are mounted on your
host. If you are on a machine that is cross-mounted, though, you can
enter a dictionary of “node_name”: “mnt_root” pairs, specifying the
nodes to search and where they are mounted on your host.
Examples
To find all the correlator data between two times.
>>> fromch_utilimportfinder>>> fromdatetimeimportdatetime>>> f=finder.Finder()>>> f.only_corr()>>> f.set_time_range(datetime(2014,02,24),datetime(2014,02,25))>>> f.print_results_summary()interval | acquisition | offset from start (s) | length (s) | N files 1 | 20140219T145849Z_abbot_corr | 378053.1 | 86400.0 | 25 2 | 20140224T051212Z_stone_corr | 0.0 | 67653.9 | 19Total 154053.858720 seconds of data.
Search for transits of a given source.
>>> importch_ephem.sources>>> f.include_transits(ch_ephem.sources.CasA,time_delta=3600)>>> f.print_results_summary()interval | acquisition | offset from start (s) | length (s) | N files 1 | 20140219T145849Z_abbot_corr | 452087.2 | 3600.0 | 2 2 | 20140224T051212Z_stone_corr | 55288.0 | 3600.0 | 2Total 7200.000000 seconds of data.
To read the data,
>>> fromch_utilimportandata>>> results_list=f.get_results()>>> # Pick result number 1>>> result=results_list[0]>>> # Pick product number 0 (autocorrelation)>>> data=result.as_loaded_data(prod_sel=0)>>> printdata.vis.shape(1024, 1, 360)
More intricate filters on the acquisitions are possible.
condition (peewee comparison) – Condition on any on chimedb.data_index.ArchiveAcq or any
class joined to chimedb.data_index.ArchiveAcq: using the
syntax from the peewee module [1].
Filter the acquisitions by the properties of its files.
Because each acquisition has many files, this filter should be
significantly slower than Finder.filter_acqs().
Parameters:
condition (peewee comparison) – Condition on any on chimedb.data_index.ArchiveAcq,
chimedb.data_index.ArchiveFile or any class joined to
chimedb.data_index.ArchiveFile using the syntax from the
peewee module [2].
file_condition (peewee comparison) – Any additional condition for filtering the files within the
acquisition. In general, this should be a filter on one of the file
information tables, e.g., chimedb.data_index.CorrFileInfo.
Get search results restricted to a given acquisition.
Parameters:
acq_ind (int) – Index of Finder.acqs for the desired acquisition.
file_condition (peewee comparison) – Any additional condition for filtering the files within the
acquisition. In general, this should be a filter on one of the file
information tables, e.g., CorrFileInfo.
Defines how global flags are treated when finding data. There are three
severities of global flag: comment, warning, and severe. There are
four possible behaviours when a search result overlaps a global flag,
represented by module constants:
GF_REJECT:
Reject any data overlapping flag silently.
GF_RAISE:
Raise an exception when retrieving data intervals.
GF_WARN:
Send a warning when retrieving data intervals but proceed.
GF_ACCEPT:
Accept the data silently, ignoring the flag.
The behaviour for all three severities is represented by a dictionary.
If no mode is set, then the default behaviour is
{‘comment’ : GF_ACCEPT, ‘warning’ : GF_WARN, ‘severe’ : GF_REJECT}.
Initialize Finder when not working on a storage node.
Normally only data that is available on the present host is searched,
and as such Finder can’t be used to browse the index when you
don’t have access to the acctual data. Initializing using this method
spoofs the ‘gong’ and ‘niedermayer’ storage nodes (which should have a
full copy of the archive) such that the data index can be search the
full archive.
Print the acquisitions included in this search and thier properties.
This method is convenient when searching the data index interactively
and you want to see what acquisitions remain after applying filters or
restricting the time range.
This is a shortcut for specifying
file_condition=(chimedb.data_index.HKFileInfo.atmel_name==name)
in get_results_acq(). Instead, one can simply call this function
with name as, e.g., “LNA”, “FLA”, and calls to
get_results_acq() will be appropriately restricted.
This method updates the time_range property and also
excludes any acquisitions that do not overlap with the new range. This
method always narrows the time range under consideration, never expands
it.
Parameters:
start_time (float or datetime.datetime) – Unix/POSIX time or UTC start of desired time range. Optional.
end_time (float or datetime.datetime) – Unix/POSIX time or UTC end of desired time range. Optional.