Пример #1
0
def analyse201_HD156274(reReduce=False):
    """
    astrometric fit
    STS-AT4 rotation test
    """

    files = files_201_HD156274
    print len(files)

    if reReduce:
        for f in files:
            a = prima.drs(os.path.join(data_directory,f))
            a.astrometryFtk(writeOut=True, max_GD_um = 2.0,
                            overwrite=True, max_err_um=10, sigma_clipping=5.0)
            del a
    
    selection = range(len(files)) # ALL files
    selection = filter(lambda x: x!=17, selection) # 17 has A-B overflow
    selection = filter(lambda x: x!=1, selection) # 17 has A-B overflow
    selection = filter(lambda x: x!=21, selection) # 17 has A-B overflow
    #selection = [0,1,2,3,4,5,6,7,8,9,19,20,21] # normal
    #selection = [0,1,5,9,19,20,21] # normal, no rotation
    #selection = [10,11,12,13,14,15,16,18, 22, 23] # swapped, 17 has A-B overflow
    #selection = [10,18,22,23] # swapped, no rotation
    #selection = [0,1,5,9,19,20,21,10,18,22,23]
    astrom.interpListOfFiles(files, data_directory,
                             plot=True,
                             fit_param  =[1, 1, 1,      0,0,0],
                             first_guess=[10.08,258.02,5.15523,0,0,0],
                             fit_only_files=selection,
                             maxResiduals=35)
    return
    at4 = prima.pssRecorder('/Volumes/DATA/PRIMA/COMM15/pssRecorder/pssguiRecorder_lat4fsm_2011-07-19_23-49-45.dat')
    at3 = prima.pssRecorder('/Volumes/DATA/PRIMA/COMM15/pssRecorder/pssguiRecorder_lat3fsm_2011-07-19_23-49-45.dat')
    pyplot.figure(1)
    pyplot.clf()
    pyplot.plot(at4.mjd[::10], at4.data['Dermec.[deg]'][::10],
                color='orange', linewidth=5, label='AT4 derot', alpha=0.9)
    pyplot.plot(at3.mjd[::10], at3.data['Dermec.[deg]'][::10],
                linestyle='dashed',
                color='green', linewidth=2, label='AT3 derot')
    pyplot.legend()
    pyplot.xlim(5.5762e4+0.01, 5.5762e4+0.17)
    pyplot.annotate('modulation\ncommand', xy=(5.5762e4+0.025, 108),
                    xycoords='data', size=12,
                    xytext=(5.5762e4+0.04, 120), textcoords='data',
                    arrowprops=dict(arrowstyle="->"))
    pyplot.annotate('tracking\nwrapping', xy=(5.5762e4+0.1, 160),
                    xycoords='data', size=12,
                    xytext=(5.5762e4+0.06, 150), textcoords='data',
                    arrowprops=dict(arrowstyle="->"))
    pyplot.annotate('swapping', xy=(5.5762e4+0.067, 60),
                    xycoords='data', size=12,
                    xytext=(5.5762e4+0.03, 50), textcoords='data',
                    arrowprops=dict(arrowstyle="->"))
    pyplot.xlabel('MJD')
    pyplot.ylabel('mechanical position (degrees)')
                  
    return
