<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Brian,<div class=""><br class=""></div><div class="">Although I would love to see FITS adopt JSON as a alternative format, I don’t quite understand the value of an encoded JSON format. As Tom points out, the devil will be in the details of real FITS files and for that, you’re going to need a robust FITS library like cfitsio to process the json.</div><div class=""><br class=""></div><div class="">In the JS9 project (image display to the Web @ <a href="http://js9.si.edu" class="">http://js9.si.edu</a>), we started by writing a FITS library in JavaScript, but found it to be totally insufficient in practice. We ended up using emscripten (<a href="http://emscripten.org" class="">http://emscripten.org</a>) to compile cfitsio to JavaScript in order to support the full range of FITS, including, for example, tile compressed images. You can drag and drop any standard FITS file onto the JS9 Web page and cfitsio will process it for display, all in JavaScript. I would recommend looking into emscripten as a means of giving your audience the benefit of standard and documented FITS access. We only wrapped the cfitsio functions we needed for image display, but it would be quite a service to give fuller access to cfitsio in JavaScript.</div><div class=""><br class=""></div><div class="">Regards,</div><div class=""><br class=""></div><div class="">Eric</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 30, 2015, at 11:37 AM, Tom McGlynn (NASA/GSFC Code 660.1) <<a href="mailto:tom.mcglynn@nasa.gov" class="">tom.mcglynn@nasa.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Hi Brian,<br class=""><br class="">I'm curious why you decided that you would do a specialized encoding of the payload rather than render it in JSON directly. Is this simply a size decision. My guess is that floating point numbers might incur s significant penalty but I'm not sure about the other types (when you include compression), but have you looked at this for real FITS files. If you're in a context where you're using JSON, providing the data in a JSON format would seem to make sense. If you only want to provide FITS metadata, then just encode the headers.<br class=""><br class="">I'm not sure I understand why you would have any loss of precision in floating point numbers as John Parejko suggests -- if it's just the quality of the supporting libraries then I don't think that need drive your standard. However you would have to worry about loss of precision of longs with large absolute values where they are not exactly representable as doubles. These you could represent as strings. Variable length records -- particularly for a FITS file that reuses heap locations - is probably another difficult area. While I think the majority of actual FITS files could be handled very naturally, it's legal to write FITS files where the same set of bytes is read as a integer for one row and a float for another. So in this most general case an intermediary byte array is required. Despite these issues, I think a more complete JSON rendering would be more popular.<br class=""><br class=""> Regards,<br class=""> Tom McGlynn<br class=""><br class="">Brian McConnell wrote:<br class=""><blockquote type="cite" class="">Hello,<br class=""><br class="">Bill Pence suggested I post here. I'm working on a project to make<br class="">FITS data more accessible to software developers who are not<br class="">necessarily familiar with the format. Specifically, we're looking at<br class="">ways to make SETI observational data available to third party<br class="">developers who may be very knowledgeable about software engineering,<br class="">digital signal processing, etc, but not field specific formats like<br class="">this.<br class=""><br class="">What I am working on is a utility that renders FITS files as JSON, a<br class="">widely used interchange format (think XML without the bloat), with<br class="">base64 encoded binary for payload data. The result is a file that is 7<br class="">bit friendly, can be viewed in any text editor, and is trivial to<br class="">parse. A typical JSONFITS file would look like:<br class=""><br class="">[<br class="">{"TARGNAME":"foo","TELESCOP":"arecibo","BINDATA":base64encodedblobofdatagoeshere},{"TARGNAME":"bar","TELESCOP":"arecibo","BINDATA":morebase64encodeddata}<br class="">]<br class=""><br class="">Someone consuming this data can then do so very easily, as in the<br class="">Python example:<br class=""><br class="">blocks = json.loads(open('test.jsn','r').read())<br class="">for b in blocks:<br class=""> target_name = b.get('TARGNAME','')<br class=""> telescope = b.get('TELESCOP','')<br class=""> payload = base64.b64decode(b.get('BINDATA',''))<br class=""> do_something_with(target_name, telescope, payload)<br class=""><br class="">I should point out that I am not suggesting a new file format, but am<br class="">thinking of this as an output filter for rendering FITS files in an<br class="">internet friendly format.<br class=""><br class="">Now you might ask won't base64 encoding bloat the file/download size?<br class="">Yes, by about 4:3, but it turns out lossless compression largely<br class="">undoes this, and as on the fly gzip compression is a built in feature<br class="">in most web servers nowadays, this is basically a non issue (same<br class="">thing for storage if you use a compressed volume). So you can have<br class="">your cake (easy to parse, human readable files) and eat it too<br class="">(similar overall footprint as binaries).<br class=""><br class="">Well, I wanted to put this out there as a discussion item, and see if<br class="">there's other work along these lines underway. My intent with the<br class="">rendering utility is to make it available as a tiny Python library<br class="">that people can use and build on.<br class=""><br class="">Thanks for your time.<br class=""><br class="">Brian McConnell <<a href="mailto:bsmcconnell@gmail.com" class="">bsmcconnell@gmail.com</a>><br class=""><br class="">_______________________________________________<br class="">fitsbits mailing list<br class=""><a href="mailto:fitsbits@listmgr.nrao.edu" class="">fitsbits@listmgr.nrao.edu</a><br class="">https://listmgr.nrao.edu/mailman/listinfo/fitsbits<br class=""></blockquote><br class="">_______________________________________________<br class="">fitsbits mailing list<br class=""><a href="mailto:fitsbits@listmgr.nrao.edu" class="">fitsbits@listmgr.nrao.edu</a><br class="">https://listmgr.nrao.edu/mailman/listinfo/fitsbits<br class=""></div></blockquote></div><br class=""></div></body></html>