示例#1
0
文件: acsrej_do.c 项目: pllim/hstcal
static void closeSciDq(int nimgs, IODescPtr ipsci[], IODescPtr ipdq[], clpar *par) {

    int n;

    /* must close all images, now that we are done reading them */
    for (n = 0; n < nimgs; ++n) {
        closeImage (ipsci[n]);
        closeImage (ipdq[n]);
    }
}
示例#2
0
int GetAsnName (char *filename, char *asn_name) {

    extern int status;
    IODescPtr im;           /* descriptor for an image */
    Hdr phdr;               /* primary header */

    /* Function definitions */
    int GetKeyStr (Hdr *, char *, int, char *, char *, int);

    /* Read primary header of ASN file into hdr. */
    initHdr (&phdr);
    im = openInputImage (filename, "", 0);
    if (hstio_err())
        return (status = OPEN_FAILED);

    getHeader (im, &phdr);          /* get primary header */
    if (hstio_err())
        return (status = OPEN_FAILED);

    closeImage (im);

    asn_name[0] = '\0';
    if (GetKeyStr (&phdr, "ASN_TAB", 0, "", asn_name, SZ_FITS_REC)) {
        trlkwerr ("ASN_TAB", asn_name);
        return (status = KEYWORD_MISSING);
    }

    /* Close the file's primary header. */
    freeHdr (&phdr);

    /* Successful return */
    return (status);

}
示例#3
0
static int UpdateHdr (char *output) {

    extern int status;

    Hdr phdr;               /* primary header */
    IODescPtr im;		/* descriptor for output image */

    int PutKeyBool (Hdr *, char *, Bool, char *);

    sprintf(MsgText, "Trying to open %s...",output);
    trlmessage (MsgText);

    initHdr (&phdr);

    /* Open input image in order to read its primary header. */
    im = openUpdateImage (output, "", 0, &phdr);				
    if (hstio_err()) {
        trlopenerr (output);
        closeImage(im);
        return (status = OPEN_FAILED);
    }

    if (PutKeyBool (&phdr, "ASN_PROD", True, "") ) {
        freeHdr (&phdr);
        trlerror ("Couldn't update ASN_PROD keyword in ASN table header");
        return(status = KEYWORD_MISSING);
    }

    /* write out primary header */
    if (putHeader (im))
        status = HEADER_PROBLEM;	
    if (hstio_err() || status) {
        trlreaderr (output);
        closeImage (im);
        return (status = OPEN_FAILED);
    }

    closeImage (im);
    /* Close the ASN table's primary header. */
    freeHdr (&phdr);

    sprintf(MsgText, "Updated Global Header for %s...",output);
    trlmessage (MsgText);

    return (status);

}
示例#4
0
文件: capture.cpp 项目: AchillesL/ARM
Capture::Capture(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Capture)
{
    ui->setupUi(this);

    //initialize
    ///111
    take_photo_flag = 0;
    ///111
    num = 0;
    send_frame_flag = 0;
    //capture = NULL;
    //timer = new QTimer(this);
    photos = new Photos();

    this->first_open_cam_flag = 0;
    this->open_cam_flag=0;
    timer=new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(update()));
    //initialize socketbind port 63636
    send_socket = new QUdpSocket(this);
    send_socket->bind(63636, QUdpSocket::ShareAddress);

    //enable button
    ui->close_pushButton->setDisabled(true);
    //ui->image_close_pushButton->setDisabled(false);
    ui->take_photo_pushButton->setDisabled(true);

    //this->setWindowFlags(Qt::Tool | Qt::X11BypassWindowManagerHint);
    this->setWindowFlags(Qt::FramelessWindowHint);
    ui->video_label->setStyleSheet ("background-color: #000000;color: #ffffff;");

    //C_translateLanguage();//set the content of button

    this->picNum = 0;

    //serial_port
    this->serial_open_flag = 0;
    struct PortSettings myComSetting = {BAUD4800,DATA_8,PAR_NONE,STOP_1,FLOW_OFF,10};
    myCom = new Posix_QextSerialPort("/dev/ttyUSB0",myComSetting,QextSerialBase::Polling);
    //myCom->open(QIODevice::ReadWrite);

    readTimer = new QTimer(this);
    readTimer->start(10);

    connect(readTimer,SIGNAL(timeout()),this,SLOT(readMyCom()));

    connect(send_socket, SIGNAL(readyRead()), this, SLOT(readData()));
    connect(ui->open_pushButton,SIGNAL(clicked()),this,SLOT(openCapture()));
    connect(ui->close_pushButton,SIGNAL(clicked()),this,SLOT(closeCapture()));
    connect(timer,SIGNAL(timeout()),this,SLOT(readFrame()));
    connect(ui->image_open_pushButton, SIGNAL(clicked()), this, SLOT(openPhotos()));
    connect(ui->image_close_pushButton, SIGNAL(clicked()), this, SLOT(closePhotos()));
    connect(photos, SIGNAL(closeImage()), this, SLOT(closePhotos()));
    connect(ui->take_photo_pushButton, SIGNAL(clicked()), this, SLOT(takePhotos()));
}
示例#5
0
/**
 * Uses the already opened image for future analysis. This must be called before any
 * of the findFilesInXXX() methods. Note that the TSK_IMG_INFO will not
 * be freed when the TskAuto class is closed.
 * @param a_img_info Handle to an already opened disk image.
 * @returns 1 on error and 0 on success
 */
