incorrect header format: python

From: <>
Date: Wed, 23 May 2012 16:18:50 +0200

Hi everyone,

I installed GADGET2 and it is running perfectly with the examples
provided by GADGET itself and with the example provided by Nathan
Goldbaum at astrobites.
So now I'm creating my initial conditions script but I decided to
create it in python. However, I always get the 'incorrect header
format' message and I have no idea why. So what did I do?:

in order to create the header I used c_type structures as follows:

class Create_Header(Structure):
    _fields_ = [("npart",SixInts),
                ("time", c_float ),
                ("redshift", c_float),
                ("bytes",c_byte*(256- 6*4- ...))] #here I force the
header to have 256 bytes

where for each of the fields I assign a list of values or a value(eg:
Later on I have to convert it to binary format, for that I'm using

     p =

I'm sure the header has 256 bytes: I checked using sizeof(header).
This way of packing seems fine: I checked using struct.unpack. basically I have no idea what I am missing... do you have any ideas?

I also tried to read my header in the IC script provided in
astrobites, using 'readu' and then save it using writeu, turns out
that GADGET stops working again... so I used the TRANSFER_COUNT while
writing this header into the file and I always get:TRANSFER_COUNT=1,
even if I change the variables or size of the header... I don't really
know much of IDL, so I was wondering that maybe you could have some
idea of what I am doing wrong...

In attach I send you a simple example based on my script, where I show
how I'm creating and saving the header so you can have a clear picture
of what I'm doing with it...

Thanks in advance,

Received on 2012-05-23 16:30:02

This archive was generated by hypermail 2.3.0 : 2023-01-10 10:01:31 CET