py4sci

Table Of Contents

Previous topic

phot – photometric functions

This Page

Reduction

mascara.reduction contains only the functions which are actually used by the MASCARA science team to reduce the raw images into light curves. More informations on how these functions work can be found in the Tutorial for the MASCARA reduction pipeline. The details of the functions can be found below in the Reference/APIS section.

Reference/APIS

reduction – mascara specific functions and reduction script

Overview

The reduction module contains functions used specifically for the mascara reduction pipeline. The module is composed of two submodules which are fainrly independant, and two configuration modules.

reduction.masc – a set of I/O functions:

MASCARA specific functions. It includes:
  • SiteReference, a mini-class to provide the local sidereal time at the MASCARA reference site.
  • tmpdbSave, saves a dictionary into a temporary dataframe/h5 file
  • CombineH5, combines the temporary h5 files in one big hdf5 file
  • IndexArray, build the indexes used for the various arrays
  • CombinePkl, combines pickle files into fits files
  • LCtable, makes an binary fits table with the light curves
  • LSTSEQ, to compute the lst -sequence index of mascara
  • light_curve_overview, plots a few fits files and saves the plot
  • reduction_summary, constructs from the log file a summary of the reduction
  • send_summary, send the summary via email to the meascara team
  • getDarkFilename, get the name and location of the last good masterdark
  • updateDarkFilename, write to file the name and location of the last good masterdark
mascara.reduction.masc.CombineH5(savepath, listdb, globdic, name='LPC', minobs=51)[source]

CombineH5 combines several .h5 files into one final file. It goes through the given directory, and merges the files together.

Inputs:
  • savepath, the path where to save the hdf5 file once constructed
  • listdb, a list of the temporary h5 files (including their location)
  • globdic, a header like dictionary with global inforation about the observation For instance, the site, the camera, the CCD temperature. Things that affects all the stars the same way
Keywords:
  • name, the name of the final file
  • minobs, the minimal numbers of observation points a star should have to be saved in the hdf5 file
Outputs:
  • None, the file is written to disk
mascara.reduction.masc.CombinePkl(Path, savepath, stid)[source]

CombinePkl combines several .pkl files into one final fits file. It goes through the given directory, and merges the files together.

