astrometry - Astrometry routines

Astrometry routine

Module to add astrometry to HETDEX catalgoues and images Contains python translation of Karl Gebhardt

vdrp.astrometry.add_ifu_xy(wdir, offset_exposure_indices)[source]

Adds IFU x y information to stars used for matching, and save to xy_expNN.dat. Requires: getoff.out, radec2.dat Analogous to rastrom3.

Parameters:
wdir : str

Work directory.

offset_exposure_indices : list

List of exposure indices to consider.

vdrp.astrometry.add_ra_dec(wdir, als_data, ra, dec, pa, fp, radec_outfile='tmp.csv')[source]

Call add_ra_dec to compute for detections in IFU space the corresponding RA/DEC coordinates.

New version, direct python call to pyheted.coordinates.tangent_projection.

Requires, fplane.txt Creates primarely EXPOSURE_tmp.csv but also radec.dat.

Parameters:
wdir : str

Work directory.

als_data : dict

Dictionary with als data for each IFU slot.

ra : float

Focal plane center RA.

dec : float

Focal plane center Dec.

pa : float

Positions angle.

fp : FPlane

Focal plane object.

radec_outfile : str

Filename that will contain output from add_ra_dec (gets overwritten!).

vdrp.astrometry.combine_radec(wdir, dither_offsets, PLOT=True)[source]

Computes - based on the RA Dec information of the individual exposures (from radec2_exp0?.dat) the final RA/Dec for the shot.

Parameters:
wdir : str

Work directory.

Notes

Creates radec2_final.dat. Optionally create a plot indicating the individual exposure positions.

vdrp.astrometry.compute_offset(wdir, prefixes, getoff2_radii, add_radec_angoff_trial, add_radec_angoff, add_radec_angoff_trial_dir, offset_exposure_indices, final_ang_offset=None, shout_ifustars='shout.ifustars', ra0=None, dec0=None)[source]

Requires, fplane.txt and radec.orig. If not ra, dec are passed explicitly then the values from radec.orig are used. The pa value from radec.orig is used in any case. Creates primarely EXPOSURE_tmp.csv but also radec2.dat.

Compute offset in RA DEC by matching detected stars in IFUs against the shuffle profived RA DEC coordinates.

Parameters:
wdir : str

Work directory.

prefixes : list

List file name prefixes for the collapsed IFU images.

getoff2_radii : list

List of matching radii for astrometric offset measurement.

add_radec_angoff_trial : list

Trial values for angular offsets.

add_radec_angoff : float

Angular offset to add during conversion of x/y coordinate to RA/Dec.

add_radec_angoff_trial_dir : str

Directory to save results of angular offset trials.

offset_exposure_indices : list

Exposure indices.

final_ang_offset : float

Final angular offset to use. This overwrites the values in add_radec_angoff and add_radec_angoff_trial

shout_ifustars : str

Shuffle output catalog of IFU stars.

ra0 : float

Optionally allows to overwrite use of RA from radec.orig

dec0 : float

Optionally allows to overwrite use of DEC from radec.orig

Notes

Analogous to rastrom3. Creates radec.dat, radec2.dat and radec_TRIAL_OFFSET_ANGLE.dat, radec_TRIAL_OFFSET_ANGLE2.dat.

vdrp.astrometry.compute_optimal_ang_off(wdir, smoothing=0.05, PLOT=True)[source]

Computes the optimal angular offset angle by findin the minimal RMS of a set of different trial angles.

Takes (if exist) all three different exposures into account and computes weighted average ange (weighted by number of stars that went into the fit).

The RMS(ang_off) are interpolate with a smoothing spline. The smoothing value is a parameter to this function.

Parameters:
wdir : str

Directory that holds the angular offset trials (e.g. 20180611v017/add_radec_angoff_trial)

Returns:
float : Optimal offset angle.
vdrp.astrometry.cp_addin_files(wdir, addin_dir, subdir='coords')[source]

Copies addin files. These are essentially the IFUcen files in a different format.

Parameters:
addin_dir : str

Directory where the *.addin files are stored.

