#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <mpi.h>
#include <mwalib.h>
#include <star/pal.h>
#include <star/palmac.h>
#include <psrfits.h>
#include "vcsbeam.h"
 | 
| void  | populate_spliced_psrfits_header (vcsbeam_context *vm, struct psrfits *pf, int max_sec_per_file, int outpol, int ds, beam_geom *beam_geom_vals, char *basename, bool is_coherent) | 
|   | Populates a PSRFITS struct with data derived from the observation.  More...
  | 
|   | 
| void  | populate_psrfits_header (vcsbeam_context *vm, struct psrfits *pf, int max_sec_per_file, int outpol, int ds, beam_geom *beam_geom_vals, char *incoh_basename, bool is_coherent) | 
|   | Populates a PSRFITS struct with data derived from the observation.  More...
  | 
|   | 
| void  | free_psrfits (struct psrfits *pf) | 
|   | Frees the memory associated with a PSRFITS struct.  More...
  | 
|   | 
| void  | vmInitMPIPsrfits (vcsbeam_context *vm, mpi_psrfits *mpf, int max_sec_per_file, int nstokes, int ds, beam_geom *bg, char *outfile, bool is_coherent) | 
|   | Initialises a struct for managing multiple PSRFITS files via MPI processes.  More...
  | 
|   | 
| void  | free_mpi_psrfits (mpi_psrfits *mpf) | 
|   | Frees the memory associated with an mpi_psrfits struct.  More...
  | 
|   | 
| void  | gather_splice_psrfits (mpi_psrfits *mpf) | 
|   | Splices the data for multiple coarse channels managed by an mpi_psrfits struct together into a single PSRFITS buffer ready for writing.  More...
  | 
|   | 
| void  | wait_splice_psrfits (mpi_psrfits *mpf) | 
|   | Causes the master MPI thread to wait until the preceding MPI_GATHER operation is complete.  More...
  | 
|   | 
◆ free_mpi_psrfits()
      
        
          | void free_mpi_psrfits  | 
          ( | 
          mpi_psrfits *  | 
          mpf | ) | 
           | 
        
      
 
Frees the memory associated with an mpi_psrfits struct. 
- Parameters
 - 
  
    | mpf | A pointer to the struct to be freed. | 
  
   
Only the memory associated with member variables are freed. The mpi_psrfits itself is not freed. 
 
 
◆ free_psrfits()
      
        
          | void free_psrfits  | 
          ( | 
          struct psrfits *  | 
          pf | ) | 
           | 
        
      
 
Frees the memory associated with a PSRFITS struct. 
- Parameters
 - 
  
    | pf | The PSRFITS struct to be freed. | 
  
   
This only frees the member variables (arrays), not the struct itself. 
 
 
◆ gather_splice_psrfits()
      
        
          | void gather_splice_psrfits  | 
          ( | 
          mpi_psrfits *  | 
          mpf | ) | 
           | 
        
      
 
Splices the data for multiple coarse channels managed by an mpi_psrfits struct together into a single PSRFITS buffer ready for writing. 
- Parameters
 - 
  
    | mpf | A pointer to the mpi_psrfits struct that is managing which MPI process is associated with which frequency.  | 
  
   
 
 
