source: sans/utils/Teabag/sanswrite.c @ 837

Last change on this file since 837 was 837, checked in by ajj, 11 years ago

Checkin of Teabag code for TISANE.

File size: 1.8 KB
Line 
1#include <stdio.h>
2#include <string.h>
3#include <math.h>
4#include "sa_data.h"
5#include "sa_rdwr.h"
6#include "sa_futil.h"
7#include "sa_mutil.h"
8
9SANSHDR header;
10int hist[128][128];
11
12
13int initdata(SANSHDR *hdr, int hst[128][128], char *filename)
14{
15  //double distance = 10000, dim = 1000, lambda = 2.0;
16  double val;
17  int i,j;
18
19  memset(hdr,0,sizeof(SANSHDR));
20
21  sprintf(hdr->fname, "%-22s",filename);
22  hdr->run.npre = 1;
23  hdr->run.ctime = 10;
24  hdr->run.rtime = 10;
25  hdr->run.numruns = 1;
26  hdr->run.moncnt  = 100000000;
27  hdr->run.savmon  = 10000.0;
28  hdr->run.atten = (float) 1.0;
29  hdr->det.calx[0]  = 5;
30  hdr->det.calx[1] = 10000;
31  hdr->det.caly[0]  = 5;
32  hdr->det.caly[1] = 10000;
33  hdr->det.siz = 65;
34  hdr->det.beamx = 64;
35  hdr->det.beamy = 64;
36  hdr->det.dis = 1.33;
37  hdr->resolution.lmda = 5;
38 
39
40  sprintf(hdr->run.type,"%s","RAW");
41
42  hdr->bmstp.xpos  = 64.0;
43  hdr->bmstp.ypos  = 64.0;
44
45  sprintf(hdr->det.typ,"%6s","ORDELA");
46
47  //FakeSansHist(hst, distance, dim, lambda);
48  for (i=0;i<128;i++) {
49    val = 0;
50    for (j=0;j<128;j++) {
51      hst[i][j] = 1;
52      hdr->run.detcnt += hst[i][j];
53      val += hst[i][j];
54    }
55    //   printf("%d %f\n",i,val);
56  }
57  //  printf("Total counts = %d\n",hdr->run.detcnt);
58
59  return 0;
60}
61
62
63/* int main(int argc, char * argv[])
64{
65  int retn;
66  int byteorder = 0;
67  char filename[23] = "test.sans";
68  FILE *fp;
69
70  retn = initdata(&header,hist, filename);
71 
72  if ((fp = fopen(filename,"wb")) == NULL) {
73        fprintf(stderr,"Counldn't write output file\n");
74        return -1;
75  }
76 
77  if ((retn = WriteSansHdr(fp, &header, byteorder)) != 0) {
78        fprintf(stderr,"Problem encountered in writing header\n");
79        return -2;
80  }
81
82  if ((retn = WriteSansHist(fp, hist, 128, 128, byteorder)) != 0) {
83        fprintf(stderr,"Problem encountered in writing data\n");
84        return -3;
85  }
86  printf("Wrote \"%s\"\n",filename);
87  return 0;
88}
89 */
Note: See TracBrowser for help on using the repository browser.