def reflectometry(self, efit_tree, globalvar): times = mdsvalue('dim_of(ne_ReflJ)') ind = np.argmin(abs(times - self.time / 1000.)) time = times[ind] index = '[*,' + str(ind) + ']' try: ne = mdsvalue('data(ne_ReflJ)' + index) except Exception as e: error_code = 104 print Exception, ":", e return None, globalvar, error_code else: error_code = 100 r = mdsvalue('data(R_ReflJ)' + index) not_nan_idx = np.isfinite(ne) ne = ne[not_nan_idx] r = r[not_nan_idx] z = np.ones(len(r)) * 0.03 rz = np.transpose([r, z]) if self.fm: efitDir = str(self.efitDir) efitDir = os.path.dirname(efitDir) mapping = east_mapping(self.shot, self.time, efitDir, rz) else: mapping = east_mapping(self.shot, time * 1000, efit_tree, rz) resultRho = np.array([mapping['rho'], ne]).T resultRho = resultRho[np.argsort(resultRho, axis=0)][:, 0] resultPsi = np.array([mapping['psi'], ne]).T resultPsi = resultPsi[np.argsort(resultPsi, axis=0)][:, 0] globalvar.value['diagnostic1_rho'] = resultRho globalvar.value['diagnostic1_psi'] = resultPsi globalvar.value['time1'] = time globalvar.d(d1_rho=resultRho) globalvar.d(d1_psi=resultPsi) return {'data_rho': resultRho, 'data_psi': resultPsi}, globalvar, error_code
def txcs(self, node_times, data_, efit_tree, par, globalvar): times = mdsvalue(node_times) ind = np.argmin(abs(times - self.time / 1000.)) time = times[ind] try: data = mdsvalue(data_['p']) err = mdsvalue(data_['err']) except Exception as e: error_code = 104 print Exception, ":", e return None, globalvar, error_code else: error_code = 100 data = data[:, ind] err = err[:, ind] not_nan_idx = np.isfinite(data) data = data[not_nan_idx] / 1000. err = err[not_nan_idx] / 1000. r = 1.9 z = mdsvalue(data_['z']) / 100. z = z[not_nan_idx] r = np.ones(len(z)) * r rz = np.transpose([r, z]) if self.fm: efitDir = str(self.efitDir) gFilePath = os.path.dirname(efitDir) mapping = east_mapping(self.shot, self.time, gFilePath, rz) else: mapping = east_mapping(self.shot, self.time, efit_tree, rz) # print 'mapping:', mapping resultRho = np.array([mapping['rho'], data]).T resultRho = resultRho[np.argsort(resultRho, axis=0)][:, 0] resultPsi = np.array([mapping['psi'], data]).T resultPsi = resultPsi[np.argsort(resultPsi, axis=0)][:, 0] err = err[np.argsort(resultRho, axis=0)][:, 0] if par['Profile'] == 'Te': globalvar.value['diagnostic5_rho'] = resultRho globalvar.value['diagnostic5_psi'] = resultPsi globalvar.value['diagnostic5_err'] = err globalvar.value['time5'] = time globalvar.d(d5_rho=resultRho) globalvar.d(d5_psi=resultPsi) elif par['Profile'] == 'Ti': globalvar.value['diagnostic3_rho'] = resultRho globalvar.value['diagnostic3_psi'] = resultPsi globalvar.value['diagnostic3_err'] = err globalvar.value['time3'] = time globalvar.d(d3_rho=resultRho) globalvar.d(d3_psi=resultPsi) return {'data_rho': resultRho, 'data_psi': resultPsi}, globalvar, error_code
def cxrs(self, node_times, data_, efit_tree, par, globalvar): times = mdsvalue(node_times) ind = np.argmin(abs(times - self.time / 1000.)) time = times[ind] index = '[*,' + str(ind) + ']' try: if par['Profile'] == 'Ti': data = mdsvalue(data_['p'] + index) / 1000. err = mdsvalue(data_['err'] + index) / 1000. elif par['Profile'] == 'Vt': data = mdsvalue(data_['p'] + index) / 10. err = mdsvalue(data_['err'] + index) / 10. except Exception as e: error_code = 104 print Exception, ":", e return None, globalvar, error_code else: error_code = 100 # data = mdsvalue('data(Ti_CXRS_T)' + index) / 1000. # err = mdsvalue('data(Ti_CXRS_Terr)' + index) / 1000. not_nan_idx = np.isfinite(data) data = data[not_nan_idx] err = err[not_nan_idx] r = mdsvalue(data_['r']) z = np.ones(len(r)) * -0.02 # z = mdsvalue(data_['z']) rz = np.transpose([r, z]) if self.fm: efitDir = str(self.efitDir) efitDir = os.path.dirname(efitDir) mapping = east_mapping(self.shot, self.time, efitDir, rz) else: mapping = east_mapping(self.shot, time * 1000, efit_tree, rz) resultRho = np.array([mapping['rho'], data]).T resultRho = resultRho[np.argsort(resultRho, axis=0)][:, 0] resultPsi = np.array([mapping['psi'], data]).T resultPsi = resultPsi[np.argsort(resultPsi, axis=0)][:, 0] err = err[np.argsort(resultRho, axis=0)][:, 0] globalvar.value['diagnostic1_rho'] = resultRho globalvar.value['diagnostic1_psi'] = resultPsi globalvar.value['diagnostic1_err'] = err globalvar.value['time1'] = time globalvar.d(d1_rho=resultRho) globalvar.d(d1_psi=resultPsi) return {'data_rho': resultRho, 'data_psi': resultPsi}, globalvar, error_code
def ece(self, efit_tree, globalvar): times = mdsvalue('dim_of(Te_HRS)') # time_window = 0.01 # time window for the MR diagnostic ind = np.argmin(abs(times - self.time / 1000.)) time = times[ind] index = '[*,' + str(ind) + ']' try: data = mdsvalue('data(Te_HRS)' + index) / 1000. err = mdsvalue('data(Te_HRSerr)' + index) / 1000. except Exception as e: error_code = 104 print Exception, ":", e return None, globalvar, error_code else: error_code = 100 r = mdsvalue('data(R_HRS)') not_nan_idx = np.isfinite(data) data = data[not_nan_idx] err = err[not_nan_idx] z = np.ones(len(r)) * 0.02 rz = np.transpose([r, z]) if self.fm: efitDir = str(self.efitDir) efitDir = os.path.dirname(efitDir) mapping = east_mapping(self.shot, self.time, efitDir, rz) else: mapping = east_mapping(self.shot, time * 1000, efit_tree, rz) resultRho = np.array([mapping['rho'], data]).T resultRho = resultRho[np.argsort(resultRho, axis=0)][:, 0] resultPsi = np.array([mapping['psi'], data]).T resultPsi = resultPsi[np.argsort(resultPsi, axis=0)][:, 0] err = err[np.argsort(resultRho, axis=0)][:, 0] globalvar.value['diagnostic3_rho'] = resultRho globalvar.value['diagnostic3_psi'] = resultPsi globalvar.value['diagnostic3_err'] = err globalvar.value['time3'] = time globalvar.d(d3_rho=resultRho) globalvar.d(d3_psi=resultPsi) return {'data_rho': resultRho, 'data_psi': resultPsi}, globalvar, error_code
def mds_file(self, globalvar, par): self.shot = par['Shot'] self.time = par['Time'] # mdsconnect('202.127.204.12') mdsopen(str(par['Tree']), self.shot) rz = globalvar.value['data_rho']['rz'] mapping = east_mapping(self.shot, self.time, str(par['Tree']), rz) resultRho = np.array([mapping['rho'], globalvar.value['data_rho']['data']]).T resultPsi = np.array([mapping['psi'], globalvar.value['data_psi']['data']]).T resultRho = resultRho[np.argsort(resultRho, axis=0)][:, 0] resultPsi = resultPsi[np.argsort(resultPsi, axis=0)][:, 0] globalvar.value['data_rho'] = resultRho globalvar.value['data_psi'] = resultPsi globalvar.value['filein_rho'] = globalvar.value['data_rho'] globalvar.value['filein_psi'] = globalvar.value['data_psi'] globalvar.d(filein_rho=globalvar.value['data_rho']) globalvar.d(filein_psi=globalvar.value['data_psi']) return globalvar
def file_file(self, globalvar, # GlobalVar par): # parameter from main window """ file_file :param globalvar: GlobalVar :param par: parameter from main window """ self.shot = par['Shot'] self.time = par['Time'] # print shot, type(shot), time, type(time) fileName = str(par['FileName']) efitDir = str(par['EfitDir']) gFilePath = os.path.dirname(efitDir) # dataFile = np.loadtxt(fileName) # if (dataFile[:, -1] > 1.e10).any(): # print 'aaa' # dataFile[:, -1] = dataFile[:, -1]/1.e19 # elif (10. < dataFile[:, -1]).any() and (dataFile[:, -1] < 10000.).any(): # dataFile[:, -1] = dataFile[:, -1]/1000. # rz = dataFile[:, 0:2] dataFile = openFile(fileName) mapping = east_mapping(self.shot, self.time, gFilePath, dataFile['rz']) resultRho = np.array([mapping['rho'], dataFile['data']]).T resultPsi = np.array([mapping['psi'], dataFile['data']]).T resultRho = resultRho[np.argsort(resultRho, axis=0)][:, 0] resultPsi = resultPsi[np.argsort(resultPsi, axis=0)][:, 0] globalvar.value['data_rho'] = resultRho globalvar.value['data_psi'] = resultPsi # mapping = RZmap(self.shot, self.time, gFileDir, fileName) # globalvar.value['data_rho'] = mapping['rho'] # globalvar.value['data_psi'] = mapping['psi'] globalvar.value['filein_rho'] = globalvar.value['data_rho'] globalvar.value['filein_psi'] = globalvar.value['data_psi'] globalvar.d(filein_rho=globalvar.value['data_rho']) globalvar.d(filein_psi=globalvar.value['data_psi']) return globalvar
def thomson_core(self, node_times, data_, efit_tree, par, globalvar): try: times = mdsvalue('dim_of(Te_maxTS)') except RuntimeError: print 'There is NO "Te_maxTS" data!' times = mdsvalue(node_times) # time_window = 0.01 # time window for the MR diagnostic ind = np.argmin(abs(times - self.time / 1000.)) time = times[ind] index = '[*,' + str(ind) + ']' # data = mdsvalue(data_['p'] + index) # err = mdsvalue(data_['err'] + index) try: data = mdsvalue(data_['p'])[ind, :] err = mdsvalue(data_['err'])[ind, :] except Exception as e: error_code = 104 print Exception, ":", e return None, globalvar, error_code else: error_code = 100 # not_nan_idx = np.isfinite(data) # data = data[not_nan_idx] # err = err[not_nan_idx] if self.shot > 76644 and self.shot != 78841: data = data[1:] err = err[1:] r = mdsvalue(data_['r']) z = mdsvalue(data_['z']) rz = np.transpose([r, z]) if data.shape != r.shape: error_code = 105 else: pass # print '0' # print rz # print rz.shape if self.fm: efitDir = str(self.efitDir) efitDir = os.path.dirname(efitDir) mapping = east_mapping(self.shot, self.time, efitDir, rz) else: mapping = east_mapping(self.shot, time * 1000, efit_tree, rz) # print '1' resultRho = np.array([mapping['rho'], data]).T resultRho = resultRho[np.argsort(resultRho, axis=0)][:, 0] resultPsi = np.array([mapping['psi'], data]).T resultPsi = resultPsi[np.argsort(resultPsi, axis=0)][:, 0] err = err[np.argsort(resultRho, axis=0)][:, 0] # print '2' if par['Profile'] == 'Te': resultRho[:, 1] /= 1000. resultPsi[:, 1] /= 1000. err /= 1000. globalvar.value['diagnostic1_rho'] = resultRho globalvar.value['diagnostic1_psi'] = resultPsi globalvar.value['diagnostic1_err'] = err globalvar.value['time1'] = time globalvar.d(d1_rho=resultRho) globalvar.d(d1_psi=resultPsi) elif par['Profile'] == 'ne': resultRho[:, 1] /= 1.e19 resultPsi[:, 1] /= 1.e19 err /= 1.e19 globalvar.value['diagnostic2_rho'] = resultRho globalvar.value['diagnostic2_psi'] = resultPsi globalvar.value['diagnostic2_err'] = err globalvar.value['time2'] = time globalvar.d(d2_rho=resultRho) globalvar.d(d2_psi=resultPsi) return {'data_rho': resultRho, 'data_psi': resultPsi}, globalvar, error_code