Home | Trees | Indices | Help |
---|
|
Interface the spectra from the Hermes spectrograph.
The most important function is search.
This looks in SIMBAD for the coordinates of a given object, and finds all
spectra matching those within a given radius. If the object's name is not
recognised, it will look for correspondence between the given name and
the contents of the FITS header's keyword object
. search
returns a record array, so that you can easily access all columns by
their names.
Note that Hermes spectra retrieved in logscale should not be corrected for the barycentric velocity (the pipeline does it). The spectra retrieved in normal wavelength scale should be corrected. These two cases are outlined below.
Example usage: retrieve all data on HD170580
>>> mydata = search('HD170580')
Keep only those with a long enough exposure time:
>>> myselection = mydata[mydata['exptime']>500]
Now read in all the data, and plot the spectra. First, we need an extra module to read the FITS file and the plotting package.
>>> from ivs.inout import fits >>> import pylab as pl
Then we can easily plot the relevant data:
>>> for fname in myselection['filename']: ... wave,flux = fits.read_spectrum(fname) ... p = pl.plot(wave,flux) >>> p = pl.ylim(0,45000) >>> p = pl.xlim(4511,4513.5)
]include figure]]ivs_catalogs_hermes_HD170580.png]
Note that you can easily shift them according to some radial velocity: as an extra example, we retrieve the data in wavelength scale, shift according to the barycentric velocity, convert to velocity space, and plot them:
First start a new figure and add extra modules:
>>> p = pl.figure() >>> from ivs.spectra.tools import doppler_shift # to apply doppler shift >>> from ivs.units import conversions # to convert to velocity space
Then get the spectra again, but now not in log scale. Make the same selection on exposure time.
>>> mydata = search('HD170580',data_type='cosmicsremoved_wavelength') >>> myselection = mydata[mydata['exptime']>500]
Then read them all in and shift according to the barycentric velocity. Also, convert the spectra to velocity space afterwards for plotting purposes.
>>> for rv,fname in zip(myselection['bvcor'],myselection['filename']): ... wave,flux = fits.read_spectrum(fname) ... wave_shifted = model.doppler_shift(wave,rv) ... velo_shifted = conversions.convert('angstrom','km/s',wave_shifted,wave=(4512.3,'angstrom')) ... p = pl.plot(velo_shifted,flux) >>> p = pl.ylim(0,45000) >>> p = pl.xlim(-70,70)
]include figure]]ivs_catalogs_hermes_HD170580_velo.png]
If you want to list the observers of a certain target, and the amount of spectra they took, you can do the following:
>>> data = search('HD50230') >>> print [(i,list(data['observer']).count(i)) for i in set(data['observer'])] [('Robin Lombaert', 4), ('Steven Bloemen', 6), ('Pieter Degroote', 25), ('Michel Hillen', 3)]
Make sure you have sourced the Hermes DRS (source
~mercator/HermesDRS.rc
) and that you make a backup of your
config file before proceeding.
In this example, we first make a mask file:
>>> from ivs.spectra import linelists >>> teff = 12500 >>> logg = 4.0 >>> ll = linelists.get_lines(teff,logg) >>> mask_file = '%.0f_%.2f.fits'%(teff,logg) >>> make_mask_file(ll['wavelength'],ll['depth'],filename=mask_file)
And run the DRS:
>>> CCFList('HD170200',mask_file=mask_file)
To ensure a fast lookup of datafiles, an overview file
HermesFullDataOverview.tsv
is created via make_data_overview. The file resides in one of the
IVSdata
directories, and there should also exist a copy at
/STER/mercator/hermes/
.
The best strategy to keep the file up-to-date is by running this module in the background in a terminal, via (probably on pleiad22):
$:> python hermes.py update
This script will look for a HermesFullDataOverview.tsv
in one of the data directories (see config module), check until what date data files are
stored, and add entries for HERMES data files created since the last
update. If you want a complete update of all the HERMES data folders,
you will need to remove the file and run the update. Indeed, if
HermesFullDataOverview.tsv
does not exist, it will create
a new file in the current working directory from scratch, and copy it
to /STER/mercator/hermes/
. It is the user's responsibility
to copy the file also to one of the IVSdata directories where the user
has write permission, so that next time the update is performed, the
script can start from the previous results.
When running the above command in the terminal, you will notice that
the script does not terminate until a manual CTRL+C
is
performed. Indeed, when left running the script will perform the update
once a day. So once it runs, as long as the filepaths do not change or
computers do not shut down, you don't need to run it again. If a
computer does stop running, just restart again with:
$:> python hermes.py update
and everything should be fine.
|
|||
HermesCCF Object that holds all information stored in the *_AllCCF.fits files written by hermesVR. |
|
|||
User functions | |||
---|---|---|---|
numpy rec array |
|
||
[array, array, dict] |
|
||
|
|||
|
|||
|
|||
Read / Write | |||
record array |
|
||
HermesCCF object |
|
||
dict |
|
||
Hermes DRS wrappers | |||
(int, str, int) |
|
||
|
|||
Administrator functions | |||
|
|||
|
|||
float |
|
||
datetime |
|
||
dict |
|
||
|
|
|||
hermesDir = os.path.expanduser('~/') Path to the directory in which the hermes folders (hermesAnalysis, hermesRun, hermesDebug) are located. |
|||
tempDir = '/scratch/%s/' %(getpass.getuser()) Path to temporary directory where files nessessary for hermesVR to run can be copied to. |
|||
logger = logging.getLogger("CAT.HERMES")
|
|
Retrieve datafiles from the Hermes catalogue. If If If If you don't give either ID or time_range, the info on all data will be returned. This is a huge amount of data, so it can take a while before it is returned. Remember that the header of each spectrum is read in and checked. Data type can be any of:
This functions needs a If this file does not exist, you can create it with make_data_overview. If you want a summary file with the data you search for, you can give
The columns in the returned record array are listed in make_data_overview, but are repeated here (capital letters are directly retrieved from the fits header, small letters are calculated values. The real header strings are all small capitals):
The column If BVCOR or BJD are not available from the FITS header, this function will attempt to calculate it. It will not succeed if the object's name is not recognised by SIMBAD. Example usage: retrieve all data on HD50230 >>> mydata = search('HD50230') Keep only those with a long enough exposure time: >>> myselection = mydata[mydata['exptime']>500] Look up the 'telalt' value in the FITS headers of all these files via a fast list comprehension: >>> telalts = [pf.getheader(fname)['telalt'] for fname in myselection['filename']] Search for all data of HD50230 taken in the night of 22 September 2009: >>> data = hermes.search('HD50230',time_range='2009-9-22') Or within an interval of a few days: >>> data = hermes.search('HD50230',time_range=('2009-9-23','2009-9-30')) Search for all data observed in a given night: >>> data = hermes.search(time_range='2009-9-22') Warning: the heliocentric correction is not calculated when no ID is given, so make sure it is present in the header if you need it, or calculate it yourself.
|
Combines HERMES spectra with sigma clipping to remove cosmics. The input spectra are given as a list of filenames for the objects and for the wavelength scales. The output is the wavelength scale of the first object, the merged and sigma clipped flux, and the adapted header of the object. In this adapted header, the exposure time is the sum of all individual exposure times, and the observing time is averaged. Uses the ivs.spectra.tools.merge_cosmic_clipping method to merge the spectra. >>> data = search('KIC9540226') >>> objlist = data['filename'] >>> wave, flux, header = merge_hermes_spectra(objlist, wscalelist=None)
|
Mimics HermesTool MakeListStar. This should work as input for HermesTool CCFList.py The result is a file in the current working directory with name
The contents of the file is: unseq, date-avg, ID, bjd, bvcor, prog_id, exptime, airmass, pmtotal
|
Make a mask file for RV calculations with the Hermes pipeline. See
|
Rough calibration of Hermes spectrum. Thanks to Roy Ostensen for computing the response function via detailed modeling of Feige 66. |
Read the velocities.data file with the resuls from hermesVR. The results are returned as a numpy record array. By setting unique to True, the method will only return a unique set of sequence numbers. When return_latest is True it will pick the latest added version, otherwise the first added is picked. You can supply a list of unseq numbers, and then only those will be returned, same goes for object. In both cases the output is ordered in the same way as the list of unseq or object that you provided. These lists can be used together with the unique option. This method will search for 'velocities.data' in 'hermesDir/hermesAnalyses/'. You can provide another file location by using the keyword filename. The field in the recored array are:
|
Read the AllCCF.fits files written by hermesVR with the individual cross correlation functions of each order. The cross-correlation functions are stored in a HermesCCF object from which they can be requested. You can read *_AllCCF.fits file by providing only the unique sequence number as an integer. In this case the file will be searched in the hermesDir/hermesAnalyses/ folder. You can also provide the complete filename instead as a string fx. >>> read_hermesVR_AllCCF(457640) >>> read_hermesVR_AllCCF('/home/jorisv/hermesAnalysis/00457640_AllCCF.fits')
|
Update the hermesConfig.xml file with the specified keywords. This method will return the original content of the file as a dictionary. You can use that dict as an argument to this function if you want to restore the hermesConfig file to the original state. write_hermesConfig will search for hermesConfig.xml in hermesDir/hermesRun/ unless a path is specified in the kwarg filename. example use: >>> old = write_hermesConfig(CurrentNight="/STER/mercator/hermes/20101214") >>> " Do some stuff " >>> write_hermesConfig(**old)
Attention: This function does not check the validity of the keywords that you provide, that is your own responsibility. |
Wrapper around hermesVR that will run hermesVR on any given filename. Thus not on sequence number. This can be usefull if you first merge together 2 back-to-back spectra and then want to calculate the radial velocity of the merged spectrum. The original file will not be modified, it is coppied to the tempDir, and the name will be changed according to the supplied flags. During the process hermesConfig.xml is adapted, but after hermesVR is finished, it is restored to its old state. When providing a wavelength scale file, provide the full path, but cut off the '_HRF_TH_ext_wavelengthScale.fits' part of the filename. Thus if you want to use: '/folder/2451577_HRF_TH_ext_wavelengthScale.fits', use: >>> run_hermesVR(filename, wvl_file = '/folder/2451577') The results of hermesVR are saved to the standard paths, as provided in the hermesConfig file. This method only returns the unseq number of the filename so you can find the corresponding output file, the output of hermesVR as a string, and a unix return signal of running hermesVR. The returncode is 0 if no errors are found. Any negative number means hermesVR failed (codes can be consulted here: unix signals). If returncode = -35, then hermesVR completed but didn't write any output. In this case consult the logs or string output to find out what went wrong.
|
Calculate radial velocities for Hermes stars. Warnings:
|
Summarize all Hermes data in a file for easy data retrieval. The file is located in one of date data directories (see
This file can most easily be read with the ivs.inout.ascii module and the command: >>> hermes_file = config.get_datafile(os.path.join('catalogs','hermes'),'HermesFullDataOverview.tsv') >>> data = ascii.read2recarray(hermes_file,splitchar='\t') |
Convert the time stamp from a HERMES FITS 'date-avg' to Julian Date.
|
Convert the time stamp from a HERMES FITS 'date-avg' to a datetime object.
|
Convert a xml tree to a dictionary.
|
|
hermesDirPath to the directory in which the hermes folders (hermesAnalysis, hermesRun, hermesDebug) are located. By default this is set to '/home/user/'.
|
tempDirPath to temporary directory where files nessessary for hermesVR to run can be copied to. You need write permission in this directory. The default is set to '/scratch/user/'
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Mar 30 10:45:19 2018 | http://epydoc.sourceforge.net |