print('plotting selected spectra')
    ccd = 1
    spec_pkl = [
        'galah_dr53_ccd1_4710_4910_wvlstep_0.040_ext4_20190801.pkl', '',
        'galah_dr53_ccd3_6475_6745_wvlstep_0.060_ext4_20190801.pkl', ''
    ][ccd - 1]
    ann_pkl = spec_pkl[:-4] + '_ann_median.pkl'
    plot_wvl = [HBETA_WVL, 0, HALPHA_WVL, 0][ccd - 1]
    wvl_plot_span = [20, 25, 30, 35][ccd - 1]

    print(' read 1')
    obs_spec = read_pkl_spectra(out_dir + spec_pkl)
    print(' read 2')
    ann_spec = read_pkl_spectra(out_dir + ann_pkl)
    print(' read done')
    wvl_spec = CollectionParameters(spec_pkl).get_wvl_values()

    # plotting repeats spectra
    plot_s_ids = [
        [
            140308000101142, 161213002601381, 161219002101381, 171206002101381,
            171207002101381
        ],
        [161209001801307, 170904002101301, 171206002601307],
        [150427002801012, 150427004801012, 150606003901012],
        [151230002201218, 171206004101218, 171208003601218],
        #[140823000401145, 140823000901144, 140823001401145, 140823001801144, 140824002501145, 140824003001144, 140824003501145, 140824003901144]
    ]

    fig, ax = plt.subplots(1, len(plot_s_ids), figsize=(14., 5), sharey=True)
    for i_ax, s_ids in enumerate(plot_s_ids):
Example #2
0
# determine unique numbers of observation field
observation_fields = np.int64(galah_param['sobject_id'] / 1000.)
all_observation_fields = np.unique(observation_fields)

selected_observation_fields = all_observation_fields
get_fields = len(selected_observation_fields)

C_LIGHT = 299792458  # m/s

wvl_min = 6479
wvl_max = 6520

print 'Reading resampled GALAH spectra'
spectra_file_csv = 'galah_dr52_ccd3_6475_6745_interpolated_wvlstep_0.06_spline_observed.csv'
# parse resampling settings from filename
csv_param = CollectionParameters(spectra_file_csv)
ccd = csv_param.get_ccd()
wvl_start, wvl_end = csv_param.get_wvl_range()
wvl_values = csv_param.get_wvl_values()

# determine the data range to be read and read it
idx_read = np.where(np.logical_and(wvl_values > wvl_min, wvl_values < wvl_max))
# alternative and much faster way
spectral_data = pd.read_csv(galah_data_dir + spectra_file_csv,
                            sep=',',
                            header=None,
                            na_values='nan',
                            usecols=idx_read[0]).values
spectal_data_size = np.shape(spectral_data)
print spectal_data_size
wvl_read = wvl_values[idx_read]
all_observation_fields = np.unique(observation_fields)

selected_observation_fields = all_observation_fields
get_fields = len(selected_observation_fields)

C_LIGHT = 299792458  # m/s

wvl_min = 6500
wvl_max = 6550

shift_for_barycentric = True

print 'Reading resampled GALAH spectra'
spectra_file_csv_obs = 'galah_dr52_ccd3_6475_6745_wvlstep_0.03_lin_RF_renorm.csv'
# parse resampling settings from filename
csv_param = CollectionParameters(spectra_file_csv_obs)
ccd = csv_param.get_ccd()
wvl_start, wvl_end = csv_param.get_wvl_range()
wvl_values = csv_param.get_wvl_values()

# determine the data range to be read and read it
idx_read = np.where(np.logical_and(wvl_values > wvl_min, wvl_values < wvl_max))
spectral_data = pd.read_csv(galah_data_dir + spectra_file_csv_obs,
                            sep=',',
                            header=None,
                            na_values='nan',
                            usecols=idx_read[0]).values
spectral_data_size = np.shape(spectral_data)
print spectral_data_size
wvl_read = wvl_values[idx_read]
wvl_read_finer = np.arange(wvl_min, wvl_max, csv_param.get_wvl_step() / 3)
txt_out_wvl3 = 'report_wavelengths_ccd3.csv'
txt_out_spectra1 = 'residuum_spectra_ccd1.csv'
txt_out_spectra3 = 'residuum_spectra_ccd3.csv'

print 'Reading data sets'
galah_data_dir = '/home/klemen/GALAH_data/'
galah_template_dir = '/home/klemen/GALAH_data/Spectra_template/'
galah_grid_dir_ccd1 = '/home/klemen/GALAH_data/Spectra_template_grid/galah_dr52_ccd1_4710_4910_wvlstep_0.02_lin_RF/Teff_300_logg_0.50_feh_0.20_snr_20_medianshift_std_3.0_redflag/'
galah_grid_dir_ccd3 = '/home/klemen/GALAH_data/Spectra_template_grid/galah_dr52_ccd3_6475_6745_wvlstep_0.03_lin_RF/Teff_300_logg_0.50_feh_0.20_snr_40_medianshift_std_3.0_redflag/'
galah_param = Table.read(galah_data_dir + 'sobject_iraf_52_reduced.fits')

spectra_file_ccd1 = 'galah_dr52_ccd1_4710_4910_wvlstep_0.04_lin_RF.pkl'
spectra_file_ccd3 = 'galah_dr52_ccd3_6475_6745_wvlstep_0.06_lin_RF.pkl'
template_file_ccd3 = ''
# parse resampling settings from filename
csv_param_ccd1 = CollectionParameters(spectra_file_ccd1)
wvl_values_ccd1 = csv_param_ccd1.get_wvl_values()
csv_param_ccd3 = CollectionParameters(spectra_file_ccd3)
wvl_values_ccd3 = csv_param_ccd3.get_wvl_values()

# change to output directory
out_dir = 'H_flux_template_grid_alpha_beta_complete'
ch_dir(out_dir)

# object selection criteria
# must be a giant - objects are further away than dwarfs
print 'Number of all objects: ' + str(len(galah_param))
if not RESUME_PROCESSING:
    # OLD definition of giant
    # idx_object_use = galah_param['logg_guess'] < 3.5
    # NEW definition of giants
n_spectra_selection_max = 150
median_correction = True
spectra_filtering = True
spectra_filtering_std = 2.5
plot_graphs = False
plot_include_all_spectra = False

print 'Reading data sets'
galah_data_input = '/home/klemen/GALAH_data/'
galah_data_output = '/home/klemen/GALAH_data/'
galah_param = Table.read(galah_data_input+'sobject_iraf_52_reduced.csv')

spectra_file = 'galah_dr52_ccd3_6475_6745_interpolated_wvlstep_0.06_spline_restframe.csv'

# parse resampling settings from filename
csv_param = CollectionParameters(spectra_file)
wvl_values = csv_param.get_wvl_values()
wvl_limits = csv_param.get_wvl_range()
ccd_number = int(csv_param.get_ccd())

# determine csv outputs
suffix = '_teff_{:.0f}_logg_{:1.2f}_feh_{:1.2f}'.format(TEFF_SPAN, LOGG_SPAN, FEH_SPAN)
if snr_limits:
    suffix += '_snr_{:3.0f}'.format(snr_limits[ccd_number - 1])
if spectra_selection:
    suffix += '_best_{:3.0f}'.format(n_spectra_selection_max)
if median_correction:
    suffix += '_medianshift'
if spectra_filtering:
    suffix += '_std_{:1.1f}'.format(spectra_filtering_std)
# final output csv file