get files and keys functions

This file creates the filelist depending on the user input as well as the keywords input

dfitspy.get_files_and_keys.get_files(files, dire=False)

This function extracts the list of files based on the files and dire parameter.

example: get_files([‘fil1.fits,file2.fits’] , ‘/home/Documents’) example: get_files([‘fil1.fits,file2.fits’])

Parameters:
fileslist of str

list of files names (without path), it can be:

[‘file1.fits,file2.fits,….’]

[‘file1.fits’]

[‘file1,fits’, ‘file2.fits’]

[‘all’]

direstr

path of the directory to look in

Returns:
allfileslist

list of all the files

dfitspy.get_files_and_keys.get_keys(key_string)

This function extracts from a string the list of keys

Parameters:
keystringstring

keys to be requested by user, example:

SEEING

SEEING,AIRMASS

SEEING,ARIMASS,OBID

if a string contains dots, e.g, ESO.SEQ.ARM it will be transform to ESO SEQ ARM (with spaces)

Returns:
keyslist

list of keys (string)

readfits functions

This file organises and reads the FITS files

dfitspy.readfits.dfitsort(listfiles, listkeys, exact=False, grepping=None, HDU=0)

This function get for all files, the value of all the keywords that are passed

Parameters:
listfileslisr

list, with file names (string, path included)

listkeyslist

list, of keywords (strings)

greplist

list of string, if not false, the grepping valueS will be compared to all the values of the keywords. If all grepping values appear in the header of one file the file will be kept

exactbool

if the exact keyword from the user must be retrieved. If not, any keyword containing the requested keyword will be used.

HDUint

extension number to look in. Default is primary: 0

Returns:
file_dictdictionary

dictionary, keys=filename & values=dictionnary of keyword-value pairs

Examples

dfitsort([file1, file2], [key1, key2]) <– no grep

dfitsort([file1, file2], [key1, key2], [‘match’, ‘match2’]) <– multi grep

dfitspy.readfits.get_all_keyword(thefile, HDU=0)

This function gets all the keyword in the header of the file

Parameters:
thefile str

path/and/file.txt

HDU int

FITS extension number to get the keywords from

Returns:
keywords list

list of keywords (string)

display function

dfitspy is a program aimed at reproducing the dfits program in python. This file codes the display in the terminal

@place: ESO - La Silla - Paranal Observatory @author(s): Romain Thomas @year(s): 2018-2020 @First version: 19.9-0 @Current version: 20.7.0 @Telescope(s): ALL @Instrument(s): ALL @Documentation url: @Last review [date + name]: 2020-07-21 - Romain Thomas

dfitspy.display.dfitsort_view(values_dict)

This function displays a-la-dfits the requested informations

First we display the number of files that was found and then we display the header with keywords

Parameters:
values_dictdictionnary

keys=filename & values=dictionnary of keyword-value pair

Returns:
None (prints in terminal)
dfitspy.display.keywords_view(keywords)

This function displays the list of keywords given in parameters. By default it displays it in a 3 columns display.

Parameters:
keywordslist

list of keywords (each keyword is a string)

Returns:
None (display in terminal)

tests module

This file organises the tests of the library

dfitspy.tests.test()

This function calls the test of each module and run them