wdir : str

Work directory.

vdrp.astrometry.cp_ixy_files(wdir, ixy_dir, subdir='coords')[source]

Copies ixy files. These are essentially the IFUcen files in a different format.

Parameters:
ixy_dir_dir :str

Directory where the *.ixy files are stored.

wdir : str

Work directory.

vdrp.astrometry.cp_post_stamps(wdir, reduction_dir, night, shotid)[source]

Copy CoFeS (collapsed IFU images).

Parameters:
wdir : str

Work directory.

reduction_dir : str

Directory that holds panacea reductions.

night : str

Night (e.g. 20180611)

shotid : str

ID of shot (e.g. 017)

Raises:
Exception
vdrp.astrometry.cp_results(tmp_dir, results_dir)[source]

Copies all relevant result files from tmp_dir results_dir.

Parameters:
tmp_dir : str

Temporary work directory.

results_dir : str

Final directory for results.

vdrp.astrometry.daophot_find(wdir, prefixes, daophot_opt, daophot_sigma, daophot_xmin, daophot_xmax, daophot_ymin, daophot_ymix)[source]

Run initial daophot find.

Parameters:
wdir : str

Work directory.

prefixes : list

List file name prefixes for the collapsed IFU images.

daophot_opt : str

Daphot sigma value.

daophot_sigma : float

Filename for daophot configuration.

daophot_xmin : float

X limit for daophot detections.

daophot_xmax : float

X limit for daophot detections.

daophot_ymin : float

Y limit for daophot detections.

daophot_ymix : float

Y limit for daophot detections.

vdrp.astrometry.daophot_phot_and_allstar(wdir, prefixes, daophot_photo_opt, daophot_allstar_opt, daophot_phot_psf)[source]

Runs daophot photo and allstar on all IFU postage stamps. Produces *.ap and *.als files. Analogous to run4a.

Parameters:
wdir : str

Work directory.

prefixes : list

List file name prefixes for the collapsed IFU images.

daophot_opt : str

Filename for daophot configuration.

daophot_photo_opt : str

Filename for daophot photo task configuration.

daophot_allstar_opt : str

Filename for daophot allstar task configuration.

vdrp.astrometry.flux_norm(wdir, mag_max, infile='all.raw', outfile='norm.dat')[source]

Reads all.raw and compute relative flux normalisation for the three exposures.

Parameters:
wdir : str

Work directory.

mag_max : float

Magnitude limit for flux normalisation.

infile : str

Output file of daomaster.

outfile : str

Filename for result file.

Notes

Analogous to run9.

vdrp.astrometry.getDefaults()[source]
vdrp.astrometry.getNorm(all_raw, mag_max)[source]

Comutes the actual normalisation for flux_norm.

Parameters:
all_raw : str

Output file name of daomaster, usuall all.raw.

mag_max : float

Magnitude cutoff for normalisation. Fainter objects will be ignored.

Notes

Analogous to run9.

vdrp.astrometry.get_active_slots(wdir, reduction_dir, exposures, night, shotid)[source]

Figures out which IFU slots actually delivered data, by checking if a corresponding multifits exists for all exposures in a shot.

vdrp.astrometry.get_als_files(fp, exp_prefixes)[source]

Derives for a list of exposure prefixes a list of *.als files, but rejects any that refer to an IFU slot which is not contained in the fplane.

Parameters:
fp : pyhetdex.het.fplane.FPlane

Fplane object.

exp_prefixes : list

List of epxosure prefixes.

Returns:
(list): List of *.als files.
vdrp.astrometry.get_exposures(prefixes)[source]

Computes unique list of exposures from prefixes.

Parameters:
args : argparse.Namespace

Parsed configuration parameters.

prefixes : list

List file name prefixes for the collapsed IFU images

Returns:
(list): Unique list of exposure strings.
vdrp.astrometry.get_exposures_files(basedir)[source]

Create list of all file prefixes based on the existing collapsed IFU files in the current directory.

From files:

