Commit 45c08fffcf396394dbfc87779b0186c0ea601832
1 parent
3dffd3da
Set unique observation identifier
Showing
1 changed file
with
19 additions
and
11 deletions
examples/make_pointings.py
| @@ -562,7 +562,7 @@ def set_lmc(hours=250.0, caldb='prod2', lst=True): | @@ -562,7 +562,7 @@ def set_lmc(hours=250.0, caldb='prod2', lst=True): | ||
| 562 | # ======================================= # | 562 | # ======================================= # |
| 563 | # Write observation definition dictionary # | 563 | # Write observation definition dictionary # |
| 564 | # ======================================= # | 564 | # ======================================= # |
| 565 | -def write_obsdef(filename, obsdef): | 565 | +def write_obsdef(filename, obsdef, idstart): |
| 566 | """ | 566 | """ |
| 567 | Write observation definition file | 567 | Write observation definition file |
| 568 | 568 | ||
| @@ -572,12 +572,17 @@ def write_obsdef(filename, obsdef): | @@ -572,12 +572,17 @@ def write_obsdef(filename, obsdef): | ||
| 572 | Observation definition file name | 572 | Observation definition file name |
| 573 | obsdef : list of dict | 573 | obsdef : list of dict |
| 574 | List of pointing definitions | 574 | List of pointing definitions |
| 575 | + idstart : int | ||
| 576 | + First identifier of observation definition file | ||
| 575 | """ | 577 | """ |
| 576 | # Open file | 578 | # Open file |
| 577 | file = open(filename, 'w') | 579 | file = open(filename, 'w') |
| 578 | 580 | ||
| 579 | # Write header | 581 | # Write header |
| 580 | - file.write('ra,dec,tmin,duration,caldb,irf,emin,emax\n') | 582 | + file.write('id,ra,dec,tmin,duration,caldb,irf,emin,emax\n') |
| 583 | + | ||
| 584 | + # Initialise identifier | ||
| 585 | + id = idstart | ||
| 581 | 586 | ||
| 582 | # Loop over pointings | 587 | # Loop over pointings |
| 583 | for obs in obsdef: | 588 | for obs in obsdef: |
| @@ -603,10 +608,13 @@ def write_obsdef(filename, obsdef): | @@ -603,10 +608,13 @@ def write_obsdef(filename, obsdef): | ||
| 603 | emax = 50.0 | 608 | emax = 50.0 |
| 604 | 609 | ||
| 605 | # Write information | 610 | # Write information |
| 606 | - file.write('%8.4f,%8.4f,%.4f,%.4f,%s,%s,%.3f,%.1f\n' % | ||
| 607 | - (ra, dec, obs['tmin'], obs['duration'], obs['caldb'], \ | 611 | + file.write('%6.6d,%8.4f,%8.4f,%.4f,%.4f,%s,%s,%.3f,%.1f\n' % |
| 612 | + (id, ra, dec, obs['tmin'], obs['duration'], obs['caldb'], \ | ||
| 608 | obs['irf'], emin, emax)) | 613 | obs['irf'], emin, emax)) |
| 609 | 614 | ||
| 615 | + # Increment identifier | ||
| 616 | + id += 1 | ||
| 617 | + | ||
| 610 | # Close file | 618 | # Close file |
| 611 | file.close() | 619 | file.close() |
| 612 | 620 | ||
| @@ -654,31 +662,31 @@ def make_pointings(): | @@ -654,31 +662,31 @@ def make_pointings(): | ||
| 654 | # Galactic plane survey | 662 | # Galactic plane survey |
| 655 | if obsname == 'gps': | 663 | if obsname == 'gps': |
| 656 | obsdef = set_gps(caldb=caldb, lst=lst) | 664 | obsdef = set_gps(caldb=caldb, lst=lst) |
| 657 | - write_obsdef('gps.dat', obsdef) | 665 | + write_obsdef('gps.dat', obsdef, 110000) |
| 658 | elif obsname == 'gps_south': | 666 | elif obsname == 'gps_south': |
| 659 | obsdef = set_gps(caldb=caldb, lst=lst, north=False) | 667 | obsdef = set_gps(caldb=caldb, lst=lst, north=False) |
| 660 | - write_obsdef('gps.dat', obsdef) | 668 | + write_obsdef('gps.dat', obsdef, 120000) |
| 661 | elif obsname == 'gps3': | 669 | elif obsname == 'gps3': |
| 662 | obsdef = set_gps(separation=1.5, caldb=caldb, lst=lst) | 670 | obsdef = set_gps(separation=1.5, caldb=caldb, lst=lst) |
| 663 | - write_obsdef('gps3.dat', obsdef) | 671 | + write_obsdef('gps3.dat', obsdef, 130000) |
| 664 | 672 | ||
| 665 | # Extragalactic survey | 673 | # Extragalactic survey |
| 666 | elif obsname == 'egal': | 674 | elif obsname == 'egal': |
| 667 | obsdef = set_egal(caldb=caldb, lst=lst) | 675 | obsdef = set_egal(caldb=caldb, lst=lst) |
| 668 | - write_obsdef('egal.dat', obsdef) | 676 | + write_obsdef('egal.dat', obsdef, 210000) |
| 669 | elif obsname == 'egal_south': | 677 | elif obsname == 'egal_south': |
| 670 | obsdef = set_egal(caldb=caldb, lst=lst, north=False) | 678 | obsdef = set_egal(caldb=caldb, lst=lst, north=False) |
| 671 | - write_obsdef('egal.dat', obsdef) | 679 | + write_obsdef('egal.dat', obsdef, 220000) |
| 672 | 680 | ||
| 673 | # Galactic centre | 681 | # Galactic centre |
| 674 | elif obsname == 'gc': | 682 | elif obsname == 'gc': |
| 675 | obsdef = set_gc(caldb=caldb, lst=lst) | 683 | obsdef = set_gc(caldb=caldb, lst=lst) |
| 676 | - write_obsdef('gc.dat', obsdef) | 684 | + write_obsdef('gc.dat', obsdef, 310000) |
| 677 | 685 | ||
| 678 | # LMC | 686 | # LMC |
| 679 | elif obsname == 'lmc': | 687 | elif obsname == 'lmc': |
| 680 | obsdef = set_lmc(caldb=caldb, lst=lst) | 688 | obsdef = set_lmc(caldb=caldb, lst=lst) |
| 681 | - write_obsdef('lmc.dat', obsdef) | 689 | + write_obsdef('lmc.dat', obsdef, 410000) |
| 682 | 690 | ||
| 683 | # Invalid pattern | 691 | # Invalid pattern |
| 684 | else: | 692 | else: |