Skip to content

Commit

Permalink
more code removal
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoughlin committed May 28, 2024
1 parent 0e8ced8 commit 8b17958
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 51 deletions.
36 changes: 1 addition & 35 deletions gwemopt/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,6 @@ def powerlaw(params, map_struct, tile_structs, previous_coverage_struct=None):
"need to specify tiles that have been observed using --observedTiles"
)

if params["treasuremap_token"] is not None and previous_coverage_struct:
tile_struct = update_observed_tiles(
params, tile_struct, previous_coverage_struct
) # coverage_struct of the previous round

coverage_struct = gwemopt.scheduler.scheduler(
params, config_struct, tile_struct
)
Expand Down Expand Up @@ -410,35 +405,6 @@ def powerlaw(params, map_struct, tile_structs, previous_coverage_struct=None):
return tile_structs, combine_coverage_structs(coverage_structs)


def update_observed_tiles(params, tile_struct, previous_coverage_struct):
if not params["doAlternatingFilters"]:
tile_struct = check_overlapping_tiles(
params, tile_struct, previous_coverage_struct
) # maps field ids to tile_struct

for key in tile_struct.keys(): # sets tile to 0 if previously observed
if "epochs" not in tile_struct[key]:
continue
ipix = tile_struct[key]["ipix"]

tot_overlap = sum(
tile_struct[key]["epochs_overlap"]
) # sums over list of overlapping ipix lengths

if params["doAlternatingFilters"]:
# only takes into account fields with same filters for total overlap
for ii, filt in enumerate(tile_struct[key]["epochs_filters"]):
if filt != params["filters"][0]:
tot_overlap -= tile_struct[key]["epochs_overlap"][ii]

rat = tot_overlap / len(ipix)

if rat > 0.3:
tile_struct[key]["prob"] = 0.0

return tile_struct


def timeallocation(params, map_struct, tile_structs, previous_coverage_struct=None):
if len(params["telescopes"]) > 1 and params["doOrderByObservability"]:
order_by_observability(params, tile_structs)
Expand Down Expand Up @@ -506,7 +472,7 @@ def timeallocation(params, map_struct, tile_structs, previous_coverage_struct=No
)

coverage_structs.append(coverage_struct)
for ii in range(len(coverage_struct["ipix"])):
for ii in range(len(coverage_struct["moc"])):
telescope = coverage_struct["telescope"][ii]
scheduled_fields[telescope].append(
coverage_struct["data"][ii, 5]
Expand Down
6 changes: 0 additions & 6 deletions gwemopt/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,6 @@ def schedule_alternating(
params, config_struct, telescope, map_struct, tile_struct
)

if params["treasuremap_token"] is not None and previous_coverage_struct:
# erases tiles from a previous round
tile_struct = gwemopt.coverage.update_observed_tiles(
params, tile_struct_hold, previous_coverage_struct
)

# set unbalanced fields to 0
if params["doBalanceExposure"] and params["unbalanced_tiles"]:
for key in params["unbalanced_tiles"]:
Expand Down
16 changes: 6 additions & 10 deletions gwemopt/utils/treasuremap.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_treasuremap_pointings(params):
coverage_struct = {}
coverage_struct["data"] = np.empty((0, 8))
coverage_struct["filters"] = []
coverage_struct["ipix"] = []
coverage_struct["moc"] = []

# read information into coverage struct
for obs in observations:
Expand All @@ -60,21 +60,17 @@ def get_treasuremap_pointings(params):
ra, dec = float(pointing[0]), float(pointing[1])

filteridx = obs.find("band") + 10 # jump to starting index of filter
filter = obs[filteridx:].split('"')[0][:-1]
filt = obs[filteridx:].split('"')[0][:-1]

instrumentidx = (
obs.find("instrumentid") + 16
) # jump to starting index of instrument id
instrument_id = int(obs[instrumentidx:].split(",")[0])

if instrument_id in FOV_square:
ipix, radecs, patch, area = getSquarePixels(
ra, dec, FOV_square[instrument_id], params["nside"]
)
moc = getSquarePixels(ra, dec, FOV_square[instrument_id])
elif instrument_id in FOV_circle:
ipix, radecs, patch, area = getCirclePixels(
ra, dec, FOV_circle[instrument_id], params["nside"]
)
moc = getCirclePixels(ra, dec, FOV_circle[instrument_id])
else:
continue

Expand All @@ -83,7 +79,7 @@ def get_treasuremap_pointings(params):
np.array([[ra, dec, -1, -1, -1, -1, -1, -1]]),
axis=0,
)
coverage_struct["filters"].append(filter)
coverage_struct["ipix"].append(ipix)
coverage_struct["filters"].append(filt)
coverage_struct["moc"].append(moc)

return coverage_struct

0 comments on commit 8b17958

Please sign in to comment.