uint8_t TskAuto::openImage(TSK_IMG_INFO * a_img_info)
{
    if (m_img_info)
        closeImage();

    m_internalOpen = false;
    m_img_info = a_img_info;
    return 0;
}
示例#6
0
/**
 * Uses the already opened image for future analysis. This must be called before any
 * of the findFilesInXXX() methods. Note that the TSK_IMG_INFO will not
 * be freed when the TskAuto class is closed.
 * @param a_img_info Handle to an already opened disk image.
 * @returns 1 on error (messages were NOT registered) and 0 on success
 */
uint8_t TskAuto::openImageHandle(TSK_IMG_INFO * a_img_info)
{
    resetErrorList();
    if (m_img_info)
        closeImage();

    m_internalOpen = false;
    m_img_info = a_img_info;
    return 0;
}
示例#7
0
int CheckDetector (char *image, int detector, char *keyword, int *badtype) {

	extern int status;

	FitsKw key;		/* location of keyword in header */
	IODescPtr im;		/* descriptor for primary header unit */
	Hdr phdr;		/* primary header */

	char keyval[SZ_FITS_REC+1];

	keyval[0] = '\0';
	initHdr (&phdr);

	/* Open the primary header of the reference file. */
	im = openInputImage (image, "", 0);
	getHeader (im, &phdr);
	if (hstio_err())
	    return (status = HEADER_PROBLEM);

	/* Get the DETECTOR keyword. */
	key = findKw (&phdr, keyword);
	if (key == NotFound) {
	    trlkwerr (keyword, image);
	    return (status = KEYWORD_MISSING);
	} else {
	    getStringKw (key, keyval, SZ_FITS_REC);
	    if (hstio_err()) {
		trlkwerr (keyword, image);
		return (status = KEYWORD_MISSING);
	    }
	}

	/* Does the ref file DETECTOR value match the science image? */
	if (detector == IR_DETECTOR) {
	    if (strncmp (keyval, "IR", strlen(keyval)) != 0) {
		sprintf (MsgText, "%s %s='%s' does not match science data",
			 image, keyword, keyval);
		trlerror (MsgText);
		(*badtype)++;
	    }
	} else {
	    if (strncmp (keyval, "UVIS", strlen(keyval)) != 0) {
		sprintf (MsgText, "%s %s='%s' does not match science data",
			 image, keyword, keyval);
		trlerror (MsgText);
		(*badtype)++;
	    }
	}

	/* Close the reference file. */
	closeImage (im);
	freeHdr (&phdr);

	return (status);
}
示例#8
0
/**
 * Opens the disk image to be analyzed.  This must be called before any
 * of the findFilesInXXX() methods. Always uses the utf8 tsk_img_open
 * even in windows.
 *
 * @param a_numImg The number of images to open (will be > 1 for split images).
 * @param a_images The path to the image files (the number of files must
 * be equal to num_img and they must be in a sorted order)
 * @param a_imgType The disk image type (can be autodetection)
 * @param a_sSize Size of device sector in bytes (or 0 for default)
 * @returns 1 on error, 0 on success
 */
uint8_t
    TskAuto::openImageUtf8(int a_numImg, const char *const a_images[],
    TSK_IMG_TYPE_ENUM a_imgType, unsigned int a_sSize)
{
    if (m_img_info)
        closeImage();

    m_internalOpen = true;
    m_img_info = tsk_img_open_utf8(a_numImg, a_images, a_imgType, a_sSize);
    if (m_img_info)
        return 0;
    else
        return 1;
}
示例#9
0
/**
 * Opens the disk image to be analyzed.  This must be called before any
 * of the findFilesInXXX() methods.
 *
 * @param a_numImg The number of images to open (will be > 1 for split images).
 * @param a_images The path to the image files (the number of files must
 * be equal to num_img and they must be in a sorted order)
 * @param a_imgType The disk image type (can be autodetection)
 * @param a_sSize Size of device sector in bytes (or 0 for default)
 * @returns 1 on error (messages were NOT registered), 0 on success
 */
