PdevFile.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2011 by Paul Demorest
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 #ifndef __PdevFile_h
10 #define __PdevFile_h
11 
12 #include "dsp/File.h"
13 
14 #define PDEV_HEADER_BYTES ((size_t)1024)
15 
16 namespace dsp {
17 
19 
42  class PdevFile : public File
43  {
44  public:
45 
47  PdevFile (const char* filename=0, const char* headername=0);
48 
50  ~PdevFile ();
51 
53  bool is_valid (const char* filename) const;
54 
56  bool swap_poln () const { return rawhdr[3] & 0x02; }
57 
59  bool swap_dim () const { return rawhdr[3] & 0x01; }
60 
61  protected:
62 
64  void open_file (const char* filename);
65 
67  void check_file_set ();
68 
70  int64_t fstat_file_ndat (uint64_t tailer_bytes=0);
71 
73  int64_t load_bytes (unsigned char *buffer, uint64_t nbytes);
74 
76  int64_t seek_bytes (uint64_t bytes);
77 
79  void parse_aoHdr ();
80 
81  private:
82 
84  unsigned int rawhdr[PDEV_HEADER_BYTES / 4];
85 
87  bool have_ascii_header;
88 
90  char basename[256];
91 
93  int curfile;
94 
96  int startfile;
97 
99  int endfile;
100 
102  std::vector<uint64_t> file_bytes;
103 
105  uint64_t total_bytes;
106 
107  };
108 }
109 
110 #endif // !defined(__PdevFile_h)
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
int64_t fstat_file_ndat(uint64_t tailer_bytes=0)
Return number of samples.
Definition: PdevFile.C:119
~PdevFile()
Destructor.
Definition: PdevFile.C:36
void open_file(const char *filename)
Open the file.
Definition: PdevFile.C:125
bool swap_poln() const
Polns need to be swapped.
Definition: PdevFile.h:56
Loads BitSeries data from file.
Definition: File.h:38
void check_file_set()
Get stats about the whole set of files.
Definition: PdevFile.C:81
virtual void close()
Close the file.
Definition: File.C:145
bool swap_dim() const
I/Q need to be swapped.
Definition: PdevFile.h:59
int64_t load_bytes(unsigned char *buffer, uint64_t nbytes)
Load bytes from the file set.
Definition: PdevFile.C:284
void set_required(std::string key, bool required=true)
Set/unset a required keyword.
Definition: ASCIIObservation.C:53
void parse_aoHdr()
Parse the "aoHdr" part of the binary header.
Definition: PdevFile.C:233
PdevFile reads baseband data from the Mock Spectrometers at Arecibo.
Definition: PdevFile.h:42
PdevFile(const char *filename=0, const char *headername=0)
Construct and open file
Definition: PdevFile.C:25
int64_t seek_bytes(uint64_t bytes)
Seek to a certain spot in the file set.
Definition: PdevFile.C:332
bool is_valid(const char *filename) const
Returns true if filename is a valid pdev file.
Definition: PdevFile.C:40
void load(const char *header)
Read the ASCII header block.
Definition: ASCIIObservation.C:88
Parses Observation attributes from an ASCII header.
Definition: ASCIIObservation.h:29

Generated using doxygen 1.8.17