Exemple #1
0
allframe.expect("Good bye", timeout=6000)
allframe.close()
print allframe.isalive()

print "ALLFRAME complete"

## Begin calibration process

## Aperture correction

flux_epoch_1 = target_stem + '_e1_3p6um'

aperture_correction_photometry.apcor_photo(flux_epoch_1)

apcor, sdev_apcor, period = calculate_aperture_correction.calc_apcor(
    flux_epoch_1, 'apcor.raw', 2.0, cat_target, cat_name)

apply_aperture_correction.apply_apcor(target_stem + '_e1_3p6um_dn.alf', apcor,
                                      1)

## Calibrate all other epochs
calibrate_all_epochs.calibrate(target_stem + '_3p6um.mch')

## location correction
all_location_corrections.location_corr(target_stem + '_3p6um.mch')

print "Calibration complete"

print "Individual epochs are in " + target_stem + "_epoch_3p6um_dn.cal files"
print "Matched file is " + target_stem + '_3p6um.cal'
print "ALLFRAME complete"

## Begin calibration process

## Aperture correction

flux_epoch_1 = target_stem + '_e1_3p6um'

aperture_correction_photometry.apcor_photo(flux_epoch_1)

cat_name = 'globular'

apcor, sdev_apcor = calculate_aperture_correction_testing.calc_apcor(flux_epoch_1, 'apcor.raw', 2.0, target_stem)

apply_aperture_correction.apply_apcor(target_stem + '_e1_3p6um_dn.alf', apcor, 1)

## Calibrate all other epochs
calibrate_all_epochs.calibrate(target_stem + '_3p6um.mch')

## location correction
all_location_corrections.location_corr(target_stem + '_3p6um.mch')

print "Calibration complete"

print "Individual epochs are in " + target_stem + "_epoch_3p6um_dn.cal files"
print "Matched file is " + target_stem + '_3p6um.cal'



Exemple #3
0
def calibrate_and_plot(row):

    directory_switcher(row, 0)
    survey_ident = row['survey_ident']
    ra = row['ra']
    dec = row['dec']
    period = row['period']
    target_name = row['target_name']

    channel = 1  ### hardwired to channel 1 here
    if (channel == 1 or channel == '3p6um' or channel == '1'):
        new_chan = '3p6um'
    elif (channel == 2 or channel == '4p5um' or channel == '2'):
        new_chan = '4p5um'
    else:
        print 'invalid channel'
        exit(1)

    if new_chan == '3p6um': num_chan = 1
    if new_chan == '4p5um': num_chan = 2
    target_stem = sgr_setup.get_target_stem(survey_ident)
    dir_name = re.sub('\.', '_', survey_ident)
    dir_name = re.sub('-', '', dir_name)
    directory = '/Users/vs522/Dropbox/TRACCS/TRACCS_Output/' + dir_name + '/' + dir_name + '_' + new_chan
    os.chdir(directory)
    if (len(glob.glob(target_stem + '*' + new_chan + '*.alf')) == 0):
        print 'You need to run ALLFRAME before you can calibrate the photometry'
        print 'This is the CALIBRATION ONLY script'
        print 'Run ``globular_pipeline_anychannel.py`` to do the combined photometry and calibration script'
        exit(1)
    flux_epoch_1 = target_stem + '_e1_' + new_chan
    aperture_correction_photometry.apcor_photo(flux_epoch_1)
    apcor, sdev_apcor = calculate_aperture_correction_testing.calc_apcor(
        flux_epoch_1, 'apcor.raw', 3, target_stem, 0.3)
    apply_aperture_correction.apply_apcor(
        target_stem + '_e1_' + new_chan + '_dn.alf', apcor, num_chan)
    calibrate_all_epochs.calibrate(target_stem + '_' + new_chan + '.mch')
    all_location_corrections.location_corr(target_stem, new_chan)
    robust_offset_calculator(row)

    #make_rrl_finder_chart(target_stem, ra, dec)

    mch_file = target_stem + '_3p6um_cal.mch'
    phot_file = target_stem + '_3p6um.cal'

    make_rrl_finder_chart(survey_ident, ra, dec)

    mag, err = find_which_star(target_stem, ra, dec)
    mjds = grab_mjds(mch_file)

    #plot_a_lc(target_stem, target_name, period, mjds, mag, err)

    #mosaic.save(target_stem + '_location.pdf')

    offsets_df = pd.read_csv(target_stem + '_3p6um_cal.off_log',
                             delim_whitespace=True,
                             header=None,
                             names=('obs', 'offset', 'sdev', 'nstars'))

    mp.close()
    mp.clf()
    mp.errorbar(offsets_df.obs,
                offsets_df.offset,
                yerr=offsets_df.sdev,
                color='k',
                ls='none')
    mp.plot(offsets_df.obs, offsets_df.offset, 'ko', ls='none')
    mp.axhline(offsets_df.offset.mean(), color='r', ls='--')
    mp.axhline(offsets_df.offset.mean() - 2 * offsets_df.offset.std(),
               color='b',
               ls='--')

    mp.show()

    #plot_existing_lc(row, 1, 1.5/12.)
    avmag1, sdev1 = plot_new_lc(row, mjds, mag, err, period, target_name, 1,
                                1.5 / 12.)
    print avmag1, sdev1
    row.av_3p6 = avmag1
    row.sdev_3p6 = sdev1

    return (row)
## Also cleans up old runs

## for omegaCen only - doesn't apply for Sgr stream, orphan stream etc:

