Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,222 changes: 3,222 additions & 0 deletions mmtwfs/data/Act2SurfTEL

Large diffs are not rendered by default.

104 changes: 104 additions & 0 deletions mmtwfs/data/Surf2ActTEL_104

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions mmtwfs/scripts/reanalyze.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python

from datetime import datetime
import concurrent.futures
import multiprocessing
from multiprocessing import Pool
from functools import partial
import pytz
from pathlib import Path
Expand Down Expand Up @@ -34,6 +34,7 @@

tz = pytz.timezone("America/Phoenix")


# instantiate all of the WFS systems...
wfs_keys = ['f9', 'newf9', 'f5', 'mmirs', 'binospec']
wfs_systems = {}
Expand Down Expand Up @@ -218,6 +219,7 @@ def process_image(f, force=False):
return None

outfile = f.parent / (f.stem + ".output")
failed = f.parent / (f.stem + ".failed")
if not force and Path.exists(outfile):
log.info(f"Already processed {f.name}, loading previous data...")
with open(outfile, 'r') as fp:
Expand All @@ -226,12 +228,18 @@ def process_image(f, force=False):
if len(lines) > 0:
return lines[0]

if not force and Path.exists(failed):
log.info(f"Already failed processing {f.name}, skipping...")
return None

try:
data, hdr = check_image(f)
except Exception as e:
log.error(f"Problem checking {f}: {e}")
failed.touch() # mark this file as failed
return None

log.info(f"Processing {f.name}...")
wfskey = hdr['WFSKEY']
obstime = hdr['OBS-TIME']
airmass = hdr['AIRMASS']
Expand Down Expand Up @@ -261,6 +269,7 @@ def process_image(f, force=False):
results = wfs_systems[wfskey].measure_slopes(str(f), plot=False)
except Exception as e:
log.error(f"Problem analyzing {f.name}: {e}")
failed.touch()
results = {}
results['slopes'] = None

Expand All @@ -286,8 +295,10 @@ def process_image(f, force=False):
return line
except Exception as e:
log.error(f"Problem fitting wavefront for {f.name}: {e}")
failed.touch()
return None
else:
failed.touch() # mark this file as failed
return None


Expand Down Expand Up @@ -357,9 +368,9 @@ def main():
_ = int(d.name) # valid WFS directories are ints of the form YYYYMMDD. if not this form, int barfs
fitsfiles = sorted(list(d.glob("*.fits")))
log.info(f"Processing {len(fitsfiles)} images in {d}...")
with Pool(processes=args.nproc) as pool:
with concurrent.futures.ProcessPoolExecutor(max_workers=args.nproc) as pool:
process = partial(process_image, force=args.force)
plines = pool.map(process, fitsfiles) # plines comes out in same order as fitslines!
plines = pool.map(process, fitsfiles, timeout=300) # plines comes out in same order as fitslines!

plines = [line for line in plines if line is not None] # trim out any None entries

Expand Down
10 changes: 5 additions & 5 deletions mmtwfs/wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ def wfsfind(data, fwhm=7.0, threshold=5.0, plot=True, ap_radius=5.0, std=None):
msg = "WFS spot detection failed or no spots detected."
raise WFSAnalysisFailed(value=msg)

# this may be redundant given the above check...
# only keep spots more than 1/4 as bright as the max. need this for f/9 especially.
sources = sources[sources["flux"] > sources["flux"].max() / 4.0]

# if only a handful of spots, then effectively none are detected.
nsrcs = len(sources)
if nsrcs == 0:
if nsrcs < 5:
msg = "No WFS spots detected."
raise WFSAnalysisFailed(value=msg)

# only keep spots more than 1/4 as bright as the max. need this for f/9 especially.
sources = sources[sources["flux"] > sources["flux"].max() / 4.0]

fig = None
if plot:
fig, ax = plt.subplots()
Expand Down
8 changes: 5 additions & 3 deletions notebooks/WFS testing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@
"#bino_file = \"/Volumes/LaCie 8TB/wfsdat/20200127/wfs_ff_cal_img_2020.0127.041552.fits\"\n",
"#bino_file = \"/Users/tim/MMT/mmtwfs/mmtwfs/data/ref_images/bino_mask.fits\"\n",
"#bino_file = \"/mnt/f/wfsdat/20220125/wfs_ff_cal_img_2022.0125.054438.fits\"\n",
"bino_file = \"~/wfs_ff_cal_img_2025.06.25T093644.964.fits\"\n",
"bino_file = \"/Users/tim/MMT/wfsdat/20250830/wfs_ff_cal_img_2025.08.30T080123.915.fits\"\n",
"results = bino.measure_slopes(bino_file, mode=\"binospec\", plot=True)\n",
"results['figures']['slopes'].show()\n",
"print(results['vlt_seeing'])"
"print(results.get('seeing', None))"
]
},
{
Expand Down Expand Up @@ -1616,7 +1618,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "py313",
"display_name": "mmtwfs",
"language": "python",
"name": "python3"
},
Expand All @@ -1630,7 +1632,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.1"
"version": "3.13.5"
}
},
"nbformat": 4,
Expand Down
Loading