Ejemplo n.º 1
0
// Any GB-specific derived parameters go here
void set_obs_params_gb(char *buf, 
                       struct guppi_params *g, 
                       struct psrfits *p) {

    // TODO could double-check telescope name first
    
    // Set the beamwidth
    if (strcmp("GBT", p->hdr.telescope)==0)
        p->hdr.beam_FWHM = beam_FWHM(p->hdr.fctr, 100.0);
    else if (strcmp("GB43m", p->hdr.telescope)==0)
        p->hdr.beam_FWHM = beam_FWHM(p->hdr.fctr, 43.0);
    else
        p->hdr.beam_FWHM = 0.0;

    // Receiver orientations, poln parameters, etc
    // Defaults:
    p->hdr.fd_hand = -1;
    p->hdr.fd_sang = 45.0;
    p->hdr.fd_xyph = 0.0;
    // Special cases:
    //   - Linear-feed gregorian rcvrs (L, S, C bands) are rotated
    //     90 degrees from PSRFITS convention.
    if (strcmp("Rcvr1_2", p->hdr.frontend)==0) {
        p->hdr.fd_sang=-45.0;
    } else if (strcmp("Rcvr2_3", p->hdr.frontend)==0) {
        p->hdr.fd_sang=-45.0;
    } else if (strcmp("Rcvr4_6", p->hdr.frontend)==0) {
        p->hdr.fd_sang=-45.0;
    }

    // Backend cross-term phase
    if (strcmp("GUPPI", p->hdr.backend)==0)
        p->hdr.be_phase = -1;
    else 
        p->hdr.be_phase = -1;
    
}
Ejemplo n.º 2
0
void fill_psrfits_struct(int numwapps, int numbits, struct HEADERP *h,
                         struct wappinfo *w, struct psrfits *pf)
{
    int slen, ii;
    char *cptr;

    pf->filenum = 0;            // Crucial for initialization
    pf->hdr.nsblk = (int) (1.0 / w->dt);        // _might_ be a problem...

    // Now set values for our hdrinfo structure
    strcpy(pf->hdr.telescope, "Arecibo");
    cptr = get_hdr_string(h, "obs_type", &slen);
    if (strncmp("PULSAR_SEARCH", cptr, slen) == 0) {
        strcpy(pf->hdr.obs_mode, "SEARCH");
    } else {
        printf("Error:  Wapp data is not in search format!\n\n");
        exit(1);
    }
    strcpy(pf->hdr.backend, "WAPP");
    cptr = get_hdr_string(h, "frontend", &slen);
    if(cptr != NULL)
      strncpy(pf->hdr.frontend, cptr, slen);
    else
      strncpy(pf->hdr.frontend, "alfa", 4);
    cptr = get_hdr_string(h, "observers", &slen);
    strncpy(pf->hdr.observer, cptr, slen);
    cptr = get_hdr_string(h, "project_id", &slen);
    strncpy(pf->hdr.project_id, cptr, slen);
    cptr = get_hdr_string(h, "src_name", &slen);
    strncpy(pf->hdr.source, cptr, slen);
    strcpy(pf->hdr.date_obs, w->date_obs);
    pf->hdr.scanlen = get_hdr_double(h, "obs_time");

    strcpy(pf->hdr.poln_type, "LIN");   // set based on known receivers
    if (get_hdr_int(h, "sum")) {
        strcpy(pf->hdr.poln_order, "AA+BB");
        pf->hdr.summed_polns = 1;
    } else if (w->numifs == 1) {
        strcpy(pf->hdr.poln_order, "AA");
        pf->hdr.summed_polns = 0;
    }
    strcpy(pf->hdr.track_mode, "TRACK");  // Potentially not-true?
    strcpy(pf->hdr.cal_mode, "OFF");      // Potentially not-true?
    strcpy(pf->hdr.feed_mode, "FA");      // check this...

    pf->hdr.beamnum = 0;
    if (get_hdr_int(h, "isalfa"))
        pf->hdr.beamnum = w->beamnum;

