Commit 45c08fffcf396394dbfc87779b0186c0ea601832

Authored by Jürgen Knödlseder
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 562 # ======================================= #
563 563 # Write observation definition dictionary #
564 564 # ======================================= #
565   -def write_obsdef(filename, obsdef):
  565 +def write_obsdef(filename, obsdef, idstart):
566 566 """
567 567 Write observation definition file
568 568  
... ... @@ -572,12 +572,17 @@ def write_obsdef(filename, obsdef):
572 572 Observation definition file name
573 573 obsdef : list of dict
574 574 List of pointing definitions
  575 + idstart : int
  576 + First identifier of observation definition file
575 577 """
576 578 # Open file
577 579 file = open(filename, 'w')
578 580  
579 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 587 # Loop over pointings
583 588 for obs in obsdef:
... ... @@ -603,10 +608,13 @@ def write_obsdef(filename, obsdef):
603 608 emax = 50.0
604 609  
605 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 613 obs['irf'], emin, emax))
609 614  
  615 + # Increment identifier
  616 + id += 1
  617 +
610 618 # Close file
611 619 file.close()
612 620  
... ... @@ -654,31 +662,31 @@ def make_pointings():
654 662 # Galactic plane survey
655 663 if obsname == 'gps':
656 664 obsdef = set_gps(caldb=caldb, lst=lst)
657   - write_obsdef('gps.dat', obsdef)
  665 + write_obsdef('gps.dat', obsdef, 110000)
658 666 elif obsname == 'gps_south':
659 667 obsdef = set_gps(caldb=caldb, lst=lst, north=False)
660   - write_obsdef('gps.dat', obsdef)
  668 + write_obsdef('gps.dat', obsdef, 120000)
661 669 elif obsname == 'gps3':
662 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 673 # Extragalactic survey
666 674 elif obsname == 'egal':
667 675 obsdef = set_egal(caldb=caldb, lst=lst)
668   - write_obsdef('egal.dat', obsdef)
  676 + write_obsdef('egal.dat', obsdef, 210000)
669 677 elif obsname == 'egal_south':
670 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 681 # Galactic centre
674 682 elif obsname == 'gc':
675 683 obsdef = set_gc(caldb=caldb, lst=lst)
676   - write_obsdef('gc.dat', obsdef)
  684 + write_obsdef('gc.dat', obsdef, 310000)
677 685  
678 686 # LMC
679 687 elif obsname == 'lmc':
680 688 obsdef = set_lmc(caldb=caldb, lst=lst)
681   - write_obsdef('lmc.dat', obsdef)
  689 + write_obsdef('lmc.dat', obsdef, 410000)
682 690  
683 691 # Invalid pattern
684 692 else:
... ...