int RuseAs( MAP *m, /* map handle */ CSF_CR useType) /* CR_UINT1,CR_INT4, CR_REAL4, CR_REAL8, VS_BOOLEAN or VS_LDD */ { CSF_CR inFileCR = RgetCellRepr(m); CSF_VS inFileVS = RgetValueScale(m); int hasInFileCellReprType2 = HasInFileCellReprType2(inFileCR); /* it is very unconvenient that both, VS and CR are taken as arguments * for this function, and previously were used in the switch statement * now, at least 'special conversions' handled first */ if((int)useType == VS_BOOLEAN){ switch(inFileVS) { case VS_LDD: case VS_DIRECTION: { M_ERROR(CANT_USE_AS_BOOLEAN); return 1; } case VS_BOOLEAN: { POSTCOND(inFileCR == CR_UINT1); m->appCR = CR_UINT1; m->file2app = same; m->app2file = same; return 0; } default: { if((!hasInFileCellReprType2) && WRITE_ENABLE(m)) { /* cellrepr is old one, we can't write that */ M_ERROR(CANT_USE_WRITE_BOOLEAN); return 1; } m->appCR = CR_UINT1; m->file2app = ConvFuncBool(inFileCR); m->app2file = ConvFunc(inFileCR, CR_UINT1); return 0; } } } else if ((int)useType == VS_LDD){ switch(inFileVS) { case VS_LDD: { POSTCOND(inFileCR == CR_UINT1); m->appCR = CR_UINT1; m->file2app = same; m->app2file = same; return 0; } case VS_CLASSIFIED: case VS_NOTDETERMINED: { switch(inFileCR) { case CR_UINT1: { m->appCR = CR_UINT1; m->file2app = UINT1tLdd; m->app2file = same; return 0; } case CR_INT2: { if(WRITE_ENABLE(m)) { M_ERROR(CANT_USE_WRITE_LDD); return 1; } m->appCR = CR_UINT1; m->file2app = INT2tLdd; m->app2file = illegal; return 0; } default: { /* This should never happen. * Shut up compiler. */ assert(0); } } } default: { M_ERROR(CANT_USE_AS_LDD); return 1; } } } switch(useType) { case CR_UINT1: case CR_INT4 : case CR_REAL4: case CR_REAL8: { if((!hasInFileCellReprType2) && WRITE_ENABLE(m)) { /* cellrepr is old one, we can't write that */ M_ERROR(CANT_USE_WRITE_OLDCR); return 1; } m->appCR = useType; m->file2app = ConvFunc(useType, inFileCR); m->app2file = ConvFunc(inFileCR, useType); POSTCOND(m->file2app != NULL); return 0; } default: { M_ERROR(ILLEGAL_USE_TYPE); return 1; } } /* NOTREACHED */ }
/** * Convolves UV weights onto a grid to determine weighting function. * Then the data weights are modified by the weighting function. * The control parameters are attached to the ObitInfoList member info * on uvdata. See ObitUVWeight class documentation for details */ void ObitUVWeightData (ObitUV *uvdata, ObitErr *err) { ObitUVWeight *myWeight = NULL; gchar *outName = NULL; olong naxis[2]; gboolean doUnifWt; gchar *routine = "ObitUVWeightData"; /* error checks */ g_assert (ObitErrIsA(err)); if (err->error) return; g_assert (ObitUVIsA(uvdata)); /* create object */ outName = g_strconcat("UVWeight for: ",uvdata->name, NULL); myWeight = newObitUVWeight(outName); g_free(outName); /* get weighting information */ ObitUVWeightInput (myWeight, uvdata, err); if (err->error) Obit_traceback_msg (err, routine, uvdata->name); /* frequency tables if not defined */ if ((uvdata->myDesc->freqArr==NULL) || (uvdata->myDesc->fscale==NULL)) { ObitUVGetFreq (uvdata, err); if (err->error) Obit_traceback_msg (err, routine, uvdata->name); } /* end setup frequency table */ /* Are we uniform Weighting? */ doUnifWt = myWeight->Robust < 7; /* Gridding for uniform weighting */ if (doUnifWt) { /* Set convolving function */ ConvFunc(myWeight); /* Create weighting grids */ naxis[0] = 1 + myWeight->nuGrid/2; naxis[1] = myWeight->nvGrid; myWeight->cntGrid = ObitFArrayCreate ("Count Grid", 2, naxis); myWeight->wtGrid = ObitFArrayCreate ("Weight Grid", 2, naxis); /* Get/grid weights if uniform weighting */ ObitUVWeightReadUV (myWeight, uvdata, err); if (err->error) Obit_traceback_msg (err, routine, uvdata->name); /* Process grid */ ProcessGrid (myWeight, err); if (err->error) Obit_traceback_msg (err, routine, uvdata->name); /* Informative messages */ Obit_log_error(err, OBIT_InfoErr, "Using Robust uniform weighting for %s", uvdata->name); /* debug fprintf (stderr,"Grid size %d %d \n",naxis[0],naxis[1]); */ } else { /* Only natural weighting (and taper and power)*/ myWeight->wtScale = 1.0; myWeight->temperance = 0.0; /* Informative messages */ Obit_log_error(err, OBIT_InfoErr, "Using natural weighting for %s", uvdata->name); } /* End of natural weighting */ /* Modify Weights */ ObitUVWeightWtUV (myWeight, uvdata, err); if (err->error) Obit_traceback_msg (err, routine, uvdata->name); /* final diagnostics */ Obit_log_error(err, OBIT_InfoErr, "Weighting increased noise by %f for %s", myWeight->noiseFactor, uvdata->name); /* cleanup */ myWeight = ObitUVWeightUnref(myWeight); } /* end ObitUVWeightData */