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 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 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 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 persist_routine(dit, offset, end_t, tag): sorting_dir = persist_dir + '/' + tag os.mkdir(sorting_dir) img_name = sorting_dir + '/img_' + str(dit) + '_' #Run sld_on.exe subprocess.call(["C:\EDT\pdv\sld_on.exe"]) print("SOAK BEGIN") cam.set_int_time(dit) cam.set_frame_time(dit + offset) fr = cam.read_frame_time() it = cam.read_int_time() print(fr, it) #Take throwaway image to open up cam cam.img_cap(routine, img_dir, 'f') os.remove(unsorted_img) #Run soak.exe subprocess.call(["C:\EDT\pdv\soak.exe"]) t0 = time.time() #Start Timer (time since soak) t = 0 print("SOAK END") while t < end_t: cam.img_cap(routine, img_dir, 'f') t1 = time.time() t = t1 - t0 t_s = round(t, 2) print("Image taken: {}".format(t_s)) file_name = img_name + str(t_s) + '_.fits' os.rename(unsorted_img, file_name) print("PROGRAM COMPLETE")
def master_bias(n, tag, T): ''' Enter docstring here ''' cam.set_int_time(0.033) cam.set_frame_time(100.033) cam.printProgressBar(0, n, prefix='Progress:', suffix='Complete', length=50) stack = np.zeros((naxis1, naxis2), dtype=np.uint16) for j in range(n): cap, _ = cam.img_cap(routine, img_dir, 'f') hdu_img = fits.open(unsorted_img) fits_img = hdu_img[0] data = fits_img.data hdu_img.close() #Close image so it can be sorted stack = np.dstack((stack, data)) cam.printProgressBar(j,n, prefix = 'Progress:', \ suffix = 'Complete', length = 50) if j == n - 1: #On final frame grab header bias_header = fits.getheader(unsorted_img) os.remove(unsorted_img) #Delete image after data retrieval bias_header.append(('NDIT', n, 'Number of integrations')) bias_header.append(('TYPE', 'MASTER_BIAS', '0s exposure frame')) bias_header.append(('FPATEMP', T, 'Temperature of detector')) #Median Stack stack = stack[:, :, 1:] #Slice off base layer master_bias = np.median(stack, axis=2) master_bias = master_bias.astype(np.uint16) #Write master frame to fits master_path = read_path + 'master_bias_' \ + tag + '.fits' fits.writeto(master_path, master_bias, bias_header) print('PROGRAM HAS COMPLETED')
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')
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)