uint8_t
    TskAuto::openImage(int a_numImg, const TSK_TCHAR * const a_images[],
    TSK_IMG_TYPE_ENUM a_imgType, unsigned int a_sSize)
{
    resetErrorList();
    if (m_img_info)
        closeImage();

    m_internalOpen = true;
    m_img_info = tsk_img_open(a_numImg, a_images, a_imgType, a_sSize);
    if (m_img_info)
        return 0;
    else
        return 1;
}
示例#10
0
int LoadHdr (char *input, Hdr *phdr) {

	extern int status;
	
	IODescPtr im;		/* descriptor for input image */
   	
	sprintf(MsgText, "Trying to open %s...",input);
	trlmessage (MsgText);

	/* Open input image in order to read its primary header. */
	im = openInputImage (input, "", 0);				

	if (hstio_err()) {
		trlopenerr (input);
	    return (status = OPEN_FAILED);
	}
		
    initHdr (phdr);	

	/* get primary header */
	if (getHeader (im, phdr) )
		status = HEADER_PROBLEM;	
	if (hstio_err() || status) {
		trlreaderr (input);
		closeImage (im);
		freeHdr (phdr);
	    return (status = OPEN_FAILED);
	}
	
	closeImage (im);
    
	sprintf(MsgText, "Read in Primary header from %s...",input);
	trlmessage (MsgText);

	return (status);
}	
示例#11
0
int CheckGain (char *image, float gain, char *keyword, int *badtype) {

	extern int status;

	FitsKw key;		/* location of keyword in header */
	IODescPtr im;   /* descriptor for primary header unit */
	Hdr phdr;		/* primary header */

	float keyval;

	initHdr (&phdr);

	/* Open the primary header of the reference file. */
	im = openInputImage (image, "", 0);
	getHeader (im, &phdr);
	if (hstio_err())
	    return (status = HEADER_PROBLEM);

	/* Get the CCDGAIN keyword. */
	key = findKw (&phdr, keyword);
	if (key == NotFound) {
	    trlkwerr (keyword, image);
	    return (status = KEYWORD_MISSING);
	} else {
	    keyval = getFloatKw (key);
	    if (hstio_err()) {
		trlkwerr (keyword, image);
		return (status = KEYWORD_MISSING);
	    }
	}

	/* Does the ref file CCDGAIN value match the science image? */
	/* A value of -1 is considered to be OK */
	if ((keyval != -1) && (gain != keyval)) {
	    sprintf (MsgText, "%s %s=%g does not match science data",
		     image, keyword, keyval);
	    trlerror (MsgText);
	    (*badtype)++;
	}

	/* Close the reference file. */
	closeImage (im);
	freeHdr (&phdr);

	return (status);
}
示例#12
0
文件: photos.cpp 项目: AchillesL/ARM
void Photos::closeEvent(QCloseEvent *)
{


    position = 0;
    original_x = 40;
    original_y = 18;
    image_width = 400;
    image_height = 250;
    transform_flag = 0;
    imageList.clear();
    imagePath.clear();
    disableButton();

    pixmap.fill(Qt::white);
    this->repaint(0, 0, QWidget::width(), QWidget::height());
    //update();

    emit(closeImage());
    this->close();
}
示例#13
0
int TargPos (StisInfo12 *sci, int extver, double shift1, double shift2) {

/* arguments:
StisInfo12 *sci        i: info about science data file
int extver             i: EXTVER number of extensions to update
double shift1, shift2  i: shift to be assigned to SHIFTAi keywords
*/

	int status;

	IODescPtr im;		/* descriptor for an image */
	Hdr hdr;		/* header for an extension */

	/* Update SCI extension. */

	initHdr (&hdr);
	im = openUpdateImage (sci->input, "SCI", extver, &hdr);
	if (hstio_err())
	    return (OPEN_FAILED);

	/* Update SHIFTAi. */
	if ((status = UpdateShift (&hdr, shift1, shift2)))
	    return (status);

	putHeader (im);
	if (hstio_err())
	    return (OPEN_FAILED);
	closeImage (im);
	freeHdr (&hdr);

	/* Update ERR extension. */

	im = openUpdateImage (sci->input, "ERR", extver, &hdr);
	if (hstio_err())
	    return (OPEN_FAILED);

	if ((status = UpdateShift (&hdr, shift1, shift2)))
	    return (status);

	putHeader (im);
	if (hstio_err())
	    return (OPEN_FAILED);
	closeImage (im);
	freeHdr (&hdr);

	/* Update DQ extension. */

	im = openUpdateImage (sci->input, "DQ", extver, &hdr);
	if (hstio_err())
	    return (OPEN_FAILED);

	if ((status = UpdateShift (&hdr, shift1, shift2)))
	    return (status);

	putHeader (im);
	if (hstio_err())
	    return (OPEN_FAILED);
	closeImage (im);
	freeHdr (&hdr);

	/* write to trailer */
	if (fabs (shift1) < MUCH_TOO_BIG)	/* shift is OK */
	    printf ("         SHIFTA1 set to %.6g\n", shift1);
	if (fabs (shift2) < MUCH_TOO_BIG)
	    printf ("         SHIFTA2 set to %.6g\n", shift2);

	return (0);
}
示例#14
0
static int FluxToNet (StisInfo6 *sts, IntensArray *inta, int sporder) {

	/* This is used to store information from the fflux file in a
           form suitable for the reference file input routines.
        */
	StisInfo6 fsts;
	ApInfo slit;
	PhotInfo phot;

	IODescPtr im;
	Hdr phdr;
	double photfactor, throughput, response, dispersion;
	double atodgain, readnoise;
	float correction;
	int i, dispc, helc, status;
	int abs_starti, thr_starti;
	int dummy;

	void FreePhot6 (PhotInfo *);
	void FreeThroughput6 (ApInfo *);
	int GetAbsPhot6 (StisInfo6 *, int, PhotInfo *, int, int *);
	int GetApDes6 (StisInfo6 *, ApInfo *);
	int GetApThr6 (StisInfo6 *, ApInfo *);
	int Get_KeyD (Hdr *, char *, int, double, double *);
	int Get_KeyS (Hdr *, char *, int, char *, char *, int);
	int GetSwitch (Hdr *, char *, int *);
	double interp1d (double, double *, double *, int, int *);
	void StisInit6 (StisInfo6 *);

	photfactor = H_PLANCK * C_LIGHT / HST_AREA;

	/* Initialize local data structures. */
	StisInit6 (&fsts);
        InitRefTab (&fsts.phottab);
        InitRefTab (&fsts.apertab);
        InitRefTab (&fsts.apdestab);
	slit.allocated  = 0;
	slit.gac_allocated  = 0;
	phot.allocated  = 0;
	phot.pcorr      = NULL;

	/* Handling the primary header here is not efficient. But keeps
           this new code manageable since everything new is added at a
           single point. In the future we may move this to outside the
           main loop and pass the necessary values as part of the sts
           structure.
        */
	initHdr (&phdr);
	im = openInputImage (sts->pxtab.name, "", 0);
	if (hstio_err())
	    return (OPEN_FAILED);
	getHeader (im, &phdr);
	if (hstio_err())
	    return (OPEN_FAILED);
	closeImage (im);

	/* Abort if both helcorr and dispcorr weren't performed.
           The criterion is: if a keyword is set to either COMPLETE
           or PERFORM, we assume that the operation was performed.
           This is because UpdHdrSwitch in Do1Dx only updates the
           keywords to COMPLETE if they are set to PERFORM in the
           input file.  (note:  UpdHdrSwitch is no longer used)
        */
	if ((status = GetSwitch (&phdr, "DISPCORR", &dispc)))
	    return (status);
	if ((status = GetSwitch (&phdr, "HELCORR", &helc)))
	    return (status);
	if (!((dispc == PERFORM || dispc == COMPLETE) &&
              (helc  == PERFORM || helc  == COMPLETE))) {
	    printf ("ERROR    No DISPCORR/HELCORR in fflux file.\n");
	    return (ERROR_RETURN);
	}

	/* Read header keywords. */
	if ((status = Get_KeyD (&phdr, "READNSE", 1, 0., &readnoise)))
	    return (status);
	if ((status = Get_KeyD (&phdr, "ATODGAIN", 1, 1., &atodgain)))
	    return (status);
	if ((status = Get_KeyS (&phdr, "PHOTTAB", FATAL, "",
                                fsts.phottab.name, STIS_LINE)))
	    return (status);
	if ((status = Get_KeyS (&phdr, "APDESTAB", FATAL, "",
                                fsts.apdestab.name, STIS_LINE)))
	    return (status);
	if ((status = Get_KeyS (&phdr, "APERTAB", FATAL, "",
                                fsts.apertab.name, STIS_LINE)))
	    return (status);

	/* Copy stuff from primary data structure into local one. */
	fsts.x1d_o    = sts->x1d_o;
	fsts.dispcorr = sts->dispcorr;
	fsts.fluxcorr = sts->fluxcorr;
	fsts.pctcorr  = sts->pctcorr;
	fsts.cenwave  = sts->cenwave;
	strcpy (fsts.opt_elem, sts->opt_elem);
	strcpy (fsts.aperture, sts->aperture);

	/* Read the required reference info. */
	dummy = 0;
	if ((status = GetAbsPhot6 (&fsts, sporder, &phot, 0, &dummy)))
	    return (status);
	if ((status = GetApDes6 (&fsts, &slit)))
	    return (status);
        if ((status = GetApThr6 (&fsts, &slit)))
	    return (status);

	abs_starti = 1;				/* initial values */
	thr_starti = 1;

	/* Loop over flux array. */
	for (i = 0;  i < inta->nelem;  i++) {
	    response   = interp1d (inta->wave[i], phot.wl, phot.thru,
                                   phot.nelem, &abs_starti);
	    throughput = interp1d (inta->wave[i], slit.wl, slit.thr,
                                   slit.nelem, &thr_starti);
	    if (i > 0)
	        dispersion = inta->wave[i] - inta->wave[i-1];
	    else
	        dispersion = inta->wave[1] - inta->wave[0];

	    /* This check is provisional; final version awaits IS's words. */
	    if (response   <= 0.0 ||
	        dispersion <= 0.0 ||
	        throughput <= 0.0) {
	        printf ("ERROR    Error in fflux file contents.\n");
	        return (ERROR_RETURN);
	    }

	    correction = (float) (photfactor / (response * throughput *
                         inta->wave[i] * dispersion * atodgain *
                         CM_PER_ANGSTROM));

	    inta->intens[i] = inta->intens[i] / correction;
	}

	FreeThroughput6 (&slit);
	FreePhot6 (&phot);

	freeHdr (&phdr);
	return STIS_OK;
}
示例#15
0
/*
Description:
------------
If using the exposure time, the scaling factors are normalized to ratios 
relative to the max exposure. 

    Date            Author      Description
    ----            ------      -----------
    24-Sep-1998     W.J. Hack   Initial Version
    18-Mar-1999     W.J. Hack   Revised to read EXPTIMEs from Primary headers
                                using image-template list directly
    20-Oct-1999     W.J. Hack   Revised to compute number of good input images
                                and insure they are less than MAX_FILES.
    14-Apr-2000     W.J. Hack   Revised to also return final EXPEND appropriate
                                for output CR-combined product
    14-Mar-2002     W.J. Hack   Added computation of cumulative DARKTIME
    4-Apr-2002      W.J. Hack   added initialization of 'totd'
   24-Apr-2002      W.J. Hack   removed darktime altogether, find initial EXPSTART
*/
int cr_scaling (char *expname, IRAFPointer tpin, float efac[], int *nimgs, double *expend, double *expstart)
{
    extern int status;

    Hdr         prihdr;
    int         nzero, k;
    char        fdata[CHAR_FNAME_LENGTH + 1];
    IODescPtr   ip;
    int         numimgs;        /* How many good input images are there? */

    double     end, keyend, keystart, start;

    int         GetKeyFlt (Hdr *, char *, int, float, float *);
    int         GetKeyDbl (Hdr *, char *, int, double, double *);
    /* -------------------------------- begin ---------------------------------- */

    /* Rewind the image template pointer */
    c_imtrew(tpin);

    *nimgs = c_imtlen(tpin);
    end = 0.0;
    keyend = 0.0;
    start = 1e+10;
    keystart = 0.0;

    
    /* Check to make sure there are not too many images to work with... */
    if (*nimgs > MAX_FILES) {
        trlerror("There are too many input images to combine. "); 
        return(status = NOTHING_TO_DO);
    }

    /* if the parameter scaling is null, all images have equal weight. 
        If no keyword name is given for the exposure time, assume equal
        weights of 1 for all images.
    */
    if (expname[0] == '\0') {
        return (status);
    }

    /* Use exposure time as scaling factor */
    nzero = 0;	
     
    /* loop all input files counting how many usable inputs there are */
    numimgs = 0;
    for (k = 0; k < *nimgs; ++k) {

        /* read the next input image name in the template list */
        c_imtgetim (tpin, fdata, CHAR_FNAME_LENGTH);

        /* open the primary header */
        ip = openInputImage (fdata, "", 0);
        if (hstio_err()) {
            sprintf (MsgText, "Cannot open data file '%s'", fdata);
            trlerror (MsgText);
            return (status = OPEN_FAILED);
        }

        initHdr (&prihdr);

        /* read in primary header from image */
        getHeader (ip, &prihdr);

        if (GetKeyFlt (&prihdr, expname, USE_DEFAULT, 0., &efac[k]) != 0) {
            sprintf (MsgText, "cannot read '%s' from the primary header of '%s'", expname, fdata);
            trlerror (MsgText);
            freeHdr (&prihdr);
            return(status = KEYWORD_MISSING);
        }
        
        if (efac[k] < 0.) {
            sprintf (MsgText, "exposure time of file '%s' is negative", fdata);
            trlerror (MsgText);
            freeHdr (&prihdr);
            return(status = INVALID_VALUE);
        }
        if (efac[k] == 0.) {
            nzero++;
        }
        
        numimgs++;
        if (GetKeyDbl (&prihdr, "EXPEND", USE_DEFAULT, 0., &keyend) != 0) {
            sprintf (MsgText, "cannot read 'EXPEND' from the primary header of '%s'", fdata);
            trlerror (MsgText);
            freeHdr (&prihdr);
            return(status = KEYWORD_MISSING);
        }
        if (GetKeyDbl (&prihdr, "EXPSTART", USE_DEFAULT, 0., &keystart) != 0) {
            sprintf (MsgText, "cannot read 'EXPSTART' from the primary header of '%s'", fdata);
            trlerror (MsgText);
            freeHdr (&prihdr);
            return(status = KEYWORD_MISSING);
        }
        
        end = (keyend > end) ? keyend: end;
        start = (keystart < start) ? keystart : start;
        closeImage (ip);
        freeHdr (&prihdr);
    }
    
    if (nzero > 0 && nzero < *nimgs) {
        trlwarn ("Some (but not all) input imsets have zero exposure time.");
        trlwarn ("Final product will be compromised!");
        
        /* This type of error will need to be handled differently in order
            to allow pipeline processing of this type of dataset. 
        return (status = INVALID_VALUE);
        */
    }
    
    /* Only return the number of valid input images,
        initial EXPSTART and final EXPEND value
    */
    *nimgs = numimgs;
    *expend = end;
    *expstart = start;
    
    return (status);
}
示例#16
0
int GetCCDInfo (WF3Info *wf3, CCD_Switch *sci_sw, RefFileInfo *sciref) {

/* arguments:
WF3Info *wf3          i: calibration flags and other info
CCD_Switch *sci_sw    o: all calibration switches (0 or 1) for science file
RefFileInfo *sciref  io: list of keyword,filename pairs for science file
*/

	extern int status;

	IODescPtr im;		/* descriptor for an image */
	Hdr phdr;		/* primary header */
	int nextend;		/* number of FITS extensions in rawfile */

	int GetKeyInt (Hdr *, char *, int, int, int *);
	int GetKeyFlt (Hdr *, char *, int, float, float *);
	int GetCCDSws (CCD_Switch *, Hdr *);
	int GetCCDRef (WF3Info *, CCD_Switch *, Hdr *, RefFileInfo *);
	
	/* Open input raw data file. */
	initHdr (&phdr);
	im = openInputImage (wf3->rawfile, "", 0);
	if (hstio_err()) {
	    sprintf (MsgText, "Member \"%s\" is not present", wf3->rawfile);
	    trlerror (MsgText);
        freeHdr(&phdr);
	    return (status = OPEN_FAILED);
	}

	/* Read primary header into pdhr. */
	getHeader (im, &phdr);
	if (hstio_err()) {
	    sprintf (MsgText, "Could not open PRIMARY header for \"%s\" ",
		     wf3->rawfile);
	    trlmessage (MsgText);
        closeImage(im);
        freeHdr(&phdr);
	    return (status = OPEN_FAILED);
	}
	closeImage (im);
	
	/* Get generic parameters: */

	/* Find out how many extensions there are in this file. */
	if (GetKeyInt (&phdr, "NEXTEND", USE_DEFAULT, EXT_PER_GROUP, &nextend)){
        freeHdr(&phdr);
        closeImage(im);
	    return (status = KEYWORD_MISSING);
    }
        
	wf3->nchips = nextend / EXT_PER_GROUP;

	/* Get binning and gain info.  We really only need this for the CCD. */
	if (GetKeyInt (&phdr, "BINAXIS1", USE_DEFAULT, 1, &wf3->scibin[0])) {
        closeImage(im);
        freeHdr(&phdr);
	    return (status = KEYWORD_MISSING);
    }
	if (GetKeyInt (&phdr, "BINAXIS2", USE_DEFAULT, 1, &wf3->scibin[1])){
        closeImage(im);
        freeHdr(&phdr);
	    return (status = KEYWORD_MISSING);
    }
	if (GetKeyFlt (&phdr, "CCDGAIN",  USE_DEFAULT, 1.5, &wf3->scigain)){
        closeImage(im);
        freeHdr(&phdr);
	    return (status = KEYWORD_MISSING);
    }
    
	wf3->samebin = 1;	/* default */

	/* Get calibration switches, and check that reference files exist. */
	if (GetCCDSws (sci_sw, &phdr))
	    return (status = KEYWORD_MISSING);
	if (GetCCDRef (wf3, sci_sw, &phdr, sciref))
	    return (status = CAL_FILE_MISSING);

	freeHdr (&phdr);
	return (status);
}
示例#17
0
ImageReader::~ImageReader() {
	closeImage();
}
示例#18
0
int CalStis11 (char *inwav, char *insci, char *output,
		int printtime, int verbose) {

	int status;

	StisInfo11 wavecal, scidata;	/* calibration switches, etc. */

	IODescPtr imWav;	/* descriptor for input wavecal */
	IODescPtr imSci;	/* descriptor for input science file */
	Hdr phdrWav;		/* primary header for input wavecal */
	Hdr phdrSci;		/* primary header for input science file */
	int subscicorr;		/* PERFORM if CCD and sclamp is HITM1 or 2 */

	int GetKeyInfo11 (StisInfo11 *, Hdr *);
	int SubSci (StisInfo11 *, StisInfo11 *);

	PrBegin (11);

	if (printtime)
	    TimeStamp ("CALSTIS-11 started", "");

	/* Initialize structure containing calstis information. */
	StisInit11 (&wavecal, &scidata);

	/* Copy command-line arguments into wavecal & scidata. */
	strcpy (wavecal.input, inwav);
	strcpy (scidata.input, insci);
	strcpy (wavecal.output, output);
	wavecal.printtime = printtime;
	scidata.printtime = printtime;
	wavecal.verbose = verbose;
	scidata.verbose = verbose;

	PrFileName ("wavecal", wavecal.input);
	PrFileName ("science", scidata.input);
	PrFileName ("output", wavecal.output);

	initHdr (&phdrWav);
	initHdr (&phdrSci);

	/* Check whether the output file already exists. */
	if ((status = FileExists (wavecal.output)))
	    return (status);

	/* Read primary header of input wavecal. */
	imWav = openInputImage (wavecal.input, "", 0);
	if (hstio_err())
	    return (OPEN_FAILED);
	getHeader (imWav, &phdrWav);
	if (hstio_err())
	    return (OPEN_FAILED);
	closeImage (imWav);

	/* Get keyword values from wavecal primary header. */
	if ((status = GetKeyInfo11 (&wavecal, &phdrWav)))
	    return (status);

	freeHdr (&phdrWav);

	/* Print information about the input wavecal. */
	PrHdrInfo (wavecal.obsmode, wavecal.aperture,
		wavecal.opt_elem, wavecal.det);

	/* Do we need to subtract the science image from the wavecal? */
	subscicorr = PERFORM;			/* initial value */
	if (wavecal.detector != CCD_DETECTOR) {
	    subscicorr = OMIT;
	    printf ("Warning  Detector is %s\n", wavecal.det);
	}
	if (strcmp (wavecal.sclamp, "HITM1") != 0 &&
		   strcmp (wavecal.sclamp, "HITM2") != 0) {
	    subscicorr = OMIT;
	    printf ("Warning  Wavecal SCLAMP is `%s', not HITM1 or HITM2\n",
			wavecal.sclamp);
	}
	if (wavecal.texpstrt >= EXT_SHUTTER_CLOSED) {
	    subscicorr = OMIT;
	    printf (
	"Warning  TEXPSTRT=%.2f implies external shutter is closed.\n",
		wavecal.texpstrt);
	}

	if (subscicorr != PERFORM) {
	    printf (
	"Warning  Science data will not be subtracted from wavecal.\n");
	    return (NOTHING_TO_DO);
	}

	/* Read primary header of input science file. */
	imSci = openInputImage (scidata.input, "", 0);
	if (hstio_err())
	    return (OPEN_FAILED);
	getHeader (imSci, &phdrSci);
	if (hstio_err())
	    return (OPEN_FAILED);
	closeImage (imSci);

	if (wavecal.printtime)
	    TimeStamp ("Begin processing", wavecal.rootname);

	/* Get keyword values from science file primary header. */
	if ((status = GetKeyInfo11 (&scidata, &phdrSci)))
	    return (status);

	freeHdr (&phdrSci);

	/* Detector, central wavelength, grating, and aperture must be
	   the same in the wavecal and science file.
	*/
	if (wavecal.detector != scidata.detector ||
	    wavecal.cenwave != scidata.cenwave ||
	    strcmp (wavecal.opt_elem, scidata.opt_elem) != 0 ||
	    strcmp (wavecal.aperture, scidata.aperture) != 0) {

	    printf ("Warning  Wavecal and science file do not match; \\\n");
	    printf ("Warning  the science file will not be subtracted.\n");
	    return (NOTHING_TO_DO);
	}

	/* Subtract the science image from the wavecal. */
	if ((status = SubSci (&wavecal, &scidata)))
	    return (status);

	printf ("\n");
	PrEnd (11);

	if (wavecal.printtime)
	    TimeStamp ("CALSTIS-11 completed", wavecal.rootname);

	return (0);
}
示例#19
0
TskAuto::~TskAuto()
{
    closeImage();
    m_tag = 0;
}
示例#20
0
int ImgPedigree (RefImage *ref) {

	FitsKw key;		/* location of keyword in header */
	IODescPtr im;		/* descriptor for primary header unit */
	Hdr phdr;		/* primary header */

	initHdr (&phdr);
	ref->goodPedigree = GOOD_PEDIGREE;	/* initial value */

	if (!GotFileName (ref->name)) {
	    ref->exists = EXISTS_NO;
	    return (0);
	}

	/* Open the primary header of the reference file. */
	im = openInputImage (ref->name, "", 0);
	if (hstio_err()) {
	    ref->exists = EXISTS_NO;
	    clear_hstioerr();
	    return (0);
	}
	ref->exists = EXISTS_YES;
	getHeader (im, &phdr);
	if (hstio_err())
	    return (HEADER_PROBLEM);

	/* Get pedigree and descrip.  If either or both are missing,
	   that's not an error in this case.
	*/
	key = findKw (&phdr, "PEDIGREE");
	if (key == NotFound) {
	    ref->pedigree[0] = '\0';
	} else {
	    getStringKw (key, ref->pedigree, STIS_FITS_REC);
	    if (hstio_err()) {
		printf ("ERROR    Trying to get PEDIGREE.\n");
		return (HEADER_PROBLEM);
	    }
	}

	key = findKw (&phdr, "DESCRIP");
	if (key == NotFound) {
	    ref->descrip[0] = '\0';
	} else {
	    getStringKw (key, ref->descrip, STIS_FITS_REC);
	    if (hstio_err()) {
		printf ("ERROR    Trying to get DESCRIP.\n");
		return (HEADER_PROBLEM);
	    }
	}

	/* Is this a dummy reference file? */
	if (strncmp (ref->pedigree, "DUMMY", 5) == 0)
	    ref->goodPedigree = DUMMY_PEDIGREE;	/* dummy, so pedigree is bad */
	else
	    ref->goodPedigree = GOOD_PEDIGREE;		/* pedigree is good */

	/* Done with this image for the time being. */
	closeImage (im);
	freeHdr (&phdr);

	return (0);
}
ossimQtSingleImageWindow::ossimQtSingleImageWindow(QWidget* parent,
        const char* name,
        Qt::WFlags f)
    : QMainWindow(parent, name, f),
      ossimConnectableObject(),
      ossimConnectableDisplayListener(),
      theImageWidget(0),
      theLastOpenedDirectory(),
      theResolutionLevelMenu(0)
{
    ossimReferenced::ref();
    setCaption("iview");

    QSize size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    setBaseSize(size);

    // This set the window's widget size.
    setGeometry(0,0,DEFAULT_WIDTH-1,DEFAULT_HEIGHT-1);

    // Create the image widget parenting it to this.
    theImageWidget = new ossimQtScrollingImageWidget(this, "image_widget");

    // This will clear out any initial garbage in the widget.
    theImageWidget->refresh();

    // Disable random caching scheme.
    theImageWidget->setRandomPriorityQueueEnabledFlag(false);

    // Set the the width and height of the window.
    theImageWidget->resize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    // Make the image widget the centralized widget.
    setCentralWidget(theImageWidget);

    // Make the "File" pull down menu.
    QMenu* file = new QMenu( this );
    menuBar()->insertItem( "&File", file );
    file->insertItem( "&Open Image",  this, SLOT(openImage()), Qt::CTRL+Qt::Key_O );
    file->insertItem( "&Close Image",  this, SLOT(closeImage()), Qt::CTRL+Qt::Key_C );
    file->insertItem( "&Export",  this, SLOT(exportImage()), Qt::CTRL+Qt::Key_E );
    file->insertItem( "&Quit",  this, SLOT(closeWindow()), Qt::CTRL+Qt::Key_Q );

    // Make the "Edit" pull down menu.
    QMenu* edit = new QMenu( this );
    menuBar()->insertItem( "&Edit", edit );
    edit->insertItem( "Image Chain",  this, SLOT(editImageChain()));

    // Make the "Utilities" pull down menu.
    QMenu* utilities = new QMenu( this );
    menuBar()->insertItem( "&Utilities", utilities );
    utilities->insertItem( "Refresh",  this, SLOT(refreshDisplay()));

    // Make the "Resolution_Level" pull down menu.
    theResolutionLevelMenu = new QMenu( this );
    menuBar()->insertItem( "&Resolution_Level",  theResolutionLevelMenu);

    QAction* rsetAct = new QAction(QString("0"), this);
    rsetAct->setCheckable(true);
    rsetAct->setChecked(true);
    rsetAct->setData(0);
    rsetAct->setEnabled(false);

    theResolutionLevelMenu->addAction( rsetAct );

    // Connect the activated signal to the changeResolutionLevel slot.
    connect( theResolutionLevelMenu, SIGNAL( triggered( QAction * ) ),
             this, SLOT ( changeResolutionLevel( QAction * ) ) );

    // Make the "Help" pull down menu.
    QMenu* help = new QMenu( this );
    menuBar()->insertItem( "&Help", help );
    help->insertItem( "&About",  this, SLOT(about()), Qt::CTRL+Qt::Key_A );

    // Connect up the slot to capture mouse events.
    connect(theImageWidget,
            SIGNAL(scrollingImageWidgetMouseEvent(ossimQtMouseEvent*)),
            this,
            SLOT(trackImageWidget(ossimQtMouseEvent*)));

    // Add us in as a listener for display events like refresh.
    addListener((ossimConnectableDisplayListener*)this);

    //---
    // Connect this display up to "theImageWidget" so that event propagation
    // comes up the chain to us.
    //---
    connectMyInputTo(theImageWidget);

    // Send a dummy message to make the status bar show.
    statusBar()->message( QString(" ") );

    //---
    // Set the last open directory to the current working dir so the open image
    // dialog will come up where you started.
    //---
    theLastOpenedDirectory = getenv("PWD");
}
示例#22
0
文件: acssum.c 项目: jhunkeler/hstcal
int AcsSum (char *input, char *output, char *mtype, int printtime, int verbose)
{

    extern int status;

    IRAFPointer tpin;

    AcsSumInfo acs;
    IODescPtr im;        /* descriptor for input image */
    Hdr phdr;        /* primary header for input image */
    int nimgs;
    int i;
    char acs_input[CHAR_FNAME_LENGTH];

    int          FileExists (char *);
    void         TimeStamp (char *, char *);
    void         PrBegin (char *);
    void         PrEnd (char *);
    void         PrFileName (char *, char *);
    void         PrHdrInfo (char *, char *, char *, char *);
    int          MkName (char *, char *, char *, char *, char *, int);
    void         WhichError (int);
    void         InitSumTrl (char *input, char *output);
    void         FindAsnRoot (char *, char *);
    int          mkNewSpt (char *, char *, char *);

    /* Determine input and output trailer files, then initialize
        output file by combining inputs into output file */
    InitSumTrl (input, output);

    PrBegin ("ACSSUM");
    nimgs = 0;

    if (printtime)
        TimeStamp ("ACSSUM started", "");

    /* open the input file template */
    tpin = c_imtopen (input);

    nimgs = c_imtlen(tpin);

    /* Initialize structure containing acssum information. */
    AcsInit (&acs,nimgs);

    /* Copy command-line arguments into acs. */
    for (i = 0; i < nimgs; i++) {
        c_imtgetim (tpin, acs.input[i], CHAR_FNAME_LENGTH);
        PrFileName ("input", acs.input[i]);
    }

    /* close file template */
    c_imtclose (tpin);

    strcpy (acs.output, output);
    acs.printtime = printtime;
    acs.verbose = verbose;

    PrFileName ("output", acs.output);
    FindAsnRoot (output, acs.rootname);

    initHdr (&phdr);

    /* Check whether the output file already exists. */
    if (FileExists (acs.output)) {
        FreeAcsInput (acs.input, nimgs);
        return (status);
    }
    strcpy(acs_input,acs.input[0]);

    /* Open input image in order to read its primary header. */
    im = openInputImage (acs_input, "", 0);

    if (hstio_err()) {
        FreeAcsInput (acs.input, nimgs);
        return (status = OPEN_FAILED);
    }

    getHeader (im, &phdr);        /* get primary header */
    if (hstio_err()) {
        FreeAcsInput (acs.input, nimgs);
        return (status = OPEN_FAILED);
    }
    closeImage (im);

    /* Get keyword values from primary header. */
    if (GetSumKeyInfo (&acs, &phdr)) {
        FreeAcsInput (acs.input, nimgs);
        return (status);
    }
    freeHdr (&phdr);

    /* Print information about this image. */
    PrHdrInfo (acs.aperture, acs.filter1, acs.filter2, acs.det);

    if (acs.printtime)
        TimeStamp ("Begin processing", acs.rootname);

    /* Sum all imsets. */
    if (SumGrps (&acs,mtype)){
        FreeAcsInput (acs.input, nimgs);
        return (status);
    }

    /* create new SPT file for output product */
    if (mkNewSpt (input, mtype, output)) {
        return(status);
    }

    /* Done... */
    trlmessage ("\n");
    PrEnd ("ACSSUM");

    if (acs.printtime)
        TimeStamp ("ACSSUM completed", acs.rootname);

    /* Write out temp trailer file to final file */
    WriteTrlFile ();

    FreeAcsInput (acs.input, nimgs);
    return (status);
}
示例#23
0
文件: calacs.c 项目: jhunkeler/hstcal
/* This routine copies a FITS file. */
static int CopyFFile (char *infile, char *outfile) {

    /* arguments:
       infile    i: name of input file
       outfile   i: name of output file
    */

    extern int status;

    FILE *ifp, *ofp;  /* for input and output files */
    void *buf;        /* buffer for copying blocks */
    int nin, nout;    /* number read and written */
    int done;
    IODescPtr im;
    Hdr phdr;

    /* function from lib */
    void UFilename (char *, Hdr *);

    if ((buf = calloc (FITS_BUFSIZE, sizeof(char))) == NULL)
        return (status = OUT_OF_MEMORY);

    if ((ofp = fopen (outfile, "wb")) == NULL) {
        sprintf (MsgText,"Can't create temporary file %s.", outfile);
        trlerror(MsgText);
        free (buf);
        return (status = INVALID_TEMP_FILE);
    }

    if ((ifp = fopen (infile, "rb")) == NULL) {
        sprintf (MsgText, "Can't open %s.", infile);
        trlerror (MsgText);
        (void)fcloseWithStatus(&ofp);
        remove (outfile);
        free (buf);
        return (status = OPEN_FAILED);
    }

    done = 0;
    while (!done) {
        nin = fread (buf, sizeof(char), FITS_BUFSIZE, ifp);
        if (ferror (ifp)) {
            sprintf (MsgText, "Can't read from %s (copying to %s).",
            infile, outfile);
            trlerror (MsgText);
            (void)fcloseWithStatus(&ofp);
            (void)fcloseWithStatus(&ifp);
            free (buf);
            return (status = FILE_NOT_READABLE);
        }
        if (feof (ifp))
            done = 1;

        nout = fwrite (buf, sizeof(char), nin, ofp);
        if (nout < nin) {
            sprintf (MsgText, "Can't copy %s to %s.", infile, outfile);
            trlerror (MsgText);
            (void)fcloseWithStatus(&ofp);
            (void)fcloseWithStatus(&ifp);
            free (buf);
            return (status = COPY_NOT_POSSIBLE);
        }
    }

    (void)fcloseWithStatus(&ofp);
    (void)fcloseWithStatus(&ifp);
    free (buf);

    /* Update the FILENAME keyword in the primary header of the output file. */
    initHdr (&phdr);
    im = openUpdateImage (outfile, "", 0, &phdr);
    UFilename (outfile, &phdr);
    putHeader (im);

    closeImage (im);
    freeHdr (&phdr);

    return (status);
}