Using LibreOffice to generate GrADS binary files

Talk about anything at all....
Post Reply
Bald Eagle
Posts: 68
Joined: Wed Apr 19, 2017 9:22 pm

Using LibreOffice to generate GrADS binary files

Post by Bald Eagle »

Hi all,

I was wondering if there are any tools in LibreOffice / OpenOffice that can take data (possibly/preferably from a Calc spreadsheet) and write it to a binary file for direct use in GrADS. Thus using the globe as a graphing surface.

http://climserv.ipsl.polytechnique.fr/d ... ddata.html

The data must be written in sequential or direct access / stream format.

Just investigating the feasibility right now, before I invest too much time in doing anything - this is an unpaid hobby application, but I could see people's interest in this if it were possible.

Thanks so much!
OpenOffice 4.1.1 on Windows 7
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Using LibreOffice to generate GrADS binary files

Post by RusselB »

A quick check on the details via the link you provided indicates to me that this is not feasible without an extension, and neither the OpenOffice or the LibreOffice extension/template sites had anything that looked correct.
Thus, at this point, I think you're going about this the wrong way, though just what software would be appropriate, I have no idea.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
robleyd
Moderator
Posts: 5079
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Using LibreOffice to generate GrADS binary files

Post by robleyd »

Looking at the link you provided, it seems to me that the GrADS file is simply two delimited text files The descriptor file is space separated and the so-called "binary" file is comma separated.

Based on what I see in your link, in both cases, I think you could simply Save As -> .csv a suitably structured Calc file, with the appropriate options for the separator.

If this isn't the case, perhaps you can link to more information?
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Bald Eagle
Posts: 68
Joined: Wed Apr 19, 2017 9:22 pm

Re: Using LibreOffice to generate GrADS binary files

Post by Bald Eagle »

Hi David,
Thanks for the reply.

I spent quite a bit more time than I wanted to trying to figure this out a while back, and the GrADS community seems pretty insistent and consistent that there IS a _data descriptor_ file that is blank-delimited text, but the file with the _data_ is, and must be written in binary.

(because only academics make the very first step of the learning curve like going all the way from the floor to the top of a rock-climbing wall)
I once plotted (almost) all of the Minor Planet data (65,000 records) in 3D, and the hardest part - aside from the wacky description of the orbital dynamics components - was unpacking the stupid DATE FORMAT. :roll: :crazy:

So rather than have a tool where you can input user data easily, if you're not using a pre-existing data set, they expect you to have to learn how to program in Fortran or C....
Notice I am annoyed, but undeterred. ;)

In the following link, this person states:
"As you can see there is no format definition for the binary file. This
is the reason wha the variables have to be in the correct form (single
our double precission) to avoid problems."
http://gradsusr.org/pipermail/gradsusr/ ... 30735.html

So I would imagine that the requirement for the specific number format excludes something like variable-length comma-delimited text records.
One also has to define a unique value to assign to missing data, which seems to be consistent with the fact that each entry takes up a certain well-defined "block" in the binary stream - the size of the data entry thus being "self-delimiting".

https://www.atmos.umd.edu/~gcm/usefuldo ... grads.html

So I was thinking maybe people have had occasion in the past to need binary data written from something like Calc, and there might be some macros or something to do that with, or adapt.

Like I said, I was just curious if Libre/Open had the capability to write to binary, as a Calc sheet would be simple, human-readable and editable, and could be used as a fairly quick and simple template to create custom data sets and start test-driving GrADS, rather than having to build the "car" from hand-machined parts.

Thanks again.
OpenOffice 4.1.1 on Windows 7
User avatar
robleyd
Moderator
Posts: 5079
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Using LibreOffice to generate GrADS binary files

Post by robleyd »

I found a sample Grads data file, and it is in fact more complex than a simple text file. So the answer to your question is probably No.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
User avatar
MrProgrammer
Moderator
Posts: 4901
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Using LibreOffice to generate GrADS binary files

Post by MrProgrammer »

Bald Eagle wrote:I was wondering if can take data … and write it to a binary file for direct use in GrADS.
Of course you can create binary files from Calc. The UNICHAR function can create any arbitrary bytes you want. Using formulas you can create any desired sequence of bytes in column A of a sheet. Exporting that sheet as CSV creates a file with any desired sequence of bytes.

There are some significant difficulties however. You must determine what byte sequence is needed for GrADS binary files. Then you must determine which formulas will produce those bytes. Integer representations will probably be easy, for example the low byte for an integer: UNICHAR(MOD(cell;256)). Floating-point numbers are more work. If you need IEEE-754 single precision for REAL*4, this Wikipedia article explaines the byte sequence for that format. The formulas won't be simple however. For example, cell<0 gives the sign and INT(LOG(ABS(cell);2)) gives the exponent. Part of the exponent is combined with the sign to form one byte: UNICHAR(IF(sign;128;0)+QUOTIENT(exponent+127;2)).

It may be a lot less work to learn enough Fortran to create the files using the standard GrADS documentation.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
RoryOF
Moderator
Posts: 34610
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Using LibreOffice to generate GrADS binary files

Post by RoryOF »

MrProgrammer wrote: It may be a lot less work to learn enough Fortran to create the files using the standard GrADS documentation.
Bearing in mind that I started to program in Fortran II in 1965 and took to BASIC instinctively as a result, BASIC might be quite sufficient.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply