Skip to content

Commit

Permalink
Merge pull request #250 from gbrammer/drizzle-variance
Browse files Browse the repository at this point in the history
Fix bugs from recent drizzle-variance merge
  • Loading branch information
gbrammer authored Oct 7, 2024
2 parents f59e58b + 09d19d1 commit 452448a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions grizli/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1924,8 +1924,8 @@ def make_SEP_catalog(root='',
WEIGHT_TYPE = "MAP_WEIGHT"

if (WEIGHT_TYPE == "MAP_WEIGHT") & (prefer_var_image):
var_file = weight_file.replace('_wht.fits', '_var.fits')
if os.path.exists(var_file):
var_file = weight_file.replace('wht.fits', 'var.fits')
if os.path.exists(var_file) & (var_file != weight_file):
weight_file = var_file
WEIGHT_TYPE = "VARIANCE"

Expand Down Expand Up @@ -3792,7 +3792,7 @@ def get_rotated_column_average(data, mask, theta, axis=1, statfunc=np.nanmedian,
return back_sl


def subtract_visit_angle_averages(visit, threshold=1.8, detection_background=True, angles=[30.0, -30.0, 0, 90], suffix='angles', niter=3, weight_type="jwst_var", instruments=['NIRCAM'], stepsize=-1, verbose=True):
def subtract_visit_angle_averages(visit, threshold=1.8, detection_background=True, angles=[30.0, -30.0, 0, 90], suffix='angles', niter=3, weight_type="jwst", instruments=['NIRCAM'], stepsize=-1, verbose=True):
"""
Subtract angle averages from exposures in a `visit` group
Expand Down Expand Up @@ -3901,7 +3901,7 @@ def subtract_visit_angle_averages(visit, threshold=1.8, detection_background=Tru
weight_type=weight_type,
)

drz_h = drz[2]
drz_h = drz[3]

drz_h['PA_APER'] = pa_aper, 'PA_APER used for reference'
drz_h['BKGANGLE'] = (','.join([f'{a:.1f}' for a in angles]),
Expand Down Expand Up @@ -5019,11 +5019,11 @@ def process_direct_grism_visit(direct={},
extra_wfc3ir_badpix=True,
verbose=False,
scale_photom=False,
weight_type='jwst_var',
weight_type='jwst',
calc_wcsmap=False,
)

_sci, _wht, _hdr, _files, _info = _
_sci, _wht, _var, _hdr, _files, _info = _
_drcfile = glob.glob(f"{direct['product']}_dr*sci.fits")[0]
_whtfile = _drcfile.replace('_sci.fits','_wht.fits')
pyfits.PrimaryHDU(data=_sci, header=_hdr).writeto(_drcfile,
Expand Down Expand Up @@ -5440,23 +5440,27 @@ def iterate_tweak_align(direct, grism, cat_threshold=7, cleanup=True, niter=3, t
utils.log_comment(utils.LOGFILE, logstr, verbose=verbose)

tmp_root_i = f"{tmp_root}_{iter_i}"


OLOGFILE = utils.LOGFILE

_ = visit_processor.cutout_mosaic(
rootname=tmp_root_i,
product='{rootname}',
ir_wcs=_wcs,
half_optical=False,
kernel='square',
pixfrac=0.8,
weight_type='jwst_var',
weight_type='jwst',
res=_res,
clean_flt=False,
gzip_output=False,
skip_existing=False,
s3output=None,
verbose=False
)


utils.LOGFILE = OLOGFILE

cat = make_SEP_catalog(tmp_root_i,
threshold=cat_threshold,
verbose=False,
Expand Down

0 comments on commit 452448a

Please sign in to comment.