Hi Alex,

The map header is binary, not text, which explains the junk you saw in your
terminal. One thing to be careful of is where the map file came from. The
map format doesn't specify the byte order written to disk, so your reading
routine has to identify whether it was written by a little- or big-endian
machine and adapt appropriately. For example, one of the header entries
encompassed by your 'REST' array is a machine stamp. You can check that and
see that it is 0x44, 0x41, 0x00, 0x00 for a little endian file, or 0x11,
0x11, 0x00, 0x00 for a big endian file. If neither, give up.

Also, check that sizeof(long) and sizeof(float) are both 4 bytes on your
machine. This might not be specified by the format (
http://www.ccp4.ac.uk/html/maplib.html#description) either, but I have only
ever seen map files with the header entries coming in 32 bit units.

Cheers

-- David


On 2 July 2012 14:41, Soares, Alexei <soa...@bnl.gov> wrote:

>  Hello, Alex here.
>
> Ten years ago, I read CCP4 maps this way, but it no longer works ... can
> anyone tell me why?  Note that map1 is an integer so that multiple headers
> can be read.  Also, supposedly the map header is text, but a simple "head
> -1" dumps lots of digital garbage from the map header.
>
> Thanks, and sorry for the beginner question!
>
>    // ********************   READ MAP HEADER ****************************
>
>    fread( &MAP_H[map1].NC     , sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].NR     , sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].NS     , sizeof(long) ,   1, read1);
>
>    fread( &MAP_H[map1].MODE   , sizeof(long) ,   1, read1);
>
>    fread( &MAP_H[map1].NCSTART, sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].NRSTART, sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].NSSTART, sizeof(long) ,   1, read1);
>
>    fread( &MAP_H[map1].NX     , sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].NY     , sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].NZ     , sizeof(long) ,   1, read1);
>
>    fread(  MAP_H[map1].CELL   , sizeof(float),   6, read1);
>
>    fread( &MAP_H[map1].MAPC   , sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].MAPR   , sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].MAPS   , sizeof(long) ,   1, read1);
>
>    fread( &MAP_H[map1].AMIN   , sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].AMAX   , sizeof(long) ,   1, read1);
>    fread( &MAP_H[map1].AMEAN  , sizeof(long) ,   1, read1);
>
>    fread( &MAP_H[map1].ISPG   , sizeof(long) ,   1, read1);
>
>    fread( &MAP_H[map1].NSY    , sizeof(long) ,   1, read1);
>
>    fread(  MAP_H[map1].REST   , sizeof(float),   32, read1);
>
>    fread(  MAP_H[map1].LAB    , sizeof(char) , LAB_LEN, read1);
>    fread(  MAP_H[map1].SYM    , sizeof(char) , MAP_H[map1].NSY, read1);
>
>

Reply via email to