Inputs:
  • path, the path to search for the pkl files
  • savepath, the path where to save the fits file
  • stid, an identifier for the files (to avoid mixing pkl files of 2 different stars together.
mascara.reduction.masc.LCtable(savingPath, ID, dat, header)[source]

LCtable saves the inputs into a binary fits table

Inputs:
  • the saving path
  • the ID, or name to save the file
  • the content of the file
  • the generic header
class mascara.reduction.masc.SiteReference[source]

Bases: object

SiteReference is a very simplified version of the Site class in mascara.observer Its main purpose is to compute te local sidereal time at the reference site which is located in LaPalma (but is not exactly the position of the La Palma mascara station)

local_sidereal_time(date, texp, lstindex=True, lstsequence=True, lst=True, quick=False)[source]

Compute the local sidereal time at the reference site

Inputs:
  • date, a datetime object or jd or an array of ...
  • texp, the exposure time (used for computing the index and sequence number
Outputs:
  • lst, the local sidereal time
  • lstidx, the lst index in a day
  • lstseq, the exposure sequence number since 01.01.2013
  • quick, to compute quickly the lstseq only!!! without passing via the LST the resulting lstseq is OK in 95% of the cases (else diverges by 1)
mascara.reduction.masc.buildTransmissionMap(*args, **kwargs)[source]

buildTransmissionMap constructs from existing dictionaries an image of the transmission.

Inputs:
  • dict, a dictionary containing the information for constructing the map: {quad indice: [list of (observed magnitude - apparent magnitude), per aperture]}
  • nulx, nuly, two scalars giving the dimension of the map
Keywords:
  • dimensions, specify the number of dimensions the map should have. If dimension > 1.
  • writetofile, boelan. If true, the map(s) are written to disk in fits format
mascara.reduction.masc.getDarkFilename(camname, path='')[source]

getDarkFilename reads from file the location and name of the last valid masterdark saved for a specific camera.

Inputs:
  • Camera Name, the name of the Camera
  • path, where the file is saved (optional). If not specified, the function will look in the current working directory.

Output: the location and name of the last masterdark for that camera.

mascara.reduction.masc.indexArray(cnx, naper=2, mode='data', minobs=1)[source]

indexArray transforms an array into an record array.

The entries of the record array are :
  • in data mode:
    • flag (as an unsigned integer going from 0 to 255
    • flux0 (as a double float)
    • eflux0 (as a double float)
    • flux1 ...
    • eflux1 ...
    • ...
    • sky (as a double float)
    • esky (as a double float)
    • peak (as a double float)
    • x (as a single float)
    • y (as a single float)
    • alt (as a single float)
    • az (as a single float)
    • ccdtemp (as a single float)
    • exptime (as a double float)
    • jdmid (as a double float)
    • lst (as a double float)
    • lstidx (as an unsigned 32-bits integer)
    • lstseq (as an unsigned 64-bits integer)
  • in header mode:
    • jdstart, jd date of start of observation of the star
    • ra, Right Ascension of the star
    • dec, Declination of the star
    • vmag, Visible magnitude of the star
    • bmag, Blue magnitude of the star
    • spectype, Spectral type of the star
    • blend, if the star is blended with another
    • blendvalue, the value of the blend (0 if not blended, 1 if overlapping)
    • nobs, the number of observations of that star during the night
Inputs:
  • cnx, a dictionary of arrays
Keywords:
  • naper, the number of aperture used
  • mode, ‘data’ or ‘header’
  • reject, a list of entries to skip
mascara.reduction.masc.light_curve_overview(Path, night, filename='LCoverview', mrange=[4.75, 4.8])[source]

selects within the given magnitude range the stars which have been observed. Saves a plot at the end.

Input:
  • Path, the location of the light curves
Keywords:
  • filename, the name for saving the image. Default if LCoverview.png
  • mrange, the magnitude range of the stars to be plotted
mascara.reduction.masc.lstseq2date(lstseq, texp, format='calendar')[source]

lstseq2date reverse computes from the lstseq the observation date.

Inputs:
  • lstseq, the sequence number
  • texp, the exposure time
Keyword:
  • format, ‘jd’ or ‘calendar’
Output:
  • the date in JD or datetime format
mascara.reduction.masc.reduction_summary(logpath, site, camera, night, date, format='html')[source]

Prepare a quick summary of the reduction. Includes the possible errors and warnings Includes the image generated at the end of the night from the astrometry

mascara.reduction.masc.send_summary(logpath, message, alternate, camera, site, night)[source]

sends the summary of the reduction as generated by the function reduction_summary under the form of an email with an embedded image

mascara.reduction.masc.tmpdbSave(*args, **kwargs)[source]

tmpdbSave saves the content of a dictionary into a database (with pandas) using h5 format.

Inputs:
  • dico, a dictionary
  • qlog, a Queue object used for logging
  • (Path, the location path of the database)
  • (ndb, the database number)
mascara.reduction.masc.updateDarkFilename(camname, filename, path='')[source]

updateDarkFilename updates the dark look-up table for the given camera name

Inputs:
  • Camera Name, the name of the Camera
  • the filename of the new valid dark for that camera
  • path, where the file is saved (optional). If not specified, the function will look in the current working directory.

No outputs

reduction.reduction – the main reduction scripts for mascara:

Module containing the tow main reduction programs for the MASCARA pipeline.

  • Reduction proceeds to the reduction of raw images following this pattern with a cadence of 50 images:

    • the fits file is read, image and header are retrieved
    • the LST index is read from the header and converted in an image number, slowind, within a set of 50
    • for a given slowindex the astrometric solution is verified
    • for each star within the CCD, the flux is calculated. The values are saved in a dictionary under the star’s identifier entry
    • the raw image is rotated and coadded to the previous ones to create a binned image
    • once theslowind reaches 50, the dictionary is saved as an hdf5 file to disk; the binned image is averaged and save as a compressed fits file; for each star down to magnitude 10 within the binned image, the flux is calculated; the binned dictionary is saved as hdf5 file to disk.
    • finally all values are resetted.
  • SaveItAll is dedicated to the saving of the light curves. It proceeds as following:
    • the last hdf5 file created is read to memory,
    • the stellar identifiers are retrieved,
    • the portion of light curve of each star is saved into a temporary directory to disk in pkl format
    • if the star has exited the CCD, the different pickles files are combined into a final fits file.
    • at the end of the night, all remaining pickle files per star are combined into a fits file, and the temporary directory is deleted
mascara.reduction.reduction.Reduction(*args, **kwargs)[source]

Reduction does the photometric reduction of the images. It either starts in parallel to the exposure sequence. In this case, the program reduces the first file in the Queue. Else, if no camera is connected, it reads all the files in the directory and reduces them.

Inputs:
  • directory, a string giving the path to the files
  • done_queue, a Queue object which is filled by the camera process with the name of the next image to reduce. The done_queue is a tuple (tagstr, camera, filename). Tagstr is dark, flat...
  • site, a Site object ;
  • savout, a Queue object to communicate with the saving process.
  • event, an multiprocessing event object
  • qlog, a queue used in the logging.

Outputs: - none.

mascara.reduction.reduction.SaveItAll(*args, **kwargs)[source]
SaveItAll creates or updates an existing fits file for every star

present in the StarID dictionnary.

Inputs:
  • PathfLC, PathsLC, the path root for saving the light curves (excluding )
  • StarID, a dictionary. The key is the stellar identifier

No outputs, the files are directly written to disk

reduction.config – the configuration file for mascara:

MASCARA specific reduction parameters. It includes:
  • the magnitude limit for the fast light curves
  • the magnitude limit for the slow light curves
  • the number of images binned together (slowbinning)
  • the various saving paths for the binned images, fast and slow light curves, and image thumbnaisl
  • the aperture radii used in the photometry
  • the sky radii used in the photometry
  • the number of dark images taken during each calibration sequence
  • the number of bias images taken during each calibration sequence
  • the number of flat images taken during each calibration sequence

reduction.credentials – what you shouldn’t modify!!!

This module contains the credential for setting up the emails