setup_profiles.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2009 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/Base/Formats/PSRFITS/setup_profiles.h
10
11#ifndef __Pulsar_setup_profiles_h
12#define __Pulsar_setup_profiles_h
13
15template<typename I, typename P>
16void setup_profiles_dat (I subint, P& profiles)
17{
18 const unsigned npol = subint->get_npol ();
19 const unsigned nchan = subint->get_nchan ();
20
21 profiles.resize (npol * nchan);
22
23 for (unsigned ipol=0; ipol<npol; ipol++)
24 for (unsigned ichan=0; ichan<nchan; ichan++)
25 profiles[ipol*nchan + ichan] = subint->get_Profile (ipol, ichan);
26}
27
29template<class E, typename I, typename P>
30void setup_profiles (I subint, P& profiles)
31{
32 E* ext = subint->get_Profile(0,0)->template get<E>();
33 if (!ext)
34 throw Error (InvalidState, "setup_profiles<Extension>",
35 "first profile is missing required Extension");
36
37 const unsigned naux = ext->get_size();
38 const unsigned nchan = subint->get_nchan ();
39
40 profiles.resize (naux * nchan);
41
42 for (unsigned ichan=0; ichan<nchan; ichan++)
43 {
44 ext = subint->get_Profile(0,ichan)->template get<E>();
45 if (!ext)
46 throw Error (InvalidState, "setup_profiles<Extension>",
47 "profile[%u] is missing required Extension", ichan);
48
49 for (unsigned iaux=0; iaux<naux; iaux++)
50 profiles[iaux*nchan + ichan] = ext->get_Profile (iaux);
51 }
52}
53
54#endif

Generated using doxygen 1.14.0