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

utils.py 2.0 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
  1. import numpy as np
  2. from astropy.io import fits
  3. from astropy import units as u
  4. from astropy.coordinates import SkyCoord
  5. def fake_catalogue(field_list, filename=None, template='cataloguetemplates/Master_CatalogueTemplate.fits',
  6. sources_per_field=[10.0], priorities=[10.0], targuse='T', targsrvy='WL', field_radius=1.0,
  7. pseudogrid=False, shot_noise=True):
  8. import numpy.random as default_rng
  9. if pseudogrid:
  10. import sobol_seq
  11. row = fits.open(template)[1].data
  12. ra = np.array([])
  13. dec = np.array([])
  14. targprio = np.array([])
  15. for field in field_list:
  16. field_center = SkyCoord(field['RA'] * u.deg, field['DEC'] * u.deg, frame='icrs')
  17. for mean_sources, priority in zip(sources_per_field, priorities):
  18. if shot_noise:
  19. nsources = default_rng.poisson(mean_sources, 1)
  20. else:
  21. nsources = mean_sources
  22. if pseudogrid:
  23. random_numbers = sobol_seq.i4_sobol_generate(2, int(nsources), skip=2 * len(ra))
  24. else:
  25. random_numbers = default_rng.random((int(nsources), 2))
  26. position_angle = 360 * random_numbers[:, 0] * u.deg
  27. distance = field_radius * np.sqrt(random_numbers[:, 1]) * u.deg
  28. source_positions = field_center.directional_offset_by(position_angle, distance)
  29. ra = np.append(ra, source_positions.ra.deg)
  30. dec = np.append(dec, source_positions.dec.deg)
  31. targprio = np.append(targprio, np.full(nsources, priority))
  32. hdu = fits.BinTableHDU.from_columns(row.columns, nrows=len(ra))
  33. hdu.data['GAIA_RA'] = ra
  34. hdu.data['GAIA_DEC'] = dec
  35. hdu.data['GAIA_EPOCH'] = '2015.5'
  36. hdu.data['TARGSRVY'] = targsrvy
  37. hdu.data['TARGPROG'] = 'MOCKOBJECT'
  38. hdu.data['TARGCAT'] = filename
  39. hdu.data['TARGID'] = range(len(ra))
  40. hdu.data['TARGPRIO'] = targprio
  41. hdu.data['TARGUSE'] = targuse
  42. if filename is not None:
  43. hdu.writeto(filename, overwrite=True)
  44. else:
  45. return hdu
Tip!

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

Comments

Loading...