    pf->hdr.dt = w->dt;
    pf->hdr.fctr = w->fctr + 0.5 * (numwapps - 1.0) * w->BW;
    pf->hdr.BW = w->BW * numwapps;
    pf->hdr.beam_FWHM = beam_FWHM(pf->hdr.fctr, 300.0);
    pf->hdr.nchan = w->numchans * numwapps;
    pf->hdr.orig_nchan = w->numchans * numwapps;
    pf->hdr.orig_df = pf->hdr.df = pf->hdr.BW / pf->hdr.nchan;
    pf->hdr.nbits = numbits;
    pf->hdr.npol = w->numifs;
    pf->hdr.MJD_epoch = w->MJD_epoch;
    pf->hdr.start_day = (int) (w->MJD_epoch);
    pf->hdr.start_sec = (w->MJD_epoch - pf->hdr.start_day) * 86400.0;
    pf->hdr.scan_number = get_hdr_int(h, "scan_number");
    pf->hdr.ra2000 = w->ra;
    dec2hms(pf->hdr.ra_str, pf->hdr.ra2000 / 15.0, 0);
    pf->hdr.dec2000 = w->dec;
    dec2hms(pf->hdr.dec_str, pf->hdr.dec2000, 1);
    pf->hdr.azimuth = get_hdr_double(h, "start_az");
    pf->hdr.zenith_ang = get_hdr_double(h, "start_za");
    pf->hdr.rcvr_polns = 2;
    pf->hdr.offset_subint = 0;
    pf->hdr.onlyI = 0;
    pf->hdr.ds_time_fact = 1;
    pf->hdr.ds_freq_fact = 1;
    pf->hdr.chan_dm = 0.0;
    pf->hdr.fd_hand = pf->hdr.be_phase = 0;     // This is almost certainly not correct
    pf->hdr.fd_sang = pf->hdr.fd_xyph = 0.0;    // This is almost certainly not correct
    pf->hdr.feed_angle = 0.0;   // This is almost certainly not correct
    pf->hdr.cal_freq = pf->hdr.cal_dcyc = pf->hdr.cal_phs = 0.0;        //  ditto

    // Now set values for our subint structure
    pf->sub.tel_az = get_hdr_double(h, "start_az");
    pf->sub.tel_zen = get_hdr_double(h, "start_za");
    pf->sub.lst = get_hdr_double(h, "start_lst");
    pf->hdr.start_lst = pf->sub.lst;
    pf->sub.tsubint = pf->hdr.nsblk * pf->hdr.dt;
    pf->sub.ra = pf->hdr.ra2000;
    pf->sub.dec = pf->hdr.dec2000;
    pf->sub.offs = 0.5 * pf->sub.tsubint;
    slaEqgal(pf->hdr.ra2000 * DEGTORAD, pf->hdr.dec2000 * DEGTORAD,
             &pf->sub.glon, &pf->sub.glat);
    pf->sub.glon *= RADTODEG;
    pf->sub.glat *= RADTODEG;
    // The following three are unknown or hard to get, I think (SMR)
    pf->sub.feed_ang = 0.0;
    pf->sub.pos_ang = 0.0;
    pf->sub.par_ang = 0.0;
    pf->sub.bytes_per_subint = (pf->hdr.nbits * pf->hdr.nchan *
                                pf->hdr.npol * pf->hdr.nsblk) / 8;
    pf->sub.FITS_typecode = TBYTE;      // 11 = byte

    // Create and initialize the subint arrays
    pf->sub.dat_freqs = gen_fvect(pf->hdr.nchan);
    pf->sub.dat_weights = gen_fvect(pf->hdr.nchan);
    for (ii = 0; ii < pf->hdr.nchan; ii++) {
        pf->sub.dat_freqs[ii] = w->lofreq + ii * pf->hdr.df;
        pf->sub.dat_weights[ii] = 1.0;
    }

    // The following are re-set to try to preserve the band shape later
    pf->sub.dat_offsets = gen_fvect(pf->hdr.nchan * pf->hdr.npol);
    pf->sub.dat_scales = gen_fvect(pf->hdr.nchan * pf->hdr.npol);
    for (ii = 0; ii < pf->hdr.nchan * pf->hdr.npol; ii++) {
        pf->sub.dat_offsets[ii] = 0.0;
        pf->sub.dat_scales[ii] = 1.0;
    }

