test_loading_data.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. from common import get_example_data_root_path, initialize_test_yml_list_measurement
  2. from view.python_core.flags import FlagsManager
  3. from view.python_core.paths import get_existing_raw_data_filename
  4. from view.python_core.view_object import VIEW
  5. from view.python_core.p1_class import get_empty_p1
  6. def load_calc_data(yml_file, animal, measus=None, flags=None):
  7. vo = VIEW()
  8. vo.update_flags_from_ymlfile(yml_filename=yml_file)
  9. if isinstance(flags, dict):
  10. vo.update_flags(flags)
  11. vo.initialize_animal(animal=animal)
  12. for measu in vo.get_measus_for_current_animal(analyze_values_to_use=(1, 2)):
  13. if measus is None or measu in measus:
  14. print(f"Doing animal={animal}, measu={measu}")
  15. vo.load_measurement_data_from_current_animal(measu=measu)
  16. vo.calculate_signals()
  17. return vo
  18. def test_loading_all_data():
  19. yml_animal_dict = {
  20. "FakeData/test_defaults.yml": ["FakeData"],
  21. "HS_Till/usage_till.yml": ["HS_bee_PELM_180416b", "HS_bee_PELM_180424b"],
  22. "IP_Fura/usage_till.yml": ["190112_locust_ip", "190112_locust_ip2", "190529_locust_ip31"],
  23. "LM_Till_only_FID/usage_till.yml":
  24. ["LM_GC-FID_or22a_170816a", "LM_GC-FID_or22a_170816b", "LM_GC-FID_or22a_170816c"],
  25. "MR_Till/usage_till.yml": ["MR_190613c_or47a", "MR_190614a_or47a"],
  26. "MS_LSM/usage_lsm.yml": ["2020_02_06_OK107_GCaMP6f", "testview"],
  27. "Or47a_test/usage_till_test.yml":
  28. ["AL_190506a_or47a", "MR_190510b_or47a", "MR_190515b_or47a", "PG_190702a_or47a"],
  29. "SS_LSM/usage_lsm.yml": ["2019_08_15_locust_oregon green"],
  30. "Bente_Test/Bente_Test_2021.yml": ["190815_h2_El_test"],
  31. "MP_LIF/LIF_test.yml": ["sNPF_210623_bee07_res"]
  32. }
  33. example_data_root_path = get_example_data_root_path()
  34. for yml_relative_path, animals in yml_animal_dict.items():
  35. yml_file = str(example_data_root_path / yml_relative_path)
  36. for animal in animals:
  37. load_calc_data.description \
  38. = f"Testing loading data and signal calculation with yml={yml_relative_path} and animal={animal}"
  39. yield load_calc_data, yml_file, animal
  40. def test_loading_data_without_measurement_list():
  41. """Testing loading data without measurement list"""
  42. example_data_root_path = get_example_data_root_path()
  43. yml_file = example_data_root_path / "HS_Till" / "usage_till.yml"
  44. animal = "HS_bee_PELM_180416b"
  45. flags = FlagsManager()
  46. flags.read_flags_from_yml(yml_file)
  47. view_obj = VIEW(flags=flags)
  48. raw_data_file \
  49. = example_data_root_path / "HS_Till" / "data" / "HS_bee_PELM_180416b.pst" / "dbb12DF.pst"
  50. view_obj.load_measurement_data_without_list_file(
  51. LE_loadExp=3,
  52. raw_data_files=[raw_data_file],
  53. sampling_rate=1 / 0.6,
  54. animal=animal)
  55. if __name__ == '__main__':
  56. # load_calc_data(
  57. # yml_file="/home/ajay/SharedWithWindows/view_test_data/HS_Till/usage_till.yml",
  58. # animal="HS_bee_PELM_180416b")
  59. # load_calc_data(
  60. # yml_file="/home/ajay/SharedWithWindows/view_test_data/FakeData/test_defaults.yml",
  61. # animal="FakeData", flags={"LE_CalcMethod": 4})
  62. # load_calc_data(yml_file="/mnt/data/ViewData/IP_Fura/view_flags_all_defaultsFURA.yml",
  63. # animal="190112_locust_ip2", flags={"LE_ScatteredLightFactor": 1})
  64. # load_calc_data(
  65. # yml_file="/home/aj/SharedWithWindows/SS_LSM/usage_lsm.yml",
  66. # animal="2019_08_09_locust_calcium green")
  67. load_calc_data(
  68. yml_file="/home/ajay/pyview_test_data/Bente_Test/Bente_Test_2021.yml",
  69. animal="190815_h2_El_test")
  70. # test_loading_data_without_measurement_list()