20180611T054545_015.fits … 20180611T054545_106.fits 20180611T055249_015.fits … 20180611T055249_106.fits 20180611T060006_015.fits … 20180611T060006_106.fits

Creates:

{
‘exp01’ : [‘20180611T054545_015’,…,‘20180611T054545_106’] ‘exp02’ : [‘20180611T055249_015’,…,‘20180611T055249_106’] ‘exp03’ : [‘20180611T060006_015’,…,‘20180611T060006_106’]

}

Parameters:
basedir : str

Directory to search.

Returns:
OrderedDict : Ordered dictionary with pairs of exposure

string “exp??” and time and list of

vdrp.astrometry.get_fiber_coords(wdir, active_slots, dither_offsets, subdir='coords')[source]

Calls add_ra_dec for all IFU slots and all dithers.

The is the main routine for getcoord which computes the on-sky positions for all fibers.

Essentially this is a whole bunch of calls like.:

add_ra_dec –ftype line_detect –astrometry 262.496605 33.194212 262.975922
–fplane /work/00115/gebhardt/maverick/sci/panacea/shifts/fplane.txt –ihmps 015 –fout i015_1.csv –dx 0 –dy 0 015.addin

… add_ra_dec –ftype line_detect –astrometry 262.496605 33.194212 262.975922

–fplane /work/00115/gebhardt/maverick/sci/panacea/shifts/fplane.txt –ihmps 015 –fout i015_2.csv –dy 1.27 –dx -0.73 015.addin

… add_ra_dec –ftype line_detect –astrometry 262.496605 33.194212 262.975922

–fplane /work/00115/gebhardt/maverick/sci/panacea/shifts/fplane.txt –ihmps 015 –fout i015_3.csv –dy 1.27 –dx 0.73 015.addin
Parameters:
wdir : str

Work directory.

Notes

This creates a list of files iIFUSLOT_DITHERNUM.csv that store the on-sky fiber coordinates.

vdrp.astrometry.get_prefixes(wdir)[source]

Create list of all file prefixes based on the existing collapsed IFU files in the current directory.

Parameters:
wdir : str

Work directory.

vdrp.astrometry.get_ra_dec_orig(wdir, reduction_dir, night, shotid, user_pa=-999999.0)[source]

Reads first of the many multi* file’d headers to get the RA, DEC, PA guess from the telescope.

Parameters:
wdir : str

Work directory.

reduction_dir : str

Directory that holds panacea reductions.

night : str

Night (e.g. 20180611)

shotid : str

ID of shot (e.g. 017)

Notes

Creates radec.orig

vdrp.astrometry.get_track(wdir, reduction_dir, night, shotid)[source]

Reads first of the many multi* file’d headers to get the track.

Parameters:
wdir : str

Work directory.

reduction_dir : str

Directory that holds panacea reductions.

night : str

Night (e.g. 20180611)

shotid : str

ID of shot (e.g. 017)

Returns
——

(int): 0 = east track, 1 = west track

Notes

This function is so emparrisingly similar to get_ra_dec_orig that they should probably be combined.

vdrp.astrometry.load_als_data(als_files)[source]

Load set of als files.

Parameters:
als_files : list

List of file names.

Returns
——

(OrderedDict): Dictionary with als data for each IFU slot.

vdrp.astrometry.main(args)[source]

Main function.

vdrp.astrometry.mk_dithall(wdir, active_slots, reduction_dir, night, shotid, subdir='.')[source]

This creates the dithall.use file that is required by the downstream processing functions like photometry and detect.

The file dithall.use contains for every exposure (1-3) and every fiber the RA/Dec on sky coordinats and the multifits file where the spectrum is stored and the fiber number.

vdrp.astrometry.mk_match_matrix(wdir, ax, exp, image_files, fplane_file, shout_ifu_file, xy_file, radec_file)[source]

Creates the actual match plot for a specific exposures. This is a subroutine to mk_match_plots.

Parameters:
wdir : str

Work directory.

prefixes : list

List file name prefixes for the collapsed IFU images.

ax : pyplot.axes

Axes object to plot into.

exp : str

Exposure string (e.g. exp01)

