Commit 70b28cc17d7937a8d58c8064e223c902d65df200
1 parent
4972e29c
Add 10 hours night / 14 hours day scheme to make_pointing and start observations on 1/1/2021
Showing
1 changed file
with
85 additions
and
15 deletions
examples/make_pointings.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Generates pointing patterns for CTA observations |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2016 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2015-2017 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -96,10 +96,49 @@ def get_positions(xmin, xmax, ymin, ymax, step): |
| 96 | 96 | return positions |
| 97 | 97 | |
| 98 | 98 | |
| 99 | +# ============== # | |
| 100 | +# Set start time # | |
| 101 | +# ============== # | |
| 102 | +def set_tmin_for_next_pointing(tmin, duration): | |
| 103 | + """ | |
| 104 | + Set start time for next pointing | |
| 105 | + | |
| 106 | + Adds duration and 2 min for slew, and takes care of day and night. It is | |
| 107 | + assumed that the night lasts from [0,10] and the day lasts from [10,24] | |
| 108 | + | |
| 109 | + Parameters | |
| 110 | + ---------- | |
| 111 | + tmin : float | |
| 112 | + Start time of current pointing (sec) | |
| 113 | + duration : float | |
| 114 | + Duration of current pointing (sec) | |
| 115 | + | |
| 116 | + Returns | |
| 117 | + ------- | |
| 118 | + tmin : float | |
| 119 | + Start time of new pointing | |
| 120 | + """ | |
| 121 | + # Update start time, add 2 min for slew | |
| 122 | + tmin += duration + 120.0 | |
| 123 | + | |
| 124 | + # If we have more than 10 hours in day then go to next day | |
| 125 | + hours_in_day = tmin/3600.0 % 24.0 | |
| 126 | + if hours_in_day > 10.0: | |
| 127 | + days = int(tmin/86400.0) | |
| 128 | + days += 1 | |
| 129 | + tmin = float(days) * 86400.0 | |
| 130 | + | |
| 131 | + # Dump result | |
| 132 | + #print(tmin, hours_in_day) | |
| 133 | + | |
| 134 | + # Return start time | |
| 135 | + return tmin | |
| 136 | + | |
| 137 | + | |
| 99 | 138 | # ====================== # |
| 100 | 139 | # Setup patch on the sky # |
| 101 | 140 | # ====================== # |
| 102 | -def set_patch(lmin=-30.0, lmax=30.0, bmin=-1.5, bmax=+1.5, | |
| 141 | +def set_patch(tmin, lmin=-30.0, lmax=30.0, bmin=-1.5, bmax=+1.5, | |
| 103 | 142 | separation=3.0, hours=100.0, run_duration=30.0, |
| 104 | 143 | site=None, caldb='prod2', lst=True, autodec=0.0): |
| 105 | 144 | """ |
| ... | ... | @@ -107,6 +146,8 @@ def set_patch(lmin=-30.0, lmax=30.0, bmin=-1.5, bmax=+1.5, |
| 107 | 146 | |
| 108 | 147 | Parameters |
| 109 | 148 | ---------- |
| 149 | + tmin : float | |
| 150 | + Observation start time (seconds) | |
| 110 | 151 | lmin : float, optional |
| 111 | 152 | Minimum Galactic Longitude (deg) |
| 112 | 153 | lmax : float, optional |
| ... | ... | @@ -163,8 +204,12 @@ def set_patch(lmin=-30.0, lmax=30.0, bmin=-1.5, bmax=+1.5, |
| 163 | 204 | # Loop over number of runs |
| 164 | 205 | for run in range(n_runs): |
| 165 | 206 | |
| 166 | - # Set positions and duration | |
| 167 | - obs = {'lon': pnt['x'], 'lat': pnt['y'], 'duration': exposure} | |
| 207 | + # Set positions, start time and duration | |
| 208 | + obs = {'lon': pnt['x'], 'lat': pnt['y'], \ | |
| 209 | + 'tmin': tmin, 'duration': exposure} | |
| 210 | + | |
| 211 | + # Update start time for next pointing | |
| 212 | + tmin = set_tmin_for_next_pointing(tmin, exposure) | |
| 168 | 213 | |
| 169 | 214 | # Optionally add-in site dependent IRF |
| 170 | 215 | if site != None: |
| ... | ... | @@ -309,28 +354,43 @@ def set_gps(separation=3.0, bmin=-1.3, bmax=1.3, caldb='prod2', lst=True): |
| 309 | 354 | # Initialise observation definition |
| 310 | 355 | obsdef = [] |
| 311 | 356 | |
| 357 | + # Initialise start time (1-1-2021) | |
| 358 | + tmin = 7671.0 * 86400.0 | |
| 359 | + | |
| 312 | 360 | # Add inner region South |
| 313 | - obsdef.extend(set_patch(lmin=-60.0, lmax=60.0, bmin=bmin, bmax=bmax, | |
| 361 | + obsdef.extend(set_patch(tmin, lmin=-60.0, lmax=60.0, bmin=bmin, bmax=bmax, | |
| 314 | 362 | separation=separation, hours=780, |
| 315 | 363 | site='South', caldb=caldb, lst=lst)) |
| 316 | 364 | |
| 365 | + # Update start time | |
| 366 | + tmin = set_tmin_for_next_pointing(obsdef[-1]['tmin'], obsdef[-1]['duration']) | |
| 367 | + | |
| 317 | 368 | # Add Vela & Carina region |
| 318 | - obsdef.extend(set_patch(lmin=240.0, lmax=300.0, bmin=bmin, bmax=bmax, | |
| 369 | + obsdef.extend(set_patch(tmin, lmin=240.0, lmax=300.0, bmin=bmin, bmax=bmax, | |
| 319 | 370 | separation=separation, hours=180, |
| 320 | 371 | site='South', caldb=caldb, lst=lst)) |
| 321 | 372 | |
| 373 | + # Update start time | |
| 374 | + tmin = set_tmin_for_next_pointing(obsdef[-1]['tmin'], obsdef[-1]['duration']) | |
| 375 | + | |
| 322 | 376 | # Add 210-240 region |
| 323 | - obsdef.extend(set_patch(lmin=210.0, lmax=240.0, bmin=bmin, bmax=bmax, | |
| 377 | + obsdef.extend(set_patch(tmin, lmin=210.0, lmax=240.0, bmin=bmin, bmax=bmax, | |
| 324 | 378 | separation=separation, hours=60, |
| 325 | 379 | site='South', caldb=caldb, lst=lst)) |
| 326 | 380 | |
| 381 | + # Initialise start time | |
| 382 | + tmin = 7671.0 * 86400.0 | |
| 383 | + | |
| 327 | 384 | # Add Cygnus, Perseus |
| 328 | - obsdef.extend(set_patch(lmin=60.0, lmax=150.0, bmin=bmin, bmax=bmax, | |
| 385 | + obsdef.extend(set_patch(tmin, lmin=60.0, lmax=150.0, bmin=bmin, bmax=bmax, | |
| 329 | 386 | separation=separation, hours=450, |
| 330 | 387 | site='North', caldb=caldb, lst=lst)) |
| 331 | 388 | |
| 389 | + # Update start time | |
| 390 | + tmin = set_tmin_for_next_pointing(obsdef[-1]['tmin'], obsdef[-1]['duration']) | |
| 391 | + | |
| 332 | 392 | # Add Anticentre |
| 333 | - obsdef.extend(set_patch(lmin=150.0, lmax=210.0, bmin=bmin, bmax=bmax, | |
| 393 | + obsdef.extend(set_patch(tmin, lmin=150.0, lmax=210.0, bmin=bmin, bmax=bmax, | |
| 334 | 394 | separation=separation, hours=150, |
| 335 | 395 | site='North', caldb=caldb, lst=lst)) |
| 336 | 396 | |
| ... | ... | @@ -362,8 +422,11 @@ def set_extgal(separation=3.0, caldb='prod2', lst=True): |
| 362 | 422 | # Initialise observation definition |
| 363 | 423 | obsdef = [] |
| 364 | 424 | |
| 425 | + # Initialise start time (1-1-2021) | |
| 426 | + tmin = 7671.0 * 86400.0 | |
| 427 | + | |
| 365 | 428 | # Set patch |
| 366 | - obsdef.extend(set_patch(lmin=-90.0, lmax=90.0, bmin=+5.0, bmax=+88.0, | |
| 429 | + obsdef.extend(set_patch(tmin, lmin=-90.0, lmax=90.0, bmin=+5.0, bmax=+88.0, | |
| 367 | 430 | separation=separation, hours=1000, |
| 368 | 431 | site='Automatic', caldb=caldb, lst=lst, |
| 369 | 432 | autodec=10.0)) |
| ... | ... | @@ -394,13 +457,19 @@ def set_gc(caldb='prod2', lst=True): |
| 394 | 457 | # Initialise observation definition |
| 395 | 458 | obsdef = [] |
| 396 | 459 | |
| 460 | + # Initialise start time (1-1-2021) | |
| 461 | + tmin = 7671.0 * 86400.0 | |
| 462 | + | |
| 397 | 463 | # Central wobble |
| 398 | - obsdef.extend(set_patch(lmin=-0.5, lmax=0.5, bmin=-0.5, bmax=0.5, | |
| 464 | + obsdef.extend(set_patch(tmin, lmin=-0.5, lmax=0.5, bmin=-0.5, bmax=0.5, | |
| 399 | 465 | separation=0.1, hours=525, |
| 400 | 466 | site='South', caldb=caldb, lst=lst)) |
| 401 | 467 | |
| 468 | + # Update start time | |
| 469 | + tmin = set_tmin_for_next_pointing(obsdef[-1]['tmin'], obsdef[-1]['duration']) | |
| 470 | + | |
| 402 | 471 | # Extended region |
| 403 | - obsdef.extend(set_patch(lmin=-10.0, lmax=10.0, bmin=-10.0, bmax=10.0, | |
| 472 | + obsdef.extend(set_patch(tmin, lmin=-10.0, lmax=10.0, bmin=-10.0, bmax=10.0, | |
| 404 | 473 | separation=1.5, hours=300, |
| 405 | 474 | site='South', caldb=caldb, lst=lst)) |
| 406 | 475 | |
| ... | ... | @@ -491,7 +560,7 @@ def write_obsdef(filename, obsdef): |
| 491 | 560 | file = open(filename, 'w') |
| 492 | 561 | |
| 493 | 562 | # Write header |
| 494 | - file.write('ra,dec,duration,caldb,irf\n') | |
| 563 | + file.write('ra,dec,tmin,duration,caldb,irf\n') | |
| 495 | 564 | |
| 496 | 565 | # Loop over pointings |
| 497 | 566 | for obs in obsdef: |
| ... | ... | @@ -509,8 +578,9 @@ def write_obsdef(filename, obsdef): |
| 509 | 578 | dec = obs['dec'] |
| 510 | 579 | |
| 511 | 580 | # Write information |
| 512 | - file.write('%8.4f,%8.4f,%.4f,%s,%s\n' % | |
| 513 | - (ra, dec, obs['duration'], obs['caldb'], obs['irf'])) | |
| 581 | + file.write('%8.4f,%8.4f,%.4f,%.4f,%s,%s\n' % | |
| 582 | + (ra, dec, obs['tmin'], obs['duration'], obs['caldb'], \ | |
| 583 | + obs['irf'])) | |
| 514 | 584 | |
| 515 | 585 | # Close file |
| 516 | 586 | file.close() | ... | ... |