Пример #1
0
def generateWidesweepFreqList(FPGAparams,
                              outputFN='rfFreqs.txt',
                              resAtten=65,
                              alias_BW=1600.E6,
                              lo_hole=512.E3,
                              tone_BW=512.0E3,
                              minNominalFreqSpacing=800.0E3):
    """
    Creates a frequency list for a widesweep centered around 0Hz.     

    INPUTS:
        FPGAparams: filename to fpga parameter file
        outputFN: name of output file
        resAtten: resonator attenuation (65 is good for MEC)
        alias_BW: bandwidth of antialiasing filter. (a little less than 2GHz). Will be clipped to the DAC bandwidth in the fpga file
        lo_hole: freq hole around LO that we should avoid
        tone_BW: bandwidth around tone to avoid crosstalk in FFT/DDS
        minNominalFreqSpacing: The number of tones should be <= alias_BW/minNominalFreqSpacing. Will be clipped to the number of channels supported by the firmware. 
    """
    try:
        params = readDict()
        params.readFromFile(FPGAparams)
    except TypeError:
        params = paramFile
    max_BW = int(params['dacSampleRate'])
    alias_BW = min(alias_BW, max_BW)
    freqResolution = params['dacSampleRate'] / (params['nDacSamplesPerCycle'] *
                                                params['nLutRowsToUse'])
    minNominalFreqSpacing = max(tone_BW + 100. * freqResolution,
                                minNominalFreqSpacing)
    nChannels = params['nChannels']
    avgSpacing = (alias_BW - tone_BW) / nChannels
    if avgSpacing < (minNominalFreqSpacing):
        avgSpacing = minNominalFreqSpacing
        nChannels = int((alias_BW - tone_BW) / avgSpacing)
    if nChannels <= 1:
        nChannels = 1
        avgSpacing = 0.
    lo = 0.

    freqs_low = makeRandomFreqSideband(
        0. - alias_BW / 2. + freqResolution / 2.,
        -lo_hole / 2. - freqResolution / 2., np.ceil(nChannels / 2.), tone_BW,
        freqResolution)
    freqs_high = makeRandomFreqSideband(lo_hole / 2. + freqResolution / 2.,
                                        alias_BW / 2. - freqResolution / 2.,
                                        np.floor(nChannels / 2.), tone_BW,
                                        freqResolution)
    freqs = np.append(freqs_low, freqs_high)

    resIDs = np.asarray(range(len(freqs)))
    attens = np.asarray([np.rint(resAtten * 4.) / 4.] * len(freqs))
    data = np.asarray([resIDs, freqs, attens]).T
    np.savetxt(outputFN, data, fmt="%4i %10.1f %4i")
Пример #2
0
                self.curAxis='x'
                print('Done.')
                print(
                    'If you want to re-select kx, click first bright spot to the right of center (red dot), otherwise close the plot')


if __name__=='__main__':
    if len(sys.argv)<2:
        print('Usage: "python alignGrid.py <configFile>", where <configFile> is in MKID_DATA_DIR')
        exit(1)

    cfgFn=sys.argv[1]
    if not os.path.isfile(cfgFn):
        mdd = os.environ['MKID_DATA_DIR']
        cfgFn = os.path.join(mdd, cfgFn)
    paramDict = readDict()
    paramDict.read_from_file(cfgFn)

    aligner = BMAligner(paramDict['masterPositionList'], paramDict['nXPix'], paramDict['nYPix'], paramDict['instrument'], paramDict['flip'])
    aligner.makeRawImage()
    #aligner.fftRawImage()
    aligner.loadFFT()
    aligner.findKvecsManual()
    aligner.findAngleAndScale()
    aligner.rotateAndScaleCoords()
    aligner.findOffset(50000)
    aligner.plotCoords()
    aligner.saveRawMap(paramDict['outputFilename'])
    if paramDict['masterDoublesList'] is not None:
        aligner.makeDoublesRawMap(paramDict['masterDoublesList'], paramDict['outputDoubleName'])
