Last change
on this file since 3973 was 3790, checked in by cmv, 15 years ago |
etude des cubes generes par le GSM, cmv 28/06/2010
|
File size:
1.5 KB
|
Rev | Line | |
---|
[3790] | 1 | #include "sopnamsp.h"
|
---|
| 2 | #include "machdefs.h"
|
---|
| 3 | #include <stdlib.h>
|
---|
| 4 | #include <stdio.h>
|
---|
| 5 | #include <fstream>
|
---|
| 6 | #include <iostream>
|
---|
| 7 | #include <string.h>
|
---|
| 8 | #include <unistd.h>
|
---|
| 9 |
|
---|
| 10 | #include "skymap.h"
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | int main(int narg,char *arg[])
|
---|
| 14 | {
|
---|
| 15 | int nside = 512;
|
---|
| 16 | string ppfrn = "cmvgsm2sph";
|
---|
| 17 |
|
---|
| 18 | if(narg<=1) {
|
---|
| 19 | cout<<"cmvgsm2sph liste_gsm.list [ppfroot_name]"<<endl;
|
---|
| 20 | return -1;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | ifstream flist(arg[1], ofstream::in);
|
---|
| 24 | if(!flist)
|
---|
| 25 | {cout<<"ERROR: open failed for "<<arg[1]<<endl; return -2;}
|
---|
| 26 | if(narg>2) ppfrn = arg[2];
|
---|
| 27 |
|
---|
| 28 | int nfilrd = 0, nfrderr = 0;;
|
---|
| 29 | while(1) {
|
---|
| 30 | string fn; double f=-1.; int is = -1;
|
---|
| 31 | flist>>is>>f>>fn;
|
---|
| 32 | if(flist.eof()) break;
|
---|
| 33 | cout<<nfilrd<<" : is="<<is<<" f="<<f<<" fn="<<fn<<endl;
|
---|
| 34 |
|
---|
| 35 | SphereHEALPix<r_4> sph(nside);
|
---|
| 36 | int npix = sph.NbPixels();
|
---|
| 37 | if(nfilrd==0) cout<<"Healpix sph nside="<<nside<<" npix="<<npix<<endl;
|
---|
| 38 |
|
---|
| 39 | ifstream fin(fn.c_str(), ofstream::in);
|
---|
| 40 | if(!fin) {
|
---|
| 41 | cout<<"ERROR: open failed for "<<fn<<endl;
|
---|
| 42 | nfrderr++;
|
---|
| 43 | continue;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | int nread = 0;
|
---|
| 47 | while(1) {
|
---|
| 48 | double v = 0;
|
---|
| 49 | fin>>v;
|
---|
| 50 | if(fin.eof()) break;
|
---|
| 51 | if(nread<npix) sph(nread) = v;
|
---|
| 52 | nread++;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | if(nread!=npix) {
|
---|
| 56 | cout<<"ERROR: mismatch nread="<<nread<<" / "<<npix<<endl;
|
---|
| 57 | nfrderr++;
|
---|
| 58 | } else {
|
---|
| 59 | char str[1024];
|
---|
| 60 | sprintf(str,"%s_%d.ppf",ppfrn.c_str(),is);
|
---|
| 61 | POutPersist pos(str);
|
---|
| 62 | sph.Info()["ISeq"] = (int_4)is;
|
---|
| 63 | sph.Info()["FMHz"] = (double)f;
|
---|
| 64 | sph.Info()["FName"] = fn;
|
---|
| 65 | pos<<PPFNameTag("sph")<<sph;
|
---|
| 66 | nfilrd++;
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 | cout<<"\nread "<<nfilrd<<" files, with "<<nfrderr<<" echecs"<<endl;
|
---|
| 70 |
|
---|
| 71 | return 0;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.