# Run the wavelength calibration¶

This is the basic usage with sample files:

Example:

1. CRSA00000001.fits is a 1550-nm monochromatic flat taken in broadband/lowres mode
2. CRSA00000002.fits through CRSA00000005.fits are broadband/lowres darks
3. CRSA10000000.fits is a science frame in broadband/lowres mode

First, we must build the calibration files. Create a directory where they will live, make this the current working directory, and run

buildcal /path/to/CRSA00000001.fits /path/to/CRSA0000000[2-5].fits


Follow the prompts to create (or not) oversampled PSFlet images. We recommend building them for any science analysis - not building them takes less time but is faster. This routine will create calibration files in the current working directory. The arguments to buildcal are:

1. The monochromatic flat, as a raw sequence of CHARIS reads
2. Background frame(s)/dark(s) (optional)

The prompt from buildcal can look like this (with no background files):

***********************************************************
************************************************************
Mode detected: lowres
Wavelength detected:  1550

************************************************************
Oversample PSFlet templates to enable fitting a subpixel offset in cube
extraction?  Cost is a factor of ~2-4 in the time to build calibrations.
************************************************************
Oversample? [Y/n]: Y

************************************************************
************************************************************
Number of threads to use [8]: 8

************************************************************
Building calibration files, placing results in current directory:
/MY_CHARIS_DIRECTORY/

Settings:

Narrow-band flatfield image: CRSA0000001.fits
Wavelength: 1550 nm
Observing mode: lowres
Upsample PSFlet templates?  True
No background will be computed.
************************************************************
Continue with these settings? [Y/n]: Y

Computing ramps from sequences of raw reads
Generating new wavelength solution
Generating narrowband template images
----------------------------------------> 100% complete
Total time elapsed: 1020 seconds


The process takes a while between a few minutes and up 30min depending on your number of cores. The parallelization will mostly take effect in the last step of the calibration. We recommend keeping a few threads free if you want to be able to operate your computer normally while buildcal is running.

## Data taken before Apr 1, 2017¶

Some of the data taken early in CHARIS’ commissioning phase do not have all the proper keywords set. Buildcal detects this and requests you to input the mode and wavelength at which the monochromatic flats were taken. The prompt will look like this:

************************************************************
The file you selected doesn't appear to have the correct header keywords set
This can happen for files taken before Apr 1st, 2017. Please enter them manually.
************************************************************
Band? [J/H/K/lowres]: lowres
Wavelength? [1200/1550/2346]: 1550

************************************************************
Oversample PSFlet templates to enable fitting a subpixel offset in cube
extraction?  Cost is a factor of ~2-4 in the time to build calibrations.
************************************************************
Oversample? [Y/n]: n

************************************************************
************************************************************
Number of threads to use [8]: 8

************************************************************
Building calibration files, placing results in current directory:
/MY_CHARIS_DIRECTORY/

Settings: