Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

make_field_files.py 2.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  1. #!/usr/bin/env python3
  2. import yaml
  3. import argparse
  4. import os
  5. import copy
  6. import astropy.table
  7. from weaveworkflow.mos.workflow.mos_stage1 import create_mos_field_cat
  8. from astropy.table import Table
  9. params_file = "params.yaml"
  10. with open(params_file, 'r') as fd:
  11. params = yaml.safe_load(fd)
  12. if __name__ == '__main__':
  13. parser = argparse.ArgumentParser(
  14. description='Makes fits files of fields from footprints.')
  15. parser.add_argument('--output',
  16. help="""Where to place the output field file.""")
  17. parser.add_argument('submission',
  18. help="""Which top level object in params.yaml to
  19. process.""")
  20. args = parser.parse_args()
  21. assert args.submission in params['submission'], \
  22. f"Didnt find {args.submission} in {params_file}"
  23. mos_field_template = params['field_template']
  24. output_field_file = args.output
  25. output_directory = os.path.dirname(output_field_file)
  26. if not os.path.isdir(output_directory):
  27. os.makedirs(output_directory)
  28. task = params['submission'][args.submission]['footprint']
  29. # Reformat fits table into expected form
  30. field_table = Table.read(task['footprint_file'])
  31. field_table['PROGTEMP'] = task['progtemp']
  32. field_table['OBSTEMP'] = task['obstemp']
  33. field_table.rename_column('NAME', 'FIELD_NAME')
  34. field_table.rename_column('RA', 'FIELD_RA')
  35. field_table.rename_column('DEC', 'FIELD_DEC')
  36. # Duplicate table for each survey
  37. surveys = task['surveys']
  38. per_survey_tables = []
  39. for targsrvy, max_fibres in zip(surveys['targsrvys'], surveys[
  40. 'max_fibres']):
  41. field_table['TARGSRVY'] = targsrvy
  42. field_table['MAX_FIBRES'] = max_fibres
  43. per_survey_tables += [copy.deepcopy(field_table)]
  44. field_table = astropy.table.vstack(per_survey_tables)
  45. trimester = task['keywords']['trimester']
  46. report_verbosity = task['keywords']['report_verbosity']
  47. author = task['keywords']['author']
  48. cc_report = task['keywords']['cc_report']
  49. create_mos_field_cat(mos_field_template, field_table, output_field_file,
  50. trimester, author, report_verbosity=report_verbosity,
  51. cc_report=cc_report)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...