create_tapestry_synthetic.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import view
  2. import pathlib as pl
  3. #mother of all folders
  4. moaf = pl.Path(__file__).parents[1]
  5. ymlfile = moaf / r"view_synthetic_666.yml"
  6. # please enter the paths of tapestry configuration files in ABSOLUTE form.
  7. # On Windows, if you copy paths from the file explorer, make sure the string below is always of the form r"......"
  8. tapestry_config_files = [
  9. moaf / r"06_PROGS/tapestry_ctv22_global.yml" ,
  10. moaf / r"06_PROGS/tapestry_ctv22_individual.yml"
  11. ]
  12. # define a function that takes a row of the measurement list and returns a string. This string will be placed
  13. # below the overview
  14. def text_below(row):
  15. # Example 1: the label below each overview will just be the odor
  16. return row['Label']+'_***_'+row['Odour']
  17. # Example 2: the label below each overview will be the odor and concentration separated by an underscore ("_")
  18. # return f"{row['Odour']}_{row['OConc']}"
  19. # define a function that takes a row of the measurement list and returns a string. This string will be placed
  20. # next to the overview on the top right.
  21. def text_right_top(row):
  22. pass
  23. # define a function that takes a row of the measurement list and creates the string to be placed below the overview
  24. def text_right_bottom(row):
  25. # return row['OConc']
  26. return tapestry_config_file.name[-9:-4]
  27. #pass
  28. if __name__ == '__main__':
  29. for tapestry_config_file in tapestry_config_files:
  30. # When text_right_bottom_func and text_right_top_func are specified to be None, the upper and lower limits
  31. # of the data shown in an overview will be printed to its right top and right bottom side
  32. # To customize the strings printed there, please define the functions 'text_right_top' and
  33. # 'text_right_bottom above and pass them appropriately below, in the place on 'None'.
  34. html_out_file, view_obj = view.create_tapestry(init_yml_flags_file=ymlfile,
  35. tapestry_config_file=tapestry_config_file,
  36. text_below_func=text_below,
  37. text_right_top_func=None,
  38. text_right_bottom_func=text_right_bottom)
  39. # backup this script and the yml file used next to the created tapestries
  40. view_obj.backup_script_flags_configs_for_tapestries(files=[__file__, ymlfile, tapestry_config_file])