1IO(3) User Contributed Perl Documentation IO(3)
2
3
4
6 PDL::IO - An overview of the modules in the PDL::IO namespace.
7
9 # At your system shell, type:
10 perldoc PDL::IO
11
13 PDL contains many modules for displaying, loading, and saving data.
14
15 • Perlish or Text-Based
16
17 A few IO modules provide Perl-inspired capabilities. These are
18 PDL::IO::Dumper and PDL::IO::Storable. PDL::IO::Misc provides
19 simpler routines for dealing with delimited files, though its
20 capabilities are limited to tabular or at most 3-d data sets.
21
22 • Raw Format
23
24 PDL has two modules that store their data in a raw binary format;
25 they are PDL::IO::FastRaw and PDL::IO::FlexRaw. They are fast but
26 the files they produce will not be readable across different
27 architectures. These two modules are so similar that they could
28 probably be combined.
29
30 • Data Browsing
31
32 At the moment, only PDL::IO::Browser provides data browsing
33 functionality.
34
35 • Image Handling
36
37 PDL has a handful of modules that will load images into ndarrays
38 for you. They include PDL::IO::Dicom, PDL::IO::FITS, PDL::IO::GD,
39 PDL::IO::Pic, and PDL::IO::Pnm. However, PDL::IO::FITS should also
40 be considered something of a general data format.
41
42 • Disk Caching
43
44 Both PDL::IO::FastRaw and PDL::IO::FlexRaw provide for direct
45 ndarray-to-disk mapping, but they use PDL's underlying mmap
46 functionality to do it, and that doesn't work for Windows.
47 However, users of all operating systems can still use
48 PDL::DiskCache, which can use any desired IO read/write
49 functionality (though you may have to write a small wrapper
50 function).
51
52 • General Data Storage Formats
53
54 PDL has a number of modules that interface general data storage
55 libraries. They include PDL::IO::HDF and PDL::IO::NDF (the latter
56 is now a separate CPAN module). There is a PDL::IO::IDL, though at
57 the moment it is not distributed with PDL. PDL::IO::FITS is
58 something of a general data format, since ndarray data can be
59 stored to a FITS file without loss. PDL::IO::FlexRaw and
60 PDL::IO::FastRaw read and write data identical C's low-level
61 "write" function and PDL::IO::FlexRaw can work with FORTRAN 77
62 UNFORMATTED files. FlexRaw and Storable provide general data
63 storage capabilities. Finally, PDL can read Grib (weather-data)
64 files using the CPAN module PDL::IO::Grib.
65
66 • Making Movies
67
68 You can make an MPEG animation using PDL::IO::Pic's wmpeg function.
69
70 Here's a brief summary of all of the modules, in alphabetical order.
71
72 PDL::DiskCache
73 The DiskCache module allows you to tie a Perl array to a collection of
74 files on your disk, which will be loaded into and out of memory as
75 ndarrays. Although the module defaults to working with FITS files, it
76 allows you to specify your own reading and writing functions. This
77 allows you to vastly streamline your code by hiding the unnecessary
78 details of loading and saving files.
79
80 If you find yourself writing scripts to procss many data files,
81 especially if that data processing is not necessarily in sequential
82 order, you should consider using PDL::DiskCache. To read more, check
83 the PDL::DiskCache documentation.
84
85 PDL::IO::Browser
86 The Browser module provides a text-based data browser for 2D data sets.
87
88 It uses the CURSES library to do the scrolling, so if your operating
89 system does not have the cureses library, you won't be able to install
90 this on your machine. (Note that the package containing the header
91 files for the CURSES library may be called "libcurses" or possibly
92 "libncurses".)
93
94 To see if the module is installed on your machine (and to get more
95 information about PDL::IO::Browser), follow this link or type at the
96 system prompt:
97
98 perldoc PDL::IO::Browser
99
100 If you want to get more information about PDL::IO::Browser and it's not
101 installed on your system, I'm afraid you'll have to pick out the pod
102 from the source file, which can be found online at
103 <https://github.com/PDLPorters/pdl/blob/master/IO/Browser/browser.pd>.
104
105 PDL::IO::Dicom
106 DICOM is an image format, and this module allows you to read image
107 files with the DICOM file format. To read more, check the
108 PDL::IO::Dicom documentation.
109
110 PDL::IO::Dumper
111 Provides functionality similar to Data::Dumper for ndarrays.
112 Data::Dumper stringifies a data structure, creating a string that can
113 be "eval"ed to reproduce the original data structure. It's also
114 usually suitable for printing, to visualize the structure.
115
116 To read more, check the PDL::IO::Dumper documentation. See also
117 PDL::IO::Storable for a more comprehensive structured data solution.
118
119 PDL::IO::FastRaw
120 Very simple module for quickly writing, reading, and memory-mapping
121 ndarrays to/from disk. It is fast to learn and fast to use, though you
122 may be frustrated by its lack of options. To quote from the original
123 POD:
124
125 "The binary files are in general NOT interchangeable between different
126 architectures since the binary file is simply dumped from the memory
127 region of the ndarray. This is what makes the approach efficient."
128
129 This creates two files for every ndarray saved - one that stores the
130 raw data and another that stores the header file, which indicates the
131 dimensions of the data stored in the raw file. Even if you save 1000
132 different ndarrays with the exact same dimensions, you will still need
133 to write out a header file for each one. You cannot store multiple
134 ndarrays in one file.
135
136 Note that at the time of writing, memory-mapping is not possible on
137 Windows.
138
139 For more details, see PDL::IO::FastRaw. For a more flexible raw IO
140 module, see PDL::IO::FlexRaw.
141
142 PDL::IO::FITS
143 Allows basic reading and writing of FITS files. You can read more
144 about FITS formatted files at
145 <http://fits.gsfc.nasa.gov/fits_intro.html> and
146 <http://en.wikipedia.org/wiki/FITS>. It is an image format commonly
147 used in Astronomy.
148
149 This module may or may not be installed on your machine. To get more
150 information, check online at
151 <http://pdl.perl.org/?docs=IO/FITS&title=PDL::IO::FITS>. To see if the
152 module is installed, look for PDL::IO::FITS on your machine by typing
153 at the system prompt:
154
155 perldoc PDL::IO::FITS
156
157 PDL::IO::FlexRaw
158 Somewhat smarter module (compared to FastRaw) for reading, writing, and
159 memory mapping ndarrays to disk. In addition to everything that
160 FastRaw can do, FlexRaw can also store multiple ndarrays in a single
161 file, take user-specified headers (so you can use one header file for
162 multiple files that have identical structure), and read compressed
163 data. However, FlexRaw cannot memory-map compressed data, and just as
164 with FastRaw, the format will not work across multiple architectures.
165
166 FlexRaw and FastRaw produce identical raw files and have essentially
167 identical performance. Use whichever module seems to be more
168 comfortable. I would generally recommend using FlexRaw over FastRaw,
169 but the differences are minor for most uses.
170
171 Note that at the time of writing, memory-mapping is not possible on
172 Windows.
173
174 For more details on FlexRaw, see PDL::IO::FlexRaw.
175
176 PDL::IO::GD
177 GD is a library for reading, creating, and writing bitmapped images,
178 written in C. You can read more about the C-library here:
179 <http://www.libgd.org/>.
180
181 In addition to reading and writing .png and .jpeg files, GD allows you
182 to modify the bitmap by drawing rectangles, adding text, and probably
183 much more. The documentation can be found here. As such, it should
184 probably be not only considered an IO module, but a Graphics module as
185 well.
186
187 This module provides PDL bindings for the GD library, which ought not
188 be confused with the Perl bindings. The perl bindings were developed
189 independently and can be found at GD, if you have Perl's GD bindings
190 installed.
191
192 PDL::IO::Grib
193 A CPAN module last updated in 2000 that allows you to read Grib files.
194 GRIB is a data format commonly used in meteorology. In the off-chance
195 that you have it installed, you should read PDL::IO::Grib's
196 documentation.
197
198 PDL::IO::HDF, PDL::IO::HDF5
199 Provides an interface to HDF4 and HDF5 file formats, which are kinda
200 like cross-platform binary XML files. HDF stands for Heierarchicl Data
201 Format. HDF was originally developed at the NCSA. To read more about
202 HDF, see <http://www.hdfgroup.org/>. Note that HDF5 is not presently
203 distributed with PDL, and neither HDF4 nor HDF5 will be installed
204 unless you have the associated C libraries that these modules
205 interface. Also note that the HDF5 library on CPAN is rather old and
206 somebody from HDF contacted the mailing list in the Fall of 2009 to
207 develop new and better HDF5 bindings for Perl.
208
209 You should look into the PDL::IO::HDF (4) documentation or
210 PDL::IO::HDF5 documentation, depending upon which module you have
211 installed.
212
213 PDL::IO::IDL
214 Once upon a time, PDL had a module for reading IDL data files.
215 Unfortunately, it cannot be distributed because the original author,
216 Craig DeForest, signed the IDL license agreement and was unable to
217 negotiate the administrative hurdles to get it published. However, it
218 can be found in Sourceforge's CVS attic, and any PDL user who has not
219 signed IDL's license agreement can fix it up and resubmit it.
220
221 PDL::IO::Misc
222 Provides mostly text-based IO routines. Data input and output is
223 restricted mostly to tabular (i.e. two-dimensional) data sets, though
224 limited support is provided for 3d data sets.
225
226 Alternative text-based modules support higher dimensions, such as
227 PDL::IO::Dumper and PDL::IO::Storable. Check the PDL::IO::Misc
228 documentation for more details.
229
230 PDL::IO::NDF
231 Starlink developed a file format for N-Dimensional data Files, which it
232 cleverly dubbed NDF. If you work with these files, you're in luck!
233 Check the PDL::IO::NDF documentation for more details.
234
235 PDL::IO::Pic
236 Provides reading/writing of images to/from ndarrays, as well as
237 creating MPEG animations! The module uses the netpbm library, so you
238 will need that on your machine in order for this to work. To read
239 more, see the PDL::IO::Pic documentation. Also look into the next
240 module, as well as PDL::IO::GD.
241
242 PDL::IO::Pnm
243 Provides methods for reading and writing pnm files (of which pbm is but
244 one). Check the PDL::IO::Pnm documentation for more details. Also
245 check out the previous module and PDL::IO::GD.
246
247 PDL::IO::Storable
248 Implements the relevant methods to be able to store and retrieve
249 ndarrays via Storable. True, you can use many methods to save a single
250 ndarray. In contrast, this module is particularly useful if you need
251 to save a complex Perl structure that contain ndarrays, such as an
252 array of hashes, each of which contains ndarrays.
253
254 Check the PDL::IO::Storable documentation for more details. See also
255 PDL::IO::Dumper for an alternative stringifier.
256
258 Copyright 2010 David Mertens (dcmertens.perl@gmail.com). You can
259 distribute and/or modify this document under the same terms as the
260 current Perl license.
261
262 See: http://dev.perl.org/licenses/
263
264
265
266perl v5.34.0 2021-08-16 IO(3)