Skip to content

Commit

Permalink
Merge pull request #8 from des-science/cache
Browse files Browse the repository at this point in the history
ENH cache the healsparse map
  • Loading branch information
beckermr committed Oct 11, 2022
2 parents cf96e52 + 778484d commit db64c16
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions des_y6utils/mdet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import subprocess
from functools import lru_cache

import numpy as np

Expand Down Expand Up @@ -124,8 +125,7 @@ def _make_mdet_cuts_v1(d, verbose=False):
msk = _make_mdet_cuts_raw_v1(d, verbose=verbose)

# apply the mask
mpth = _get_mask_path("y6-combined-hleda-gaiafull-hsmap16384-nomdet.fits")
hmap = healsparse.HealSparseMap.read(mpth)
hmap = _read_hsp_mask("y6-combined-hleda-gaiafull-hsmap16384-nomdet.fits")
in_footprint = hmap.get_values_pos(d["ra"], d["dec"], valid_mask=True)
msk &= in_footprint
if verbose:
Expand Down Expand Up @@ -166,6 +166,12 @@ def _compute_asinh_mags(flux, i):
return mag


@lru_cache
def _read_hsp_mask(fname):
mpth = _get_mask_path(fname)
return healsparse.HealSparseMap.read(mpth)


def _get_mask_path(fname):
# get or make meds dir
meds_dir = os.environ.get("MEDS_DIR", None)
Expand Down

0 comments on commit db64c16

Please sign in to comment.