Keck HIRES Precision Radial Velocity Data Reduction

This service enables reduction and analysis of precision radial velocity (PRV) data from the HIRES Keck instrument.

This notebook is meant to be a template to set up your own processing using the code snippets provided here. The notebook may not run exactly as presented if you attempt to run the full notebook directly. The code has not been rigorously tested from within a notebook environemnt.

This notebook introduces the Keck HIRES Precision Radial Velocity (PRV) pipeline service and works through one specific example. There are number of variations, mostly having to do with planning processing, which will be covered in more detail by other notebooks but here you will see all the basics.

The notebook is kept with the HIRES PRV Python access toolkit in GitHub: https://github.com/Caltech-IPAC/hiresprv

Login

Logging in the first time creates a workspace for the user and associates it with a KOA account.

Users of this service must have Keck Observatory Archive (KOA) accounts and use that login here to gain access to their data. Even researchers planning to use only public data will need a KOA login as this service is maintaining persistent storage under that ID.

The login is persisted through the use of HTTP cookies and logging in from multiple clients will connect the user to the same account, storage, and processing history. This environment (user workspace) is permanent as we expect some on-going research to span years. The login for a give client machine need only be done once, assuming the cookie file in the local storage is not deleted. If it is, logging in again will reconstruct it.

The cookie file, processing state information, and downloaded results like 1D spectra and RV curve tables will be kept locally in the same space as this notebook. If you wish to change that, simply add in whatever directory management and navigation you like.

In [9]:
from IPython.display import IFrame
from hiresprv.auth import login

login('prv.cookies')
KOA userid: koaadmin
KOA Password: ········
Successful login as koaadmin

KOA Data Retrieval

The PRV workspace first needs to be populated with data from KOA. This can be done all at once, if the data exists, or incrementally as the data are taken/identified.

This step is more than a simple data transfer. "Raw reduction" of the data, which converts the 2D CCD echelle images to 1D spectra, is done up-front as the data are retrieved a night at a time. The UT dates you give here are actually shifted a few hours to catch any calibration data collected in the afternoon of the same (Hawaii-local) day.

In [2]:
from hiresprv.archive import Archive

koa = Archive('prv.cookies')

rtn = koa.by_dates("""2009-12-31
2013-06-29
2013-09-12
2015-06-06""")
{
    "status": "ok",
    "msg": "Processing dates in background."
}

Note that since the data in the workspace are permanent, repeated request for the same data would not change anything and so those dates will be ignored. Therefore, you can add to the above list or replace it with new dates as you choose. Dates must be formatted as YYYY-MM-DD.

The above service responds immediately with an acknowledgement of the request and starts the actual transfer and raw data reduction (which can take some time) as a background job. The job status can be checked by polling or can be monitored using the function below. While one retrieval job (or processing job below) is running, no others can be initiated.

PRV Processing Monitor

Some steps in the PRV processing can take quite a long time (hours) and we do not want to tie up this notebook page waiting for it to finish. Below we show how to retrieve a snapshot of the status (and you would have to poll manually to track the progress of the job) but the preferred approach is to start a real-time monitor in a custom page/tab which uses Javascript and an HTTP Event stream. Run the next cell to generate a link to this monitor:

In [5]:
from hiresprv.status import Status
from IPython.core.display import HTML

monitor = Status('prv.cookies')

link = monitor.generate_link()

HTML(link)
Out[5]:

But if you still want a static status snapshoot, run the following:

In [10]:
from hiresprv.status import Status

monitor = Status('prv.cookies')

url = monitor.processing_status()

IFrame(url, 950, 500)
Out[10]:

Metadata

Once data have been retrieved and the "nightly" raw reduction performed, a set of records is added to a persistent metadata table, one row is added per observation. These observations are all taken through the HIRES PRV instrument (2D CCD) and will have been reduced to 1D spectra by the raw reduction. They fall into five classes:

  • RV observations -- Multiple observations of a star with the iodine cell in the light path. Precision, relative radial velocities are calculated for this type of observation.

  • Templates -- One long observation of the same star without iodine, for reference.

  • B stars -- A set of observations of rapidly rotating B stars bracketing the template observation and used to reduce it.

  • Iodine -- Reference observation of iodine for nightly calibration.

  • Miscellaneous other calibration observations (labelled as "Unknown").

By inspecting this table, the user can determine what objects were observed, whether there are template observations for them (and adequate B star data to reduce a template), and whether there are enough RV measurements to generate a final RV curve.

With a small metadata table, this is simple enough to do by inspection but a typical workspace can easily have thousands of files covering tens or hundreds of objects. Furthermore, since observations for a single object are frequently spread out over years, the metadata table is often fairly thorougly mixed in time.

Luckily, there are a number of tools available in client-side Python subset and organize the metadata, so we provide it for download as a CSV table or an SQLite binary file or even, as here, as a simple HTML table. The workspace copy of the data is maintained in an SQLite database so we also provide a basic filtering mechanism as an optional addition to the download. This filtering is often adequate for basic processing scenarios.

Note that metadata retrieval can't be done while the system is "busy" (downloading additional data or further reducing data in the workspace). Otherwise, metadata downloads can be done at any time.

Also note that the client-side file will become out-of-date once new data download or processing requests are submitted. It is up to the user to re-request the new metadata.

In [11]:
from hiresprv.database import Database

state = Database('prv.cookies')

url = state.search()

IFrame(url, 950,  500)
Out[11]:

Reducing RV Measurements for a Star

Subsetting the Metadata: Single Target

Ultimately, to make an RV curve for one star we need to reduce its observations into RV measurements. Assuming there are adequate B star observations to reduce the template, we can isolate appropriate records in the metadata above by simply filtering on TARGET name. There are many ways to do this; in our case we we used the remote SQLite query capability and filtered it with

