Objects are like universes, in the beginning, they have to be created. Xmidispvisi objects differ, however, they need some MIDI data to work with. So the syntax to create an xmidispvisi-object, read in the data, and initialize everything, is
x = obj_new('xmidispvisi',fringefile,photfileA,photfileB[,options])(Note that the part in [...] is optional, that's why it's called options. The names of the options are in fact different, see below.)
There is also a shortcut for people who are too lazy to type all that, to challenged to get words with more than 4 letters right, or too scared of objects to call them bu name:
x = xmdv(files[,options])Here, the three filesnames have to be given in an array. This is quite handy, since midigui returns the filenames in an array already. The order of files in the array is not important, xmdv will try to figure out which file has the fringes and which have the photometry, and crash happily if it can't.
Since January 2007, you can feed xmdv an array with even more files, and it will create an xmidispvisi-object for every triple of fringe-track, photometry A, and -B files. The results will be returned in an array of objects.
There are a number of options that can be used with obj_new and xmdv. The most important are top secret, the not-so-important important are (in alphabetical order, not order of unimportance):
DISPERSEDTRACK = d
When dispersed fringe tracking is used and MIDI is configured
to track at an OPD different from zero, the fringe amplitude
of the white light is too small to be usable. This flag
enables an algorithm that divides the N-band into "d" bins, and
then adds up the amplitudes.
This is independent from the bins used in the computation of
the correlated flux, visibility etc., use
set_lambda_bins to change that.
DSKY = dsky (in versions after 1.2)
This parameter is passed to
oirChopPhotoImages.
It shifts the region where the sky background is measured from
its nominal position.
ERRORLOG = log
Do not stop and wait for the user to press return when some
problem is found in the data. Instead, a message is appended
to the variable "log". If all goes well, the contents of the
variable will not be changed. This is mainly useful in scripts
or if you don't care whether the results make any sense.
It is expected that the caller checks if the variable contains
more error messages afterwards and acts accordingly (e.g. by
not publishing the surprising results you get from
crappy data)
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, as long as it is in the secret
and sacred MIDI-format.
MASKWIDTH = w
Create a mask that is wider by a factor w than the default.
w can also be smaller than 1, in which case the mask will be
narrower 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).
/NOEWSPHOT (in versions after 1.2)
This option tells MIA that it should not use the EWS-routines
for photometry
(oirChopPhotometry),
but the old routines. These old routines do not do a background
subtraction, so you should use this option only for
very bright sources. See also the
dSky-parameter.
/NOMASKCHECK
Use this option if you believe that the mask created by
miamask is perfect and don't even want to look at it.
Blind faith in MIA is good for you, of course, but it might be
bad for your results.
PREFIX = prefix (available with xmdv only)
Put "prefix" in front of all the input filenames. Useful if
midiguis() does not return the full path. This will change
the input filenames in the caller's variable!
/RUNNING_HIPASS
Apply a hipass-filter running across scans. Default is to
subtract the mean of each scan from itself. This option exists
only so that someone can check if it makes any difference.
/TRUECOLOR
use colors suitable for a 24-bit truecolor display.
Use this if you don't see green and red in the GUI, but only
black and white. MIA should be able to figure it out by itself,
but sometimes it gets confused, just like any X-windows user.
All the magic happening when the object is created and initialized should be described elsewhere in this manual.
The GUI is started by telling the object to start it:
x->gui
There are two options for this command:
x->gui,/truecolor
This will use 24bit colors and *might* help if your plots are in
black and white only (see the option with the same name in the section
about creating the object).
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.
The GUI itself has many menus, buttons, and plots for you to play with, which should be described elsewhere.
The diagrams in the GUI are scaled automatically by default, but according to Murphy's law, this does never work quite right. Since version 1.3, there are a number of routines to set the limits (only the long diagrams in the upper half of the window, feel free to implement something similar for the others).
All routines expect an array with two values as input, which gives the minimum and maximum of the corresponding axis. Currently, the routines do not re-plot the data, so to see their effect, you have to re-start the GUI.
x->set_frame_range, rng
Set the X-axis for all four plots. The x-axis of the fourth
plot is in scan numbers, not frame numbers, the range is
adjusted accordingly.
x->set_opd_range, rng
Set the range in OPD plotted in the topmost diagram.
x->set_flux_range, rng
Set the range of fluxes plotted in the second diagram.
x->set_fluxdiff_range, rng
Set the range of flux difference in the third diagram.
x->set_fringe_ampl_range, rng
Set the range in fringe amplitude plotted in the lowest
diagram.
To obtain the information shown in the GUI in a postscript-file, use
x->hardcopy, filename, /NOCOLOR, /TRACES, /DONTCLOSEfilename 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.
The mask is handled by an object that is described elsewhere. This object is embedded in the xmidispvisi-object, so you don't have to worry about its creation, destruction, and funeral. There are a few functions in xmidispvisi to access it:
Get the traces (i.e. the position and FWHM of the masks).
Up to and including MIA+EWS version 1.1:
tr = x->get_trace(i,/WIN1,/WIN2)
i selects the dataset: -1 is the fringe data, 0 is
photometry A, 1 is photometry B. If /WIN2 is set, the trace of
window 2 will be returned, else that of window 1.
Since MIA+EWS version 1.2:
tr = x->get_trace(i,WIN=w)
i selects the dataset: -1 is the fringe data, 0 is photometry A, 1 is photometry B. If WIN is not set, an array of the traces for all windows is returned. If WIN is set, only the trace for this window is returned. WIN can be 1 or 2 for HIGH_SENS data, or 1-4 for SCI_PHOT data.
tr is a midisptrace structure (or an array of those):
tr.trace | 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 |
tr.trace_coeff | the coefficients of the trace-polynomial |
tr.sigma_coeff | the coefficients of the sigma-polynomial |
Show the traces
x->show_traces, filenameCalls the routine with the same name in the mask-object. Nobody knows what might happen then.
Open the Mask-GUI
x->maskguicalls the gui-function of the mask object. Note that changes to the mask have no effect once the xmidispvisi-object is initialized, you can use the mask-GUI only to check the parameters. Any changes to them will be ignored.
To decide whether a scan was at the right spot in OPD or not, MIA uses the fringe amplitude of the white light (i.e. integrated over the full N-band). Unfortunately, if MIDI was tracking at an OPD different from zero, the fringe amplitude of the white light is always low (because the fringe packet with a wide wavelength band is too small). This is often the case if dispersed fringe tracking is used. Our way around this problem is to split the N-band into a number of narrow(er) bands, measure the fringe amplitude in each of them, and sum up the results.
To enable this, use
x->make_white_fringeThe (current) default is to integrate the light. To enable the code for dispersed fringe tracking, use
x->make_white_fringe, /BINSThe default is to use 10 bins, which is enough for the standard OPD offset. If you think you need a different number of bins, give it after the BINS keyword, e.g.
x->make_white_fringe, BINS=14
To find out what the object thinks the wavelengths are, ask it:
lambda = x->lambda()Returns an array that gives wavelength in microns as function of pixel number. If you want or need the wavelength as function of wavelength bin, see photometry or correlflux.
If you want to convince the object that the wavelengths are different, tell it:
x->set_lambda, lambdaThis sets the wavelength as function of pixel number. This might be useful with GRISM-data, where the default wavelength calibration is less than perfect. Of course, I would like to improve this, so if you happen to have a better one and are willing to share it, tell me.
Look at the wavelength-binning parameters and set them interactively:
x->lambda_gui
Find out what the parameters are in a script or from the command line:
array = x->get_lambda_bins()array[0]: the number of the first column used
Set the parameters:
x->set_lambda_bins, start, end, step, width
start | the number of the first column used |
end | the number of the last column used |
step | the spacing between columns |
width | the number of columns added for one bin. |
For example:
x->set_lambda_bins, 0, 100, 25, 50will set bins from 0 to 49, 25 to 74, 50 to 99, 75 to 124, and 100 to 149 pixels.
It is checked if the start and end values are within the detector window. If not, they are set to 0 and the highest pixel number. If you pass the two values via variables, you can find out what they are set to afterwards:
lstart = -1 lend = 999 x->set_lambda_bins, lstart, lend, 3, 3 print, lstart, lendwill probably give the result:
0 170Why this doesn't work if start and end are given as numbers is left as an exercise to the reader.
There are three parameters that control which scans are used to estimate the signal and the noise:
To find out what the thresholds are:
ts = x->get_thresholds()The return value is an array of the three thresholds:
Set the thresholds:
x->set_thresholds, signal, noise, noiseopdAll parameters are optional. You will get a warning message if the noise threshold is larger than zero, or if the noiseopd is so small that you still have signal in the scans selected by it.
Finally, if you want to know how many scans get selected by those thresholds:
goodbad = x->get_percent_goodbad()Returns the percentage of good and bad scans with the current thresholds.
Get the amplitude of the white light fringe:
a = x->whitefringeampl()returns an array of the amplitude of the fringes in the white light, as function of scna-number. Unless DISPERSEDTRACK was used when the object was initialized, we integrated over wavelength first, and then determine the fringe amplitude! This is the quantity used to select scans with signal based on the "good" threshold.
Get the fringe signal:
fringes = x->fringes()returns a 3D-array: fringes[0,*,*] is the opd, fringes[1,*,*] is the fringe signal, i.e. the difference in flux between the two interferometric channels. Note that this is integrated over wavelength. The second index counts the frame-no within a scan, the third index is the scan-number.
Get everything there is to know about the fringes:
dispfringes = x->dispfringes()returns the spectrally dispersed fringe signal. The first index is the wavelength, the second the frame within a scan, and the third is the scan-number. The careful reader will have noticed that the fringe signal returned by x->fringes() can be obtained by integrating dispfringes over the first index, i.e. total(dispfringes,1).
Find out where the telescopes were pointing:
tartyp = x->tartyp()returns an array of strings, one for each scan. The value of a string is "T" if the telescopes were pointing at the target during the corresponding scan, it is "S" if they were pointing at the sky, and "U" if they were doing funny things during the scan (like switching from target to sky in the middle of the scan).
Only scans pointing to the target are used to select "good" scans (those with fringe signal).
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, the other results are simple strings.
(Well, actually the results are only as final as you get them from MIA, you still have to interpret them and write the Nature paper yourself).
Photometry = Uncorrelated Flux (in fact, spectra):
phot = x->photometry(/Atotal,/Aphot,/Btotal,/Bphot,/Quiet,/PLOT)returns a 3 by N array, where N is the number of bins in lambda. The first row (phot[0,*])is the wavelength in the center of the bins, the second row (phot[1,*]) is the width of the wavelength bins, and the third row (phot[2,*]) is a photometric spectrum in ADU/sec, binned in wavelength according to the wavelength-binning parameters.
Without any keywords, sqrt(A1*B1)+sqrt(A2*B2) is returned, which happens to be the combination of the fluxes we measure in the fringe signal (see this PDF-document). With keywords /Atotal or /Btotal, the total photometric flux from telescope A or B is returned. The keywords /Aphot and /Bphot (introduced on October 12., 2005) are only valid with data taken in SCI_PHOT-mode. They return the spectra in the additional channels in the photometric data files. The wavelength is not correct for these spectra!
For historic reasons, there is another way to get the spectra:
spec = x->get_photometry(LAMBDA=lambda,/Atotal,/Btotal,/PLOT)This function may be removed in the future, therefore you should not use it in new code.
cf = x->correlflux(/PLOT,/CFPLOT,/SSN)
returns 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.
The 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
The secret keyword /SSN (for "Same Sky Noise") will estimate the noise from the same scans as the correlated flux. Contact an expert before you attempt to use it.
visi = x->visibility(/PLOT,/VISPLOT)The result has the same format as the result of correlflux(), except that visi[2,*] is the visibility, defined as
correlated_flux / uncorrelated_fluxas obtained from x->get_photometry and x->correlflux.
Instrumental Visibility from a Calibrator
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, otherwise the name given in the FITS-header will be used (which may or may not be correct). insvis is another 3 by N array with wavelengths and visibilities.
Calibrate a Science Target
calvis = x->calibratedvisi(cals,diameter,NAME=name,/plot,/visplot)cals is an array of the xmidispvisi-objects of the calibrators you wish to use (can be an array with only one element). The instrumental visibility is obtained from each calibrator and the results averaged. Diameter and name are used to call its instruvisi()-function. This makes sense only if all the calibrator-objects are observations of the same calibrator, otherwise you have to rely on the automatic lookup in the calibrator database. The binning in lambda of the calibrator objects is set to the same values as in the science object.
Projected Baseline (since July 18., 2006)
base_len = x->baseline, base_pa, /QUIETReturns length and position angle of the baseline projected on the plane of the sky. There is also another baseline-routine that can be used without an object.
Save the Visibility (since October 5., 2005)
x->save_visibility [, filename]Although visibilities are not yet on the list of endangered species, you might want to save them. This routine writes it to a FITS-file in the standard format for visibilities specified by the IAU. If filename is omitted, a dialog will pop up and ask for it.
(since October 12., 2005)
x->print_results [, filename] [, CALIBRATOR=cal]prints photometric and correlated flux, the visibility, and the power spectra to a postscript file. The name can be given as argument, otherwise the name is MIAplots*.ps, where * is replaced by the date and time of the first fringe file.
The xmidispvisi-object of a calibrator star can be given with the CALIBRATOR-option. In this case, the fluxes and visibility of the calibrator, as well as the calibrated visibility of the science target are printed, too.
obj_destroy, xwill remove the object from memory. If you do not destroy it before re-using the variable, the object will continue to haunt your computer like a zombie. The only way to get rid of it once the reference to it is lost is to call the IDL garbage-collector with heap_gc. If you don't do this, the memory of your computer will be filled with xmidispvisi-objects until it either explodes or collapses into a black hole (depending on the internal pressure of the objects, the theory of collapsing objects is beyond the scope of this manual).
There are currently two routines in MIA that deal with photometry. Both are independent from the xmidispvisi-object.
Like chop_nod_phot, but for dispersed (PRISM) data.
Routine to measure photometry on chopping or nodding data.
Usage for chopping data:
chop_nod_phot, filesUsage for nodding data:
chop_nod_phot, files_on_star, files_on_skyThe "files" should be like the result of midigui("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.
Here is 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,filesIt 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 (if you managed to find some), 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.
In this section a number of routines are described that might be useful for you.
Uses the IDL-function FILE_SEARCH to search files, checks which fulfill the criteria given by the caller, combines files belonging to the same data sets, and returns the result as an array:
files = midifile_search(paths[,options])paths is a scalar string or an array of strings giving the path to the for MIDI files. If the PATTERN-option is not used, path should end in a pattern like "MIDI.*.fits" to make sure only valid MIDI FITS-file are checked.
Options are:
PATTERN = pattern
Activates recursive searching. All subdirectories starting at
paths are searched for files with names matching
pattern. See the IDL-documentation about FILE_SEARCH.
FIRST = firstfile
Returns only files with names greater or equal than
firstfile. It compares only the part of the name
after the rightmost "/", this is usually "MIDI.*.fits", where
the star is replaced by the date and time of the data
acquisition. Therefore, "greater" filenames correspond to later
observations (unless you changed the order by renaming your
files).
LAST = lastfile
Same as the FIRST-option, but returns files with names less or
equal then lastfile.
OBJECT = obj_pattern
Checks the "OBS TARG NAME" keyword in the files and returns only
those matching obj_pattern. Wildcards like "*" and "?" are
allowed.
/FRINGE_SEARCH or /FSEARCH
Return files containing fringe-search data. Can be used
together with /FRINGE_TRACK and /PHOTOMETRY to return several
kinds of data.
/FRINGE_TRACK or /FTRACK
Return files containing fringe-track data. Can be used
together with /FRINGE_SEARCH and /PHOTOMETRY to return several
kinds of data.
/PHOTOMETRY
Return files containing photometry data (the kind used to
compute the visibility, i.e. with beam combiner and only one
open shutter). Can be used together with /FRINGE_SEARCH and
/FRNIGE_TRACK to return several kinds of data.
/PRISM
Return only files with prism-data
/GRISM
Return only files with grism-data
/HIGH_SENSE
Return only files taken in HIGH_SENS-mode
/SCI_PHOT
Return only files taken in SCI_PHOT-mode
KEYWORD = keyword and KEYVALUE = keyvalue
Return only files where the value of the header-keyword
keyword matches keyvalue.
Keyvalue may contain wildcards like "*" and "?".
This can be used for specialized selections that are not
possible with the standard options. Only one
keyword/value pair can be used.
/VERBOSE
Print information about the files.
OBJ_NAMES = obj_names
Returns the object-names (header keyword "OBS TARG NAME")
NRTS_MODES = nrts_modes
Returns the NRTS-modes (OBS_FRINGE_TRACK_DISPERSED, DEFAULT_CHOP
etc.)
SHUTTERS = shutters
Returns the shutter-status (AOPEN, BOPEN, ABOPEN)
DISPERSERS = dispersers
Returns the disperser names (PRISM or GRISM)
BEAMSPLITS = beamsplits
Returns the beam-splitter configurations (HIGH_SENS or SCI_PHOT)
Find out what the name of the mask created by chop_nod_phot is:
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.
Print an overview of the parameters of the data-files in a directory:
make_midi_log, directory-nameThe name of the output file can be given via the LOGBOOK-parameter, e.g.
make_midi_log, directory_name, LOGBOOK= directory_name+'.log'
Routine that puts MIDI-windows together into one array and calls atv with that array. Atv is an IDL-routine for displaying images (a kind of saoimage-clone written in IDL). It was written by Aaron Barth, its homepage is http://www.physics.uci.edu/~barth/atv/.
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.
baseline, filename, LENGTH=length, ANGLE=angle, /QUIETComputes length and position angle of the baseline projected on the sky at the time of the observation in file "filename". The results are returned in the variables specified and printed on the screen (unless the option /QUIET was given).
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 |
Plot the visibility as returned by x->visibility(), x->instruvisi(), or x->calibratedvisi():
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.