def main(): # Determine at which frequencies the ITC needs "tau" files. taus = list(HeterodyneReceiver._tau_data.keys()) mms = [] # Perform a binary search to determine the "WH2O" parameter which gives # each desired 225 GHz opacity. for tau in taus: mm_min = 0.1 mm_max = 10.0 while True: mm_mid = (mm_min + mm_max) / 2.0 values = run_am(225.0, 225.0, 0.01, mm_mid) assert len(values) == 1 tau_mid = values[0][1] if abs(tau_mid - tau) < 0.0000001: break if tau_mid > tau: mm_max = mm_mid else: mm_min = mm_mid mms.append(mm_mid) # Generate data for each of the desired conditions. for (tau, mm) in zip(taus, mms): values = run_am(200.0, 1000.0, 0.01, mm) values = compress_list(values) filename = 'tau{}.dat'.format('{:.03f}'.format(tau)[2:]) print('Writing:', filename) with open(filename, 'w') as f: for (freq, d) in values: print(freq, d, file=f)
mm_max = mm_mid else: mm_min = mm_mid mms.append(mm_mid) # Now reconfigure ATM to use the whole frequency range in which we are # interested and generate data for each of the desired conditions. at.initSpectralWindow(1, qa.quantity(600, 'GHz'), qa.quantity(800, 'GHz'), qa.quantity(0.01, 'GHz')) for (tau, mm) in zip(taus, mms): at.setUserWH2O(qa.quantity(mm, 'mm')) values = [] for i in range(at.getNumChan()): freq = at.getChanFreq(chanNum=i)['value'][0] d = at.getWetOpacity(nc=i)['value'][0] + at.getDryOpacity(nc=i) values.append((freq, d)) values = compress_list(values) filename = 'tau{}.dat'.format('{:.03f}'.format(tau)[2:]) print('Writing:', filename) with open(filename, 'w') as f: for (freq, d) in values: print(freq, d, file=f)