Coverage for soxspipe/commonutils/tests/test_create_dispersion_map.py: 0%

# Coverage for soxspipe/commonutils/tests/test_create_dispersion_map.py : 0%

## 55 statements 0 run 55 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 from __future__ import print_function

2 from builtins import str

3 import os

4 import unittest

5 import shutil

6 import unittest

7 import yaml

8 from soxspipe.utKit import utKit

9 from fundamentals import tools

10 from os.path import expanduser

11 from astropy.nddata import CCDData

12 from astropy import units as u

13 home = expanduser("~")

14

15 packageDirectory = utKit("").get_project_root()

16 settingsFile = packageDirectory + "/test_settings.yaml"

17# settingsFile = home + \

18# "/git_repos/_misc_/settings/soxspipe/test_settings.yaml"

19

20 su = tools(

21 arguments={"settingsFile": settingsFile},

22 docString=__doc__,

23 logLevel="DEBUG",

24 options_first=False,

25 projectName=None,

26 defaultSettingsFile=False

27)

28 arguments, settings, log, dbConn = su.setup()

29

30# SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA

31 moduleDirectory = os.path.dirname(__file__)

32 pathToInputDir = moduleDirectory + "/input/"

33 pathToOutputDir = moduleDirectory + "/output/"

34

35 try:

36 shutil.rmtree(pathToOutputDir)

37 except:

38 pass

39# COPY INPUT TO OUTPUT DIR

40 shutil.copytree(pathToInputDir, pathToOutputDir)

41

42# Recursively create missing directories

43 if not os.path.exists(pathToOutputDir):

44 os.makedirs(pathToOutputDir)

45

46

47# xt-setup-unit-testing-files-and-folders

48

49

50 class test_create_dispersion_map(unittest.TestCase):

51

52 def test_create_dispersion_map_single_nir_function(self):

53 frame = "~/xshooter-pipeline-data/unittest_data/create_dispersion_map/single_pinhole_NIR_calibrated.fits"

54 from os.path import expanduser

55 home = expanduser("~")

56 frame = frame.replace("~", home)

57 frame = CCDData.read(frame, hdu=0, unit=u.electron, hdu_uncertainty='ERRS',

58 hdu_mask='QUAL', hdu_flags='FLAGS', key_uncertainty_type='UTYPE')

59

60 from soxspipe.commonutils import create_dispersion_map

61 mapPath = create_dispersion_map(

62 log=log,

63 settings=settings,

64 pinholeFrame=frame

65 ).get()

66 print(mapPath)

67

68 def test_create_dispersion_map_multi_nir_function(self):

69 frame = "~/xshooter-pipeline-data/unittest_data/create_dispersion_map/20170818T173315_NIR_ARC_MULTIPIN.fits"

70 from os.path import expanduser

71 home = expanduser("~")

72 frame = frame.replace("~", home)

73 frame = CCDData.read(frame, hdu=0, unit=u.electron, hdu_uncertainty='ERRS',

74 hdu_mask='QUAL', hdu_flags='FLAGS', key_uncertainty_type='UTYPE')

75

76 from soxspipe.commonutils import create_dispersion_map

77 mapPath = create_dispersion_map(

78 log=log,

79 settings=settings,

80 pinholeFrame=frame,

81 firstGuessMap="~/xshooter-pipeline-data/unittest_data/create_dispersion_map/20170820T153602_NIR_DISP_MAP.csv"

82 ).get()

83 print(mapPath)

84

85 def test_create_dispersion_map_function_exception(self):

86

87 from soxspipe.commonutils import create_dispersion_map

88 try:

89 this = create_dispersion_map(

90 log=log,

91 settings=settings,

92 fakeKey="break the code"

93 )

94 this.get()

95 assert False

96 except Exception as e:

97 assert True

98 print(str(e))

99

100 # x-print-testpage-for-pessto-marshall-web-object

101

102 # x-class-to-test-named-worker-function