import trm.ucm as ucm if len(sys.argv) < 2: file = raw_input('Name of ucm file: ') else: file = sys.argv[1] file = file if file.endswith('.ucm') else file + '.ucm' if not os.path.isfile(file): print file,' is not a file.' exit(1) file = file if file.endswith('.ucm') else file + '.ucm' ucm = ucm.rucm(file) print 'read ucm file' if len(sys.argv) < 3 and len(ucm.data) > 1: nccd = int(raw_input('CCD number to display: ')) elif len(ucm.data) > 1: nccd = int(sys.argv[2]) else: nccd = 1 xbin = ucm.xbin ybin = ucm.ybin image = npy.zeros((ucm.nxtot//xbin,ucm.nytot//ybin)) for i in range(len(ucm.data[nccd-1])):
# positional parser.add_argument('idata', type=UcmFile('rb'), help='input data, a standard ucm frame.') parser.add_argument('odata', type=UcmFile('wb'), help='output data, a standard ucm frame.') # optional parser.add_argument('-d', dest='dblurr', type=float, default=3.,\ help='RMS to blurr data with in order to measure deviations.') parser.add_argument('-v', dest='vblurr', type=float, default=3.,\ help='RMS to blurr variances with.') # parse them args = parser.parse_args() # read the frame uc = ucm.rucm(args.idata) data = uc.data gd = gauss_kern(args.dblurr) gv = gauss_kern(args.vblurr) for nccd,ccd in enumerate(data): for nwin,win in enumerate(ccd): print 'Processing window',nwin+1,'of CCD',nccd+1 devsq = win - signal.convolve2d( win, gd, mode='same', boundary='symm') devsq *= devsq data[nccd][nwin] = np.sqrt(signal.convolve2d( devsq, gv, mode='same', boundary='symm')) uc.write(args.odata)
parser.add_argument('-n', dest='nccd', type=int, default=0, help='CCD number to plot; 0 for all') parser.add_argument('-x1', dest='x1', type=float, default=0., help='left plot limit') parser.add_argument('-x2', dest='x2', type=float, default=0., help='right plot limit') parser.add_argument('-y1', dest='y1', type=float, default=0., help='lower plot limit') parser.add_argument('-y2', dest='y2', type=float, default=0., help='upper plot limit') # parse them args = parser.parse_args() # read the bias frame bias = ucm.rucm(args.bias) pgopen(args.device) pgsch(1.5) pgslw(3) x1 = args.x1 y1 = args.y1 x2 = args.x2 if args.x2 != 0. else float(bias.nxtot) y2 = args.y2 if args.y2 != 0. else float(bias.nytot) nccd = len(bias.data) if args.nccd == 0: pgsubp(nccd,1) for nc in range(nccd): pgpanl(nc+1,1)
fstr = open(flist) fnames = [x.strip() if x.strip().endswith('.ucm') else x.strip() + '.ucm' for x in fstr.readlines()] fstr.close() for fname in fnames: if not os.path.isfile(fname): print '\n',fname,'is not a file; script aborted.' exit(1) # OK now have a list of valid file names, compute and store means # while checking format compatibility. first = True means = [] for fname in fnames: ufile = ucm.rucm(fname) if first: fufile = copy.deepcopy(ufile) nwin = ufile.nwin(0) for nc in range(1,ufile.nccd()): if ufile.nwin(nc) != nwin: print 'Script only works for same number of windows for each CCD' exit(1) ffname = fname first = False if ufile != fufile: print '\nFormat of',fname,'clashes with that of the first file read',ffname exit(1) mc = []
xml = os.path.join('raw_data', bias + '.xml') if not os.path.exists(xml): print 'WARNING: xml file =',xml,'does not exist; run skipped.' continue jnk = os.path.join('raw_data', bias + '.jnk') if os.path.exists(jnk): print 'WARNING: file =',jnk,'indicates that run is flagged as junk; run skipped.' continue ufile = os.path.join('derived_data', bias + '.ucm') dufile = clobber if not clobber and os.path.exists(ufile): # read file uf = ucm.rucm(ufile) if (not other and not pbias) or (other and 'Procbias' in uf) or (pbias and 'Procbias' not in uf): print 'WARNING: ucm file =',ufile,'already exists; run skipped.' continue else: dufile = True # Search for .dat then .dat.gz; if redo=True, also look on astronas # gunzip if .dat.gz data = os.path.join('raw_data', bias + '.dat') retrieved = False if not os.path.exists(data): datagz = os.path.join('raw_data', bias + '.dat.gz') if not os.path.exists(datagz): if redo: if not subprocess.Popen(['ssh', 'astronas', 'cd ultracam; ls ' + data]).wait():