/tests/conftest.py

https://github.com/micasense/imageprocessing
Python | 190 lines | 142 code | 40 blank | 8 comment | 2 complexity | 545059c3bcd3e649ba77d4cfb4271e12 MD5 | raw file
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. """
  4. Test image class
  5. Copyright 2019 MicaSense, Inc.
  6. Permission is hereby granted, free of charge, to any person obtaining a copy of
  7. this software and associated documentation files (the "Software"), to deal in the
  8. Software without restriction, including without limitation the rights to use,
  9. copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
  10. Software, and to permit persons to whom the Software is furnished to do so,
  11. subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in all
  13. copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  16. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  17. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  18. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. """
  21. import pytest
  22. import os, glob
  23. import micasense.capture as capture
  24. import micasense.image as image
  25. import micasense.metadata as metadata
  26. @pytest.fixture()
  27. def files_dir():
  28. return os.path.join('data', '0000SET', '000')
  29. @pytest.fixture()
  30. def altum_files_dir():
  31. return os.path.join('data', 'ALTUM1SET', '000')
  32. @pytest.fixture()
  33. def ten_band_files_dir():
  34. return os.path.join('data', '10BANDSET', '000')
  35. @pytest.fixture()
  36. def panel_rededge_file_list(files_dir):
  37. return sorted(glob.glob(os.path.join(files_dir, 'IMG_0000_*.tif')))
  38. @pytest.fixture()
  39. def non_panel_rededge_file_list(files_dir):
  40. return sorted(glob.glob(os.path.join(files_dir, 'IMG_0001_*.tif')))
  41. @pytest.fixture()
  42. def bad_file_list(files_dir):
  43. file1 = os.path.join(files_dir, 'IMG_0000_1.tif')
  44. file2 = os.path.join(files_dir, 'IMG_0001_1.tif')
  45. return [file1, file2]
  46. @pytest.fixture()
  47. def panel_altum_file_list(altum_files_dir):
  48. return sorted(glob.glob(os.path.join(altum_files_dir, 'IMG_0000_*.tif')))
  49. @pytest.fixture()
  50. def panel_rededge_capture(panel_rededge_file_list):
  51. return capture.Capture.from_filelist(panel_rededge_file_list)
  52. @pytest.fixture()
  53. def non_panel_rededge_capture(non_panel_rededge_file_list):
  54. return capture.Capture.from_filelist(non_panel_rededge_file_list)
  55. @pytest.fixture()
  56. def panel_10band_rededge_file_list(ten_band_files_dir):
  57. return sorted(glob.glob(os.path.join(ten_band_files_dir, 'IMG_0000_*.tif')))
  58. @pytest.fixture()
  59. def flight_10band_rededge_file_list(ten_band_files_dir):
  60. return sorted(glob.glob(os.path.join(ten_band_files_dir, 'IMG_0431_*.tif')))
  61. @pytest.fixture()
  62. def panel_altum_capture(panel_altum_file_list):
  63. imgs = [image.Image(fle) for fle in panel_altum_file_list]
  64. return capture.Capture(imgs)
  65. @pytest.fixture()
  66. def non_panel_altum_file_list(altum_files_dir):
  67. return sorted(glob.glob(os.path.join(altum_files_dir, 'IMG_0008_*.tif')))
  68. @pytest.fixture()
  69. def non_panel_altum_capture(non_panel_altum_file_list):
  70. imgs = [image.Image(fle) for fle in non_panel_altum_file_list]
  71. return capture.Capture(imgs)
  72. @pytest.fixture()
  73. def panel_image_name():
  74. image_path = os.path.join('data', '0000SET', '000')
  75. return os.path.join(image_path, 'IMG_0000_1.tif')
  76. @pytest.fixture()
  77. def panel_image_name_red():
  78. image_path = os.path.join('data', '0000SET', '000')
  79. return os.path.join(image_path, 'IMG_0000_2.tif')
  80. @pytest.fixture()
  81. def panel_image_name_RP06_blue():
  82. image_path = os.path.join('data', '0002SET', '000')
  83. return os.path.join(image_path, 'IMG_0000_1.tif')
  84. @pytest.fixture()
  85. def panel_images_RP06():
  86. image_path = os.path.join('data', '0002SET', '000')
  87. return sorted(glob.glob(os.path.join(image_path, 'IMG*.tif')))
  88. @pytest.fixture()
  89. def flight_image_name():
  90. image_path = os.path.join('data', '0000SET', '000')
  91. return os.path.join(image_path, 'IMG_0001_1.tif')
  92. @pytest.fixture()
  93. def altum_panel_image_name(altum_files_dir):
  94. return os.path.join(altum_files_dir, 'IMG_0000_1.tif')
  95. @pytest.fixture()
  96. def altum_lwir_image_name(altum_files_dir):
  97. return os.path.join(altum_files_dir, 'IMG_0000_6.tif')
  98. @pytest.fixture()
  99. def altum_flight_image_name(altum_files_dir):
  100. return os.path.join(altum_files_dir, 'IMG_0008_1.tif')
  101. @pytest.fixture()
  102. def img(files_dir):
  103. return image.Image(os.path.join(files_dir,'IMG_0000_1.tif'))
  104. @pytest.fixture()
  105. def img2(files_dir):
  106. return image.Image(os.path.join(files_dir,'IMG_0000_2.tif'))
  107. @pytest.fixture()
  108. def panel_altum_file_name(altum_files_dir):
  109. return os.path.join(altum_files_dir, 'IMG_0000_1.tif')
  110. @pytest.fixture()
  111. def panel_altum_image(panel_altum_file_name):
  112. return image.Image(panel_altum_file_name)
  113. @pytest.fixture()
  114. def altum_flight_image(altum_flight_image_name):
  115. return image.Image(altum_flight_image_name)
  116. @pytest.fixture()
  117. def non_existant_file_name(altum_files_dir):
  118. return os.path.join(altum_files_dir, 'NOFILE.tif')
  119. @pytest.fixture()
  120. def altum_lwir_image(altum_files_dir):
  121. return image.Image(os.path.join(altum_files_dir, 'IMG_0000_6.tif'))
  122. @pytest.fixture()
  123. def meta():
  124. image_path = os.path.join('data', '0000SET', '000')
  125. return metadata.Metadata(os.path.join(image_path, 'IMG_0000_1.tif'))
  126. @pytest.fixture()
  127. def meta_v3():
  128. image_path = os.path.join('data', '0001SET', '000')
  129. return metadata.Metadata(os.path.join(image_path, 'IMG_0002_4.tif'))
  130. @pytest.fixture()
  131. def meta_bad_exposure():
  132. image_path = os.path.join('data', '0001SET', '000')
  133. return metadata.Metadata(os.path.join(image_path, 'IMG_0003_1.tif'))
  134. @pytest.fixture()
  135. def meta_altum_dls2(altum_flight_image_name):
  136. return metadata.Metadata(altum_flight_image_name)
  137. @pytest.fixture()
  138. def bad_dls2_horiz_irr_image():
  139. image_path = os.path.join('data', 'ALTUM0SET', '000')
  140. return image.Image(os.path.join(image_path, 'IMG_0000_1.tif'))
  141. @pytest.fixture()
  142. def panel_10band_rededge_capture(panel_10band_rededge_file_list):
  143. return capture.Capture.from_filelist(panel_10band_rededge_file_list)
  144. @pytest.fixture()
  145. def flight_10band_rededge_capture(flight_10band_rededge_file_list):
  146. return capture.Capture.from_filelist(flight_10band_rededge_file_list)