dfitspy package

Submodules

dfitspy.cli module

—dfitspy—

dfitspy is a program aimed at reproducing the dfits program in python. the functions can be used inside another program or it can also be called as an executable

This file organises the command line interface (and nunit test it)

@place: ESO - La Silla - Paranal Observatory @author(s): Romain Thomas @year(s): 2018 @First version: 18.09-0 @Current version: 18.10-0 @Telescope(s): ALL @Instrument(s): ALL @Valid for SciOpsPy: v0.1-b @Documentation url: @Last SciOps review [date + name]: 18-09-2018 - Romain Thomas @Usage: inside another code (dfitspy) @Licence: GPL @Testable: Yes @Test data place (if any required): N.A.

class dfitspy.cli.Interfacetest(methodName='runTest')

Bases: unittest.case.TestCase

Class that define the test for the command line interface

test_cli()

This method tests the command line interface The principle is that we send some argument configuration and see what the interface is giving back

dfitspy.cli.command_line(args)

This function defines the command line interface of the program. It is used only if dfitspy is used as an executable

None

args Namespace with arguments

dfitspy.display module

—dfitspy—

dfitspy is a program aimed at reproducing the dfits program in python. the functions can be used inside another program or it can also be called as an executable

This file organises the terminal display of the output od the code, if used as an executable

@place: ESO - La Silla - Paranal Observatory @author(s): Romain Thomas @year(s): 2018 @First version: 18.09-0 @Current version: 18.10-0 @Telescope(s): ALL @Instrument(s): ALL @Valid for SciOpsPy: v0.1-b @Documentation url: @Last SciOps review [date + name]: 18-09-2018 - Romain Thomas @Usage: inside another code (dfitspy) @Licence: GPL @Testable: Yes @Test data place (if any required): N.A.

class dfitspy.display.Testdisplayfinal(methodName='runTest')

Bases: unittest.case.TestCase

Class that tests the final display function

displayfinal(param, exp, mock_stdout)

Function that actually run the test

test_displayfinal()

test the final display function

class dfitspy.display.Testdisplaylist(methodName='runTest')

Bases: unittest.case.TestCase

Class that test the display of the list of header keywords

displaylist(param, exp, mock_stdout)

Function that run that actually run the test

test_five()

idem with five

test_four()

idem with 4 keywords

test_six()

idem with six

test_three()

Test if 3 keywords have to be displayed

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 Then we display the header with keywords

values_dict
dictionnary, keys=filename
values=dictionnary of keyword-value pair

None

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 :

1 2 3 4 5 6 . . . . . .

keywords
list of keywords (string)

None (display in terminal)

dfitspy.get_files_and_keys module

—dfitspy—

dfitspy is a program aimed at reproducing the dfits program in python. the functions can be used inside another program or it can also be called as an executable

This file create the file list depending on the user input as well as the keywords input

@place: ESO - La Silla - Paranal Observatory @author(s): Romain Thomas @year(s): 2018 @First version: 18.09-0 @Current version: 18.10-0 @Telescope(s): ALL @Instrument(s): ALL @Valid for SciOpsPy: v0.1-b @Documentation url: @Last SciOps review [date + name]: 18-09-2018 - Romain Thomas @Usage: inside another code (dfitspy) @Licence: GPL @Testable: Yes @Test data place (if any required): N.A.

class dfitspy.get_files_and_keys.Testgetfiles(methodName='runTest')

Bases: unittest.case.TestCase

Class that tests the get file function

test_get_file_all_no_files()

Here we test the get_files function when the user does not precise the directory (<–> look current directory), ask for all file and does not get any file in return (no fits file)

test_get_file_all_with_files()

Here we test the get_files function when the user does not precise the directory (<–> look current directory), ask for all file and does get file file in return

test_get_multi_file_goodname()

Test for multiple files

test_get_single_file_goodname()

Test with single file when a good filename is given

test_get_single_file_wrongname()

Test with single file when a wrong filename is given

test_list_files()

Test for list of files as input

class dfitspy.get_files_and_keys.Testgetkeys(methodName='runTest')

Bases: unittest.case.TestCase

Class that tests the keyword relative functions

test_get_multi_key()

We give three keywords and have to get the three keywords contained in a list

test_get_single_key()

We give a single keyword and have to get exaclty the same keyword contained in a list

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

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

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

files
list of str, list of files names (without path)
it can be [‘file1.fits,file2.fits,….’]
[‘file1.fits’] [‘file1,fits’, ‘file2.fits’] [‘all’]
dire
str, path of the directory to look in

list of files

dfitspy.get_files_and_keys.get_keys(key_string)

This function extract from a string the list of keys

keystring
string, keys to be requested by user
ex: 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)

keys
list, list of keys (string)

dfitspy.readfits module

—dfitspy—

dfitspy is a program aimed at reproducing the dfits program in python. the functions can be used inside another program or it can also be called as an executable

This file organises reads the fits files

