here_moon = use_moon[I] print('\n') print("\t--> Working on image: ", fsim) h = pyfits.open(fsim) mjd,mjd0 = cafeutils.mjd_fromheader2(h) ronoise, gain = float(h[0].header['CCDRON']),float(h[0].header['CCDGAIN']) # Object name obname = h[0].header['OBJECT'] print("\t\tObject name:",obname) # Open file, trim, overscan subtract and MasterBias subtract data = cafeutils.b_col(h[0].data) data = cafeutils.OverscanTrim( data ) - MasterBias drift,c_new = GLOBALutils.get_drift(data,P,c_all,pii=1024,win=10) P_new = GLOBALutils.shift_P(P,drift,c_new,ext_aperture) #print 'ydrift:',drift bacfile = dirout + 'BAC_' + fsim.split('/')[-1][:-4]+'fits' if os.access(bacfile,os.F_OK)==False: Centers = np.zeros((len(c_new),data.shape[1])) for i in range(nord): Centers[i,:]=scipy.polyval(c_new[i,:],np.arange(len(Centers[i,:]))) bac = GLOBALutils.get_scat(data,Centers,span=7) if (os.access(bacfile,os.F_OK)): os.remove( bacfile ) hdbac = pyfits.PrimaryHDU( bac ) hdbac.writeto(bacfile) else: bac = pyfits.getdata(bacfile)
bkg_obj_fits = dirout + 'Bkg_' + nama + '.fits' obj_fits_simple = dirout + nama + '.spec.simple.fits.S' if ( os.access(obj_fits,os.F_OK) == False ) or \ ( os.access(obj_fits_simple,os.F_OK) == False ) or \ (force_sci_extract): print "\t\tNo previous extraction or extraction forced for science file", obj, "extracting..." dat = pyfits.getdata(obj).astype('float') dat -= MasterBias if len(MasDarl) > 0 and dark_corr: dat -= pucherosutils.get_dark(MasDarl, hd['EXPTIME']) dat = dat.T drift, c_new = GLOBALutils.get_drift(dat, P, c_all, pii=512, win=5) print '\t\ty drift:', drift P_new = GLOBALutils.shift_P(P, drift, c_new, ext_aperture) if back_corr: Centers = np.zeros((len(c_new), dat.shape[1])) for i in range(c_new.shape[0]): Centers[i, :] = scipy.polyval(c_new[i, :], np.arange(len(Centers[i, :]))) bac = GLOBALutils.get_scat(dat, Centers, span=5, allow_neg=True) dat -= bac if not have_flat: P_new = GLOBALutils.obtain_P(dat,c_new,ext_aperture,RON,\ GAIN,NSigma_Marsh, S_Marsh, \