def dark_current(n, T, tag='', amb_temp=''): int_times = np.round(np.linspace(5, 500, n), 0) cam.printProgressBar(0, sum(int_times)) y = 0 for j in int_times: cam.set_int_time(j) cam.set_frame_time(j + 20) cap, _ = cam.img_cap(routine, img_dir, 'f') hdu_img = fits.open(unsorted_img) data = hdu_img[0].data dark_header = fits.getheader(unsorted_img) dark_header.append(('FPATEMP', T, 'Temperature of detector')) dark_header.append(('TEMPAMB', amb_temp, 'Ambient Temperature')) hdu_img.close() os.remove(unsorted_img) #Delete image after data retrieval fits.writeto(unsorted_img, data, dark_header) cam.file_sorting(img_dir, j, j + 20, tag=tag) y += j cam.printProgressBar(y, sum(int_times)) print('PROGRAM HAS COMPLETED')
def ramp(n, tag=''): int_times = np.round(np.linspace(50, 5000, n), 0) for j in int_times: cam.set_int_time(j) cam.set_frame_time(j + 20) cam.img_cap(routine, img_dir, 'f') cam.file_sorting(img_dir, j, j + 20, tag=tag) print('PROGRAM COMPLETE')
def full_well(n, int_t, tag=''): dit = cam.set_int_time(int_t) cam.set_frame_time(int_t + 20) cam.printProgressBar(0, n) for j in range(n): cap, _ = cam.img_cap(routine, img_dir, 'f') cam.file_sorting(img_dir, dit, dit + 20, tag=tag) cam.printProgressBar(j, n)
def expose(i, tag=''): int_t = cam.set_int_time(i) frame_t = cam.set_frame_time(i + 100) frame, int_header = cam.simple_cap() if args.c != '': int_header.append(('COMMENT', args.c, 'User-defined comment')) fits.writeto(unsorted_img, frame, int_header) cam.weather_to_fits(unsorted_img) cam.file_sorting(local_img_dir, int_t, frame_t, tag=tag)
def expose(i,tag=''): int_t = cam.set_int_time(i) frame_t = cam.set_frame_time(i+250) frame , int_header = cam.simple_cap() if args.c != '': int_header.append(('COMMENT',args.c,'User-defined comment')) # os.remove(unsorted_img) fits.writeto(unsorted_img,frame,int_header,overwrite=True) cam.weather_to_fits(unsorted_img) cam.file_sorting(img_dir,int_t,frame_t,tag=tag) print('EXPOSE COMPLETE')
def pair_ramp(n, tag=''): int_times = np.round(np.linspace(400, 700, n), 3) for j in int_times: cam.set_int_time(j) cam.set_frame_time(j + 250) #Take pair of images cam.img_cap(routine, img_dir, 'f') cam.file_sorting(img_dir, j, j + 250, tag=tag) print('PROGRAM COMPLETE')
def master_dark(i, n, T, tag=''): ''' DIT and NDIT are inputs Function can also take tag for sorting individual frames onto local drive T is the FPA temperature used to record temperature of FPA for this dark which is written to file name and FITS header Program also outputs a .npy binary file containing 3D datacube of central (100,100) window for studying temporal variance over stack ''' cam.set_int_time(i) cam.set_frame_time(i + 20) bias = cam.get_master_bias(T) cam.printProgressBar(0, n, prefix='Progress:', suffix='Complete', length=50) stack = np.zeros((naxis1, naxis2), dtype=np.uint16) window = np.zeros((100, 100), dtype=np.uint16) for j in range(n): _, _ = cam.img_cap(routine, img_dir, 'f') hdu_img = fits.open(unsorted_img) data = hdu_img[0].data hdu_img.close() #Close image so it can be sorted data = data - bias stack = np.dstack((stack, data)) data_window = cam.window(data, 100) window = np.dstack((window, data_window)) cam.printProgressBar(j,n, prefix = 'Progress:', \ suffix = 'Complete', length = 50) if j == n - 1: #On final frame grab header dark_header = fits.getheader(unsorted_img) #Save single frame to local drive cam.file_sorting(local_img_dir, i, i + 20, tag=tag) #Median stack stack = stack[:, :, 1:] #Slice off base layer master_dark = np.median(stack, axis=2) #Prepare window for temporal analysis window = window[:, :, 1:] #Slice off base layer temp_var = np.median(np.var(stack, axis=2)) temp_path = master_darks + 'dark_cube' \ + str(i/1000) + '_' +str(T) +'C.npy' np.save(temp_path, window) dark_header.append(('NDIT', n, 'Number of integrations')) dark_header.append(('TYPE', 'MASTER_DARK', 'Median stack of dark frames')) dark_header.append(('FPATEMP', T, 'Temperature of detector')) dark_header.append( ('TEMPVAR', temp_var, 'Median temporal variance of central (100,100) window')) #Output master frame to fits master_path = master_darks + 'master_dark_' \ + str(i/1000) + '_' +str(T) +'C.fits' fits.writeto(master_path, master_dark, dark_header) print('PROGRAM HAS COMPLETED')
else: frame_t = cam.set_frame_time(args.t) else: if args.v: frame_t = cam.read_frame_time(verbose=True) else: frame_t = cam.read_frame_time() #Capture image w/ or w/out defined location if args.l: for i in range(args.l): if args.r: capture_resp, _ = capture(args.p, args.r, 'f') cam.file_sorting(args.r, int_t, frame_t, '.raw', args.p, tag=args.g) elif args.b: capture_resp, _ = capture(args.p, args.b, 'b') cam.file_sorting(args.b, int_t, frame_t, routine=args.p, tag=args.g) elif args.f: capture_resp, _ = capture(args.p, args.f, 'f') cam.file_sorting(args.f, int_t, frame_t, '.fits',
import scicam as cam import argparse parser = argparse.ArgumentParser(prog='capture Image', description='Captures image using specified routine') parser.add_argument('-i', type=float, help='Integration Time') parser.add_argument('-g', type=str, help='Naming Tag',default = '') parser.add_argument('-l', type=int, help='Number of integrations (NDIT)') args = parser.parse_args() img_dir = '//merger.anu.edu.au/mbirch/images' if args.i: int_t = cam.set_int_time(args.i) frame_t = cam.set_frame_time((args.i+20)) else: int_t = cam.read_int_time() frame_t = cam.read_frame_time() if args.l: for i in range(args.l): cam.img_cap('capture',img_dir) cam.file_sorting(img_dir,int_t,frame_t,tag=args.g) else: cam.img_cap('capture',img_dir) cam.file_sorting(img_dir,int_t,frame_t,tag=args.g)