casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Viff.h
Go to the documentation of this file.
1 //# Viff.h: Convert between Khoros Viff format and AIPS++ Arrays
2 //# Copyright (C) 1993,1994,1995,2000
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef NRAO_VIFF_H
29 #define NRAO_VIFF_H
30 
31 // .LIB(aips)
32 
33 // This class encapsulates the Khoros "Viff" format. It will normally be
34 // used to interconvert AIPS++ in-memory arrayss and Viff disk files. The
35 // primary limitation of the Viff format is that it can only deal with up-to
36 // 3-dimensional arrays. If an array of greater than 3-dimensions is put into
37 // a Viff structure an error is returned (first, however an attempt is made
38 // to remove degenerate (length==1) axes).
39 
40 // All Viff types are handled, and conversions will occur automatically.
41 // The conversions use the normal C++ assignments, e.g. converting from floats
42 // to bytes is not apt to be very meaningful (maybe we should put in automatic
43 // scalings?).
44 
45 // TBF - At the moment the user array types are only floats, although any underlying
46 // Viff format is supported, except for the complex types.
47 
48 #include <casa/aips.h>
49 
50 // These should be forward declared; how do you do that with templates?
51 #include <casa/Arrays/Array.h>
52 #include <casa/Arrays/Cube.h>
53 #include <casa/BasicSL/Complex.h>
54 
55 struct xvimage; // From Khoros
56 
57 class Viff {
58 public:
60  Viff();
61 
62  ~Viff();
63 
64  // Put casacore::Array (or any class derived from it, casacore::Vector, casacore::Matrix, Cube...)
65  // into this Viff structure. Non-degenerate arrays of dimension >=4
66  // will cause a "false" to be returned, since Viff images are restricted
67  // to 3 dimensions. When the Viff type and the casacore::Array types differ,
68  // a conversion will be done. casacore::Complex types are turned into real and
69  // integer by taking the real component.
72 
73  // Get the casacore::Array out of this Viff structre. If the Viff structure isn't
74  // initialized it will return a 0-sized array and set the flag to false.
75  // This will convert from the internal Viff type to the desired casacore::Array<T>
76  // type. casacore::Complex types are turned into real
77  // and integer types by taking the real component.
80 
81  // Read the Viff file specified by name; return false if it fails
82  // (file does not exist, no permissions, etc).
84 
85  // Write the current Viff structure to a file; create a 0-sized Viff
86  // image if this object has not been previously filled (by read or by
87  // put). Return true if this succeeds, false otherwise. Note that this
88  // will overwrite an existing file.
90 
91  // Viff can be thought of as always containing a "3D" data structure, and
92  // a vector is when only one of the dimentions is non-unity. nx(), ny() and
93  // nx() return 0 if the Viff object isn't defined.
94  casacore::uInt nx() const;
95  casacore::uInt ny() const;
96  casacore::uInt nz() const;
97 
98  // We can assign an N dimensional location to each (x,y) position in
99  // the Viff object (yes, this is strange - ask the authors of Viff),
100  // i.e. we can assign nx()*ny() N-dimensional locations. Fundamentally
101  // this is done by giving a casacore::Cube<float> of values where the first two
102  // indices in the casacore::Cube correspond to the (x,y) in the Viff structure, and
103  // the Z-depth of the cube corresponds to the dimensionality of the
104  // positions we want to assign.
105  // Because a casacore::Cube can be constructed from a casacore::Vector, to create a file which
106  // contains a y vs x vector plot, you merely have to do something like:
107  // viff.put(y); viff.putLocations(x);
109 
110 private:
111  // These members are the arguments to create image;
112  void setDefaults();
113  unsigned long col_size, row_size, num_data_bands; // shape parameters
114  unsigned long data_storage_type; // Defaults to float
115  unsigned long num_of_images; // always 1
116  char *comment;
117  unsigned long map_row_size, map_col_size, // Maps aren't used
119  unsigned long location_type, location_dim;
120 
121  xvimage *kimage;
122 };
123 
124 #endif
casacore::Bool read(casacore::String name)
Read the Viff file specified by name; return false if it fails (file does not exist, no permissions, etc).
unsigned long row_size
Definition: Viff.h:113
unsigned long col_size
Definition: Viff.h:113
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1886
unsigned long map_row_size
Definition: Viff.h:117
casacore::Bool putLocations(const casacore::Cube< float > &)
We can assign an N dimensional location to each (x,y) position in the Viff object (yes...
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
casacore::Bool put(const casacore::Array< float > &array)
Put casacore::Array (or any class derived from it, casacore::Vector, casacore::Matrix, Cube...) into this Viff structure.
char * comment
Definition: Viff.h:116
unsigned long map_scheme
Definition: Viff.h:117
casacore::uInt nx() const
Viff can be thought of as always containing a &quot;3D&quot; data structure, and a vector is when only one of t...
unsigned long num_of_images
Definition: Viff.h:115
unsigned long location_type
Definition: Viff.h:119
unsigned long map_col_size
Definition: Viff.h:117
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
unsigned long num_data_bands
Definition: Viff.h:113
xvimage * kimage
Definition: Viff.h:121
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
casacore::uInt ny() const
unsigned long data_storage_type
Definition: Viff.h:114
unsigned long location_dim
Definition: Viff.h:119
String: the storage and methods of handling collections of characters.
Definition: String.h:223
unsigned long map_storage_type
Definition: Viff.h:117
casacore::uInt nz() const
void setDefaults()
These members are the arguments to create image;.
Definition: Viff.h:57
unsigned int uInt
Definition: aipstype.h:51
casacore::Bool write(casacore::String name)
Write the current Viff structure to a file; create a 0-sized Viff image if this object has not been p...