    // This is the raw data block that will be updated 
    // for each row of the PSRFITS file
    pf->sub.data = gen_bvect(pf->sub.bytes_per_subint);
}
Ejemplo n.º 3
0
void fill_psrfits_struct(int numbits, struct psrfits *pf, float dt, char* source, int nchantot, float df, int imjd, int smjd, float offs, char* ra, char* dec, float lofreq, char *basename)
{
    int ii;

    pf->filenum = 0;            // Crucial for initialization
    strcpy(pf->basefilename, basename);
    pf->hdr.nsblk = (int) (roundf(1.0 / dt));

    // Now set values for our hdrinfo structure
    strcpy(pf->hdr.telescope, "VLA");
    strcpy(pf->hdr.obs_mode, "SEARCH");
    strcpy(pf->hdr.backend, "YUPPI");
    strcpy(pf->hdr.frontend, "HFF");
    strcpy(pf->hdr.observer, " ");
    strcpy(pf->hdr.project_id, " ");
    strcpy(pf->hdr.source, source);
    strcpy(pf->hdr.date_obs, " ");
    //pf->hdr.scanlen = get_hdr_double(h, "obs_time");

    strcpy(pf->hdr.poln_type, "LIN");   // set based on known receivers
    strcpy(pf->hdr.poln_order, "AA");
    pf->hdr.summed_polns = 0;
    
    strcpy(pf->hdr.track_mode, "TRACK");  // Potentially not-true?
    strcpy(pf->hdr.cal_mode, "OFF");      // Potentially not-true?
    strcpy(pf->hdr.feed_mode, "FA");      // check this...

    pf->hdr.dt = dt;
    pf->hdr.fctr = lofreq + (nchantot/2.0 - 0.5)*df;
    pf->hdr.BW = nchantot*df;
    pf->hdr.beam_FWHM = beam_FWHM(pf->hdr.fctr, 34.0);
    pf->hdr.nchan = nchantot;
    pf->hdr.orig_nchan = nchantot;
    pf->hdr.df = df;
    pf->hdr.orig_df = df;
    pf->hdr.nbits = numbits;
    pf->hdr.npol = 1;
    pf->hdr.start_day = imjd;
    pf->hdr.start_sec = smjd;
    pf->hdr.MJD_epoch = (long double)imjd + ((long double)smjd + (long double)offs)/((long double)(24*3600));
    pf->hdr.scan_number = 0;
    strcpy(pf->hdr.ra_str, ra);
    strcpy(pf->hdr.dec_str, dec);
    
    pf->hdr.ra2000 = 0.0;
    pf->hdr.dec2000 = 0.0;

    pf->hdr.azimuth = 0.0;
    pf->hdr.zenith_ang = 0.0;
    pf->hdr.rcvr_polns = 1;
    pf->hdr.offset_subint = 0;
    pf->hdr.onlyI = 0;
    pf->hdr.ds_time_fact = 1;
    pf->hdr.ds_freq_fact = 1;
    pf->hdr.chan_dm = 0.0;
    pf->hdr.fd_hand = 1.0;
    pf->hdr.be_phase = 0;     // This is almost certainly not correct
    pf->hdr.fd_sang = pf->hdr.fd_xyph = 0.0;    // This is almost certainly not correct
    pf->hdr.feed_angle = 0.0;   // This is almost certainly not correct
    pf->hdr.cal_freq = pf->hdr.cal_dcyc = pf->hdr.cal_phs = 0.0;        //  ditto

    // Now set values for our subint structure
    pf->sub.tel_az = 0.0;
    pf->sub.tel_zen = 0.0;
    pf->sub.lst = 0.0;
    pf->sub.tsubint = pf->hdr.nsblk * pf->hdr.dt;
    pf->sub.ra = pf->hdr.ra2000;
    pf->sub.dec = pf->hdr.dec2000;
    pf->sub.offs = 0.5 * pf->sub.tsubint;
    //slaEqgal(pf->hdr.ra2000 * DEGTORAD, pf->hdr.dec2000 * DEGTORAD,
    //         &pf->sub.glon, &pf->sub.glat);
    //pf->sub.glon *= RADTODEG;
    //pf->sub.glat *= RADTODEG;
    // The following three are unknown or hard to get, I think (SMR)
    pf->sub.feed_ang = 0.0;
    pf->sub.pos_ang = 0.0;
    pf->sub.par_ang = 0.0;

    pf->sub.bytes_per_subint = (pf->hdr.nbits/8) * pf->hdr.nchan * pf->hdr.npol * pf->hdr.nsblk;

    pf->sub.FITS_typecode = TBYTE;        // newer, back to bytes
    //pf->sub.FITS_typecode = TFLOAT;     // new
    //pf->sub.FITS_typecode = TBYTE;      // 11 = byte

    // Create and initialize the subint arrays
    pf->sub.dat_freqs = gen_fvect(pf->hdr.nchan);
    pf->sub.dat_weights = gen_fvect(pf->hdr.nchan);
    for (ii = 0; ii < pf->hdr.nchan; ii++) {
        pf->sub.dat_freqs[ii] = lofreq + ii * pf->hdr.df;
        pf->sub.dat_weights[ii] = 1.0;
    }

    // The following are re-set to try to preserve the band shape later
    pf->sub.dat_offsets = gen_fvect(pf->hdr.nchan * pf->hdr.npol);
    pf->sub.dat_scales = gen_fvect(pf->hdr.nchan * pf->hdr.npol);
    for (ii = 0; ii < pf->hdr.nchan * pf->hdr.npol; ii++) {
        pf->sub.dat_offsets[ii] = 0.0;
        pf->sub.dat_scales[ii] = 1.0; 
    }

    // This is the raw data block that will be updated 
    // for each row of the PSRFITS file

    pf->sub.data = gen_bvect( pf->sub.bytes_per_subint );   // newest 
    //pf->sub.data = gen_bvect( (pf->sub.bytes_per_subint)/4 );   // newer
    //pf->sub.data = gen_fvect( (pf->sub.bytes_per_subint)/4 ); // new
    //pf->sub.data = gen_bvect(pf->sub.bytes_per_subint);
}