select DATE, OBTYPE, FILENAME, TARGET, BJD, BCVEL from FILES where TARGET like 'HD185144';

The resulting records are shown below.

In [12]:
url = state.search(sql="select DATE, OBTYPE, FILENAME, TARGET, BJD, BCVEL from FILES where TARGET like 'HD185144';")

IFrame(url, 700,  325)
Out[12]:

Templates and B-stars

Another subset that comes up is matching B-Star observations with the template observations they will be used with. This can be many to many so the easiest quick look is just to list out all B-star and Template observations in time order and then match visually:

select DATE, OBTYPE, FILENAME, TARGET, BJD from FILES where OBTYPE like 'TEMPLATE' or OBTYPE like 'B Star';

The resulting records are shown below.

In [13]:
url = state.search(sql="select DATE, OBTYPE, FILENAME, TARGET, BJD from FILES where OBTYPE like 'TEMPLATE' or OBTYPE like 'B Star';")

IFrame(url, 700,  325)
Out[13]:

RV Pipeline Processing

This shows that on 12/31/2009 three separate RV observations were made of HD185144 followed by five template observations (which the pipeline will combine into a single template). Five years later, another three RV observations were made.

As with the data download, the further reduction steps in the pipeline can be quite lengthy (minutes to hours each), so rather than have the user monitor each one, we provide a scripting mechanism so complex reduction jobs can be submitted in on shot.

In order to turn any of the RV observations into an RV value, we need the template. So we will generate that first. Since it is possible to repeat the template observations on more than one day, we need to explicitly state which object and which day. The script command for this is:

template 185144 20091231

To reduce an RV measurement, we have to refer to this template (the target name is enough) and specify which file to reduce. For example:

rv 185144 r20091231.7

Finally, once we have a set of RV measurements for an object, we a generate an RV curve (the pipeline finds all the appropriate RV measurements):

rvcurve 185144

As long as we follow the general rules that we need a template before we can reduce an RV measurement and we need at least three RV measurements before we can generate an RV curve, we can otherwise scripte things in whatever order we wish (e.g. all the templates first).

All of this is submitted to the pipeline as a text script:

In [10]:
from hiresprv.idldriver import Idldriver

idl = Idldriver('prv.cookies')

rtn = idl.run_script("""
template 185144 20091231
rv 185144 r20091231.72
rv 185144 r20091231.73
rv 185144 r20091231.74
rv 185144 r20150606.145
rv 185144 r20150606.146
rv 185144 r20150606.147
rvcurve 185144
""")

print(rtn)
status= ok
msg= Script running in background. Consult monitor for status.
None

Monitoring (again)

To monitor the pipeline processing request, the best idea is to use the same monitor page from above. It stops whenever a given script is finished but you can restart it any time to see the currently-running job. You can also insert a monitor start-up or status polling call here as well.

Product Retrieval

There is a utility function for retrieving the RV curves (CSV files) for each target (similarly, there is a function -- data.spectrum -- for retrieving the 1D FITS spectrum files).

In [5]:
from hiresprv.download import Download

data = Download('prv.cookies')

rtn = data.rvcurve('185144')

with open('vst185144.csv', 'r') as file:
  for line in file:
    print(line, end='')
BJD_TDB,RV,RV_ERR,BC,ADU,CHI2
15196.69208800001,-2.860674413602231,0.789710,-4620.095214843750,52362,1.05080
15196.69270200003,1.730315543645411,0.812607,-4620.210937500000,51591,1.04891
15196.69329199987,1.431450932849171,0.803164,-4620.320800781250,48950,1.05804
17180.10972899990,-2.845576383390323,0.890091,3189.794921875000,55029,1.10542
17180.11030799989,1.235438116773508,0.825978,3189.327880859375,55717,1.10771
17180.11088699987,1.047083913731319,0.828699,3188.863037109375,48769,1.10120

Ancillary Tools

Workspace Directory Listing

We can get a list of all the downloadable files in the workspace. There are utility functions (below) for quickly downloading the final products but we often want to see the intermediate products to evaluate/diagnose the processing.

In [7]:
import json
from hiresprv.download import Download

data = Download('prv.cookies')

listing = data.directory_listing()