## Aperture correction

flux_epoch_1 = target_stem + '_e1_' + new_chan

aperture_correction_photometry.apcor_photo(flux_epoch_1)

cat_name = 'globular'

## The 2.0 on the input here refers to the sigma clipping, not the channel
apcor, sdev_apcor = calculate_aperture_correction_testing.calc_apcor(flux_epoch_1, 'apcor.raw', 2.5, target_stem, 0.3)

apply_aperture_correction.apply_apcor(target_stem + '_e1_' + new_chan + '_dn.alf', apcor, num_chan)

## Calibrate all other epochs
calibrate_all_epochs.calibrate(target_stem + '_' + new_chan + '.mch')


### August 18 - 3:12pm - pipeline works to here. Need to fix location correction now some naming conventions have been changed.

## location correction
all_location_corrections.location_corr(target_stem, new_chan)

print "Calibration complete"

print "Individual epochs are in " + target_stem + "_epoch_' + new_chan + '_dn.cal files"
print "Matched file is " + target_stem + '_' + new_chan + '.cal'
def calibrate_and_plot(row):

	directory_switcher(row, 0)
	survey_ident = row['survey_ident']
	ra = row['ra']
	dec = row['dec']
	period = row['period']
	target_name = row['target_name']
    
	channel = 1 ### hardwired to channel 1 here
	if (channel == 1 or channel == '3p6um' or channel == '1'): new_chan = '3p6um'
	elif (channel == 2 or channel == '4p5um' or channel == '2'): new_chan = '4p5um'
	else: 
		print 'invalid channel'
		exit(1)

	if new_chan == '3p6um': num_chan = 1
	if new_chan == '4p5um': num_chan = 2
	target_stem = sgr_setup.get_target_stem(survey_ident)
	dir_name = re.sub('\.', '_', survey_ident)
	dir_name = re.sub('-', '', dir_name)
	directory = '/Users/vs522/Dropbox/TRACCS/TRACCS_Output/' + dir_name + '/' + dir_name + '_' + new_chan
	os.chdir(directory)
	if (len(glob.glob(target_stem + '*' + new_chan +'*.alf'))==0):
		print 'You need to run ALLFRAME before you can calibrate the photometry'
		print 'This is the CALIBRATION ONLY script'
		print 'Run ``globular_pipeline_anychannel.py`` to do the combined photometry and calibration script'
		exit(1)
	flux_epoch_1 = target_stem + '_e1_' + new_chan
	aperture_correction_photometry.apcor_photo(flux_epoch_1)
	apcor, sdev_apcor = calculate_aperture_correction_testing.calc_apcor(flux_epoch_1, 'apcor.raw', 3, target_stem, 0.3)
	apply_aperture_correction.apply_apcor(target_stem + '_e1_' + new_chan + '_dn.alf', apcor, num_chan)
	calibrate_all_epochs.calibrate(target_stem + '_' + new_chan + '.mch')
	all_location_corrections.location_corr(target_stem, new_chan)
	robust_offset_calculator(row)

    
    #make_rrl_finder_chart(target_stem, ra, dec)

	mch_file = target_stem + '_3p6um_cal.mch'
	phot_file = target_stem + '_3p6um.cal'

	make_rrl_finder_chart(survey_ident, ra, dec)

	mag, err = find_which_star(target_stem, ra, dec)
	mjds = grab_mjds(mch_file)
    
    #plot_a_lc(target_stem, target_name, period, mjds, mag, err)
    
	
	#mosaic.save(target_stem + '_location.pdf')

	offsets_df = pd.read_csv(target_stem + '_3p6um_cal.off_log', delim_whitespace=True, header=None, names=('obs', 'offset', 'sdev', 'nstars'))
	
	mp.close()
	mp.clf()
	mp.errorbar(offsets_df.obs, offsets_df.offset, yerr=offsets_df.sdev, color='k', ls='none')
	mp.plot(offsets_df.obs, offsets_df.offset, 'ko', ls='none')
	mp.axhline(offsets_df.offset.mean(), color='r', ls='--')
	mp.axhline(offsets_df.offset.mean()- 2*offsets_df.offset.std(), color='b', ls='--')

	mp.show()
	
	#plot_existing_lc(row, 1, 1.5/12.)
	avmag1, sdev1 = plot_new_lc(row, mjds, mag, err, period, target_name, 1, 1.5/12.)	
	print avmag1, sdev1
	row.av_3p6 = avmag1
	row.sdev_3p6 = sdev1

	return(row)
print "ALLFRAME complete"

## Begin calibration process

## Aperture correction

flux_epoch_1 = target_stem + '_e1_' + new_chan

aperture_correction_photometry.apcor_photo(flux_epoch_1)

cat_name = 'globular'

## The 2.0 on the input here refers to the sigma clipping, not the channel
apcor, sdev_apcor = calculate_aperture_correction_testing.calc_apcor(flux_epoch_1, 'apcor.raw', 2.0, target_stem)

apply_aperture_correction.apply_apcor(target_stem + '_e1_' + new_chan + '_dn.alf', apcor, num_chan)

## Calibrate all other epochs
calibrate_all_epochs.calibrate(target_stem + '_' + new_chan + '.mch')

## location correction
all_location_corrections.location_corr(target_stem, new_chan)

print "Calibration complete"

print "Individual epochs are in " + target_stem + "_epoch_' + new_chan + '_dn.cal files"
print "Matched file is " + target_stem + '_' + new_chan + '.cal'