[993] | 1 | #pragma TextEncoding = "MacRoman" |
---|
| 2 | #pragma rtGlobals=3 // Use modern global access method and strict wave access. |
---|
| 3 | |
---|
| 4 | |
---|
[994] | 5 | |
---|
| 6 | //////// function to take VCALC information and |
---|
| 7 | // fill in the simulated information as needed to make a "fake" data file |
---|
| 8 | // |
---|
| 9 | // TODO: |
---|
| 10 | // -- identify all of the necessary bits to change |
---|
| 11 | // -- maybe want a panel to make it easier to decide what inputs to change in the file |
---|
| 12 | // -- decide if it's better to write wholesale, or as individual waves |
---|
| 13 | // |
---|
| 14 | Macro Copy_VCALC_to_VSANSFile() |
---|
| 15 | |
---|
| 16 | String fileName = V_DoSaveFileDialog("pick the file to write to") |
---|
| 17 | print fileName |
---|
| 18 | // |
---|
| 19 | if(strlen(fileName) > 0) |
---|
| 20 | writeVCALC_to_file(fileName) |
---|
| 21 | endif |
---|
| 22 | End |
---|
| 23 | |
---|
| 24 | // |
---|
| 25 | // TODO -- fill this in as needed to get fake data that's different |
---|
| 26 | // |
---|
| 27 | Function writeVCALC_to_file(fileName) |
---|
| 28 | String fileName |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | // the detectors, all 9 + the correct SDD (that accounts for the offset of T/B panels |
---|
| 32 | // the data itself (as INT32) |
---|
| 33 | // the front SDD (correct units) |
---|
| 34 | // the middle SDD (correct units) |
---|
| 35 | // the back SDD (correct units) |
---|
| 36 | Variable ii,val |
---|
| 37 | String detStr |
---|
| 38 | for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) |
---|
| 39 | detStr = StringFromList(ii, ksDetectorListAll, ";") |
---|
| 40 | Duplicate/O $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+detStr+":det_"+detStr) tmpData |
---|
| 41 | Redimension/I tmpData |
---|
| 42 | tmpData = (tmpData == 2147483647) ? 0 : tmpData //the NaN "mask" in the sim data (T/B only)shows up as an ugly integer |
---|
| 43 | V_writeDetectorData(fileName,detStr,tmpData) |
---|
| 44 | |
---|
[995] | 45 | val = VCALC_getSDD(detStr)*100 // make sure value is in cm |
---|
[994] | 46 | print val |
---|
| 47 | V_writeDet_distance(fileName,detStr,val) |
---|
| 48 | |
---|
[995] | 49 | val = VCALC_getTopBottomSDDOffset(detStr) //val is in mm, as for data file |
---|
| 50 | if(val != 0) |
---|
| 51 | V_writeDet_TBSetback(fileName,detStr,val) |
---|
| 52 | endif |
---|
| 53 | |
---|
[994] | 54 | // x and y pixel sizes for each detector should be correct in the "base" file - but if not... |
---|
| 55 | //Function VCALC_getPixSizeX(type) // returns the pixel X size, in [cm] |
---|
| 56 | //Function VCALC_getPixSizeY(type) |
---|
| 57 | V_writeDet_x_pixel_size(fileName,detStr,VCALC_getPixSizeX(detStr)*10) // data file is expecting mm |
---|
| 58 | V_writeDet_y_pixel_size(fileName,detStr,VCALC_getPixSizeY(detStr)*10) |
---|
| 59 | |
---|
| 60 | // write out the xCtr and yCtr (pixels) that was used in the q-calculation, done in VC_CalculateQFrontPanels() |
---|
| 61 | V_writeDet_beam_center_x(fileName,detStr,V_getDet_beam_center_x("VCALC",detStr)) |
---|
| 62 | V_writeDet_beam_center_y(fileName,detStr,V_getDet_beam_center_y("VCALC",detStr)) |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | // the calibration data for each detector (except B) is already correct in the "base" file |
---|
| 66 | //V_writeDetTube_spatialCalib(fname,detStr,inW) |
---|
| 67 | // and for "B" |
---|
| 68 | //V_writeDet_cal_x(fname,detStr,inW) |
---|
| 69 | //V_writeDet_cal_y(fname,detStr,inW) |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | // the dead time for each detector is already correct in the "base" file |
---|
| 73 | // V_writeDetector_deadtime(fname,detStr,inW) |
---|
| 74 | // TODO: need a new, separate function to write the single deadtime value in/out of "B" |
---|
| 75 | |
---|
| 76 | endfor |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | //? other detector geometry - lateral separation? |
---|
| 80 | |
---|
| 81 | // the wavelength |
---|
| 82 | // Variable lam = V_getWavelength("VCALC") //doesn't work, the corresponding folder in VCALC has not been defined |
---|
| 83 | V_writeWavelength(fileName,VCALC_getWavelength()) |
---|
| 84 | |
---|
| 85 | // description of the sample |
---|
| 86 | |
---|
| 87 | // sample information |
---|
| 88 | // name, title, etc |
---|
| 89 | |
---|
| 90 | // fake the information about the count setup, so I have different numbers to read |
---|
| 91 | // count time = fake time of 100 s |
---|
| 92 | V_writeCount_time(fileName,100) |
---|
| 93 | |
---|
| 94 | // monitor count (= imon) |
---|
| 95 | // returns the number of neutrons on the sample |
---|
| 96 | //Function VCALC_getImon() |
---|
| 97 | |
---|
| 98 | // ?? anything else that I'd like to see on the catalog - I could change them here to see different values |
---|
| 99 | // different collimation types? |
---|
| 100 | // |
---|
| 101 | |
---|
| 102 | return(0) |
---|
| 103 | end |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | |
---|
[993] | 108 | // writes out "perfect" detector calibration constants for all 8 tube banks |
---|
| 109 | Function V_WritePerfectCalibration() |
---|
| 110 | |
---|
| 111 | Make/O/D/N=(3,48) tmpCalib |
---|
| 112 | // for the "tall" L/R banks |
---|
| 113 | tmpCalib[0][] = -512 |
---|
| 114 | tmpCalib[1][] = 8 |
---|
| 115 | tmpCalib[2][] = 0 |
---|
| 116 | |
---|
| 117 | V_writeDetTube_spatialCalib("","FR",tmpCalib) |
---|
| 118 | V_writeDetTube_spatialCalib("","FL",tmpCalib) |
---|
| 119 | V_writeDetTube_spatialCalib("","MR",tmpCalib) |
---|
| 120 | V_writeDetTube_spatialCalib("","ML",tmpCalib) |
---|
| 121 | |
---|
| 122 | // for the "short" T/B banks |
---|
| 123 | tmpCalib[0][] = -256 |
---|
| 124 | tmpCalib[1][] = 4 |
---|
| 125 | tmpCalib[2][] = 0 |
---|
| 126 | |
---|
| 127 | V_writeDetTube_spatialCalib("","FT",tmpCalib) |
---|
| 128 | V_writeDetTube_spatialCalib("","FB",tmpCalib) |
---|
| 129 | V_writeDetTube_spatialCalib("","MT",tmpCalib) |
---|
| 130 | V_writeDetTube_spatialCalib("","MB",tmpCalib) |
---|
| 131 | |
---|
| 132 | KillWaves tmpCalib |
---|
| 133 | return(0) |
---|
| 134 | end |
---|
| 135 | |
---|
| 136 | // TODO -- need a function to write out "bad" and "perfect" dead time values |
---|
| 137 | // to the HDF file |
---|
| 138 | //V_writeDetector_deadtime(fname,detStr,inW) |
---|
| 139 | //V_writeDetector_deadtime_B(fname,detStr,val) |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | Function V_FakeBeamCenters() |
---|
| 143 | // fake beam center values |
---|
| 144 | V_putDet_beam_center_x("RAW","B",75) |
---|
| 145 | V_putDet_beam_center_y("RAW","B",75) |
---|
| 146 | |
---|
| 147 | V_putDet_beam_center_x("RAW","MB",64) |
---|
| 148 | V_putDet_beam_center_y("RAW","MB",55) |
---|
| 149 | V_putDet_beam_center_x("RAW","MT",64) |
---|
| 150 | V_putDet_beam_center_y("RAW","MT",-8.1) |
---|
| 151 | V_putDet_beam_center_x("RAW","MR",-8.1) |
---|
| 152 | V_putDet_beam_center_y("RAW","MR",64) |
---|
| 153 | V_putDet_beam_center_x("RAW","ML",55) |
---|
| 154 | V_putDet_beam_center_y("RAW","ML",64) |
---|
| 155 | |
---|
| 156 | V_putDet_beam_center_x("RAW","FB",64) |
---|
| 157 | V_putDet_beam_center_y("RAW","FB",55) |
---|
| 158 | V_putDet_beam_center_x("RAW","FT",64) |
---|
| 159 | V_putDet_beam_center_y("RAW","FT",-8.7) |
---|
| 160 | V_putDet_beam_center_x("RAW","FR",-8.1) |
---|
| 161 | V_putDet_beam_center_y("RAW","FR",64) |
---|
| 162 | V_putDet_beam_center_x("RAW","FL",55) |
---|
| 163 | V_putDet_beam_center_y("RAW","FL",64) |
---|
| 164 | |
---|
| 165 | return(0) |
---|
| 166 | end |
---|
| 167 | |
---|
| 168 | Function V_FakeScaleToCenter() |
---|
| 169 | |
---|
| 170 | V_RescaleToBeamCenter("RAW","MB",64,55) |
---|
| 171 | V_RescaleToBeamCenter("RAW","MT",64,-8.7) |
---|
| 172 | V_RescaleToBeamCenter("RAW","MR",-8.1,64) |
---|
| 173 | V_RescaleToBeamCenter("RAW","ML",55,64) |
---|
| 174 | V_RescaleToBeamCenter("RAW","FL",55,64) |
---|
| 175 | V_RescaleToBeamCenter("RAW","FR",-8.1,64) |
---|
| 176 | V_RescaleToBeamCenter("RAW","FT",64,-8.7) |
---|
| 177 | V_RescaleToBeamCenter("RAW","FB",64,55) |
---|
| 178 | |
---|
| 179 | return(0) |
---|
| 180 | End |
---|