@place: ESO - La Silla - Paranal Observatory @author(s): Romain Thomas @year(s): 2018 @First version: 18.09-0 @Current version: 18.10-0 @Telescope(s): ALL @Instrument(s): ALL @Valid for SciOpsPy: v0.1-b @Documentation url: @Last SciOps review [date + name]: 18-09-2018 - Romain Thomas @Usage: inside another code (dfitspy) @Licence: GPL @Testable: Yes @Test data place (if any required): N.A.

class dfitspy.readfits.Testextractheader(methodName='runTest')

Bases: unittest.case.TestCase

This class tests the extraction of the header from the fits file

test_readfile()

This function test the header extraction

class dfitspy.readfits.Testkeywordextraction(methodName='runTest')

Bases: unittest.case.TestCase

This class is a testing class that deal with the extraction of the keywords inside the fits files

test_get_all_keyword()

This function test function that extracts all the keyword of the header

test_get_value_no_grep()

This function tests the extraction of keywords without grepping values

test_get_value_true()

This function test function that gets the value of the keyword in the file in the case the keyword exists

test_get_value_with_grep()

Same as before but woth grepping

test_get_value_wrong()

This function test function that gets the value of the keyword in the file in the case the keyword does not exist

dfitspy.readfits.dfitsort(listfiles, listkeys, grepping=None)

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

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

listfiles
list, with file names (string, path included)
listkeys
list, of keywords (strings)
grep
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
file_dict
dictionnary, keys=filename
values=dictionnary of keyword-value pairs
dfitspy.readfits.get_all_keyword(thefile)

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

thefile
str, path/and/file.txt
keywords
list, of keywords (string)
dfitspy.readfits.keywords_in_file(thefile, keyword)

This function extracts in the thefile file the value of the keyword

thefile
str, path/to/file.fits
keyword
str, keyword to get the value of
value
str, value of the keyword inside the file
dfitspy.readfits.read_fitsfile(thefile)

This function is largely inspired from the fitsio python library and used the python wrapper around the cFitsio library. It takes as argument the name (including path if the location of the file is different from the current folder) and returns a dictionnary of keyword = header keyword and value = header value.

WARNING: in the ESO fits header format, the HIERARCH prefix will be ignored by this function
and the resulting dictionnary will not contain the HIERARCH prefix. Ex: ‘HIERARCH ESO TEL ALT’ will become ‘ESO TEL ALT’
filename
str, path/to/file (fits file)
dict_values
python dictionnary with header keywords/value pairs.

dfitspy.tests module

—dfitspy—

dfitspy is a program aimed at reproducing the dfits program in python. the functions can be used inside another program or it can also be called as an executable

This file organises the tests of the library

@place: ESO - La Silla - Paranal Observatory @author(s): Romain Thomas @year(s): 2018 @First version: 18.09-0 @Current version: 18.10-0 @Telescope(s): ALL @Instrument(s): ALL @Valid for SciOpsPy: v0.1-b @Documentation url: @Last SciOps review [date + name]: 18-09-2018 - Romain Thomas @Usage: inside another code (dfitspy) @Licence: GPL @Testable: Yes @Test data place (if any required): N.A.

dfitspy.tests.test()

This function calls the test of each module and run them

Module contents

dfitspy.get_files(files, dire=False)

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

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

files
list of str, list of files names (without path)
it can be [‘file1.fits,file2.fits,….’]
[‘file1.fits’] [‘file1,fits’, ‘file2.fits’] [‘all’]
dire
str, path of the directory to look in

list of files

dfitspy.get_keys(key_string)

This function extract from a string the list of keys

keystring
string, keys to be requested by user
ex: 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)

keys
list, list of keys (string)
dfitspy.test()

This function calls the test of each module and run them

dfitspy.read_fitsfile(thefile)

This function is largely inspired from the fitsio python library and used the python wrapper around the cFitsio library. It takes as argument the name (including path if the location of the file is different from the current folder) and returns a dictionnary of keyword = header keyword and value = header value.

WARNING: in the ESO fits header format, the HIERARCH prefix will be ignored by this function
and the resulting dictionnary will not contain the HIERARCH prefix. Ex: ‘HIERARCH ESO TEL ALT’ will become ‘ESO TEL ALT’
filename
str, path/to/file (fits file)
dict_values
python dictionnary with header keywords/value pairs.
dfitspy.dfitsort(listfiles, listkeys, grepping=None)

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

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

listfiles
list, with file names (string, path included)
listkeys
list, of keywords (strings)
grep
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
file_dict
dictionnary, keys=filename
values=dictionnary of keyword-value pairs
dfitspy.keywords_in_file(thefile, keyword)

This function extracts in the thefile file the value of the keyword

thefile
str, path/to/file.fits
keyword
str, keyword to get the value of
value
str, value of the keyword inside the file
dfitspy.dfitsort_view(values_dict)

This function displays a-la-dfits the requested informations

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

values_dict
dictionnary, keys=filename
values=dictionnary of keyword-value pair

None

dfitspy.keywords_view(keywords)

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

1 2 3 4 5 6 . . . . . .

keywords
list of keywords (string)

None (display in terminal)