| 1 |
<html> |
| 2 |
<head> |
| 3 |
<title>JCDF</title> |
| 4 |
</head> |
| 5 |
<body> |
| 6 |
<h1>JCDF</h1> |
| 7 |
|
| 8 |
<h2>Overview</h2> |
| 9 |
|
| 10 |
<p>JCDF is a pure java library capable of reading files in the |
| 11 |
<a href="http://cdf.gsfc.nasa.gov/">Common Data Format</a> defined by NASA. |
| 12 |
It runs within the J2SE1.5 (or later), but other than that has no dependencies, |
| 13 |
neither the official CDF C library nor any other java class libraries. |
| 14 |
</p> |
| 15 |
|
| 16 |
<h2>Documentation</h2> |
| 17 |
|
| 18 |
<p>The classes are provided with comprehensive |
| 19 |
<a href="javadocs/index.html">javadocs</a>. |
| 20 |
Start reading at the |
| 21 |
<a href="javadocs/uk/ac/bristol/star/cdf/CdfContent.html" |
| 22 |
><code>CdfContent</code></a> class |
| 23 |
for high-level access to CDF data and metadata, or |
| 24 |
<a href="javadocs/uk/ac/bristol/star/cdf/CdfReader.html" |
| 25 |
><code>CdfReader</code></a> |
| 26 |
for low-level access to the CDF internal records. |
| 27 |
</p> |
| 28 |
|
| 29 |
<h2>Comparison with the official CDF library</h2> |
| 30 |
|
| 31 |
<p>JCDF is a completely separate implementation from the Java interface to |
| 32 |
the official CDF library, which uses native code via JNI. |
| 33 |
It was written mainly with reference to the CDF Internal Format Description |
| 34 |
document (v3.4). Minor updates at version JCDF 1.1 are believed to |
| 35 |
bring it into line with CDF v3.6. |
| 36 |
</p> |
| 37 |
|
| 38 |
<p>The main benefit of using JCDF, and the reason for developing it, |
| 39 |
is that it's pure java, so it can be deployed using only the JCDF jar file. |
| 40 |
There is no need to install the system-dependent official CDF library. |
| 41 |
</p> |
| 42 |
|
| 43 |
<p>The API is very different from that of the official CDF library. |
| 44 |
JCDF gives you a simple view of the CDF file, in terms of its |
| 45 |
global attributes, variable attributes and variables. |
| 46 |
This is fairly easy to use, but may or may not suit your purposes. |
| 47 |
It's also possible to get a low-level view of the CDF file as a |
| 48 |
sequence of CDF records. |
| 49 |
</p> |
| 50 |
|
| 51 |
<p>JCDF offers no capabilities for writing or editing CDF files, |
| 52 |
it only reads them. |
| 53 |
</p> |
| 54 |
|
| 55 |
<h2>Implementation Notes</h2> |
| 56 |
|
| 57 |
<p>JCDF is based on NIO mapped ByteBuffers, it's expected to be reasonably |
| 58 |
fast, but I haven't done any benchmarking. |
| 59 |
</p> |
| 60 |
|
| 61 |
<p>Use of mapped buffers leads to efficient serial and random I/O, but |
| 62 |
does have some associated problems concerning release of allocated resources. |
| 63 |
For reasons that are quite |
| 64 |
<a href="http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4724038">complicated</a>, |
| 65 |
it is hard to release mapped buffers after use, which means that for instance |
| 66 |
files you have read using JCDF may be hard to delete, |
| 67 |
and that reading large files may leak significant amounts of virtual memory. |
| 68 |
There are some more or less nasty ways to work round this in user code or |
| 69 |
in the library. If these issues cause practical problems for library users, |
| 70 |
you are encouraged to contact me by email or open a github issue. |
| 71 |
</p> |
| 72 |
|
| 73 |
<h2>Implementation Status</h2> |
| 74 |
|
| 75 |
<p>Support for the CDF format is almost, but not totally, complete. |
| 76 |
In particular: |
| 77 |
</p> |
| 78 |
<ul> |
| 79 |
<li><strong>Versions:</strong> |
| 80 |
The code was written with reference to version 3.4 |
| 81 |
(updated to 3.6) of the CDF Internal Format Description document. |
| 82 |
Following comments in that document, it is believed that |
| 83 |
versions 2.6, 2.7 and 3.* of the CDF format are supported. |
| 84 |
</li> |
| 85 |
<li><strong>Large files:</strong> |
| 86 |
The library imposes no restriction on file size, |
| 87 |
so >2Gb files should be OK for v3 CDF files (CDF v2 did not |
| 88 |
support 64-bit addressing) as long as a 64-bit JVM is in use. |
| 89 |
At JCDF v1.2 I didn't have any large files to test on, |
| 90 |
and there was a bug which caused a failure. |
| 91 |
Jeremy Faden kindly pointed me at some large CDFs |
| 92 |
which allowed me to identify and fix the bug, |
| 93 |
so at v1.2 and beyond this is tested and working. |
| 94 |
</li> |
| 95 |
<li><strong>Compression:</strong> |
| 96 |
All formats supported (GZIP, HUFF, AHUFF, RLE). |
| 97 |
</li> |
| 98 |
<li><strong>Numeric encodings:</strong> |
| 99 |
Normal big- and little-endian encodings supported, |
| 100 |
but VMS D_FLOAT and G_FLOAT encodings are not supported. |
| 101 |
</li> |
| 102 |
<li><strong>Layout:</strong> |
| 103 |
Single-file CDF files are supported, but multiple-file CDF files are not. |
| 104 |
This could be added fairly easily if necessary. |
| 105 |
</li> |
| 106 |
<li><strong>I/O:</strong> |
| 107 |
Access is read-only, there is no attempt or intention |
| 108 |
to support write access. |
| 109 |
</li> |
| 110 |
<li><strong>Data types:</strong> |
| 111 |
All CDF data types are supported, more or less. |
| 112 |
Unsigned integer types are transformed to larger signed types on read, |
| 113 |
because of the difficulty of handling unsigned integers in java, |
| 114 |
so for instance a CDF_UINT1 is read as a java <code>short</code> (16-bit) |
| 115 |
integer. |
| 116 |
</li> |
| 117 |
<li><strong>Record data access</strong>: |
| 118 |
For array-valued variables you can currently only read a whole record |
| 119 |
at a time, not just part of an array-valued record. |
| 120 |
You can either get the raw elements or a shaped version. |
| 121 |
This is considerably less flexible than a hyper-read. |
| 122 |
</li> |
| 123 |
</ul> |
| 124 |
|
| 125 |
<h2>Utilities</h2> |
| 126 |
|
| 127 |
<p>The library comes with a couple of simple utilities for examining |
| 128 |
CDF files: |
| 129 |
</p> |
| 130 |
<dl> |
| 131 |
<dt><strong><code>CdfList</code></strong>:</dt> |
| 132 |
<dd>displays the metadata and data from a CDF file, |
| 133 |
along the lines of the <code>cdfdump</code> command in the official |
| 134 |
CDF distribution. |
| 135 |
If the <code>-data</code> flag is supplied, record data as well as |
| 136 |
metadata is shown. |
| 137 |
See <a href="cdflist.html">CdfList examples</a>. |
| 138 |
</dd> |
| 139 |
<dt><strong><code>CdfDump</code></strong>:</dt> |
| 140 |
<dd>displays a dump of the sequence of low-level |
| 141 |
CDF records found in the CDF file, along the lines of the |
| 142 |
<code>cdfirsdump</code> command in the official CDF distribution. |
| 143 |
If the <code>-fields</code> flag is supplied, field information from |
| 144 |
each record is shown. If the <code>-html</code> flag is supplied, |
| 145 |
the output is in HTML with files offsets displayed as hyperlinks, |
| 146 |
which is nice for chasing pointers. |
| 147 |
See <a href="cdfdump.html">CdfDump examples</a>. |
| 148 |
</dd> |
| 149 |
</dl> |
| 150 |
|
| 151 |
<h2>Downloads</h2> |
| 152 |
|
| 153 |
<p>The source code is hosted on github at |
| 154 |
<a href="https://github.com/mbtaylor/jcdf">https://github.com/mbtaylor/jcdf</a>. |
| 155 |
It comes with a makefile that can be used to build the jar file, |
| 156 |
javadocs, and this documentation, and to run some tests. |
| 157 |
</p> |
| 158 |
|
| 159 |
<p>Pre-built copies of the jar file and documentation |
| 160 |
for the current version (v1.2-5) can be found here: |
| 161 |
</p> |
| 162 |
<ul> |
| 163 |
<li><a href="jcdf.jar">jcdf.jar</a></li> |
| 164 |
<li><a href="javadocs/index.html">javadocs</a></li> |
| 165 |
<li><a href="https://search.maven.org/artifact/uk.ac.starlink/jcdf" |
| 166 |
>Maven central repository</a></li> |
| 167 |
</ul> |
| 168 |
<p>Previous versions may be available at |
| 169 |
<a href="https://www.star.bristol.ac.uk/mbt/releases/jcdf/" |
| 170 |
>https://www.star.bristol.ac.uk/mbt/releases/jcdf/</a>. |
| 171 |
</p> |
| 172 |
|
| 173 |
<h2>History</h2> |
| 174 |
|
| 175 |
<dl> |
| 176 |
<dt><strong>Version 0.1 (28 Jun 2013)</strong></dt> |
| 177 |
<dd>Initial release. |
| 178 |
Tested, documented and believed working, though could use some |
| 179 |
more testing and perhaps functionality related to time-related DataTypes. |
| 180 |
Support for some time types not complete. |
| 181 |
</dd> |
| 182 |
<dt><strong>Version 1.0 (13 Aug 2013)</strong></dt> |
| 183 |
<dd><ul> |
| 184 |
<li>More extensive tests added.</li> |
| 185 |
<li>Fix failure when reading non-sparse variables with zero records.</li> |
| 186 |
<li>Fix bug: pad values not explicitly defined are given default values |
| 187 |
rather than causing an error.</li> |
| 188 |
<li>Fix EPOCH16 bug.</li> |
| 189 |
<li>Add EPOCH16 formatting.</li> |
| 190 |
<li>Modify CdfList data output: better formatting, and distinguish |
| 191 |
NOVARY values from virtual ones.</li> |
| 192 |
<li>TIME_TT2000 values now handled correctly, including leap seconds, |
| 193 |
and optional leap seconds table referenced by |
| 194 |
<code>CDF_LEAPSECONDSTABLE</code> environment variable as for |
| 195 |
NASA library. Internal leap seconds table is updated until |
| 196 |
2012-07-01.</li> |
| 197 |
</ul> |
| 198 |
</dd> |
| 199 |
<dt><strong>Version 1.1 (23 Apr 2015)</strong></dt> |
| 200 |
<dd><ul> |
| 201 |
<li>2015-07-01 leap second added to internal leap second table.</li> |
| 202 |
<li>Updated to match v3.6 of the CDF library/format. |
| 203 |
The GDR field <code>rfuD</code> is now renamed as |
| 204 |
<code>leapSecondLastUpdated</code>. |
| 205 |
It is also used when formatting TIME_TT2000 data values for output; |
| 206 |
if the library leap second table is out of date with respect to |
| 207 |
the data a warning is issued for information, and if the |
| 208 |
time values are known to have leap seconds applied invalidly, |
| 209 |
an error is thrown or a severe log message is issued. |
| 210 |
This behaviour follows that of the official CDF library.</li> |
| 211 |
</ul></dd> |
| 212 |
<dt><strong>Version 1.2 (9 Sep 2015)</strong></dt> |
| 213 |
<dd><ul> |
| 214 |
<li>Fix a bug that caused a failure when accessing large (>2Gb) files. |
| 215 |
</li> |
| 216 |
<li>Update tests to use NASA's CDF library v3.6.0.4; |
| 217 |
this fixes a missing leap second bug, which simplifies the tests |
| 218 |
somewhat.</li> |
| 219 |
</ul></dd> |
| 220 |
<dt><strong>Version 1.2-1 (25 Sep 2015)</strong></dt> |
| 221 |
<dd><ul> |
| 222 |
<li>Fix a bug in leap second handling - it was sensitive to the JVM's |
| 223 |
default time zone, and only ran correctly if the default time zone |
| 224 |
matched UTC. The error in formatting TIME_TT2000 data values |
| 225 |
was previously a second out within up to a day of the |
| 226 |
occurrence of a leap second.</li> |
| 227 |
<li>Add <code>Variable.getDescriptor</code> method.</li> |
| 228 |
<li>Improve the build (mainly javadocs) a bit to reduce |
| 229 |
some warnings that showed up in JDKs later than Java 5. |
| 230 |
Also add a switch in the makefile to reduce noise |
| 231 |
when building under JDK8.</li> |
| 232 |
</ul></dd> |
| 233 |
<dt><strong>Version 1.2-2 (4 Jan 2017)</strong></dt> |
| 234 |
<dd><ul> |
| 235 |
<li>2017-01-01 leap second added to internal leap second table.</li> |
| 236 |
</ul></dd> |
| 237 |
<dt><strong>Version 1.2-3 (16 Nov 2017)</strong></dt> |
| 238 |
<dd><ul> |
| 239 |
<li>Fix bugs in low-level reading code (<code>BankBuf</code>): |
| 240 |
unsigned bytes could be read wrong in some cases, and |
| 241 |
data could be read wrong near the boundaries of multi-buffer files |
| 242 |
(only likely to show up for files >2Gbyte). |
| 243 |
Thanks to Lukas Kvasnica (Brno) for identifying and fixing these.</li> |
| 244 |
<li>Add unit tests to test the supplied <code>Buf</code> |
| 245 |
implementations.</li> |
| 246 |
<li>Some minor adjustments to the build/test framework to accommodate |
| 247 |
Debian packaging (mostly replacement of test data files encumbered |
| 248 |
by NASA copyright statement). |
| 249 |
No change to distributed library code.</li> |
| 250 |
</ul></dd> |
| 251 |
<dt><strong>Version 1.2-4 (15 Dec 2021)</strong></dt> |
| 252 |
<dd><ul> |
| 253 |
<li>Some runtime log warnings about unexpected field values removed. |
| 254 |
These generally concerned fields marked "Reserved for future use" |
| 255 |
in the CDF Internal Format Description, and reported on deviations |
| 256 |
from a particular CDF version (currently 3.4), but which may have |
| 257 |
legitimate use in later versions of the CDF format.</li> |
| 258 |
<li>Fix an error in interpreting the <code>leapSecondLastUpdated</code> |
| 259 |
field from the Global Descriptor Record; this could cause a |
| 260 |
RuntimeException with a message about the library leap second table |
| 261 |
being out of date during TT2000 date formatting.</li> |
| 262 |
</ul></dd> |
| 263 |
<dt><strong>Version 1.2-5 (27 Feb 2025)</strong></dt> |
| 264 |
<dd><ul> |
| 265 |
<li>Performance improvements achieved by removing synchronized blocks |
| 266 |
in the code. Read performance typically improved by about 40% |
| 267 |
for large files.</li> |
| 268 |
<li><code>EpochFormatter</code> class instances are now thread-safe.</li> |
| 269 |
</ul></dd> |
| 270 |
</dl> |
| 271 |
|
| 272 |
<h2>Context</h2> |
| 273 |
|
| 274 |
<p>This software was written by |
| 275 |
<a href="https://www.star.bristol.ac.uk/mbt/">Mark Taylor</a> |
| 276 |
at the University of Bristol at the request of, and funded by, |
| 277 |
the science archive group at ESA's European Space Astronomy Centre (ESAC). |
| 278 |
</p> |
| 279 |
|
| 280 |
<p>It is used within |
| 281 |
<a href="http://www.starlink.ac.uk/topcat/">TOPCAT</a |
| 282 |
>/<a href="http://www.starlink.ac.uk/stilts/">STILTS</a |
| 283 |
>/<a href="http://www.starlink.ac.uk/stil/">STIL</a> |
| 284 |
to enable access to CDF tables alongside other tabular data formats |
| 285 |
by that software. |
| 286 |
It is believed to be in some use also at ESAC and elsewhere. |
| 287 |
If anybody out there is using it and is willing to be listed here, |
| 288 |
let me know. |
| 289 |
</p> |
| 290 |
|
| 291 |
<p>It is licenced under the LGPL, though if you need a different licence |
| 292 |
I can probably fix it. |
| 293 |
</p> |
| 294 |
|
| 295 |
<p>My thanks to several people who have helped with development and |
| 296 |
testing, including Christophe Arviset, Robert Candey, Michael Liu, |
| 297 |
Jeremy Faden and Bogdan Nicula. |
| 298 |
</p> |
| 299 |
|
| 300 |
<p>Bugs, questions, feedback, enhancement requests welcome to |
| 301 |
<a href="mailto:[email protected]">[email protected]</a>. |
| 302 |
</p> |
| 303 |
|
| 304 |
<address> |
| 305 |
<hr /> |
| 306 |
Mark Taylor -- |
| 307 |
<a href='https://www.bristol.ac.uk/physics/research/astrophysics/' |
| 308 |
>Astrophysics Group</a>, |
| 309 |
<a href='https://www.bristol.ac.uk/physics/'>School of Physics</a>, |
| 310 |
<a href='https://www.bristol.ac.uk/'>University of Bristol</a> |
| 311 |
</address> |
| 312 |
</body> |
| 313 |
</html> |