print(json.dumps(listing, indent=4, sort_keys=True))
{
    "database": "prvState.db",
    "deblazed": [
        "deblazed/r20091231.232.fits",
        "deblazed/r20150606.140.fits",
        "deblazed/r20091231.8.fits",
        "deblazed/r20091231.177.fits",
        "deblazed/r20150606.79.fits",
        "deblazed/r20091231.146.fits",
        "deblazed/r20091231.89.fits",
        "deblazed/r20091231.248.fits",
        "deblazed/r20091231.203.fits",
        "deblazed/r20150606.90.fits",
        "deblazed/r20150606.4.fits",
        "deblazed/r20091231.124.fits",
        "deblazed/r20091231.288.fits",
        "deblazed/r20150606.158.fits",
        "deblazed/r20091231.186.fits",
        "deblazed/r20091231.261.fits",
        "deblazed/r20150606.113.fits",
        "deblazed/r20150606.122.fits",
        "deblazed/r20091231.250.fits",
        "deblazed/r20091231.78.fits",
        "deblazed/r20150606.88.fits",
        "deblazed/r20150606.61.fits",
        "deblazed/r20091231.115.fits",
        "deblazed/r20091231.91.fits",
        "deblazed/r20091231.109.fits",
        "deblazed/r20091231.142.fits",
        "deblazed/r20091231.207.fits",
        "deblazed/r20150606.94.fits",
        "deblazed/r20150606.144.fits",
        "deblazed/r20091231.236.fits",
        "deblazed/r20091231.173.fits",
        "deblazed/r20091231.138.fits",
        "deblazed/r20091231.254.fits",
        "deblazed/r20150606.126.fits",
        "deblazed/r20091231.95.fits",
        "deblazed/r20091231.111.fits",
        "deblazed/r20150606.65.fits",
        "deblazed/r20091231.120.fits",
        "deblazed/r20150606.117.fits",
        "deblazed/r20091231.265.fits",
        "deblazed/r20091231.182.fits",
        "deblazed/r20091231.167.fits",
        "deblazed/r20091231.269.fits",
        "deblazed/r20091231.222.fits",
        "deblazed/r20150606.150.fits",
        "deblazed/r20150606.80.fits",
        "deblazed/r20150606.161.fits",
        "deblazed/r20091231.213.fits",
        "deblazed/r20091231.258.fits",
        "deblazed/r20091231.70.fits",
        "deblazed/r20091231.99.fits",
        "deblazed/r20091231.156.fits",
        "deblazed/r20150606.69.fits",
        "deblazed/r20091231.271.fits",
        "deblazed/r20150606.103.fits",
        "deblazed/r20091231.12.fits",
        "deblazed/r20091231.196.fits",
        "deblazed/r20150606.148.fits",
        "deblazed/r20091231.134.fits",
        "deblazed/r20091231.81.fits",
        "deblazed/r20091231.105.fits",
        "deblazed/r20150606.71.fits",
        "deblazed/r20150606.98.fits",
        "deblazed/r20091231.68.fits",
        "deblazed/r20150606.132.fits",
        "deblazed/r20091231.240.fits",
        "deblazed/r20091231.74.fits",
        "deblazed/r20150606.84.fits",
        "deblazed/r20091231.217.fits",
        "deblazed/r20150606.165.fits",
        "deblazed/r20091231.152.fits",
        "deblazed/r20091231.119.fits",
        "deblazed/r20091231.128.fits",
        "deblazed/r20091231.284.fits",
        "deblazed/r20091231.163.fits",
        "deblazed/r20150606.154.fits",
        "deblazed/r20091231.226.fits",
        "deblazed/r20150606.75.fits",
        "deblazed/r20091231.101.fits",
        "deblazed/r20091231.85.fits",
        "deblazed/r20150606.8.fits",
        "deblazed/r20091231.244.fits",
        "deblazed/r20150606.136.fits",
        "deblazed/r20091231.4.fits",
        "deblazed/r20091231.192.fits",
        "deblazed/r20091231.16.fits",
        "deblazed/r20150606.107.fits",
        "deblazed/r20091231.275.fits",
        "deblazed/r20091231.130.fits",
        "deblazed/r20091231.166.fits",
        "deblazed/r20150606.151.fits",
        "deblazed/r20091231.223.fits",
        "deblazed/r20091231.268.fits",
        "deblazed/r20091231.259.fits",
        "deblazed/r20091231.71.fits",
        "deblazed/r20150606.81.fits",
        "deblazed/r20091231.212.fits",
        "deblazed/r20150606.160.fits",
        "deblazed/r20091231.157.fits",
        "deblazed/r20150606.68.fits",
        "deblazed/r20091231.98.fits",
        "deblazed/r20091231.13.fits",
        "deblazed/r20091231.197.fits",
        "deblazed/r20150606.149.fits",
        "deblazed/r20091231.1.fits",
        "deblazed/r20150606.102.fits",
        "deblazed/r20091231.270.fits",
        "deblazed/r20091231.135.fits",
        "deblazed/r20150606.70.fits",
        "deblazed/r20091231.80.fits",
        "deblazed/r20091231.104.fits",
        "deblazed/r20091231.69.fits",
        "deblazed/r20091231.241.fits",
        "deblazed/r20150606.133.fits",
        "deblazed/r20150606.99.fits",
        "deblazed/r20150606.85.fits",
        "deblazed/r20150606.164.fits",
        "deblazed/r20091231.216.fits",
        "deblazed/r20091231.75.fits",
        "deblazed/r20091231.118.fits",
        "deblazed/r20091231.153.fits",
        "deblazed/r20091231.162.fits",
        "deblazed/r20091231.129.fits",
        "deblazed/r20091231.285.fits",
        "deblazed/r20091231.227.fits",
        "deblazed/r20150606.155.fits",
        "deblazed/r20091231.100.fits",
        "deblazed/r20091231.84.fits",
        "deblazed/r20150606.74.fits",
        "deblazed/r20150606.137.fits",
        "deblazed/r20091231.245.fits",
        "deblazed/r20150606.9.fits",
        "deblazed/r20091231.274.fits",
        "deblazed/r20150606.106.fits",
        "deblazed/r20091231.5.fits",
        "deblazed/r20091231.193.fits",
        "deblazed/r20091231.17.fits",
        "deblazed/r20091231.131.fits",
        "deblazed/r20091231.278.fits",
        "deblazed/r20150606.141.fits",
        "deblazed/r20091231.233.fits",
        "deblazed/r20091231.9.fits",
        "deblazed/r20091231.176.fits",
        "deblazed/r20091231.88.fits",
        "deblazed/r20150606.78.fits",
        "deblazed/r20091231.147.fits",
        "deblazed/r20150606.5.fits",
        "deblazed/r20091231.202.fits",
        "deblazed/r20150606.91.fits",
        "deblazed/r20091231.249.fits",
        "deblazed/r20091231.125.fits",
        "deblazed/r20150606.112.fits",
        "deblazed/r20091231.260.fits",
        "deblazed/r20150606.159.fits",
        "deblazed/r20091231.187.fits",
        "deblazed/r20150606.89.fits",
        "deblazed/r20091231.251.fits",
        "deblazed/r20150606.123.fits",
        "deblazed/r20091231.79.fits",
        "deblazed/r20091231.114.fits",
        "deblazed/r20091231.90.fits",
        "deblazed/r20091231.143.fits",
        "deblazed/r20091231.108.fits",
        "deblazed/r20150606.1.fits",
        "deblazed/r20091231.206.fits",
        "deblazed/r20150606.95.fits",
        "deblazed/r20091231.237.fits",
        "deblazed/r20150606.145.fits",
        "deblazed/r20091231.139.fits",
        "deblazed/r20091231.172.fits",
        "deblazed/r20150606.127.fits",
        "deblazed/r20091231.255.fits",
        "deblazed/r20150606.64.fits",
        "deblazed/r20091231.94.fits",
        "deblazed/r20091231.110.fits",
        "deblazed/r20091231.121.fits",
        "deblazed/r20091231.183.fits",
        "deblazed/r20091231.264.fits",
        "deblazed/r20150606.116.fits",
        "deblazed/r20091231.221.fits",
        "deblazed/r20150606.153.fits",
        "deblazed/r20150606.118.fits",
        "deblazed/r20150606.10.fits",
        "deblazed/r20091231.283.fits",
        "deblazed/r20091231.164.fits",
        "deblazed/r20091231.155.fits",
        "deblazed/r20150606.129.fits",
        "deblazed/r20091231.73.fits",
        "deblazed/r20150606.83.fits",
        "deblazed/r20150606.162.fits",
        "deblazed/r20091231.210.fits",
        "deblazed/r20091231.137.fits",
        "deblazed/r20091231.195.fits",
        "deblazed/r20091231.11.fits",
        "deblazed/r20091231.239.fits",
        "deblazed/r20091231.3.fits",
        "deblazed/r20091231.272.fits",
        "deblazed/r20150606.100.fits",
        "deblazed/r20150606.131.fits",
        "deblazed/r20091231.243.fits",
        "deblazed/r20091231.208.fits",
        "deblazed/r20150606.72.fits",
        "deblazed/r20091231.106.fits",
        "deblazed/r20091231.82.fits",
        "deblazed/r20091231.151.fits",
        "deblazed/r20150606.87.fits",
        "deblazed/r20091231.214.fits",
        "deblazed/r20150606.166.fits",
        "deblazed/r20091231.77.fits",
        "deblazed/r20150606.157.fits",
        "deblazed/r20091231.225.fits",
        "deblazed/r20091231.189.fits",
        "deblazed/r20091231.160.fits",
        "deblazed/r20091231.287.fits",
        "deblazed/r20091231.247.fits",
        "deblazed/r20150606.135.fits",
        "deblazed/r20091231.86.fits",
        "deblazed/r20091231.102.fits",
        "deblazed/r20150606.76.fits",
        "deblazed/r20091231.149.fits",
        "deblazed/r20091231.178.fits",
        "deblazed/r20091231.133.fits",
        "deblazed/r20150606.104.fits",
        "deblazed/r20091231.276.fits",
        "deblazed/r20091231.7.fits",
        "deblazed/r20091231.15.fits",
        "deblazed/r20091231.191.fits",
        "deblazed/r20091231.174.fits",
        "deblazed/r20150606.108.fits",
        "deblazed/r20091231.19.fits",
        "deblazed/r20091231.231.fits",
        "deblazed/r20150606.143.fits",
        "deblazed/r20091231.200.fits",
        "deblazed/r20150606.93.fits",
        "deblazed/r20150606.139.fits",
        "deblazed/r20150606.7.fits",
        "deblazed/r20091231.145.fits",
        "deblazed/r20091231.262.fits",
        "deblazed/r20150606.110.fits",
        "deblazed/r20091231.229.fits",
        "deblazed/r20091231.185.fits",
        "deblazed/r20091231.127.fits",
        "deblazed/r20091231.92.fits",
        "deblazed/r20091231.116.fits",
        "deblazed/r20150606.62.fits",
        "deblazed/r20091231.218.fits",
        "deblazed/r20150606.121.fits",
        "deblazed/r20091231.253.fits",
        "deblazed/r20091231.67.fits",
        "deblazed/r20091231.204.fits",
        "deblazed/r20150606.97.fits",
        "deblazed/r20150606.3.fits",
        "deblazed/r20091231.141.fits",
        "deblazed/r20091231.170.fits",
        "deblazed/r20091231.199.fits",
        "deblazed/r20150606.147.fits",
        "deblazed/r20091231.235.fits",
        "deblazed/r20091231.159.fits",
        "deblazed/r20150606.66.fits",
        "deblazed/r20091231.112.fits",
        "deblazed/r20091231.96.fits",
        "deblazed/r20091231.257.fits",
        "deblazed/r20150606.125.fits",
        "deblazed/r20091231.181.fits",
        "deblazed/r20150606.114.fits",
        "deblazed/r20091231.266.fits",
        "deblazed/r20091231.123.fits",
        "deblazed/r20091231.168.fits",
        "deblazed/r20091231.175.fits",
        "deblazed/r20091231.18.fits",
        "deblazed/r20150606.142.fits",
        "deblazed/r20091231.230.fits",
        "deblazed/r20150606.109.fits",
        "deblazed/r20150606.6.fits",
        "deblazed/r20150606.138.fits",
        "deblazed/r20091231.201.fits",
        "deblazed/r20150606.92.fits",
        "deblazed/r20091231.144.fits",
        "deblazed/r20091231.228.fits",
        "deblazed/r20091231.184.fits",
        "deblazed/r20150606.111.fits",
        "deblazed/r20091231.263.fits",
        "deblazed/r20091231.126.fits",
        "deblazed/r20150606.63.fits",
        "deblazed/r20091231.93.fits",
        "deblazed/r20091231.117.fits",
        "deblazed/r20091231.252.fits",
        "deblazed/r20150606.120.fits",
        "deblazed/r20091231.219.fits",
        "deblazed/r20150606.2.fits",
        "deblazed/r20091231.205.fits",
        "deblazed/r20150606.96.fits",
        "deblazed/r20091231.66.fits",
        "deblazed/r20091231.140.fits",
        "deblazed/r20091231.171.fits",
        "deblazed/r20091231.198.fits",
        "deblazed/r20091231.234.fits",
        "deblazed/r20150606.146.fits",
        "deblazed/r20091231.113.fits",
        "deblazed/r20091231.97.fits",
        "deblazed/r20091231.158.fits",
        "deblazed/r20150606.67.fits",
        "deblazed/r20150606.124.fits",
        "deblazed/r20091231.256.fits",
        "deblazed/r20091231.267.fits",
        "deblazed/r20150606.115.fits",
        "deblazed/r20091231.180.fits",
        "deblazed/r20091231.169.fits",
        "deblazed/r20091231.122.fits",
        "deblazed/r20150606.119.fits",
        "deblazed/r20150606.152.fits",
        "deblazed/r20091231.220.fits",
        "deblazed/r20091231.165.fits",
        "deblazed/r20091231.154.fits",
        "deblazed/r20150606.82.fits",
        "deblazed/r20091231.211.fits",
        "deblazed/r20150606.128.fits",
        "deblazed/r20091231.72.fits",
        "deblazed/r20091231.136.fits",
        "deblazed/r20150606.101.fits",
        "deblazed/r20091231.273.fits",
        "deblazed/r20091231.194.fits",
        "deblazed/r20091231.10.fits",
        "deblazed/r20091231.238.fits",
        "deblazed/r20091231.2.fits",
        "deblazed/r20091231.209.fits",
        "deblazed/r20091231.242.fits",
        "deblazed/r20150606.130.fits",
        "deblazed/r20091231.107.fits",
        "deblazed/r20091231.83.fits",
        "deblazed/r20150606.73.fits",
        "deblazed/r20091231.150.fits",
        "deblazed/r20091231.76.fits",
        "deblazed/r20150606.86.fits",
        "deblazed/r20091231.215.fits",
        "deblazed/r20091231.224.fits",
        "deblazed/r20150606.156.fits",
        "deblazed/r20091231.188.fits",
        "deblazed/r20091231.286.fits",
        "deblazed/r20091231.161.fits",
        "deblazed/r20150606.134.fits",
        "deblazed/r20091231.246.fits",
        "deblazed/r20150606.77.fits",
        "deblazed/r20091231.148.fits",
        "deblazed/r20091231.87.fits",
        "deblazed/r20091231.103.fits",
        "deblazed/r20091231.132.fits",
        "deblazed/r20091231.179.fits",
        "deblazed/r20091231.6.fits",
        "deblazed/r20091231.14.fits",
        "deblazed/r20091231.190.fits",
        "deblazed/r20091231.277.fits",
        "deblazed/r20150606.105.fits"
    ],
    "dnloadlog": [
        "dnloadlog/20130912.json",
        "dnloadlog/20091231.json",
        "dnloadlog/20150606.json",
        "dnloadlog/20130629.json"
    ],
    "files": [
        "files/vst185144.csv"
    ],
    "fits": [
        "fits/r20091231.19.fits",
        "fits/r20091231.278.fits",
        "fits/r20150606.141.fits",
        "fits/r20091231.233.fits",
        "fits/r20091231.3.fits",
        "fits/r20091231.176.fits",
        "fits/r20091231.147.fits",
        "fits/r20091231.202.fits",
        "fits/r20091231.249.fits",
        "fits/r20150606.93.fits",
        "fits/r20091231.125.fits",
        "fits/r20150606.112.fits",
        "fits/r20091231.260.fits",
        "fits/r20091231.187.fits",
        "fits/r20150606.159.fits",
        "fits/r20091231.251.fits",
        "fits/r20150606.123.fits",
        "fits/r20091231.114.fits",
        "fits/r20150606.62.fits",
        "fits/r20091231.92.fits",
        "fits/r20091231.143.fits",
        "fits/r20091231.108.fits",
        "fits/r20150606.97.fits",
        "fits/r20091231.67.fits",
        "fits/r20091231.206.fits",
        "fits/r20091231.237.fits",
        "fits/r20150606.145.fits",
        "fits/r20091231.7.fits",
        "fits/r20091231.139.fits",
        "fits/r20091231.172.fits",
        "fits/r20150606.127.fits",
        "fits/r20091231.255.fits",
        "fits/r20091231.96.fits",
        "fits/r20091231.110.fits",
        "fits/r20150606.66.fits",
        "fits/r20091231.121.fits",
        "fits/r20091231.183.fits",
        "fits/r20091231.264.fits",
        "fits/r20150606.116.fits",
        "fits/r20091231.166.fits",
        "fits/r20150606.10.fits",
        "fits/r20150606.151.fits",
        "fits/r20091231.223.fits",
        "fits/r20091231.268.fits",
        "fits/r20150606.83.fits",
        "fits/r20091231.259.fits",
        "fits/r20091231.212.fits",
        "fits/r20150606.160.fits",
        "fits/r20091231.73.fits",
        "fits/r20091231.157.fits",
        "fits/r20150606.149.fits",
        "fits/r20091231.197.fits",
        "fits/r20150606.102.fits",
        "fits/r20091231.270.fits",
        "fits/r20091231.11.fits",
        "fits/r20091231.135.fits",
        "fits/r20091231.82.fits",
        "fits/r20150606.7.fits",
        "fits/r20150606.72.fits",
        "fits/r20091231.104.fits",
        "fits/r20091231.241.fits",
        "fits/r20150606.133.fits",
        "fits/r20150606.164.fits",
        "fits/r20091231.216.fits",
        "fits/r20091231.77.fits",
        "fits/r20150606.87.fits",
        "fits/r20091231.118.fits",
        "fits/r20091231.153.fits",
        "fits/r20091231.162.fits",
        "fits/r20091231.285.fits",
        "fits/r20091231.129.fits",
        "fits/r20091231.227.fits",
        "fits/r20150606.155.fits",
        "fits/r20150606.76.fits",
        "fits/r20091231.100.fits",
        "fits/r20150606.3.fits",
        "fits/r20091231.86.fits",
        "fits/r20150606.137.fits",
        "fits/r20091231.245.fits",
        "fits/r20091231.274.fits",
        "fits/r20150606.106.fits",
        "fits/r20091231.15.fits",
        "fits/r20091231.193.fits",
        "fits/r20091231.131.fits",
        "fits/r20091231.167.fits",
        "fits/r20091231.269.fits",
        "fits/r20091231.222.fits",
        "fits/r20150606.150.fits",
        "fits/r20091231.72.fits",
        "fits/r20150606.161.fits",
        "fits/r20091231.213.fits",
        "fits/r20091231.258.fits",
        "fits/r20150606.82.fits",
        "fits/r20091231.156.fits",
        "fits/r20091231.10.fits",
        "fits/r20091231.271.fits",
        "fits/r20150606.103.fits",
        "fits/r20150606.148.fits",
        "fits/r20091231.196.fits",
        "fits/r20091231.134.fits",
        "fits/r20150606.73.fits",
        "fits/r20091231.105.fits",
        "fits/r20091231.83.fits",
        "fits/r20150606.6.fits",
        "fits/r20150606.132.fits",
        "fits/r20091231.240.fits",
        "fits/r20150606.86.fits",
        "fits/r20091231.76.fits",
        "fits/r20091231.217.fits",
        "fits/r20150606.165.fits",
        "fits/r20091231.152.fits",
        "fits/r20091231.119.fits",
        "fits/r20091231.284.fits",
        "fits/r20091231.128.fits",
        "fits/r20091231.163.fits",
        "fits/r20150606.154.fits",
        "fits/r20091231.226.fits",
        "fits/r20150606.2.fits",
        "fits/r20091231.87.fits",
        "fits/r20150606.77.fits",
        "fits/r20091231.101.fits",
        "fits/r20091231.244.fits",
        "fits/r20150606.136.fits",
        "fits/r20091231.192.fits",
        "fits/r20091231.14.fits",
        "fits/r20150606.107.fits",
        "fits/r20091231.275.fits",
        "fits/r20091231.130.fits",
        "fits/r20091231.232.fits",
        "fits/r20150606.140.fits",
        "fits/r20091231.18.fits",
        "fits/r20091231.177.fits",
        "fits/r20091231.2.fits",
        "fits/r20091231.146.fits",
        "fits/r20150606.92.fits",
        "fits/r20091231.248.fits",
        "fits/r20091231.203.fits",
        "fits/r20091231.288.fits",
        "fits/r20091231.124.fits",
        "fits/r20091231.186.fits",
        "fits/r20150606.158.fits",
        "fits/r20091231.261.fits",
        "fits/r20150606.113.fits",
        "fits/r20150606.122.fits",
        "fits/r20091231.250.fits",
        "fits/r20091231.93.fits",
        "fits/r20091231.115.fits",
        "fits/r20150606.63.fits",
        "fits/r20091231.109.fits",
        "fits/r20091231.142.fits",
        "fits/r20091231.207.fits",
        "fits/r20091231.66.fits",
        "fits/r20150606.96.fits",
        "fits/r20150606.144.fits",
        "fits/r20091231.236.fits",
        "fits/r20091231.173.fits",
        "fits/r20091231.138.fits",
        "fits/r20091231.6.fits",
        "fits/r20091231.254.fits",
        "fits/r20150606.126.fits",
        "fits/r20091231.111.fits",
        "fits/r20150606.67.fits",
        "fits/r20091231.97.fits",
        "fits/r20091231.120.fits",
        "fits/r20150606.117.fits",
        "fits/r20091231.265.fits",
        "fits/r20091231.182.fits",
        "fits/r20150606.119.fits",
        "fits/r20150606.152.fits",
        "fits/r20091231.220.fits",
        "fits/r20091231.165.fits",
        "fits/r20150606.69.fits",
        "fits/r20091231.99.fits",
        "fits/r20091231.154.fits",
        "fits/r20091231.70.fits",
        "fits/r20091231.211.fits",
        "fits/r20150606.128.fits",
        "fits/r20150606.80.fits",
        "fits/r20091231.136.fits",
        "fits/r20091231.8.fits",
        "fits/r20091231.12.fits",
        "fits/r20150606.101.fits",
        "fits/r20091231.273.fits",
        "fits/r20091231.238.fits",
        "fits/r20091231.194.fits",
        "fits/r20091231.68.fits",
        "fits/r20091231.209.fits",
        "fits/r20091231.242.fits",
        "fits/r20150606.130.fits",
        "fits/r20150606.98.fits",
        "fits/r20150606.71.fits",
        "fits/r20091231.107.fits",
        "fits/r20091231.81.fits",
        "fits/r20150606.4.fits",
        "fits/r20091231.150.fits",
        "fits/r20150606.84.fits",
        "fits/r20091231.74.fits",
        "fits/r20091231.215.fits",
        "fits/r20091231.188.fits",
        "fits/r20091231.224.fits",
        "fits/r20150606.156.fits",
        "fits/r20091231.286.fits",
        "fits/r20091231.161.fits",
        "fits/r20150606.134.fits",
        "fits/r20091231.246.fits",
        "fits/r20091231.148.fits",
        "fits/r20091231.85.fits",
        "fits/r20150606.75.fits",
        "fits/r20091231.103.fits",
        "fits/r20091231.132.fits",
        "fits/r20091231.179.fits",
        "fits/r20091231.190.fits",
        "fits/r20091231.16.fits",
        "fits/r20091231.277.fits",
        "fits/r20150606.105.fits",
        "fits/r20091231.175.fits",
        "fits/r20150606.142.fits",
        "fits/r20091231.230.fits",
        "fits/r20150606.109.fits",
        "fits/r20150606.90.fits",
        "fits/r20150606.138.fits",
        "fits/r20091231.201.fits",
        "fits/r20091231.144.fits",
        "fits/r20091231.89.fits",
        "fits/r20150606.79.fits",
        "fits/r20091231.184.fits",
        "fits/r20091231.228.fits",
        "fits/r20150606.111.fits",
        "fits/r20091231.263.fits",
        "fits/r20091231.126.fits",
        "fits/r20091231.91.fits",
        "fits/r20091231.117.fits",
        "fits/r20150606.61.fits",
        "fits/r20150606.88.fits",
        "fits/r20091231.252.fits",
        "fits/r20150606.120.fits",
        "fits/r20091231.219.fits",
        "fits/r20091231.78.fits",
        "fits/r20091231.205.fits",
        "fits/r20150606.94.fits",
        "fits/r20150606.8.fits",
        "fits/r20091231.140.fits",
        "fits/r20091231.4.fits",
        "fits/r20091231.171.fits",
        "fits/r20091231.234.fits",
        "fits/r20150606.146.fits",
        "fits/r20091231.198.fits",
        "fits/r20091231.113.fits",
        "fits/r20150606.65.fits",
        "fits/r20091231.95.fits",
        "fits/r20091231.158.fits",
        "fits/r20150606.124.fits",
        "fits/r20091231.256.fits",
        "fits/r20091231.267.fits",
        "fits/r20150606.115.fits",
        "fits/r20091231.180.fits",
        "fits/r20091231.169.fits",
        "fits/r20091231.122.fits",
        "fits/r20091231.174.fits",
        "fits/r20091231.1.fits",
        "fits/r20150606.108.fits",
        "fits/r20091231.231.fits",
        "fits/r20150606.143.fits",
        "fits/r20091231.200.fits",
        "fits/r20150606.139.fits",
        "fits/r20150606.91.fits",
        "fits/r20150606.78.fits",
        "fits/r20091231.145.fits",
        "fits/r20091231.88.fits",
        "fits/r20091231.262.fits",
        "fits/r20150606.110.fits",
        "fits/r20091231.185.fits",
        "fits/r20091231.229.fits",
        "fits/r20091231.127.fits",
        "fits/r20091231.116.fits",
        "fits/r20091231.90.fits",
        "fits/r20091231.79.fits",
        "fits/r20091231.218.fits",
        "fits/r20150606.121.fits",
        "fits/r20091231.253.fits",
        "fits/r20150606.89.fits",
        "fits/r20150606.95.fits",
        "fits/r20091231.204.fits",
        "fits/r20150606.9.fits",
        "fits/r20091231.141.fits",
        "fits/r20091231.170.fits",
        "fits/r20091231.5.fits",
        "fits/r20150606.147.fits",
        "fits/r20091231.235.fits",
        "fits/r20091231.199.fits",
        "fits/r20091231.94.fits",
        "fits/r20091231.159.fits",
        "fits/r20091231.112.fits",
        "fits/r20150606.64.fits",
        "fits/r20091231.257.fits",
        "fits/r20150606.125.fits",
        "fits/r20091231.181.fits",
        "fits/r20150606.114.fits",
        "fits/r20091231.266.fits",
        "fits/r20091231.123.fits",
        "fits/r20091231.168.fits",
        "fits/r20091231.221.fits",
        "fits/r20150606.153.fits",
        "fits/r20150606.118.fits",
        "fits/r20091231.283.fits",
        "fits/r20091231.164.fits",
        "fits/r20091231.98.fits",
        "fits/r20091231.155.fits",
        "fits/r20150606.68.fits",
        "fits/r20150606.81.fits",
        "fits/r20150606.129.fits",
        "fits/r20150606.162.fits",
        "fits/r20091231.210.fits",
        "fits/r20091231.71.fits",
        "fits/r20091231.9.fits",
        "fits/r20091231.137.fits",
        "fits/r20091231.239.fits",
        "fits/r20091231.195.fits",
        "fits/r20091231.272.fits",
        "fits/r20150606.100.fits",
        "fits/r20091231.13.fits",
        "fits/r20150606.99.fits",
        "fits/r20150606.131.fits",
        "fits/r20091231.243.fits",
        "fits/r20091231.208.fits",
        "fits/r20091231.69.fits",
        "fits/r20091231.80.fits",
        "fits/r20150606.5.fits",
        "fits/r20150606.70.fits",
        "fits/r20091231.106.fits",
        "fits/r20091231.151.fits",
        "fits/r20091231.214.fits",
        "fits/r20150606.166.fits",
        "fits/r20091231.75.fits",
        "fits/r20150606.85.fits",
        "fits/r20091231.189.fits",
        "fits/r20150606.157.fits",
        "fits/r20091231.225.fits",
        "fits/r20091231.160.fits",
        "fits/r20091231.287.fits",
        "fits/r20091231.247.fits",
        "fits/r20150606.135.fits",
        "fits/r20150606.74.fits",
        "fits/r20091231.102.fits",
        "fits/r20150606.1.fits",
        "fits/r20091231.149.fits",
        "fits/r20091231.84.fits",
        "fits/r20091231.178.fits",
        "fits/r20091231.133.fits",
        "fits/r20150606.104.fits",
        "fits/r20091231.276.fits",
        "fits/r20091231.17.fits",
        "fits/r20091231.191.fits"
    ],
    "idllog": [
        "idllog/idlDebug.2019-05-15T14:55:03.txt",
        "idllog/idlDebug.2019-05-15T14:34:43.txt",
        "idllog/idlDebug.2019-05-15T16:30:20.txt",
        "idllog/idlDebug.2019-05-15T15:18:05.txt",
        "idllog/idlDebug.2019-05-15T14:57:24.txt"
    ],
    "logsheets": [
        "logsheets/20091231.logsheet1",
        "logsheets/20150606.logsheet1"
    ],
    "rv": [],
    "statuslog": [
        "statuslog/status.2019-05-15T14:34:43.txt",
        "statuslog/status.2019-05-15T14:55:03.txt",
        "statuslog/status.2019-05-15T16:30:20.txt",
        "statuslog/status.2019-05-15T15:18:05.txt",
        "statuslog/status.2019-05-16T07:34:14.txt",
        "statuslog/status.2019-05-15T14:57:24.txt"
    ]
}

