Previous: Visibilities
List of Procedures written at MPIA
(This can also be found in the file README.HD in the MIA directory)
SOME UTILITIES
--------------
make_midi_log.pro
-----------------
IDL-routine by Olivier to print an overview of the parameters of the
data-files in a directory.
USAGE (in IDL):
make_midi_log, '/disk-c/mididata/2003-02-23'
The name of the logbook can be given via the LOGBOOK-parameter, e.g.
make_midi_log, '/disk-c/mididata/2003-02-23', LOGBOOK='important.log'
=============================================================================
plot_visibility
---------------
Plots the visibility as returned by xmidispvisi (see below).
USAGE:
plot_visibility, vis1, vis2, ...
Up to five visibilities can be given. It also accepts all the
keywords of IDL's plot-command, in particular YRANGE.
=============================================================================
atv.pro
-------
IDL-routine for looking at images (some kind of saoimage-clone written
in IDL). Written by someone at Caltech, its homepage is
http://www.astro.caltech.edu/~barth/atv/
Basic Usage:
atv, Fits-file-name
or
atv, IDL-array
For more options, read ews/software/EWS/idl/ews/midi/heidelberg/atv.pro
=============================================================================
mtv.pro
-------
Little IDL-routine that puts MIDI-windows together into one array and
calls atv with that array. It knows about sci-phot data, but I'm not
sure if the layout of the four windows makes sense.
USAGE:
data = oirgetmeanrms(filename)
mtv, data[1]
All the flags known by atv can also be used with mtv.
If data contains two data-tags (data1 and data2), they are displayed
side by side, data1 to the left and data2 to the right.
If data contains four data-tags (data1, -2, -3, and -4), the layout is
this:
+-----------+
|data1 data2|
| |
|data3 data4|
+-----------+
If the number of data-tags is not two or four, you are in trouble.
=============================================================================
The Name-utilities
------------------
str = MIDIname_date(filename) returns the date part of a MIDI filename
str = MIDIname_time(filename) returns the time part of a MIDI filename
str = MIDIname_datime(filename) returns the date and time part
=============================================================================
chop_nod_phot.pro
-----------------
IDL-routine by Olivier to measure photometry on chopping or nodding data.
Usage for chopping data: chop_nod_phot, files
Usage for nodding data: chop_nod_phot, files_on_star, files_on_sky
The "files" should be like the result of gorgonzola, i.e. strings with
space-separated names of all the files belonging to one dataset.
As a result, the routine creates a subdirectory PHOTOMETRY and creates
a "Mask_*.fits" and a "Phot_*.txt" file, where "*" is the date and
time part of the input filename.
Mask*.fits contains the MIDI-mask used to extract the flux from the
frames. The same mask should be used to extract the fringes.
Phot*.fits is a simple text-file with the results of the photometry.
Ok, here's an example:
Start IDL and type
files = midiguida(dir=mididata0224,filter="*_[0-9][0-9].fits")
Select a chopping dataset, e.g. MIDI.2003-02-24T00:13:07.000_01.fits
and click on "Select". Now do the photometry:
chop_nod_phot,files
It will first tell you that it treats the data as chopping data.
Then it will display the gaussian fit that is used to find the
position of the star. If you are happy with the result, hit return,
"n" and return otherwise. Then it does aperture photometry with
increasing radii and selects the best radius based on a convergence
estimator. Finally, it prints some results to the screen and to the
file PHOTOMETRY/Phot_2003-02-24T00:13:07.000_01.txt
For nodding data, start midigui as above, but pick the file on the
object and the file on the sky of a nodding sequence, e.g.
MIDI.2003-02-24T00:17:05.000_01.fits and
MIDI.2003-02-24T00:17:57.000_01.fits
Do the photometry like this:
chop_nod_phot, files[1], files[0]
It should tell you that it assumes nodding data, the rest should be
like in the case of chopping.
=============================================================================
chop_nod_disp.pro
-----------------
Like chop_nod_phot, but for dispersed (PRISM) data.
==============================================================================
make_maskname.pro
-----------------
IDL-routine to find out what the name of the mask created by
chop_nod_phot is.
USAGE:
maskname = make_maskname(MIDI-file)
maskname will be the name of the mask created by chop_nod_phot if you
give it "MIDI-file" as first argument.
=============================================================================
midivisi.pro
------------
IDL-routine to give a simple estimate of (surprise!) the visibility.
Usage:
midivisi, fringe_file, phot_file, sky_file,
MASKFILE=maskfile, THRESHOLD=threshold,
MOVIE=movie, FOURIER=fourier, NOPOSCHECK=noposcheck
Mandatory arguments:
fringefile MIDI file with fringe data
photfile MIDI file with photometric data (chop or nod)
Optional arguments:
skyfile MIDI file with sky for nodding data (optional)
maskfile Mask to use when reading in data
Default is to use the mask created from photfile
Use make_maskname to find out the name of a
mask created by chop_nod_phot
threshold start value for the threshold used to detect
scans with fringes. This can be changed later
interactively.
/movie Show the amplitudes of single scans
/fourier Show powerspectra in movie (untested)
/noposcheck Don't show the rms frame with and without mask
to check the position of the star
Result is a screen filled with diagrams...
The top window shows the opd, fringe amplitude and photometry as
function of frame number, and the integral of the power spectra over
the N-band as function of scan-number (called power-spectrum amplitude
in the following - better ideas are welcome ;-)
The lower panel in the lower right window shows the histogram of
power-spectrum amplitudes, and two vertical lines to mark the
threshold for noise and for signal (both are at the same position
initially, that's why you see only one). All scans with
power-spectrum amplitude above the "good" threshold are assumed to be
fringe detections and averaged to give the signal amplitude. All
scans with amplitude below the "bad" threshold are assumed to contain
only noise and averaged to give the noise amplitude. Signal and noise
amplitude are plotted in the upper panel as function of their
threshold. Clicking with the left mouse button in the lower left
window will change the "good" threshold, clicking with the middle
mouse button will change the "bad" threshold. Clicking with the right
mouse button will end the program.
The lower left window shows power spectra of all "good" and all "bad"
scans.
In the end, the program print the power-spectra amplitudes of signal
and noise (based on the final thresholds), the fluxes from the
photometry data files, and the visibility estimated from all these
numbers.
=============================================================================
xmidivisi.pro
-------------
Similar to midivisi, but with a graphical user interface. The additional
buttons should be self-explaining, with the exception of "Write to Log".
This function appends the results to the textfile "PHOTOMETRY/visibilities"
Finally, the hardcopy is a postscript-file whose name is "Midivisi_" with
the date and time of the first fringe-file appended.
=============================================================================
xmidispvisi.pro
---------------
Similar to xmidivisi, but for dispersed mode (and object-oriented).
1. Initialize it:
x = obj_new('xmidispvisi',fringefile,photfileA,photfileB)
This will read in the data, show the masks and ask if they are ok
and initialize everything.
If the three filenames are in an array, you can use a shortcut:
x = xmdv(files)
There are a number of keywords that can be used with the object-
and the shortcut method. The most important are top secret, the
not-so-important important are:
MASKFILE = filename
use this file as mask to extract photometric flux and fringe
signal. This can be the mask of photometry A or B or any
other mask you found somewhere.
However, the name has to be something like
"PHOTOMETRY/Mask...", because the first 11 characters are
chopped off, and the rest is used in the name of the
compressed file.
/FRINGEMASK
search in the fringe data for the object and create the mask
from that. This works only if the C-program has been
compiled, which needs some special libraries.
The default mask used is the average of the masks of photometry A
and B (average in the sense that position of the maximum and FWHM
are averaged).
MASKWIDTH = w
Create a mask that is wider by a factor w than the default.
This works with the mask created by averaging mask A and B,
and with the mask created from fringedata, but not with a mask
given via the MASKFILE keyword!
NOISEFILE = noisefile
Give a file to be prepended to the fringe track data. The
idea is to use a fringe search file, which (hopefully)
contains scans without any fringes (even at long wavelengths).
Selecting those fringe-free scans is difficult, I expect that
a threshold for the amplitude doesn't work.
/RUNNING_HIPASS
apply a hipass-filter running across scans.
Default is to subtract the mean of each scan from itself.
/NOCOLOR
Don't plot in color (not fully functional)
/DWIM Do what I mean (without asking silly questions)
/DISPERSEDTRACK
Use an experimental algorithm to get a usable pseudo-white-
light fringe amplitude from data taking using dispersed fringe
tracking. The algorithm adds up the amplitudes, not the power.
SHOW_TRACES = flag
Show a plot of the position and widths of the photometric
spectra and the mask used for extracting the interferometric
signal. If flag is "ps", the plots are dumped to the files
"traces_win1.ps" and "traces_win2.ps"
2. Start the GUI:
x->gui
This will open the gui and allow you to set the thresholds.
Clicking on the lower left plot (the one with good and bad fringes)
will open another window with the separate plots for different
wavelength bins. It will also open a window and show the
visibility as a function of wavelength.
There are two options for this command:
x->gui,/tru
This will use 24bit colors and *might* help if your plots are in
black and white only.
x->gui,/block
This will turn off xmanager's /no_block option, i.e. you can't
enter IDL commands on the command line until the GUI is closed.
This can be useful in scripts that want to open the gui and wait
for the user to adjust something. If you don't know what I'm
talking about then you won't need it.
3. Wavelength calibration
lambda = x->lambda()
Returns an array that gives wavelength in microns as function of
pixel number.
x->set_lambda, lambda
Sets the wavelength as function of pixel number.
4. Set the parameters for the binning in wavelength:
x->set_lambda_bins, start, end, step, width
start is the number of the first column used
end is the number of the last column used
step is the spacing between columns
width is the number of columns added for one bin.
For example:
x->set_lambda_bins, 0, 100, 25, 50
will set bins from 0 to 49, 25 to 74, 50 to 99, 75 to 124, and
100 to 149 pixels (yes, the last bin can extend beyond the end
column given)
x->lambda_gui
Set the lambda-binning parameters interactively.
5. get/set the thresholds for good and bad scans:
ts = x->get_thresholds()
ts[0] will be the threshold for good scans,
ts[1] that for bad scans (noise),
ts[2] is the minimum distance in OPD of "noise scans" from the
median OPD (in meters). Scans with a mean OPD that is more
than ts[2] away from the median OPD of all scans are used to
estimate the noise in the power spectrum.
x->set_thresholds, good, bad, noiseopd
Should be self-explaining. noiseopd is optional.
goodbad = x->get_percent_goodbad()
Returns the percentage of good and bad scans with the current
thresholds.
6. get the fringe amplitudes:
fringes = x->fringes()
returns a 3D-array: fringes[0,*,*] is the opd, fringes[1,*,*] is
the fringe amplitude. The second index counts the scan, the third
the frame-no within a scan (or the other way round).
6b. get the maximum amplitude of the white light fringe:
a = x->whitefringeampl()
This is the amplitude of the fringes in the white light,
i.e. integrated over wavelength. To get the amplitude, we
integrate over wavelength, Fourier-transform each scan, add up the
power spectrum at the frequencies where we expect fringes, and
calculate the square root.
7. get the traces (i.e. the position and FWHM of the masks):
tr = x->get_trace(i,/WIN1,/WIN2)
i selects the dataset: 0 is the fringe data, 1 is photometry A, 2
is photometry B. If /WIN2 is set, the trace of window 2 will be
returned, else that of window 1.
tr is a midisptrace structure:
tr.trace is the measured position of the peak as
function of pixel number
tr.FWHM the measured FWHM
tr.fluxmax the height of the peak (as returned by the
1D-gaussfit)
tr.range the indices of good trace-measurements
tr.nRange the number of good measurements
trace_coeff the coefficients of the trace-polynomial
sigma_coeff the coefficients of the sigma-polynomial
8. get the photometry (in fact, the spectra):
spec = x->get_photometry(/Atotal,/A1,/A2,/Btotal,/B1,/B2,/AB)
Default is to return the sum of all 4 spectra as function of
pixel-number. Keywords /Atotal and /Btotal return the sum of the
two A- or B-spectra, respectively. Keywords /A1, /A2, /B1, and /B2
return the corresponding spectrum (Beam A, window 1 and so on).
Everything is in ADU/sec.
9. get the correlated flux as function of wavelength:
cf = x->correlflux(/PLOT,/CFPLOT)
This is a 3 by N array, where N is the number of bins in lambda.
The first row (cf[0,*])is the wavelength in the center of the bins,
the second row (cf[1,*]) is the width of the wavelength bins, and
the third row (cf[2,*]) is the correlated flux in ADU/sec.
Keyword /PLOT will plot the good and bad fringes in the lambda
bins, and the correlated flux. Keyword /CFPLOT will plot only the
correlated flux. To plot it again, use
plot, cf[0,*], cf[2,*], ystyle=2
10. get the visibility as function of wavelength:
visi = x->visibility(/PLOT,/VISPLOT,/MULTIPLYTHENMASK)
Result has the same format as the result of correlflux(), except
that visi[2,*] is the visibility.
With keyword "Multiplythenmask", it will use the photometric flux
obtained by multiplying the images before applying the mask an
integrating in y-direction (this is the Right Thing to do and will
become the default as soon as no-one is looking).
The other keywords are secret and won't be explained here.
11. get the instrumental visibility from a calibrator object
insvis = x->instruvisi(diameter,NAME=name)
diameter is the diameter of the calibrator in mas. If the object
is listed in the calibrator database, the diameter can be omitted.
The name that should be used to find the object in the database can
be given with the NAME parameter.
insvis is another 3 by N array with wavelengths and visibilities.
12. calibrate a science target with a calibrator
calvis = x->calibratedvisi(cal,diameter,NAME=name,/plot,/visplot)
cal is the xmidispvisi object of the calibrator, diameter and name
are used to call its instruvisi()-function. The binning in lambda
of the calibrator object set to the same values as in the science
object.
13. Create a harcopy:
x->hardcopy, filename, /NOCOLOR, /TRACES, /DONTCLOSE
filename is the name of the ps-file to print to, if omitted, it
will be created from the name of the fringe data. /NOCOLOR prints
in black and white, /TRACES prints the traces, too, and /DONTCLOSE
doesn't close the file afterwards, so you can append more plots.
14. Get the filenames etc. (useful in scripts):
object = x->get_objectname()
fringefile= x->get_filename()
photfiles = x->get_filename(/PHOT)
maskfile = x->get_filename(/MASK)
photfiles is an array of filenames.
14. Destroy the object and free all its memory:
obj_destroy, x
If you fail to do this before re-using the variable, the object
will stay in memory. There's no way to destroy it once the
reference to it is lost (IDL has no garbage collection).
Previous: Visibilities
Rainer Köhler, 11-Oct-2004