Пример #2
0
def FSM_full_test(model=False, AT='AT4'):
    """
    """
    directory = '/Volumes/DATA500/PRIMA/COMM16/'
    ### AT4
    if AT=='AT4' or AT==4:
        AT = 'AT4'; DT = .6/(24*3600)
        #a = prima.drs(directory+'2011-08-29/PACMAN_OBJ_ASTRO_242_0014.fits')
        #p = prima.pssRecorder(directory+'PSSRECORDER/pssguiRecorder_lat4vcm_2011-08-30_09-09-54.dat')
        #f = open(directory+'PIEZOSCAN/pscsosfPiezoScan2_lat4fsm_2011-08-30T09_10_46.txt')
        a = prima.drs(directory+'2011-08-29/PACMAN_OBJ_ASTRO_242_0018.fits')
        p = prima.pssRecorder(directory+'PSSRECORDER/pssguiRecorder_lat4vcm_2011-08-30_09-49-23.dat')
        f = open(directory+'PIEZOSCAN/pscsosfPiezoScan2_lat4fsm_2011-08-30T09_50_11.txt')
        #a = prima.drs(directory+'2011-08-29/PACMAN_OBJ_ASTRO_242_0021.fits')
        #p = prima.pssRecorder(directory+'PSSRECORDER/pssguiRecorder_lat4vcm_2011-08-30_10-24-43.dat')
        #f = open(directory+'PIEZOSCAN/pscsosfPiezoScan2_lat4fsm_2011-08-30T10_25_14.txt')
        #a = prima.drs(directory+'2011-08-29/PACMAN_OBJ_ASTRO_242_0023.fits')
        #p = prima.pssRecorder(directory+'PSSRECORDER/pssguiRecorder_lat4vcm_2011-08-30_10-35-52.dat')
        #f = open(directory+'PIEZOSCAN/pscsosfPiezoScan2_lat4fsm_2011-08-30T10_36_31.txt')
    else:
        ### AT3
        AT = 'AT3'; DT=0.75/(24.*3600)
        #a = prima.drs(directory+'2011-08-29/PACMAN_OBJ_ASTRO_242_0016.fits')
        #p = prima.pssRecorder(directory+'PSSRECORDER/pssguiRecorder_lat3vcm_2011-08-30_09-27-37.dat')
        #f = open(directory+'PIEZOSCAN/pscsosfPiezoScan2_lat3fsm_2011-08-30T09_28_22.txt')
        #a = prima.drs(directory+'2011-08-29/PACMAN_OBJ_ASTRO_242_0020.fits')
        #p = prima.pssRecorder(directory+'PSSRECORDER/pssguiRecorder_lat3vcm_2011-08-30_10-09-40.dat')
        #f = open(directory+'PIEZOSCAN/pscsosfPiezoScan2_lat3fsm_2011-08-30T10_10_09.txt')
        #a = prima.drs(directory+'2011-08-29/PACMAN_OBJ_ASTRO_242_0024.fits')
        #p = prima.pssRecorder(directory+'PSSRECORDER/pssguiRecorder_lat3vcm_2011-08-30_10-41-53.dat')
        #f = open(directory+'PIEZOSCAN/pscsosfPiezoScan2_lat3fsm_2011-08-30T10_43_04.txt')
        #a = prima.drs(directory+'2011-08-29/PACMAN_OBJ_ASTRO_242_0026.fits')
        #p = prima.pssRecorder(directory+'PSSRECORDER/pssguiRecorder_lat3vcm_2011-08-30_10-53-32.dat')
        #f = open(directory+'PIEZOSCAN/pscsosfPiezoScan2_lat3fsm_2011-08-30T10_54_20.txt')
        a = prima.drs(directory+'2011-08-29/PACMAN_OBJ_ASTRO_242_0027.fits')
        p = prima.pssRecorder(directory+'PSSRECORDER/pssguiRecorder_lat3vcm_2011-08-30_11-00-29.dat')
        f = open(directory+'PIEZOSCAN/pscsosfPiezoScan2_lat3fsm_2011-08-30T11_00_58.txt')

    lines = f.readlines()
    f.close()
    lines = filter(lambda x: not '#' in x and len(x)>10, lines)
    mjd =  [astro.tag2mjd('2011-08-30T'+x.split()[1])+DT for x in lines]
    xmjd = np.linspace(min(mjd), max(mjd), 200)

    FSM1X = [float(x.split()[2]) for x in lines]
    FSM1Y = [float(x.split()[3]) for x in lines]
    FSM2X = [float(x.split()[4]) for x in lines]
    FSM2Y = [float(x.split()[5]) for x in lines]

    print 'PCR START:', a.raw[0].header['ESO PCR ACQ START']
    print 'PCR END  :', a.raw[0].header['ESO PCR ACQ END']

    min_mjd = min(mjd)
    max_mjd = max(mjd)
    if model:
        param = np.array([0,0,.1,.1,.1,.1])
        mjd_primet =  1e-6*a.raw['METROLOGY_DATA'].data.field('TIME')/\
                   (24*3600)+astro.tag2mjd(a.raw[0].header['ESO PCR ACQ START'])
        primet =  (a.raw['METROLOGY_DATA'].data.field('DELTAL')-
                   a.raw['METROLOGY_DATA'].data.field('DELTAL').mean())*1e6
        print 'w_fit:'
        w_fit = np.where((mjd_primet>min_mjd)*(mjd_primet<max_mjd))
        #w_fit = np.where((mjd_primet>min_mjd))
        w_fit = (w_fit[0][::200],)
        print 'x_fit:'
        X_fit = [mjd_primet[w_fit]-mjd_primet[w_fit].mean(),
                 interpByStep(mjd_primet[w_fit], mjd, np.array(FSM1X)-FSM1X[0]),
                 interpByStep(mjd_primet[w_fit], mjd, np.array(FSM1Y)-FSM1Y[0]),
                 interpByStep(mjd_primet[w_fit], mjd, np.array(FSM2X)-FSM2X[0]),
                 interpByStep(mjd_primet[w_fit], mjd, np.array(FSM2Y)-FSM2Y[0])]
        Y_fit = primet[w_fit]
        print 'fit:'
        fit = myfit.fit(primetFsmBias, X_fit, param, Y_fit)
        fit.leastsqfit()
        print 'dOPD_um/(FSM1X_um - %5.3f) = %6.4f' %\
              (FSM1X[0], fit.leastsq_best_param[2])
        print 'dOPD_um/(FSM1Y_um - %5.3f) = %6.4f' %\
              (FSM1Y[0], fit.leastsq_best_param[3])
        print 'dOPD_um/(FSM2X_um - %5.3f) = %6.4f' %\
              (FSM2X[0], fit.leastsq_best_param[4])
        print 'dOPD_um/(FSM2Y_um - %5.3f) = %6.4f' %\
              (FSM2Y[0], fit.leastsq_best_param[5])

        pylab.figure(4, figsize=(17,3))
        pylab.clf()
        pylab.subplots_adjust(left=0.06, bottom=0.15, right=0.96, top=0.85,
                              wspace=0.15, hspace=0.01)
        pylab.title(AT+' FSM test:'+a.filename)
        pylab.plot(mjd_primet,  primet, 'b-', label='PRIMET A-B')
        pylab.plot(mjd_primet[w_fit[0]],
                   primetFsmBias(X_fit,fit.leastsq_best_param),
                   'r-', alpha=0.5, linewidth=3, label='linear model FSM')
        pylab.plot(mjd_primet[w_fit[0]],
                   Y_fit-primetFsmBias(X_fit,fit.leastsq_best_param),
                   '-', color='g', alpha=0.5, linewidth=3, label='residuals')
        pylab.hlines([0], min(mjd), max(mjd), color='k', linestyle='dashed',
                     linewidth=2)
        pylab.legend(ncol=3, loc=('upper left' if AT=='AT4' else 'upper right'))
        pylab.xlim(min_mjd, max_mjd)
        pylab.ylabel('PRIMET A-B ($\mu$m)')

    pylab.figure(3, figsize=(17,9))
    pylab.subplots_adjust(left=0.06, bottom=0.07, right=0.96, top=0.96,
                          wspace=0.15, hspace=0.01)
    pylab.clf()

    ax1 = pylab.subplot(5,2,1)
    pylab.title(AT+' FSM test:'+a.filename)
    pylab.plot(1e-6*a.raw['METROLOGY_DATA'].data.field('TIME')/(24*3600)+
               astro.tag2mjd(a.raw[0].header['ESO PCR ACQ START']),
               (a.raw['METROLOGY_DATA'].data.field('DELTAL')-
                a.raw['METROLOGY_DATA'].data.field('DELTAL').mean())*1e6,
               'b-')
    pylab.ylabel('PRIMET A-B ($\mu$m)')

    pylab.subplot(5,2,3, sharex=ax1)
    #pylab.plot(mjd, FSM1X, '-k', markersize=8, linestyle='steps')
    pylab.plot(xmjd, interpByStep(xmjd, mjd, FSM1X), 'k-')
    pylab.ylabel('FSM1 X ($\mu$m)')

    pylab.subplot(5,2,5, sharex=ax1)
    #pylab.plot(mjd, FSM1Y, '-k', markersize=8, linestyle='steps')
    pylab.plot(xmjd, interpByStep(xmjd, mjd, FSM1Y), 'k-')
    pylab.ylabel('FSM1 Y ($\mu$m)')

    pylab.subplot(5,2,7, sharex=ax1)
    #pylab.plot(mjd, FSM2X, '-k', markersize=8, linestyle='steps')
    pylab.plot(xmjd, interpByStep(xmjd, mjd, FSM2X), 'k-')
    pylab.ylabel('FSM2 X ($\mu$m)')

    pylab.subplot(5,2,9, sharex=ax1)
    #pylab.plot(mjd, FSM2Y, '-k', markersize=8, linestyle='steps')
    pylab.plot(xmjd, interpByStep(xmjd, mjd, FSM2Y), 'k-')
    pylab.ylabel('FSM2 Y ($\mu$m)')
    pylab.xlabel('MJD')

    pylab.subplot(5,2,2, sharex = ax1, sharey= ax1)
    pylab.title(AT+' FSM test:'+a.filename)
    pylab.plot(1e-6*a.raw['METROLOGY_DATA'].data.field('TIME')/(24*3600)+
               astro.tag2mjd(a.raw[0].header['ESO PCR ACQ START']),
               (a.raw['METROLOGY_DATA'].data.field('DELTAL')-
                a.raw['METROLOGY_DATA'].data.field('DELTAL').mean())*1e6,
               'b-')

    pylab.subplot(5,2,4, sharex=ax1)
    pylab.plot(p.mjd, p.data['VCM1X[um]'], '-k')
    pylab.ylabel('VCM1 X ($\mu$m)')

    pylab.subplot(5,2,6, sharex=ax1)
    pylab.plot(p.mjd, p.data['VCM1Y[um]'], '-k')
    pylab.ylabel('VCM1 Y ($\mu$m)')

    pylab.subplot(5,2,8, sharex=ax1)
    pylab.plot(p.mjd, p.data['VCM2X[um]'], '-k')
    pylab.ylabel('VCM2 X ($\mu$m)')

    pylab.subplot(5,2,10, sharex=ax1)
    pylab.plot(p.mjd, p.data['VCM2Y[um]'], '-k')
    pylab.ylabel('VCM2 Y ($\mu$m)')
    pylab.xlim(min_mjd, max_mjd)
    del a

    return