Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Netcdf how to use?

21 views
Skip to first unread message

the...@hotmail.com

unread,
Mar 20, 2017, 12:49:22 PM3/20/17
to
Hi,

I made a program that outputs a text file with two columns in it, of data. Instead of the text file output, I want to make my output binary, in netcdf format. There doesn't seem to be anything useful online. I found only the netcdf header file but it doesn't really help me.

How do I turn a text file output into binary netcdf format?

Thanks

Alf P. Steinbach

unread,
Mar 20, 2017, 2:22:35 PM3/20/17
to
On 20-Mar-17 5:49 PM, the...@hotmail.com wrote:
> Hi,
>
> I made a program that outputs a text file with two columns in it, of
> data. Instead of the text file output, I want to make my output
> binary, in netcdf format. There doesn't seem to be anything useful
> online.

Google directed me to Wikipedia, which has an article about netcdf:

<url: https://en.wikipedia.org/wiki/NetCDF#Access_libraries>


> I found only the netcdf header file but it doesn't really
> help me.
>
> How do I turn a text file output into binary netcdf format?

Just find those access libraries. ;-)


Cheers!,

- Alf



the...@hotmail.com

unread,
Mar 20, 2017, 3:17:20 PM3/20/17
to
I'm sorry Alf, I don't really understand what I'm supposed to do. I already have the libraries downloaded. I don't know what to do in my actual code. I need to replace the command that writes my output to a textfile...with something. Much like if I were to just do ordinary binary output I would replace .txt with .bin. But I assume with netcdf its more complicated.

I looked around some more and found a few examples of where the results are being pasted to the netcdf binary output files as arrays. But supposing you don't know the length of your array? I would need things like NX and NY but I don't want to hardcode array length in case sometimes I want to make fewer result values and sometimes I want to make more result values.

Jorgen Grahn

unread,
Mar 20, 2017, 4:35:52 PM3/20/17
to
I followed the Wikipedia article to http://www.unidata.ucar.edu/software/netcdf/
which seems to have tons of stuff: FAQs, tools, documentation, tutorials ...

I don't know if this is a good idea. NetCDF seems fairly specialized,
the phrase "array-oriented scientific data" gets used, and FORTRAN is
mentioned. You may find you're supposed to have domain knowledge to
use it.

What's your background? Why do you want to create NetCDF files
instead of the text files you create today?

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

the...@hotmail.com

unread,
Mar 20, 2017, 4:53:48 PM3/20/17
to
@Jorgen,

I was also following that site but its very confusing. My text file has 2 columns, but the rows are 52 million. I was trying to make my output into an array for netcdf but how can I do that without specifying the number of rows? What if I don't know how many rows there are?

My background is very minimal in coding. I have very small amount of experience in matlab, and started learning c++ two months ago. The netcdf thing is for my homework. It wasn't taught in my lecture but its a part of the assignment.

Jorgen Grahn

unread,
Mar 20, 2017, 5:53:43 PM3/20/17
to
On Mon, 2017-03-20, the...@hotmail.com wrote:
> @Jorgen,
>
> I was also following that site but its very confusing. My text file
> has 2 columns, but the rows are 52 million. I was trying to make my
> output into an array for netcdf but how can I do that without
> specifying the number of rows? What if I don't know how many rows
> there are?

(You just said they were 52e6, but I guess that was just an example.)

That's a good question. But I cannot answer it. Maybe someone else
here can, but I suspect few have come in contact with this library,
and digging into the API is likely to take some time even for
experienced programmers.

Perhaps that's just not part of the problem they try to solve.
Perhaps your data should be like a huge, fixed-size Excel sheet
(although that seems very limiting). I cannot tell, since I don't
understand the domain.

> My background is very minimal in coding. I have very small amount of
> experience in matlab, and started learning c++ two months ago. The
> netcdf thing is for my homework. It wasn't taught in my lecture but
> its a part of the assignment.

Ok, I see.
0 new messages