-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulate_Ha_measurement_SN.py
More file actions
executable file
·66 lines (45 loc) · 2.44 KB
/
simulate_Ha_measurement_SN.py
File metadata and controls
executable file
·66 lines (45 loc) · 2.44 KB
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
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
#Add path of our modules so we can import them
import sys
import os
sys.path.append(os.path.expanduser('~/Science/KCLASH/Halpha_Sizes'))
import measure_Halpha_size as MH
import make_mock_cube as MG
N_samples=1000
SNs=np.logspace(0, 1.5, N_samples)
for i, sn in enumerate(tqdm(SNs)):
Xcen=7 #pixels
Ycen=7 #pixels
PA=45 #Degrees
ell=0.2
I0=1
h=3 #Pixels
z=0.4 #Redshift
peak_flux=2 #Times the continuum level
SN=sn #times the noise
Ha_velocity_dispersion=100.0#km/s
cube=MG.make_mock_cube(Xcen, Ycen, PA, ell, I0, h, z, peak_flux, SN, Ha_velocity_dispersion, outfolder=os.path.expanduser('~/Science/KCLASH/Halpha_Sizes/Halpha_sims/mock_galaxy'))
# max_val=np.nanmax(cube.data)
# cube.data=cube.data/max_val*1e-19
# cube.noise=cube.noise/max_val*1e-19
galaxy_directory='sims'
#Dictionary of all the filenames
filename_dict={'Halpha_image_filename':'{}/Halpha_image_SN.fits'.format(galaxy_directory),
'Halpha_config':'Halpha_config.txt'.format(galaxy_directory),
'Halpha_mask_filename':'{0}/Halpha_mask_SN.fits'.format(galaxy_directory),
'Halpha_noise_filename':'{0}/Halpha_noise_SN.fits'.format(galaxy_directory),
'Halpha_psf_filename':'mock_galaxy/Halpha_PSF.fits',
'Halpha_model_output_filename':'{}/Halpha_model_SN.fits'.format(galaxy_directory),
'Halpha_residual_output_filename':'{0}/Halpha_residual_SN.fits'.format(galaxy_directory),
'Halpha_params_output_filename':'{0}/outputs/SN/SN_{1:03d}_Halpha_single_fit_params_changing_peak_SN.dat'.format(galaxy_directory, i),
}
#Get a mask around H-alpha
spec_mask=cube.get_spec_mask_around_wave(cube.Ha_lam, width=0.002)
MH.prepare_input_fits_files_Halpha(cube, filename_dict, spec_mask, make_mask=True)
imfit_command_Halpha=MH.make_imfit_command(image=filename_dict['Halpha_image_filename'], config=filename_dict['Halpha_config'], mask=filename_dict['Halpha_mask_filename'], noise=filename_dict['Halpha_noise_filename'],
psf=filename_dict['Halpha_psf_filename'], model_output=filename_dict['Halpha_model_output_filename'], residual_output=filename_dict['Halpha_residual_output_filename'], params_output=filename_dict['Halpha_params_output_filename'],
N_bootstraps=None, bootstrap_output=None, sky=0, silent=True)
ret_code_Halpha=MH.run_imfit(imfit_command_Halpha)