image_files : list

List of file names.

fplane_file : str

Focal plane file filename.

shout_ifu_file : str

Shuffle IFU star catalog output filename.

xy_file : str

Filename for list of matched stars, aka xy_exp??.dat.

radec_file : str

File that contains shot ra dec position.

vdrp.astrometry.mk_match_plots(wdir, prefixes)[source]

Creates match plots.

Parameters:
wdir : str

Work directory.

prefixes : list

List file name prefixes for the collapsed IFU images.

vdrp.astrometry.mk_post_stamp_matrix(wdir, prefixes, cofes_vis_vmin, cofes_vis_vmax)[source]

Create the IFU postage stamp matrix image.

Parameters:
wdir : str

Work directory.

prefixes : list

List file name prefixes for the collapsed IFU images.

cofes_vis_vmin : float

Minimum value (= black) for matrix overview plot.

cofes_vis_vmax : float

Maximum value (= black) for matrix overview plot.

vdrp.astrometry.mkmosaic(wdir, prefixes, night, shotid, mkmosaic_angoff)[source]

Creates mosaic fits image.

Parameters:
wdir : str

Work directory.

prefixes : list

List file name prefixes for the collapsed IFU images.

night : str

Night (e.g. 20180611)

shotid : str

ID of shot (e.g. 017)

mkmosaic_angoff : float

Angular offset to add for creation of mosaic image.

vdrp.astrometry.mktot(wdir, prefixes, mktot_ifu_grid, mktot_magmin, mktot_magmax, mktot_xmin, mktot_xmax, mktot_ymin, mktot_ymax, dither_offsets)[source]

Reads all *.als files. Put detections on a grid corresponding to the IFU position in the focal plane as defined in config/ifu_grid.txt (should later become fplane.txt. Then produces all.mch.

Parameters:
wdir : str

Work directory.

prefixes : list

List file name prefixes for the collapsed IFU images.

mktot_ifu_grid : str

Name of file that holds gird of IFUs offset fit (mktot).

mktot_magmin : float

Magnitude limit for offset fit.

mktot_magmax : float

Magnitude limit for offset fit.

mktot_xmin : float

X limit for offset fit.

mktot_xmax : float

X limit for offset fit.

mktot_ymin : float

Y limit for offset fit.

mktot_ymax : float

Y limit for offset fit.

Notes

Analogous to run6 and run6b.

vdrp.astrometry.parseArgs(args)[source]

Parses configuration file and command line arguments. Command line arguments overwrite configuration file settiongs which in turn overwrite default values.

Parameters:
args : argparse.Namespace

Return the populated namespace.

vdrp.astrometry.project_xy(wdir, radec_file, fplane_file, ra, dec)[source]

Translate all catalog stars to x/y to display then and to see which ones got matched. Call pyhetdex tangent_plane’s functionality to project ra,dec to x,y.

Parameters:
wdir : str

Work directory.

radec_file : str

File that contains shot ra dec position.

fplane_file : str

Focal plane file filename.

ra : list

List of ra positions (in float, degree).

dec : list

List of dec positions (in float, degree).

vdrp.astrometry.redo_shuffle(wdir, ra, dec, track, acam_magadd, wfs1_magadd, wfs2_magadd, shuffle_cfg, fplane_txt, night, catalog=None)[source]

Reruns shuffle to obtain catalog of IFU stars.

Creates a number of output files, most importantly shout.ifustars which is used as catalog for the offset computation.

Parameters:
wdir : str

Work directory.

ra : float

Right ascension in degrees.

dec : float

Declination in degrees.

track : int

East or west track (0, 1)

acam_magadd : float

do_shuffle acam magadd.

wfs1_magadd : float

do_shuffle wfs1 magadd.

wfs2_magadd : float

do_shuffle wfs2 magadd.

vdrp.astrometry.rmaster(wdir)[source]

Executes daomaster. This registers the sets of detections for the thre different exposrues with respec to each other.

Parameters:
wdir : str

Work directory.

Notes

Analogous to run8b.

vdrp.astrometry.run()[source]