Attachment 'NIKA2_Time_Estimator.py'
Download 1 #!/usr/bin/env python
2 #####################################################################################
3 ### Author: P. Garcia ###
4 ### Title: NIKA2_Time_Estimator.py ###
5 ### Purpose: Calculation of the total integration time for observing proposals ###
6 ### Creation Date: 2016.JULY.28 ###
7 ### Date of last revision: 2017.JAN.29 ###
8 ### Revision history: ###
9 ### - 2016.JULY.29: comments from C. Kramer & A. Sievers implemented ###
10 ### - 2016.AUG.03 : changed formula to N. Billot expression ###
11 ### - 2017.JAN.29 : - fpix set to 0.75 (commisi. results) ###
12 ### - NEFD0 @ 2 mm set to 15 mJy/sqrt(hz) (commisi. results) ###
13 ### - overhead set as used defined parameter between 1.5 - 2.0 ###
14 #####################################################################################
15
16 import numpy as np, sys
17 import math
18 import sys
19 import os
20 os.system("rm -f *.py~")
21
22 version = 'v 2017.JAN.29'
23
24 class bcolors:
25 HEADER = '\033[95m'
26 OKBLUE = '\033[94m'
27 OKGREEN = '\033[92m'
28 WARNING = '\033[93m'
29 FAIL = '\033[91m'
30 ENDC = '\033[0m'
31 BOLD = '\033[1m'
32 UNDERLINE = '\033[4m'
33
34 print ''
35 print bcolors.UNDERLINE + bcolors.HEADER + bcolors.BOLD + 'Time-estimator-NIKA2 '+version+' '+bcolors.ENDC
36 print ''
37 print bcolors.HEADER + bcolors.BOLD + ' See the "Guidelines for observing time estimates with the NIKA2 continuum camera' + bcolors.ENDC
38 print bcolors.HEADER + bcolors.BOLD + ' at the IRAM-30m Telescope" for details on used parameters and calculations.\n' + bcolors.ENDC
39
40 ################################
41 ##### CONVERSION FACTORS #######
42 ################################
43
44 ########## K_cmb ############
45 def b_v_cmb(freq,tcmb):
46 h = 6.626070040*10**(-34) # (J.s) Planck constant
47 k = 1.38064852*10**(-23) # (J/K) Boltzmann constant
48 c = 299792458 # (m/s^2) light speed
49 freq = freq*10**9 # Hz
50 bv = 1.0/(((2*h*freq**3)/((c**2)*(np.e**((h*freq)/(k*tcmb)) - 1)))*(np.e**((h*freq)/(k*tcmb))/(np.e**((h*freq)/(k*tcmb)) - 1))*(h*freq/(k*tcmb**2))) / 10**20
51 return bv
52
53 ########## Ysz ##############
54 def y_sz(freq,tcmb):
55 h = 6.626070040*10**(-34) # (J.s) Planck constant
56 k = 1.38064852*10**(-23) # (J/K) Boltzmann constant
57 c = 299792458 # (m/s^2) light speed
58 freq = freq*10**9 # Hz
59 Ysz = 1.0
60 bv = 1.0/(((2*h*freq**3)/((c**2)*(np.e**((h*freq)/(k*tcmb)) - 1)))*(np.e**((h*freq)/(k*tcmb))/(np.e**((h*freq)/(k*tcmb)) - 1))*(h*freq/(k*tcmb**2)))
61 bv = 1.0/bv
62 y_sz = (bv*tcmb)*(((h*freq/(k*tcmb))*((np.e**((h*freq)/(k*tcmb)) + 1)/(np.e**((h*freq)/(k*tcmb)) -1))) -4)*Ysz /10**(-20)
63 y_sz = 1.0/y_sz
64 return y_sz
65
66 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 #%%%%%%%%%%%%%%%%%%%%% FIXED GENERAL PARAMETERS %%%%%%%%%%%%%%%%%%%%%%
68 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69
70 ################################################
71 ##### BEAM SIZES AND CONVERSION TO RADIANS #####
72 ################################################
73 res_band1_spec = 12.0 #MEMO # 12.0 # [arcsec]
74 res_band2_spec = 18.0 #MEMO # 20.0 # [arcsec]
75 teta_band1_spec = res_band1_spec*math.pi/180.0/3600.0 # in sr units
76 teta_band2_spec = res_band2_spec*math.pi/180.0/3600.0 # in sr units
77 area_teta_band1_spec = ((teta_band1_spec/2.0)**2)*math.pi # in sr units
78 area_teta_band2_spec = ((teta_band2_spec/2.0)**2)*math.pi # in sr units
79 ############################
80 ##### OTHER PARAMETERS #####
81 ############################
82 fpix_spec = 0.75
83 bv_1 = 0.075 # band1, do not change
84 cv_1 = 0.001 # band1, do not change
85 bv_2 = 0.025 # band2, do not change
86 cv_2 = 0.001 # band2, do not change
87 tiempo = 1.0 # [hours]
88 FoV = 6.5 # [arcmin] diameter
89 FoVArea = ((FoV/2.0)**2)*math.pi # [arcmin^2]
90 narrays1 = 2
91 narrays2 = 1
92 verbose_flag = 0
93 #foverhead = 2.0 # value fixed for all proposals in 2016
94 ##########################################
95 ##### NEFDo VALUES FROM OBSERVATIONS #####
96 ##########################################
97 NEFD_band1_spec = 30 #MEMO
98 NEFD_band2_spec = 15 #comissioning results 2016
99 #######################################
100 ##### SAMPLING ANGULAR VELOCITIES #####
101 #######################################
102 sampl_vel_fast = 48.0 # [arcsec/second]
103 sampl_vel_mid = 24.0 # [arcsec/second]
104 sampl_vel_slow = 12.0 # [arcsec/second]
105 sampl_rate = 23.84 # [hz]
106 sampl_rate_pol = 2*23.84 # [hz]
107 slewing_loss = 1.0 # to account for slewing of single OTF line
108 ##########################################
109 ##########################################
110 ##########################################
111
112 rango = len(sys.argv)
113 for i in range(rango):
114
115 if sys.argv[i] == ("--help") or rango == 1:
116
117 print ' USAGE:\n'
118 print ' python NIKA2_Time_Estimator.py --help '
119 print ' python NIKA2_Time_Estimator.py --band 1 --rms 2.00 --pwv 2 --elevation 40 --Xsize 2 --Ysize 2 --filter 1.0 --overhead 1.5'
120 print ' python NIKA2_Time_Estimator.py --band 2 --rms 1.00 --pwv 4 --elevation 50 --Xsize 15 --Ysize 15 --filter 2.0 --overhead 2.0 --verbose '
121 print '\n'
122 print ' OPTIONS:\n'
123 print ' help => This help.'
124 print ' band => Set 1 or 2 for the 1 mm or the 2 mm bands, respectively.'
125 print ' rms => Wanted flux density per beam. Any value above the confusion limit in [mJy/beam].'
126 print ' pwv => Precipitable water vapor in [mm].'
127 print ' elevation => Values from 15 to < 83 [deg].'
128 print ' Xsize Ysize => Map lengths. Xsize and Ysize are in [arcmin]. Minimum map size is 2x2 [arcmin^2] for homogeneous RMS noise distribution.'
129 print ' filter => Factor for post-processing noise filtering. Values from 1.0 (point-like source) to 2.0 (extended bright emission).'
130 print ' overhead => Factor for telescope overheads between 1.5 and 2.0 (slewing, pointing, focusing, calibration), i.e. all telescope time which is not spend integrating on-source.'
131 print ' verbose => Set to get list of parameters used in the calculations, RMS noise unit conversion, and allowed OTF scan speeds.\n'
132 sys.exit()
133
134 if sys.argv[i] == ("--band"):
135 band = int(sys.argv[i+1])
136 if band == 1:
137 narrays = narrays1
138 mili = 1.2
139 if band == 2:
140 narrays = narrays2
141 mili = 2.0
142 if band < 1 or band > 2:
143 print ' %%%%%%%%%%%%%%%%%%%%%%%'
144 print bcolors.BOLD + bcolors.FAIL +' Band %2i is not defined.' % (band) + bcolors.ENDC
145 print ' %%%%%%%%%%%%%%%%%%%%%%%'
146 print ''
147 sys.exit()
148
149 if sys.argv[i] == ("--rms"):
150 rms = float(sys.argv[i+1])
151
152 if sys.argv[i] == ("--pwv"):
153 pwv = float(sys.argv[i+1])
154
155 if sys.argv[i] == ("--elevation"):
156 elevation = float(sys.argv[i+1])
157 if elevation < 15 or elevation > 83:
158 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
159 print bcolors.BOLD + bcolors.FAIL +' Elevation %3i [degrees] is outside the telescope`s limits: 15 - 83 [degrees].' % (elevation) + bcolors.ENDC
160 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
161 print ''
162 sys.exit()
163
164 if sys.argv[i] == ("--Xsize"):
165 dx = float(sys.argv[i+1])
166
167 if sys.argv[i] == ("--Ysize"):
168 dy = float(sys.argv[i+1])
169
170 if sys.argv[i] == ("--filter"):
171 filtering = float(sys.argv[i+1])
172 if filtering < 1 or filtering > 2:
173 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
174 print bcolors.BOLD + bcolors.FAIL +' Filter value %2.1f is outside the standard limits: 1.0 - 2.0' % (filtering) + bcolors.ENDC
175 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
176 print ''
177 sys.exit()
178
179 if sys.argv[i] == ("--overhead"):
180 foverhead = float(sys.argv[i+1])
181 if foverhead < 1.5 or foverhead > 2:
182 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
183 print bcolors.BOLD + bcolors.FAIL +' Overhead value %2.1f is outside the standard limits: 1.5 - 2.0' % (foverhead) + bcolors.ENDC
184 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
185 print ''
186 sys.exit()
187
188 if sys.argv[i] == ("--verbose"):
189 verbose_flag = 1
190
191 area_obs = dx*dy
192
193 if area_obs < 4.0:
194 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
195 print bcolors.BOLD + bcolors.FAIL +' Introduced map size is %3.1f [arcmin^2]. Minimum value is 4.0 [arcmin^2]' % (area_obs) + bcolors.ENDC
196 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
197 print ''
198 sys.exit()
199
200 ###############################################################################################
201 ### SIGMA ESTIMATION CALCULATION, EFFECTIVE NEFD FROM PWV GIVEN VALUES AND UNITS CONVERSION ###
202 ###############################################################################################
203
204 if band == 1:
205 tau = bv_1*pwv + cv_1
206 NEFD_spec_eff = NEFD_band1_spec*(np.e**(tau/np.sin(elevation*math.pi/180.)))
207 rms_point_MJy_spec = rms/area_teta_band1_spec/10**9
208 rms_point_cmb_spec = rms_point_MJy_spec*b_v_cmb(260,2.726)*10**6
209 rms_point_ys_spec = rms_point_MJy_spec*y_sz(260,2.726)*10**6
210 rms_point_ys_spec = np.abs(rms_point_ys_spec)
211
212 if band == 2:
213 tau = bv_2*pwv + cv_2
214 NEFD_spec_eff = NEFD_band2_spec*(np.e**(tau/np.sin(elevation*math.pi/180.)))
215 rms_point_MJy_spec = rms/area_teta_band2_spec/10**9
216 rms_point_cmb_spec = rms_point_MJy_spec*b_v_cmb(150,2.726)*10**6
217 rms_point_ys_spec = rms_point_MJy_spec*y_sz(150,2.726)*10**6
218 rms_point_ys_spec = np.abs(rms_point_ys_spec)
219
220 #########################################
221 ### ratio of areas with approximation ###
222 #########################################
223
224 factor_area_spec = (1+(area_obs/(FoVArea*fpix_spec))) # from N. Billot Doc.
225
226 ##########################################################
227 ### Integration Time calculations for given conditions ###
228 ##########################################################
229
230 t_spec = ((NEFD_spec_eff*filtering/rms)**2)*factor_area_spec*(foverhead)/3600.0 #hours
231 s_map_spec = ((dx*dy)/(((NEFD_spec_eff*filtering)**2)*foverhead))*3600.0 # arcmin^2 / hour^-1/ mJy^-2
232
233 #########################################
234 #### TIME PER OTF LINE TO REACH TOTAL ###
235 #########################################
236
237 T_SLOW = slewing_loss*((dx*60.0)/sampl_vel_slow)/60.0 # [minutes]
238 T_MID = slewing_loss*((dx*60.0)/sampl_vel_mid)/60.0 # [minutes]
239 T_FAST = slewing_loss*((dx*60.0)/sampl_vel_fast)/60.0 # [minutes]
240
241 if verbose_flag == 1:
242
243 print ''
244 print '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
245 print '%%%%%%%%%% General Parameters Used for the Calculations %%%%%%%%%%%'
246 print '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
247 print ''
248 print '------------------------------------------------------------------------'
249 print '| Parameters | Band 1 (1.2 mm) | Band 2 (2.0 mm) |'
250 print '------------------------------------------------------------------------'
251 print '| opacity | %6.3fxpwv + %6.3f | %6.3fxpwv + %6.3f |' % (bv_1,cv_1,bv_2,cv_2)
252 print '------------------------------------------------------------------------'
253 print '| HPBW [arcsec] | %6.1f | %6.1f |' % (res_band1_spec,res_band2_spec)
254 print '------------------------------------------------------------------------'
255 print '| NEFDo [mJy.s^0.5] | %6.1f | %6.1f |' % (NEFD_band1_spec,NEFD_band2_spec)
256 print '------------------------------------------------------------------------'
257 if band == 1:
258 print '| rms [mJy/beam] | %6.2f | |' % (rms)
259 if band == 2:
260 print '| rms [mJy/beam] | | %6.2f |' % (rms)
261 print '------------------------------------------------------------------------'
262 print '| fpix | %6.2f |' % (fpix_spec)
263 print '------------------------------------------------------------------------'
264 print '| FoV [arcmin] | %6.1f |' % (FoV)
265 print '------------------------------------------------------------------------'
266 print '| h-filtering | %6.2f |' % (filtering)
267 print '------------------------------------------------------------------------'
268 print '| h-overhead | %6.2f |' % (foverhead)
269 print '------------------------------------------------------------------------'
270 print '| OTF slow [arcsec/s] | %4i |' % (sampl_vel_slow)
271 print '------------------------------------------------------------------------'
272 print '| OTF mid [arcsec/s] | %4i |' % (sampl_vel_mid)
273 print '------------------------------------------------------------------------'
274 print '| OTF fast [arcsec/s] | %4i |' % (sampl_vel_fast)
275 print '------------------------------------------------------------------------'
276 print '| Dump [hz] | %6.2f |' % (sampl_rate)
277 print '------------------------------------------------------------------------'
278 print '| Dump POL [hz] | %6.2f |' % (sampl_rate_pol)
279 print '------------------------------------------------------------------------'
280 print ''
281
282 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
283 print ' %%%%%%%%%%%%%%%%% Units Conversion %%%%%%%%%%%%%%%%%'
284 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
285 print ''
286 print ' --------------------------------------------------------'
287 print ' | (User Defined) | Band %1i |' % (band)
288 print ' --------------------------------------------------------'
289 print ' |rms [mJy/beam] | %8.2f |' % (rms)
290 print ' --------------------------------------------------------'
291 print ' |rms point-like source [MJy/sr] | %6.2f |' % (rms_point_MJy_spec)
292 print ' |rms point-like source [K_CMB]x10^-6 | %5i |' % (rms_point_cmb_spec)
293 print ' |*rms point.like source [Ysz]x10^-6 | %5i |' % (rms_point_ys_spec)
294 print ' --------------------------------------------------------'
295 print ' |* for Ysz = 1.0 |'
296 print ' --------------------------------------------------------'
297 print ''
298
299 #############################
300 #### TABLE FINAL RESULTS ####
301 #############################
302
303 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
304 print ' %%%%%%%%%%%%%%%%%%%%%% Results %%%%%%%%%%%%%%%%%%%%%%'
305 print ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
306 print ''
307 print ' for: El = %2i (deg), PWV = %1i (mm), tau = %4.2f, rms = %6.2f' % (elevation,pwv,tau,rms)
308 print ' Area = %4.1f (arcmin^2), Filter = %4.1f, Overhead = %4.1f' % (area_obs,filtering,foverhead)
309 print ' ---------------------------------------------------------------'
310 print ' | (User Defined) | | |'
311 print ' ---------------------------------------------------------------'
312 print ' | Band | | %1i |' % (band)
313 print ' ---------------------------------------------------------------'
314 print ' | Total Integration Time | [hours] | %6.1f |' % (t_spec)
315 print ' ---------------------------------------------------------------'
316 print ' | Mapping speed | [arcmin^-2/hour/mJy^-2 ] | %6.1f |' % (s_map_spec)
317 print ' ---------------------------------------------------------------'
318 print ' '
319
320 if verbose_flag == 1:
321
322 print bcolors.WARNING + ' WARNING1: For proposed maps taking longer than 40 minutes, the total'
323 print bcolors.WARNING + ' integration time should be split into several maps.\n' + bcolors.ENDC
324 print ' '
325 print bcolors.WARNING + ' WARNING2: Note that the confusion noise is not included in this Time'
326 print bcolors.WARNING + ' Estimator and it should be discussed in the proposal whether appro-'
327 print bcolors.WARNING + ' priate. The RMS noise does not decrease indefinitely with integra- '
328 print bcolors.WARNING + ' tion time but stops at the confusion limit caused by unresolved sour-'
329 print bcolors.WARNING + ' ces within the beam. The exact threshold at which the RMS noise '
330 print bcolors.WARNING + ' reaches the confusion limit will vary with wavelength, beam size, '
331 print bcolors.WARNING + ' and the type of astronomical source (Galactic or Extra-Galactic). For'
332 print bcolors.WARNING + ' instance, for the GOODS-N field (part of the Deep Field GT Proposal),'
333 print bcolors.WARNING + ' a preliminary 1 sigma confusion limit around ~ 0.090 mJy and ~ 0.056'
334 print bcolors.WARNING + ' mJy at 1.2 mm and 2.0 mm, respectively, has been estimated (A. Beelen,'
335 print bcolors.WARNING + ' private communication).\n' + bcolors.ENDC
336
337 print ' '
338 print ' Time per OTF line for allowed scanning speeds '
339 print ' -----------------------------------------------------'
340 print ' | | OTF Scan Velocity | TIME PER OTF LINE |'
341 print ' -----------------------------------------------------'
342 print ' | | [arcsec/s] | [minutes] |'
343 print ' -----------------------------------------------------'
344 print ' | OTF-SLOW | %6.1f | %6.2f |' % (sampl_vel_slow,T_SLOW)
345 print ' | OTF-MID | %6.1f | %6.2f |' % (sampl_vel_mid,T_MID)
346 print ' | OTF-FAST | %6.1f | %6.2f |' % (sampl_vel_fast,T_FAST)
347 print ' -----------------------------------------------------'
348 print ' '
349
350 ###############################
351 #### CONVERSION TO MINUTES ####
352 ###############################
353
354 if t_spec >= 1.:
355 time_str_spec=str(round(t_spec,1))+' hours'
356
357 if t_spec < 1. and t_spec >= 1./60.:
358 time_str_spec=str(round(t_spec*60,1))+' minutes'
359
360 if t_spec < 1./60. and t_spec >= 0.1/3600.:
361 time_str_spec=str(int(t_spec*3600))+' seconds'
362
363 if t_spec < 0.1/3600.:
364 time_str_spec='0.1 (seconds)'
365
366 slew_overhe = str(int((slewing_loss-1.0)*100.0))
367
368 ##############################
369 #### OUTPUT FINAL RESULTS ####
370 ##############################
371
372 print bcolors.HEADER + '**********************************************'
373 print '*** Total Integration Time => ' + time_str_spec + ' ***'
374 print '**********************************************\n'
375 print ''
376
377 print bcolors.HEADER + bcolors.UNDERLINE + 'Please include the following text into your proposal:\n' + bcolors.ENDC
378
379 print 'According to the specifications of the NIKA2 instrument, the total observing time using the NIKA2 '+str(band)+' mm band to map a region of '+str(round(area_obs,1))+' [arcmin^2] to reach an rms of '+str(rms)+' [mJy/beam], assuming '+str(pwv)+' [mm] pwv, '+str(elevation)+' [deg] elevation, Filter = '+str(filtering)+', Overhead = '+str(foverhead)+', was estimated to be *'+time_str_spec+'*, using the time estimator '+version+'.\n'
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.