◆ populate_psrfits_header()
      
        
          | void populate_psrfits_header  | 
          ( | 
          vcsbeam_context *  | 
          vm,  | 
        
        
           | 
           | 
          struct psrfits *  | 
          pf,  | 
        
        
           | 
           | 
          int  | 
          max_sec_per_file,  | 
        
        
           | 
           | 
          int  | 
          outpol,  | 
        
        
           | 
           | 
          int  | 
          ds,  | 
        
        
           | 
           | 
          beam_geom *  | 
          beam_geom_vals,  | 
        
        
           | 
           | 
          char *  | 
          incoh_basename,  | 
        
        
           | 
           | 
          bool  | 
          is_coherent  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Populates a PSRFITS struct with data derived from the observation. 
- Parameters
 - 
  
    | vm | The VCSBeam context struct  | 
    | pf | The PSRFITS struct to be populated  | 
    | max_sec_per_file | The number of seconds written to each output PSRFITS file  | 
    | outpol | Either 1 (for Stokes I only) or 4 (for full Stokes)  | 
    | ds | Downsampling factor, must be a value divisible by the fine sampling rate, otherwise set to 1 in the main code  | 
    | beam_geom_vals | A beam_geom struct containing pointing information  | 
    | incoh_basename | The prefix for the output PSRFITS files (only for incoherent beamforming)  | 
    | is_coherent | true for tied-array beamforming, false for incoherent beamforming | 
  
   
This function is designed for PSRFITS files containing a single coarse channel.
- Todo:
 - Merge with populate_spliced_psrfits_header() to avoid code duplication. 
 
 
 
◆ populate_spliced_psrfits_header()
      
        
          | void populate_spliced_psrfits_header  | 
          ( | 
          vcsbeam_context *  | 
          vm,  | 
        
        
           | 
           | 
          struct psrfits *  | 
          pf,  | 
        
        
           | 
           | 
          int  | 
          max_sec_per_file,  | 
        
        
           | 
           | 
          int  | 
          outpol,  | 
        
        
           | 
           | 
          int  | 
          ds,  | 
        
        
           | 
           | 
          beam_geom *  | 
          beam_geom_vals,  | 
        
        
           | 
           | 
          char *  | 
          basename,  | 
        
        
           | 
           | 
          bool  | 
          is_coherent  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Populates a PSRFITS struct with data derived from the observation. 
- Parameters
 - 
  
    | vm | The VCSBeam context struct  | 
    | pf | The PSRFITS struct to be populated  | 
    | max_sec_per_file | The number of seconds written to each output PSRFITS file  | 
    | outpol | Either 1 (for Stokes I only) or 4 (for full Stokes)  | 
    | ds | Downsampling factor, must be a value divisible by the fine sampling rate, otherwise set to 1 in the main code  | 
    | beam_geom_vals | A beam_geom struct containing pointing information  | 
    | basename | The prefix for the output PSRFITS files  | 
    | is_coherent | true for tied-array beamforming, false for incoherent beamforming | 
  
   
This function is designed for PSRFITS files containing multiple coarse channels.
- Todo:
 - Change the name to conform to standard. 
 
 
 
◆ vmInitMPIPsrfits()
      
        
          | void vmInitMPIPsrfits  | 
          ( | 
          vcsbeam_context *  | 
          vm,  | 
        
        
           | 
           | 
          mpi_psrfits *  | 
          mpf,  | 
        
        
           | 
           | 
          int  | 
          max_sec_per_file,  | 
        
        
           | 
           | 
          int  | 
          nstokes,  | 
        
        
           | 
           | 
          int  | 
          ds,  | 
        
        
           | 
           | 
          beam_geom *  | 
          bg,  | 
        
        
           | 
           | 
          char *  | 
          outfile,  | 
        
        
           | 
           | 
          bool  | 
          is_coherent  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Initialises a struct for managing multiple PSRFITS files via MPI processes. 
- Parameters
 - 
  
    | vm | The VCSBeam context struct  | 
    | mpf | A pointer to the new struct to be initialised  | 
    | max_sec_per_file | The number of seconds written to each output PSRFITS file  | 
    | nstokes | Either 1 (for Stokes I only) or 4 (for full Stokes)  | 
    | ds | Downsampling factor, must be a value divisible by the fine sampling rate, otherwise set to 1 in the main code  | 
    | bg | A beam_geom struct containing pointing information  | 
    | outfile | The prefix for the output PSRFITS files  | 
    | is_coherent | true for tied-array beamforming, false for incoherent beamforming  | 
  
   
 
 
◆ wait_splice_psrfits()
      
        
          | void wait_splice_psrfits  | 
          ( | 
          mpi_psrfits *  | 
          mpf | ) | 
           | 
        
      
 
Causes the master MPI thread to wait until the preceding MPI_GATHER operation is complete. 
- Parameters
 - 
  
    | mpf | A pointer to the mpi_psrfits struct that is managing which MPI process is associated with which frequency.  |