Skip to content

Commit

Permalink
Adding requested changes and changing the name of the instrument
Browse files Browse the repository at this point in the history
attribute into detectors (doesn't work)
  • Loading branch information
jacquot committed Jan 8, 2025
1 parent 2f81508 commit 1e8bb5a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
26 changes: 11 additions & 15 deletions bin/pycbc_make_sky_grid
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ parser.add_argument(
"otherwise radians are assumed.",
)
parser.add_argument(
'--instruments',
'--detectors',
nargs="+",
type=str,
required=True,
help="List of instruments to analyze.",
help="List of detectors to analyze.",
)
parser.add_argument(
'--sky-error',
Expand Down Expand Up @@ -92,11 +92,11 @@ args = parser.parse_args()

pycbc.init_logging(args.verbose)

if len(args.instruments) == 1:
if len(args.detectors) == 1:
parser.error('Can not make a sky grid for only one detector.')

args.instruments.sort() # Put the ifos in alphabetical order
detectors = args.instruments
args.detectors.sort() # Put the ifos in alphabetical order
detectors = args.detectors
detectors = [Detector(d) for d in detectors]
detector_pairs = list(itertools.combinations(detectors, 2))

Expand Down Expand Up @@ -166,19 +166,15 @@ spher = cart_to_spher(rota)
# Calculate the time delays between the Earth center
# and each detector for each sky point
sky_grid = SkyGrid(
spher[:, 0], spher[:, 1], args.instruments, args.trigger_time
spher[:, 0], spher[:, 1], args.detectors, args.trigger_time
)
time_delays = sky_grid.calculate_time_delays()

extra_attributes = {
'trigger_ra': args.ra,
'trigger_dec': args.dec,
'sky_error': args.sky_error,
'timing_uncertainty': args.timing_uncertainty
}

extra_datasets = {
'time_delays': time_delays
}
'trigger_ra': args.ra,
'trigger_dec': args.dec,
'sky_error': args.sky_error,
'timing_uncertainty': args.timing_uncertainty
}

sky_grid.write_to_file(args.output, extra_attributes, extra_datasets)
Binary file added bin/sky_grid.hdf5
Binary file not shown.
13 changes: 6 additions & 7 deletions pycbc/tmpltbank/sky_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,18 @@ def read_from_file(cls, path):
ref_gps_time = hf.attrs['ref_gps_time']
return cls(ra, dec, detectors, ref_gps_time)

def write_to_file(self, path, extra_attrs, extra_datasets):
def write_to_file(self, path, extra_attrs=None, extra_datasets=None):
"""Writes a sky grid to an HDF5 file."""
with h5py.File(path, 'w') as hf:
breakpoint()
hf['ra'] = self.ras
hf['dec'] = self.decs
hf.attrs['detectors'] = self.detectors
hf.attrs['ref_gps_time'] = self.ref_gps_time
if extra_attrs is not None:
for attribute in extra_attrs:
hf.attrs[attribute] = extra_attrs[attribute]
if extra_datasets is not None:
for datasets in extra_datasets:
hf[datasets] = extra_datasets[datasets]
for attribute in (extra_attrs or {}):
hf.attrs[attribute] = extra_attrs[attribute]
for datasets in (extra_datasets or {}):
hf[datasets] = extra_datasets[datasets]

def calculate_antenna_patterns(self):
"""Calculate the antenna pattern functions at each point in the grid
Expand Down

0 comments on commit 1e8bb5a

Please sign in to comment.