FitsFileGroup#
- class astropop.file_collection.FitsFileGroup(location=None, files=None, ext=0, compression=False, database=':memory:', **kwargs)#
Bases:
object
Easy handle groups of fits files.
- Parameters:
- locationstr, optional
Location of the fits files. If not specified, the files must be specified in the files parameter.
- fileslist, optional
List of files to be included in the group. If not specified, the location parameter must be specified.
- extint, optional
FITS extension to be used. Default is 0.
- compressionbool, optional
If True, add compression file name extensions to the list of extensions to be searched. Default is False.
- databasestr, optional
SQLite database to be used to store the information. Default is ‘:memory:’, which means that the database will be stored in memory.
- glob_includestr, optional
Glob pattern to include files. Default is None.
- glob_excludestr, optional
Glob pattern to exclude files. Default is None.
- fits_extstr, optional
FITS file name extension to be used. Default is None, wich means that the default extensions will be used.
- show_progress_barbool, optional
If True, show a progress bar while reading the files. Default is False. Requires
tqdm
module. May not be compatible with every mod.
Attributes Summary
List files in the group.
List the keywords of the headers table.
Get a readonly table with summary of the fits files.
Methods Summary
add_column
(name[, values])Add a new column to the summary.
add_file
(file)Add a new file to the group.
data
([ext])Read the files and iterate over their data.
filtered
(keywords)Create a new FitsFileGroup with only filtered files.
framedata
([ext])Read the files and iterate over their data.
full_path
(file)Get the full path of a file in the group.
group_by
(keywords)Create FitsFileGroups grouped by keywords.
hdus
([ext])Read the files and iterate over their HDUs.
headers
([ext])Read the files and iterate over their headers.
relative_path
(file)Get the relative path of a file.
remove_file
(file)Remove a file from the group.
update
([files, location, compression])Update the database with the current files.
values
(keyword[, unique])Return the values of a keyword in the summary.
Attributes Documentation
- files#
List files in the group.
- keys#
List the keywords of the headers table.
- summary#
Get a readonly table with summary of the fits files.
Methods Documentation
- add_column(name, values=None)#
Add a new column to the summary.
- Parameters:
- namestr
Name of the column.
- valueslist, optional
List of values for the column. If None, the column is initialized with null values.
- add_file(file)#
Add a new file to the group.
- Parameters:
- filestr
File name with absolute path or relative to the filegroup location.
- data(ext=None, **kwargs)#
Read the files and iterate over their data.
- filtered(keywords)#
Create a new FitsFileGroup with only filtered files.
- Parameters:
- keywordsdict
Dictionary with the keywords to be used to filter the files. The keys are the column names and the values are the values to be used to filter the files.
- Returns:
- FitsFileGroup
A new FitsFileGroup with only the files that match the keywords.
- framedata(ext=None, **kwargs)#
Read the files and iterate over their data.
- full_path(file)#
Get the full path of a file in the group.
- Parameters:
- filestr or int
If string, the file name. If int, the index of the file.
- Returns:
- pathstr
Full path of the file.
- group_by(keywords)#
Create FitsFileGroups grouped by keywords.
- Parameters:
- keywordslist
List of column names to be used to group the files.
- Yields:
- FitsFileGroup
A new FitsFileGroup with only the files that match the keywords.
- hdus(ext=None, **kwargs)#
Read the files and iterate over their HDUs.
- headers(ext=None, **kwargs)#
Read the files and iterate over their headers.
- relative_path(file)#
Get the relative path of a file.
- Parameters:
- filestr
Full path of the file.
- Returns:
- pathstr
Relative path of the file.
- remove_file(file)#
Remove a file from the group.
- Parameters:
- filestr or int
If string, the file name with absolute path or relative to the filegroup location. If int, the index of the file.
- update(files=None, location=None, compression=False)#
Update the database with the current files.
- values(keyword, unique=False)#
Return the values of a keyword in the summary.
- Parameters:
- keywordstr
Name of the keyword to be used to filter the files.
- uniquebool, optional
If unique, only unique values returned.
- Returns:
- list
List of values for the keyword.