File Download

Any of the files in the listing can be retrieved by name.

In [2]:
from hiresprv.download import Download

data = Download('prv.cookies')

rtn = data.download('deblazed/r20091231.238.fits', 'deblazed_example.fits')

print(rtn)
{'status': 'ok', 'msg': ''}

Augmented Processing

There are no tunable parameters associated with the HIRES PRV pipeline. However, you can affect the processing in a couple of places by "removing" files (usually because there is something suspect about them. For instance, a bad B-star file can adversely affect the stellar template calculation so you man want to rerun the template building without it. We don't actually delete the file; we deactivate it but leave it in place in case you change your mind.

Similarly, in making the final RV curve you may decide to remove one or more of the reduced RV measurements.

Deactivating Files

Sometimes it turns out that a data file is suboptimal and should probably be removed from the processing. It might be a B-star observation bracketing a template measurement or one of the RV observation that should be removed from an RV curve.

The PRV service takes responsibility for remembering what files have been processed and for providing a mechanism (the "DEACTIVATED" column in the database) for "turning off" specific files. It does not automatically redo all the affected downstream processing. That is left up to the user so it is best to take care of all of that as soon as possible.

In this example, we will turn off one of the B-star observations. This requires regenerating the template(s) it applies:

In [14]:
from hiresprv.idldriver import Idldriver

idl = Idldriver('prv.cookies')

rtn = idl.run_script("""
deactivate r20091231.77
template 185144 20091231
""")

print(rtn)
status= ok
msg= Script running in background. Consult monitor for status.
None

Having regenerated the template, we must therefore regenerate the downstream data (RVs and RV curve). The underlying processing code is smart enough to not regenerate the reduced RV data if that file already exists so we need to first remove the reduced RV files:

In [4]:
from hiresprv.idldriver import Idldriver

idl = Idldriver('prv.cookies')

rtn = idl.run_script("""
deactivate vdaa185144_r20091231.72
deactivate vdaa185144_r20091231.73
deactivate vdaa185144_r20091231.74
deactivate vdaa185144_r20150606.145
deactivate vdaa185144_r20150606.146
deactivate vdaa185144_r20150606.147
rv 185144 r20091231.72
rv 185144 r20091231.73
rv 185144 r20091231.74
rv 185144 r20150606.145
rv 185144 r20150606.146
rv 185144 r20150606.147
rvcurve 185144
""")

print(rtn)
status= ok
msg= Script running in background. Consult monitor for status.
None

After further consideration, we decide that the second RV measurement was of inferior quality, so we deactivate it, too. You can find the name of the reduced RV file by listing out the full database again or by doing a database search (if you look a the file name, it follows a simple pattern):

In [14]:
url = state.search(sql="select DATE, OBTYPE, FILENAME, TARGET, BJD, BCVEL from FILES where TARGET like 'rv data';")

IFrame(url, 700,  325)
Out[14]:
In [6]:
from hiresprv.idldriver import Idldriver

idl = Idldriver('prv.cookies')

rtn = idl.run_script("""
deactivate vdaa185144_r20091231.73
rvcurve 185144
""")

print(rtn)
status= ok
msg= Script running in background. Consult monitor for status.
None

So now we have only five reduced RV measurements and they were reduced with a slightly different template measurement. This is reflected in the RV curve, which you can compare to the original:

In [8]:
from hiresprv.download import Download

data = Download('prv.cookies')

rtn = data.rvcurve('185144')

with open('vst185144.csv', 'r') as file:
  for line in file:
    print(line, end='')
BJD_TDB,RV,RV_ERR,BC,ADU,CHI2
15196.69208800001,-2.176984931266687,0.782362,-4620.095214843750,52362,1.04989
15196.69329199987,2.082068283340939,0.778802,-4620.320800781250,48950,1.05804
17180.10972899990,-2.351030457353758,0.769511,3189.794921875000,55029,1.10542
17180.11030799989,1.241724284090688,0.678055,3189.327880859375,55593,1.10771
17180.11088699987,0.9359797393606732,0.686433,3188.863037109375,48769,1.10120