Пример #3
0
if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='ML Inference Script')
    parser.add_argument('mlConfig',
                        nargs=1,
                        help='Machine learning model config file')
    parser.add_argument('inferenceData',
                        nargs=1,
                        help='HDF5 file containing powersweep data')
    parser.add_argument('-o',
                        '--output-dir',
                        nargs=1,
                        default=[None],
                        help='Directory to save output file')
    parser.add_argument('-s',
                        '--add-scores',
                        action='store_true',
                        help='Adds a score column to the output file')
    args = parser.parse_args()

    mlDict = readDict()
    mlDict.readFromFile(args.mlConfig[0])

    h5FileName = args.inferenceData[0]
    if not os.path.isfile(h5FileName):
        h5FileName = os.path.join(os.environ['MKID_DATA_DIR'], h5FileName)

    outputDir = args.output_dir[0]

    findPowers(mlDict, h5FileName, outputDir, args.add_scores)
Пример #4
0
def loadClickthroughFile(fn):
    '''
    Loads clickthrough results from WideAna output file. Returns list of
    ResIDs, peak locations, and frequencies (in GHz)
    '''
    if not os.path.isfile(fn):
        fn = os.path.join(mdd, fn)
    resIDs, locs, freqs = np.loadtxt(fn, unpack=True)
    return resIDs, locs, freqs


if __name__ == '__main__':
    if len(sys.argv) < 3:
        print 'Usage: python findLOsAndMakeFreqFiles.py <setupcfgfile> <templarcfgfile>'

    setupDict = readDict()
    try:
        setupDict.readFromFile(sys.argv[1])
        try:
            mdd = setupDict['MKID_DATA_DIR']
        except KeyError:
            mdd = os.environ['MKID_DATA_DIR']
    except IOError:
        mdd = os.environ['MKID_DATA_DIR']
        setupDict.readFromFile(os.path.join(mdd, sys.argv[1]))
    #print setupDict
    templarCfgFile = sys.argv[2]
    freqFiles = []
    los = []
    flNums = []
    freqBandFlags = []
Пример #5
0
        log.info('N good pixels: ' + str(np.sum(self.beamMap.flags.astype(int)==beamMapFlags['good'])))
        log.info('N doubles: ' + str(np.sum(self.beamMap.flags.astype(int)==beamMapFlags['double'])))
        log.info('N failed pixels (read out but not beammapped): ' + str(np.sum((self.beamMap.flags.astype(int)!=beamMapFlags['good']) & (self.beamMap.flags.astype(int)!=beamMapFlags['double']) & (self.beamMap.flags.astype(int)!=beamMapFlags['noDacTone']))))
        np.savetxt(path, np.transpose([self.beamMap.resIDs.astype(int), self.beamMap.flags.astype(int), self.placedXs.astype(int), self.placedYs.astype(int)]), fmt='%4i %4i %4i %4i')
     

if __name__=='__main__':
    parser = argparse.ArgumentParser(description='argument parser')
    parser.add_argument('cfgFile', nargs=1, type=str, default='/mnt/data0/MEC/20181218/clean.cfg', help='Configuration file')
    #default config file location
    args = parser.parse_args()
    configFileName = args.cfgFile[0]
    resolutionType = args
    log.setLevel(logging.INFO)

    configData = readDict()
    configData.read_from_file(configFileName)
    beammapDirectory = configData['beammapDirectory']
    finalBMFile = configData['finalBMFile']
    rawBMFile = configData['rawBMFile']
    useFreqs = configData['useFreqs']
    psFiles = configData['powersweeps']
    designFile = configData['designMapFile']
    numRows = configData['numRows']
    numCols = configData['numCols']
    flipParam = configData['flip']
    inst = configData['instrument']

    rawBeamMap = Beammap(rawBMFile, (146, 140), 'MEC')
    if useFreqs:
        rawBeamMap.loadFrequencies(psFiles)