00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _H_M3_internal
00026 #define _H_M3_internal
00027
00028 #include <stdlib.h>
00029 #include <stdio.h>
00030 #include <string.h>
00031 #include <math.h>
00032 #include <libxml/xmlmemory.h>
00033 #include <libxml/parser.h>
00034
00035 #define M3_TOD_FILE_TYPE 0
00036 #define M3_TOC_FILE_TYPE 1
00037 #define M3_POINTING_FILE_TYPE 2
00038 #define M3_NOISE_FILE_TYPE 3
00039 #define M3_FILTER_FILE_TYPE 4
00040 #define M3_MAP_FILE_TYPE 5
00041 #define M3_MASK_FILE_TYPE 6
00042 #define M3_COORD_FILE_TYPE 7
00043 #define M3_SPECTRUM_FILE_TYPE 8
00044 #define M3_BIN_FILE_TYPE 9
00045 #define M3_BPS_FILE_TYPE 10
00046 #define M3_FISHER_FILE_TYPE 11
00047 #define M3_SPARSE_FILE_TYPE 12
00048 #define M3_GCPOINTING_FILE_TYPE 13
00049 #define M3_AUX_FILE_TYPE 14
00050
00051 #define M3_NO_SIM_TYPE 0
00052 #define M3_MAPSCAN_SIM_TYPE 1
00053 #define M3_OOFNOISE_SIM_TYPE 2
00054
00055 #define M3_MULTIPLY_TOC_ACTION 0
00056 #define M3_DIVIDE_TOC_ACTION 1
00057
00058
00059
00060
00061 typedef struct intervalTag
00062 {
00063 M3_Interval interval;
00064 void *v;
00065 struct intervalTag *next;
00066 } M3_IntervalLL;
00067
00068 typedef struct timeIntervalTag
00069 {
00070 M3_TimeInterval interval;
00071 void *v;
00072 struct timeIntervalTag *next;
00073 } M3_TimeIntervalLL;
00074
00075
00076
00077
00078
00079
00080
00081
00082 typedef struct
00083 {
00084 M3_Interval interval;
00085 double calib;
00086 } M3_TODfileParamStruct;
00087
00088 typedef struct
00089 {
00090 M3_Interval interval;
00091 double calib;
00092 int32_t action;
00093 } M3_TOCfileParamStruct;
00094
00095 typedef struct
00096 {
00097 M3_Interval interval;
00098 double calib;
00099 } M3_PointingFileParamStruct;
00100
00101 typedef struct
00102 {
00103 M3_Interval interval;
00104 double calib;
00105 int64_t corLength;
00106 } M3_NoiseFileParamStruct;
00107
00108 typedef struct
00109 {
00110 M3_Interval interval;
00111 int64_t length;
00112 int64_t bandWidth;
00113 } M3_FilterFileParamStruct;
00114
00115 typedef struct
00116 {
00117 int32_t numPixel;
00118 int32_t offset;
00119 } M3_MapFileParamStruct;
00120
00121 typedef struct
00122 {
00123 int64_t numColumn;
00124 int64_t numNZ;
00125 int64_t offset;
00126 } M3_SparseFileParamStruct;
00127
00128 typedef struct
00129 {
00130 int32_t offset;
00131 } M3_CoordFileParamStruct;
00132
00133 typedef struct
00134 {
00135 int32_t offset;
00136 } M3_MaskFileParamStruct;
00137
00138 typedef struct
00139 {
00140 M3_TimeEl firstTime;
00141 int64_t numSample;
00142 double sampleRate;
00143 int32_t numDataPerSample;
00144 } M3_GCPointingFileParamStruct;
00145
00146 typedef struct
00147 {
00148 size_t size;
00149 } M3_AuxFileParamStruct;
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 typedef union
00178 {
00179 M3_TODfileParamStruct tod;
00180 M3_TOCfileParamStruct toc;
00181 M3_PointingFileParamStruct pointing;
00182 M3_NoiseFileParamStruct noise;
00183 M3_FilterFileParamStruct filter;
00184 M3_MapFileParamStruct map;
00185 M3_SparseFileParamStruct sparse;
00186 M3_MaskFileParamStruct mask;
00187 M3_CoordFileParamStruct coord;
00188 M3_GCPointingFileParamStruct gcpointing;
00189 M3_AuxFileParamStruct aux;
00190
00191
00192
00193
00194
00195
00196 } M3_FileParamUnion;
00197
00198
00199
00200
00201 typedef struct
00202 {
00203 char *name;
00204 char *format;
00205 int32_t fileType;
00206 M3_FileParamUnion param;
00207 } M3_File;
00208
00209
00210
00211 typedef struct fileTag
00212 {
00213 M3_File file;
00214 void *v;
00215 struct fileTag *next;
00216 } M3_FileLL;
00217
00218
00219
00220
00221
00222 typedef struct spectrumClassTag
00223 {
00224 int32_t spectrumType;
00225 int32_t lmax;
00226 int32_t numBin;
00227 M3_File *shapeFile;
00228 M3_File *binFile;
00229 M3_File *bpsFile;
00230 struct spectrumClassTag *next;
00231 } M3_SpectrumClassLL;
00232
00233
00234 typedef struct
00235 {
00236 int32_t numBin;
00237 M3_SpectrumClassLL *spectrumClassList;
00238 M3_File *fisherMatrix;
00239 } M3_PowerSpectrumStruct;
00240
00241
00242
00243
00244
00245
00246 typedef struct pixelClassTag
00247 {
00248 char *className;
00249 int32_t classIndex;
00250 int32_t pixelType;
00251 int32_t numPixelInClass;
00252 int32_t globalPixelOffset;
00253 M3_File *mapFile;
00254 M3_File *coordFile;
00255 M3_File *windowFile;
00256 M3_FileLL *maskFileList;
00257 M3_FileLL *templateFileList;
00258 void *v;
00259 struct pixelClassTag *next;
00260 } M3_PixelClassLL;
00261
00262
00263
00264
00265
00266 typedef struct GCPointingStoreTag
00267 {
00268 M3_TimeEl firstTime;
00269 int64_t numSample;
00270 double sampleRate;
00271 int32_t numDataPerSample;
00272 double *data;
00273 void *v;
00274 struct GCPointingStoreTag *next;
00275 } M3_GCPointingStoreLL;
00276
00277 typedef struct GCPointingGroupTag
00278 {
00279 char *name;
00280 char *GCPointingType;
00281 M3_File *auxFile;
00282 M3_FileLL *GCPointingFileList;
00283 M3_GCPointingStoreLL *GCPointingStoreList;
00284 void *auxStore;
00285 void *v;
00286 struct GCPointingGroupTag *next;
00287 } M3_GCPointingGroupLL;
00288
00289
00290
00291 typedef struct pointingSubclassTag
00292 {
00293 int32_t numNZ;
00294 int32_t columnOffset;
00295 int32_t isFull;
00296 M3_FileLL *pointingFileList;
00297 M3_GCPointingGroupLL *GCPointingGroupNode;
00298 char *auxComplement;
00299 void *v;
00300 struct pointingSubclassTag *next;
00301 } M3_PointingSubclassLL;
00302
00303
00304
00305 typedef struct pointingClassTag
00306 {
00307 int32_t numNZ;
00308 int32_t columnOffset;
00309 M3_PixelClassLL *pixelClassNode;
00310 M3_PointingSubclassLL *subclassList;
00311 M3_FileLL *pointingCalibFileList;
00312 void *v;
00313 struct pointingClassTag *next;
00314 } M3_PointingClassLL;
00315
00316
00317
00318
00319
00320 typedef struct subcomponentTag
00321 {
00322 int32_t simType;
00323 M3_FileLL *todFileList;
00324 M3_PointingClassLL *mapScanSimPointingList;
00325 M3_FileLL *oofNoiseSimFileList;
00326 void *v;
00327 struct subcomponentTag *next;
00328 } M3_SubcomponentLL;
00329
00330 typedef struct componentTag
00331 {
00332 M3_SubcomponentLL *subcomponentList;
00333 M3_FileLL *todCalibFileList;
00334 void *v;
00335 struct componentTag *next;
00336 } M3_ComponentLL;
00337
00338 typedef struct NoiseFilterTag
00339 {
00340 M3_Interval interval;
00341 int64_t corLength;
00342 int64_t filterLength;
00343 double *noiseFilterTime;
00344 double *noiseFilterFreq;
00345 void *v;
00346 struct NoiseFilterTag *next;
00347 } M3_NoiseFilterLL;
00348
00349 typedef struct
00350 {
00351 int32_t numGlobalPix;
00352 int32_t myNumPix;
00353 int32_t numPixelClass;
00354 int32_t useFullLookup;
00355 int32_t *globalPixToMyPix;
00356 int32_t *myPixToGlobalPix;
00357 int32_t *classOffset;
00358 M3_MapEl *mapSimStore;
00359 } M3_PixelConvertStruct;
00360
00361
00362 typedef struct mallocRecordTag
00363 {
00364 void *space;
00365 size_t size;
00366 struct mallocRecordTag *next;
00367 } M3_MallocRecordLL;
00368
00369 struct runConfigTag;
00370
00371 typedef struct dataSetTag
00372 {
00373 char *name;
00374 M3_TimeEl firstTime;
00375 double sampleRate;
00376 M3_IntervalLL *coveredIntervalList;
00377 M3_ComponentLL *componentList;
00378 M3_FileLL *noiseFileList;
00379 M3_FileLL *filterFileList[M3_NUM_FILTER_TYPE];
00380 M3_PointingClassLL *pointingClassList;
00381 int32_t numNZ;
00382 M3_NoiseFilterLL *noiseFilterSimStore;
00383 M3_PixelConvertStruct *pixelConvertNode;
00384 struct runConfigTag *runConfigNode;
00385 void *v;
00386 struct dataSetTag *next;
00387 } M3_DataSetLL;
00388
00389
00390 typedef struct todRequestTag
00391 {
00392 M3_DataSetLL *dataSetNode;
00393 M3_Interval sampleInterval;
00394 struct todRequestTag *next;
00395 } M3_TODrequestLL;
00396
00397
00398 typedef struct
00399 {
00400 int useGCPcache;
00401 int useScanMapCache;
00402 M3_TODrequestLL *todRequestList;
00403 M3_MallocRecordLL *mallocRecordList;
00404 size_t storeSize;
00405 } M3_TODcacheStruct;
00406
00407
00408
00409
00410
00411
00412 typedef struct runConfigTag
00413 {
00414 uint64_t globalSeedSim;
00415 M3_TODcacheStruct todCache;
00416 M3_PixelConvertStruct pixelConvert;
00417 M3_DataSetLL *dataSetList;
00418 M3_PixelClassLL *pixelClassList;
00419 M3_PowerSpectrumStruct powerSpectrum;
00420 M3_File *sparsePixelMatrix;
00421 M3_GCPointingGroupLL *GCPointingGroupList;
00422 void *v;
00423 } M3_RunConfigStruct;
00424
00425
00426
00427 size_t M3_RunConfigStruct_duplicateP( M3_RunConfigStruct *inRunConfig, M3_RunConfigStruct **outRunConfig, int outputIsPacked );
00428 void M3_RunConfigStruct_refine( M3_RunConfigStruct *runConfig, int runType );
00429
00430 void M3_DataSetLL_getClassPointing( M3_DataSetLL *dataSetNode, M3_Interval readInterval, char *className, M3_PointingEl *pointing);
00431 void M3_DataSetLL_destroyList( M3_DataSetLL *dataSetList );
00432 void M3_DataSetLL_calibratePointing( M3_DataSetLL *dataSetNode, M3_PointingEl *pointing, M3_Interval pointingInterval );
00433 void M3_DataSetLL_getPointingIQU( M3_DataSetLL *dataSetNode, M3_Interval requestInterval, int32_t nside, int pixelScheme, long *pixels, double *weights );
00434
00435 void M3_RunConfigStruct_shiftPointers( M3_RunConfigStruct *runConfig, int shiftDirection);
00436 size_t M3_RunConfigStruct_duplicateP( M3_RunConfigStruct *inRunConfig, M3_RunConfigStruct **outRunConfig, int outputIsPacked );
00437
00438
00439
00440 void M3_GCPointingGroupLL_destroyList( M3_GCPointingGroupLL *GCPointingGroupList );
00441 void M3_GCPointingStoreLL_destroyList( M3_GCPointingStoreLL *GCPointingStoreList );
00442
00443 void M3_PixelClassLL_insertInOrder( M3_PixelClassLL *thisPixelClass, M3_PixelClassLL **pixeClassList );
00444 void M3_PixelClassLL_destroyList( M3_PixelClassLL *pixelClassList );
00445
00446 void M3_IntervalLL_insertInOrder( M3_IntervalLL *intervalNode, M3_IntervalLL **intervalList );
00447 void M3_IntervalLL_destroyList( M3_IntervalLL *list);
00448
00449 void M3_FileLL_insertInOrder( M3_FileLL *fileNode, M3_FileLL **fileList );
00450 void M3_FileLL_duplicateList( M3_FileLL *inFileList, M3_FileLL **outFileList );
00451 void M3_FileLL_destroyList( M3_FileLL *list );
00452
00453 void M3_File_getInterval( M3_File *thisFile, M3_Interval *theInterval );
00454 int M3_File_getStringSizes( M3_File theFile );
00455 void M3_File_destroy( M3_File *thisFile );
00456
00457 void M3_SpectrumClassLL_destroyList( M3_SpectrumClassLL *spectrumClassList );
00458
00459
00460 void M3_XML_decend( xmlNodePtr thisXMlnode, xmlNodePtr *childXMLnode, int nameLength, char *name );
00461 void M3_XML_follow( xmlNodePtr theXMLnode, xmlNodePtr *nextXMLnode, int nameLength, char *name );
00462 void M3_XML_getContent( xmlNodePtr theXMLnode, int contentLength, char *content );
00463
00464 void M3_XML_parsePixelClassNode( xmlNodePtr pixelClassXMLnode, int runType, M3_PixelClassLL *thisPixelClass );
00465 void M3_XML_parseSparsePixelMatrixNode( xmlNodePtr sparseMatrixNode, int runType, M3_File **m3file );
00466 void M3_XML_parseFileNode( xmlNodePtr fileXMLnode, int fileType, int isInputFile, M3_File *m3file );
00467 void M3_XML_parseIntervalNode( xmlNodePtr intervalXMLnode, M3_Interval *interval );
00468 void M3_XML_parseDataSetNode( xmlNodePtr dataSetXMLnode, int32_t runType, M3_PixelClassLL *pixelClassList, M3_GCPointingGroupLL *GCPointingGroupList, M3_DataSetLL *outDataSet );
00469 void M3_XML_parsePowerSpectrumNode( xmlNodePtr spectrumXMLnode, int runType, M3_PowerSpectrumStruct *outPowerSpectrum );
00470 void M3_XML_parseGCPointingGroupNode( xmlNodePtr GCPointingGroupXMLnode, int runType, M3_GCPointingGroupLL *outPointingGroup );
00471
00472 M3_IntervalLL *M3_fileListToIntervalList( M3_FileLL *fileList );
00473 M3_IntervalLL *M3_intersectIntervalLists( M3_IntervalLL *aList, M3_IntervalLL *bList );
00474 M3_IntervalLL *M3_gcpFileListToIntervalList( M3_FileLL *gcpFileList, M3_TimeEl dataSetFirstTime, double dataSetSampleRate );
00475
00476 #endif